@samirify/messenger 0.1.5 → 0.1.6

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.
@@ -17,6 +17,14 @@ function MessengerUiProvider({ children }) {
17
17
  setThreadId(id);
18
18
  setOpen(true);
19
19
  }, []);
20
+ const focusInbox = react.useCallback(() => {
21
+ setThreadId(null);
22
+ setOpen(false);
23
+ }, []);
24
+ const focusThread = react.useCallback((id) => {
25
+ setThreadId(id);
26
+ setOpen(false);
27
+ }, []);
20
28
  const close = react.useCallback(() => {
21
29
  setOpen(false);
22
30
  }, []);
@@ -26,10 +34,12 @@ function MessengerUiProvider({ children }) {
26
34
  threadId,
27
35
  openInbox,
28
36
  openThread,
37
+ focusInbox,
38
+ focusThread,
29
39
  close,
30
40
  setOpen
31
41
  }),
32
- [open, threadId, openInbox, openThread, close]
42
+ [open, threadId, openInbox, openThread, focusInbox, focusThread, close]
33
43
  );
34
44
  return /* @__PURE__ */ jsxRuntime.jsx(MessengerUiContext.Provider, { value, children });
35
45
  }
@@ -78,5 +88,5 @@ exports.MessengerUiProvider = MessengerUiProvider;
78
88
  exports.useMessengerUi = useMessengerUi;
79
89
  exports.useOptionalMessengerUi = useOptionalMessengerUi;
80
90
  exports.useUnreadTotal = useUnreadTotal;
81
- //# sourceMappingURL=chunk-M2F3K6UX.cjs.map
82
- //# sourceMappingURL=chunk-M2F3K6UX.cjs.map
91
+ //# sourceMappingURL=chunk-MH5UXWCD.cjs.map
92
+ //# sourceMappingURL=chunk-MH5UXWCD.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/uiController.tsx","../src/hooks/useUnreadTotal.ts"],"names":["createContext","useState","useCallback","useMemo","jsx","useContext","useOptionalMessengerConfig","useQuery","messengerKeys","listThreads","sumUnread"],"mappings":";;;;;;;AA8BA,IAAM,kBAAA,GAAqBA,oBAAuC,IAAI,CAAA;AAE/D,SAAS,mBAAA,CAAoB,EAAE,QAAA,EAAS,EAA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SAAA;AAAA,IACjB,YAAY,KAAA,CAAM,UAAA;AAAA,IAClB,SAAS,KAAA,CAAM,OAAA;AAAA,IACf,OAAA,EAAS;AAAA,GACX;AACF","file":"chunk-MH5UXWCD.cjs","sourcesContent":["import React, {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useState,\n type ReactNode,\n} from \"react\";\n\nexport interface MessengerUiState {\n open: boolean;\n threadId: number | null;\n /** Open the floating dock on the inbox. */\n openInbox: () => void;\n /** Open the floating dock on a thread. */\n openThread: (threadId: number) => void;\n /**\n * Select the inbox without opening the dock — for full-page / dashboard\n * surfaces and notification deep-links that navigate away from the dock.\n */\n focusInbox: () => void;\n /**\n * Select a thread without opening the dock — for full-page / dashboard\n * surfaces and notification deep-links that navigate away from the dock.\n */\n focusThread: (threadId: number) => void;\n close: () => void;\n setOpen: (open: boolean) => void;\n}\n\nconst MessengerUiContext = createContext<MessengerUiState | null>(null);\n\nexport function MessengerUiProvider({ children }: { children: ReactNode }) {\n const [open, setOpen] = useState(false);\n const [threadId, setThreadId] = useState<number | null>(null);\n\n const openInbox = useCallback(() => {\n setThreadId(null);\n setOpen(true);\n }, []);\n\n const openThread = useCallback((id: number) => {\n setThreadId(id);\n setOpen(true);\n }, []);\n\n const focusInbox = useCallback(() => {\n setThreadId(null);\n setOpen(false);\n }, []);\n\n const focusThread = useCallback((id: number) => {\n setThreadId(id);\n setOpen(false);\n }, []);\n\n const close = useCallback(() => {\n setOpen(false);\n }, []);\n\n const value = useMemo(\n () => ({\n open,\n threadId,\n openInbox,\n openThread,\n focusInbox,\n focusThread,\n close,\n setOpen,\n }),\n [open, threadId, openInbox, openThread, focusInbox, focusThread, close]\n );\n\n return (\n <MessengerUiContext.Provider value={value}>\n {children}\n </MessengerUiContext.Provider>\n );\n}\n\nexport function useMessengerUi(): MessengerUiState {\n const ctx = useContext(MessengerUiContext);\n if (!ctx) {\n throw new Error(\n \"@gymlium/messenger: useMessengerUi must be used within MessengerUiProvider\"\n );\n }\n return ctx;\n}\n\nexport function useOptionalMessengerUi(): MessengerUiState | null {\n return useContext(MessengerUiContext);\n}\n","import { useMemo } from \"react\";\nimport { useQuery } from \"@tanstack/react-query\";\nimport { listThreads, sumUnread } from \"../api\";\nimport { messengerKeys } from \"../queryKeys\";\nimport { useOptionalMessengerConfig } from \"../provider\";\n\n/**\n * Total unread across threads. Works outside MessengerProvider (returns 0).\n * Prefer mounting MessengerProvider above host chrome that needs this.\n */\nexport function useUnreadTotal(options?: { enabled?: boolean }) {\n const cfg = useOptionalMessengerConfig();\n const featureOn = cfg?.enabled === true;\n const http = cfg?.http;\n const enabled = (options?.enabled ?? true) && featureOn && !!http;\n\n const query = useQuery({\n queryKey: messengerKeys.threads(),\n queryFn: async () => {\n const res = await listThreads(http!);\n if (!res.success) {\n throw new Error(res.message ?? \"Failed to load threads\");\n }\n return res.data;\n },\n enabled,\n });\n\n const total = useMemo(\n () => (query.data ? sumUnread(query.data) : 0),\n [query.data]\n );\n\n return {\n total,\n isLoading: query.isLoading,\n isFetching: query.isFetching,\n refetch: query.refetch,\n enabled: featureOn,\n };\n}\n"]}
@@ -15,6 +15,14 @@ function MessengerUiProvider({ children }) {
15
15
  setThreadId(id);
16
16
  setOpen(true);
17
17
  }, []);
18
+ const focusInbox = useCallback(() => {
19
+ setThreadId(null);
20
+ setOpen(false);
21
+ }, []);
22
+ const focusThread = useCallback((id) => {
23
+ setThreadId(id);
24
+ setOpen(false);
25
+ }, []);
18
26
  const close = useCallback(() => {
19
27
  setOpen(false);
20
28
  }, []);
@@ -24,10 +32,12 @@ function MessengerUiProvider({ children }) {
24
32
  threadId,
25
33
  openInbox,
26
34
  openThread,
35
+ focusInbox,
36
+ focusThread,
27
37
  close,
28
38
  setOpen
29
39
  }),
30
- [open, threadId, openInbox, openThread, close]
40
+ [open, threadId, openInbox, openThread, focusInbox, focusThread, close]
31
41
  );
32
42
  return /* @__PURE__ */ jsx(MessengerUiContext.Provider, { value, children });
33
43
  }
@@ -73,5 +83,5 @@ function useUnreadTotal(options) {
73
83
  }
74
84
 
75
85
  export { MessengerUiProvider, useMessengerUi, useOptionalMessengerUi, useUnreadTotal };
76
- //# sourceMappingURL=chunk-OTJZXVON.js.map
77
- //# sourceMappingURL=chunk-OTJZXVON.js.map
86
+ //# sourceMappingURL=chunk-OUM2PDMW.js.map
87
+ //# sourceMappingURL=chunk-OUM2PDMW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/uiController.tsx","../src/hooks/useUnreadTotal.ts"],"names":["useMemo"],"mappings":";;;;;AA8BA,IAAM,kBAAA,GAAqB,cAAuC,IAAI,CAAA;AAE/D,SAAS,mBAAA,CAAoB,EAAE,QAAA,EAAS,EAA4B;AACzE,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,SAAS,KAAK,CAAA;AACtC,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAI,SAAwB,IAAI,CAAA;AAE5D,EAAA,MAAM,SAAA,GAAY,YAAY,MAAM;AAClC,IAAA,WAAA,CAAY,IAAI,CAAA;AAChB,IAAA,OAAA,CAAQ,IAAI,CAAA;AAAA,EACd,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,MAAM,UAAA,GAAa,WAAA,CAAY,CAAC,EAAA,KAAe;AAC7C,IAAA,WAAA,CAAY,EAAE,CAAA;AACd,IAAA,OAAA,CAAQ,IAAI,CAAA;AAAA,EACd,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,MAAM,UAAA,GAAa,YAAY,MAAM;AACnC,IAAA,WAAA,CAAY,IAAI,CAAA;AAChB,IAAA,OAAA,CAAQ,KAAK,CAAA;AAAA,EACf,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,MAAM,WAAA,GAAc,WAAA,CAAY,CAAC,EAAA,KAAe;AAC9C,IAAA,WAAA,CAAY,EAAE,CAAA;AACd,IAAA,OAAA,CAAQ,KAAK,CAAA;AAAA,EACf,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,M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S;AAChB,QAAA,MAAM,IAAI,KAAA,CAAM,GAAA,CAAI,OAAA,IAAW,wBAAwB,CAAA;AAAA,MACzD;AACA,MAAA,OAAO,GAAA,CAAI,IAAA;AAAA,IACb,CAAA;AAAA,IACA;AAAA,GACD,CAAA;AAED,EAAA,MAAM,KAAA,GAAQA,OAAAA;AAAA,IACZ,MAAO,KAAA,CAAM,IAAA,GAAO,SAAA,CAAU,KAAA,CAAM,IAAI,CAAA,GAAI,CAAA;AAAA,IAC5C,CAAC,MAAM,IAAI;AAAA,GACb;AAEA,EAAA,OAAO;AAAA,IACL,KAAA;AAAA,IACA,WAAW,KAAA,CAAM,SAAA;AAAA,IACjB,YAAY,KAAA,CAAM,UAAA;AAAA,IAClB,SAAS,KAAA,CAAM,OAAA;AAAA,IACf,OAAA,EAAS;AAAA,GACX;AACF","file":"chunk-OUM2PDMW.js","sourcesContent":["import React, {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useState,\n type ReactNode,\n} from \"react\";\n\nexport interface MessengerUiState {\n open: boolean;\n threadId: number | null;\n /** Open the floating dock on the inbox. */\n openInbox: () => void;\n /** Open the floating dock on a thread. */\n openThread: (threadId: number) => void;\n /**\n * Select the inbox without opening the dock — for full-page / dashboard\n * surfaces and notification deep-links that navigate away from the dock.\n */\n focusInbox: () => void;\n /**\n * Select a thread without opening the dock — for full-page / dashboard\n * surfaces and notification deep-links that navigate away from the dock.\n */\n focusThread: (threadId: number) => void;\n close: () => void;\n setOpen: (open: boolean) => void;\n}\n\nconst MessengerUiContext = createContext<MessengerUiState | null>(null);\n\nexport function MessengerUiProvider({ children }: { children: ReactNode }) {\n const [open, setOpen] = useState(false);\n const [threadId, setThreadId] = useState<number | null>(null);\n\n const openInbox = useCallback(() => {\n setThreadId(null);\n setOpen(true);\n }, []);\n\n const openThread = useCallback((id: number) => {\n setThreadId(id);\n setOpen(true);\n }, []);\n\n const focusInbox = useCallback(() => {\n setThreadId(null);\n setOpen(false);\n }, []);\n\n const focusThread = useCallback((id: number) => {\n setThreadId(id);\n setOpen(false);\n }, []);\n\n const close = useCallback(() => {\n setOpen(false);\n }, []);\n\n const value = useMemo(\n () => ({\n open,\n threadId,\n openInbox,\n openThread,\n focusInbox,\n focusThread,\n close,\n setOpen,\n }),\n [open, threadId, openInbox, openThread, focusInbox, focusThread, close]\n );\n\n return (\n <MessengerUiContext.Provider value={value}>\n {children}\n </MessengerUiContext.Provider>\n );\n}\n\nexport function useMessengerUi(): MessengerUiState {\n const ctx = useContext(MessengerUiContext);\n if (!ctx) {\n throw new Error(\n \"@gymlium/messenger: useMessengerUi must be used within MessengerUiProvider\"\n );\n }\n return ctx;\n}\n\nexport function useOptionalMessengerUi(): MessengerUiState | null {\n return useContext(MessengerUiContext);\n}\n","import { useMemo } from \"react\";\nimport { useQuery } from \"@tanstack/react-query\";\nimport { listThreads, sumUnread } from \"../api\";\nimport { messengerKeys } from \"../queryKeys\";\nimport { useOptionalMessengerConfig } from \"../provider\";\n\n/**\n * Total unread across threads. Works outside MessengerProvider (returns 0).\n * Prefer mounting MessengerProvider above host chrome that needs this.\n */\nexport function useUnreadTotal(options?: { enabled?: boolean }) {\n const cfg = useOptionalMessengerConfig();\n const featureOn = cfg?.enabled === true;\n const http = cfg?.http;\n const enabled = (options?.enabled ?? true) && featureOn && !!http;\n\n const query = useQuery({\n queryKey: messengerKeys.threads(),\n queryFn: async () => {\n const res = await listThreads(http!);\n if (!res.success) {\n throw new Error(res.message ?? \"Failed to load threads\");\n }\n return res.data;\n },\n enabled,\n });\n\n const total = useMemo(\n () => (query.data ? sumUnread(query.data) : 0),\n [query.data]\n );\n\n return {\n total,\n isLoading: query.isLoading,\n isFetching: query.isFetching,\n refetch: query.refetch,\n enabled: featureOn,\n };\n}\n"]}
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkM2F3K6UX_cjs = require('./chunk-M2F3K6UX.cjs');
3
+ var chunkMH5UXWCD_cjs = require('./chunk-MH5UXWCD.cjs');
4
4
  var chunk42TCO5DV_cjs = require('./chunk-42TCO5DV.cjs');
5
5
 
6
6
  // src/deepLink.ts
@@ -20,19 +20,19 @@ function resolveMessageNotificationRoute(data) {
20
20
 
21
21
  Object.defineProperty(exports, "MessengerUiProvider", {
22
22
  enumerable: true,
23
- get: function () { return chunkM2F3K6UX_cjs.MessengerUiProvider; }
23
+ get: function () { return chunkMH5UXWCD_cjs.MessengerUiProvider; }
24
24
  });
25
25
  Object.defineProperty(exports, "useMessengerUi", {
26
26
  enumerable: true,
27
- get: function () { return chunkM2F3K6UX_cjs.useMessengerUi; }
27
+ get: function () { return chunkMH5UXWCD_cjs.useMessengerUi; }
28
28
  });
29
29
  Object.defineProperty(exports, "useOptionalMessengerUi", {
30
30
  enumerable: true,
31
- get: function () { return chunkM2F3K6UX_cjs.useOptionalMessengerUi; }
31
+ get: function () { return chunkMH5UXWCD_cjs.useOptionalMessengerUi; }
32
32
  });
33
33
  Object.defineProperty(exports, "useUnreadTotal", {
34
34
  enumerable: true,
35
- get: function () { return chunkM2F3K6UX_cjs.useUnreadTotal; }
35
+ get: function () { return chunkMH5UXWCD_cjs.useUnreadTotal; }
36
36
  });
37
37
  Object.defineProperty(exports, "MessengerI18n", {
38
38
  enumerable: true,
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { M as MessengerHttp, A as ApiResult, a as MessageThread, C as ChatMessage, P as PickedImage } from './types-B7dU_l7c.cjs';
2
2
  export { b as MessengerConfig, c as MessengerNavigation, d as MessengerTheme, e as MessengerUser, T as TranslateFn } from './types-B7dU_l7c.cjs';
3
- export { M as MessengerProvider, a as MessengerUiProvider, u as useMessengerConfig, b as useMessengerUi, c as useOptionalMessengerConfig, d as useOptionalMessengerUi } from './uiController-CM_cznOa.cjs';
3
+ export { M as MessengerProvider, a as MessengerUiProvider, u as useMessengerConfig, b as useMessengerUi, c as useOptionalMessengerConfig, d as useOptionalMessengerUi } from './uiController-COf59SW2.cjs';
4
4
  import * as _tanstack_react_query from '@tanstack/react-query';
5
5
  import * as _tanstack_query_core from '@tanstack/query-core';
6
6
  import 'react';
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { M as MessengerHttp, A as ApiResult, a as MessageThread, C as ChatMessage, P as PickedImage } from './types-B7dU_l7c.js';
2
2
  export { b as MessengerConfig, c as MessengerNavigation, d as MessengerTheme, e as MessengerUser, T as TranslateFn } from './types-B7dU_l7c.js';
3
- export { M as MessengerProvider, a as MessengerUiProvider, u as useMessengerConfig, b as useMessengerUi, c as useOptionalMessengerConfig, d as useOptionalMessengerUi } from './uiController-CNCLZw4I.js';
3
+ export { M as MessengerProvider, a as MessengerUiProvider, u as useMessengerConfig, b as useMessengerUi, c as useOptionalMessengerConfig, d as useOptionalMessengerUi } from './uiController-Ju0xoRyd.js';
4
4
  import * as _tanstack_react_query from '@tanstack/react-query';
5
5
  import * as _tanstack_query_core from '@tanstack/query-core';
6
6
  import 'react';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { MessengerUiProvider, useMessengerUi, useOptionalMessengerUi, useUnreadTotal } from './chunk-OTJZXVON.js';
1
+ export { MessengerUiProvider, useMessengerUi, useOptionalMessengerUi, useUnreadTotal } from './chunk-OUM2PDMW.js';
2
2
  export { MessengerI18n, MessengerProvider, getThread, listThreads, markThreadRead, messengerKeys, openThread, sendMessage, sumUnread, useMessengerConfig, useOpenThread, useOptionalMessengerConfig, useSendMessage, useThread, useThreads } from './chunk-O5XNJHGZ.js';
3
3
 
4
4
  // src/deepLink.ts
@@ -12,8 +12,20 @@ declare function useOptionalMessengerConfig(): MessengerConfig | null;
12
12
  interface MessengerUiState {
13
13
  open: boolean;
14
14
  threadId: number | null;
15
+ /** Open the floating dock on the inbox. */
15
16
  openInbox: () => void;
17
+ /** Open the floating dock on a thread. */
16
18
  openThread: (threadId: number) => void;
19
+ /**
20
+ * Select the inbox without opening the dock — for full-page / dashboard
21
+ * surfaces and notification deep-links that navigate away from the dock.
22
+ */
23
+ focusInbox: () => void;
24
+ /**
25
+ * Select a thread without opening the dock — for full-page / dashboard
26
+ * surfaces and notification deep-links that navigate away from the dock.
27
+ */
28
+ focusThread: (threadId: number) => void;
17
29
  close: () => void;
18
30
  setOpen: (open: boolean) => void;
19
31
  }
@@ -12,8 +12,20 @@ declare function useOptionalMessengerConfig(): MessengerConfig | null;
12
12
  interface MessengerUiState {
13
13
  open: boolean;
14
14
  threadId: number | null;
15
+ /** Open the floating dock on the inbox. */
15
16
  openInbox: () => void;
17
+ /** Open the floating dock on a thread. */
16
18
  openThread: (threadId: number) => void;
19
+ /**
20
+ * Select the inbox without opening the dock — for full-page / dashboard
21
+ * surfaces and notification deep-links that navigate away from the dock.
22
+ */
23
+ focusInbox: () => void;
24
+ /**
25
+ * Select a thread without opening the dock — for full-page / dashboard
26
+ * surfaces and notification deep-links that navigate away from the dock.
27
+ */
28
+ focusThread: (threadId: number) => void;
17
29
  close: () => void;
18
30
  setOpen: (open: boolean) => void;
19
31
  }
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunkM2F3K6UX_cjs = require('../chunk-M2F3K6UX.cjs');
3
+ var chunkMH5UXWCD_cjs = require('../chunk-MH5UXWCD.cjs');
4
4
  var chunk42TCO5DV_cjs = require('../chunk-42TCO5DV.cjs');
5
5
  var framerMotion = require('framer-motion');
6
- var jsxRuntime = require('react/jsx-runtime');
7
6
  var react = require('react');
7
+ var jsxRuntime = require('react/jsx-runtime');
8
8
 
9
9
  function initials(name) {
10
10
  const parts = name.trim().split(/\s+/).filter(Boolean);
@@ -14,7 +14,8 @@ function initials(name) {
14
14
  }
15
15
  function ThreadRow({
16
16
  thread,
17
- onSelect
17
+ onSelect,
18
+ active
18
19
  }) {
19
20
  const { user, t, isRtl, theme } = chunk42TCO5DV_cjs.useMessengerConfig();
20
21
  const unread = Number(thread.unread_count ?? 0);
@@ -34,17 +35,19 @@ function ThreadRow({
34
35
  textAlign: isRtl ? "right" : "left",
35
36
  padding: "12px 14px",
36
37
  margin: "0 8px",
37
- border: "none",
38
+ border: active ? `1px solid color-mix(in srgb, ${theme.accentColor} 28%, transparent)` : "1px solid transparent",
38
39
  borderRadius: 16,
39
- background: unread > 0 ? `color-mix(in srgb, ${theme.accentColor} 8%, transparent)` : "transparent",
40
+ background: active ? `color-mix(in srgb, ${theme.accentColor} 14%, ${theme.colors.surface})` : unread > 0 ? `color-mix(in srgb, ${theme.accentColor} 8%, transparent)` : "transparent",
40
41
  cursor: "pointer",
41
42
  color: theme.colors.text,
42
- transition: "background 160ms ease"
43
+ transition: "background 160ms ease, border-color 160ms ease"
43
44
  },
44
45
  onMouseEnter: (e) => {
46
+ if (active) return;
45
47
  e.currentTarget.style.background = `color-mix(in srgb, ${theme.accentColor} 12%, ${theme.colors.surfaceSecondary})`;
46
48
  },
47
49
  onMouseLeave: (e) => {
50
+ if (active) return;
48
51
  e.currentTarget.style.background = unread > 0 ? `color-mix(in srgb, ${theme.accentColor} 8%, transparent)` : "transparent";
49
52
  },
50
53
  children: [
@@ -147,7 +150,8 @@ function ThreadRow({
147
150
  );
148
151
  }
149
152
  function ThreadList({
150
- onSelectThread
153
+ onSelectThread,
154
+ activeThreadId
151
155
  }) {
152
156
  const { user, t, theme } = chunk42TCO5DV_cjs.useMessengerConfig();
153
157
  const threadsQuery = chunk42TCO5DV_cjs.useThreads();
@@ -278,7 +282,15 @@ function ThreadList({
278
282
  gap: 2,
279
283
  paddingBottom: 8
280
284
  },
281
- children: threads.map((th) => /* @__PURE__ */ jsxRuntime.jsx(ThreadRow, { thread: th, onSelect: onSelectThread }, th.id))
285
+ children: threads.map((th) => /* @__PURE__ */ jsxRuntime.jsx(
286
+ ThreadRow,
287
+ {
288
+ thread: th,
289
+ onSelect: onSelectThread,
290
+ active: activeThreadId === th.id
291
+ },
292
+ th.id
293
+ ))
282
294
  }
283
295
  )
284
296
  ]
@@ -756,6 +768,15 @@ function ChatPanel({
756
768
  variant = "dock"
757
769
  }) {
758
770
  const { enabled, t, isRtl, theme, onFeatureOff } = chunk42TCO5DV_cjs.useMessengerConfig();
771
+ const [wide, setWide] = react.useState(false);
772
+ react.useEffect(() => {
773
+ if (variant !== "page" || typeof window === "undefined") return;
774
+ const mq = window.matchMedia("(min-width: 768px)");
775
+ const apply = () => setWide(mq.matches);
776
+ apply();
777
+ mq.addEventListener("change", apply);
778
+ return () => mq.removeEventListener("change", apply);
779
+ }, [variant]);
759
780
  if (!enabled) {
760
781
  if (onFeatureOff) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: onFeatureOff() });
761
782
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -771,14 +792,17 @@ function ChatPanel({
771
792
  }
772
793
  );
773
794
  }
795
+ const inThread = threadId != null;
796
+ const pageSplit = variant === "page" && wide;
774
797
  const shell = variant === "page" ? {
775
798
  display: "flex",
776
- flexDirection: "column",
799
+ flexDirection: pageSplit ? isRtl ? "row-reverse" : "row" : "column",
777
800
  height: "100%",
778
801
  width: "100%",
779
802
  overflow: "hidden",
780
803
  background: theme.colors.surface,
781
- borderTop: `1px solid color-mix(in srgb, ${theme.colors.border} 80%, transparent)`
804
+ border: `1px solid color-mix(in srgb, ${theme.colors.border} 85%, transparent)`,
805
+ borderRadius: 0
782
806
  } : {
783
807
  display: "flex",
784
808
  flexDirection: "column",
@@ -789,110 +813,189 @@ function ChatPanel({
789
813
  ${theme.colors.surface}
790
814
  `
791
815
  };
792
- const inThread = threadId != null;
793
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: shell, children: [
794
- !inThread ? /* @__PURE__ */ jsxRuntime.jsxs(
795
- "header",
796
- {
797
- style: {
798
- display: "flex",
799
- flexDirection: isRtl ? "row-reverse" : "row",
800
- alignItems: "center",
801
- gap: 12,
802
- padding: "16px 16px 14px",
803
- borderBottom: `1px solid color-mix(in srgb, ${theme.colors.border} 80%, transparent)`,
804
- background: `linear-gradient(180deg, color-mix(in srgb, ${theme.colors.surface} 92%, transparent), color-mix(in srgb, ${theme.colors.surface} 70%, transparent))`,
805
- backdropFilter: "blur(12px)"
806
- },
807
- children: [
808
- /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { flex: 1, minWidth: 0, textAlign: isRtl ? "right" : "left" }, children: [
809
- /* @__PURE__ */ jsxRuntime.jsx(
810
- "div",
811
- {
812
- style: {
813
- fontFamily: theme.fonts.displayBold,
814
- fontWeight: 700,
815
- fontSize: 20,
816
- letterSpacing: "-0.02em",
817
- color: theme.colors.text,
818
- lineHeight: 1.15
819
- },
820
- children: t(chunk42TCO5DV_cjs.MessengerI18n.messages.key, chunk42TCO5DV_cjs.MessengerI18n.messages.fallback)
821
- }
822
- ),
823
- /* @__PURE__ */ jsxRuntime.jsx(
824
- "div",
825
- {
826
- style: {
827
- marginTop: 3,
828
- fontFamily: theme.fonts.body,
829
- fontSize: 12.5,
830
- color: theme.colors.textMuted
831
- },
832
- children: t(chunk42TCO5DV_cjs.MessengerI18n.messagesHint.key, chunk42TCO5DV_cjs.MessengerI18n.messagesHint.fallback)
833
- }
834
- )
835
- ] }),
836
- onClose ? /* @__PURE__ */ jsxRuntime.jsx(
837
- "button",
838
- {
839
- type: "button",
840
- onClick: onClose,
841
- "aria-label": "Close",
842
- style: {
843
- border: `1px solid color-mix(in srgb, ${theme.colors.border} 90%, transparent)`,
844
- background: `color-mix(in srgb, ${theme.colors.surfaceSecondary} 80%, transparent)`,
845
- color: theme.colors.textSecondary,
846
- width: 36,
847
- height: 36,
848
- borderRadius: 12,
849
- cursor: "pointer",
850
- display: "grid",
851
- placeItems: "center",
852
- flexShrink: 0
853
- },
854
- children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon, { size: 16 })
855
- }
856
- ) : null
857
- ]
858
- }
859
- ) : null,
860
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { flex: 1, minHeight: 0, position: "relative" }, children: /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { mode: "wait", initial: false, children: inThread ? /* @__PURE__ */ jsxRuntime.jsx(
861
- framerMotion.motion.div,
862
- {
863
- initial: { opacity: 0, x: isRtl ? -16 : 16 },
864
- animate: { opacity: 1, x: 0 },
865
- exit: { opacity: 0, x: isRtl ? 12 : -12 },
866
- transition: { duration: 0.22, ease: [0.22, 1, 0.36, 1] },
867
- style: { height: "100%" },
868
- children: /* @__PURE__ */ jsxRuntime.jsx(
869
- Conversation,
816
+ const listPane = /* @__PURE__ */ jsxRuntime.jsxs(
817
+ "div",
818
+ {
819
+ style: {
820
+ display: "flex",
821
+ flexDirection: "column",
822
+ height: "100%",
823
+ width: pageSplit ? 320 : "100%",
824
+ flexShrink: 0,
825
+ borderInlineEnd: pageSplit ? `1px solid color-mix(in srgb, ${theme.colors.border} 80%, transparent)` : void 0,
826
+ background: pageSplit ? `linear-gradient(180deg, color-mix(in srgb, ${theme.colors.surfaceSecondary} 55%, ${theme.colors.surface}), ${theme.colors.surface})` : void 0
827
+ },
828
+ children: [
829
+ /* @__PURE__ */ jsxRuntime.jsxs(
830
+ "header",
831
+ {
832
+ style: {
833
+ display: "flex",
834
+ flexDirection: isRtl ? "row-reverse" : "row",
835
+ alignItems: "center",
836
+ gap: 12,
837
+ padding: "16px 16px 14px",
838
+ borderBottom: `1px solid color-mix(in srgb, ${theme.colors.border} 80%, transparent)`
839
+ },
840
+ children: [
841
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { flex: 1, minWidth: 0, textAlign: isRtl ? "right" : "left" }, children: [
842
+ /* @__PURE__ */ jsxRuntime.jsx(
843
+ "div",
844
+ {
845
+ style: {
846
+ fontFamily: theme.fonts.displayBold,
847
+ fontWeight: 700,
848
+ fontSize: pageSplit ? 18 : 20,
849
+ letterSpacing: "-0.02em",
850
+ color: theme.colors.text,
851
+ lineHeight: 1.15
852
+ },
853
+ children: t(chunk42TCO5DV_cjs.MessengerI18n.messages.key, chunk42TCO5DV_cjs.MessengerI18n.messages.fallback)
854
+ }
855
+ ),
856
+ /* @__PURE__ */ jsxRuntime.jsx(
857
+ "div",
858
+ {
859
+ style: {
860
+ marginTop: 3,
861
+ fontFamily: theme.fonts.body,
862
+ fontSize: 12.5,
863
+ color: theme.colors.textMuted
864
+ },
865
+ children: t(chunk42TCO5DV_cjs.MessengerI18n.messagesHint.key, chunk42TCO5DV_cjs.MessengerI18n.messagesHint.fallback)
866
+ }
867
+ )
868
+ ] }),
869
+ onClose && !pageSplit ? /* @__PURE__ */ jsxRuntime.jsx(
870
+ "button",
871
+ {
872
+ type: "button",
873
+ onClick: onClose,
874
+ "aria-label": "Close",
875
+ style: {
876
+ border: `1px solid color-mix(in srgb, ${theme.colors.border} 90%, transparent)`,
877
+ background: `color-mix(in srgb, ${theme.colors.surfaceSecondary} 80%, transparent)`,
878
+ color: theme.colors.textSecondary,
879
+ width: 36,
880
+ height: 36,
881
+ borderRadius: 12,
882
+ cursor: "pointer",
883
+ display: "grid",
884
+ placeItems: "center",
885
+ flexShrink: 0
886
+ },
887
+ children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon, { size: 16 })
888
+ }
889
+ ) : null
890
+ ]
891
+ }
892
+ ),
893
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { flex: 1, minHeight: 0 }, children: /* @__PURE__ */ jsxRuntime.jsx(
894
+ ThreadList,
870
895
  {
871
- threadId,
872
- onBack: onBackToList,
873
- onClose
896
+ onSelectThread,
897
+ activeThreadId: threadId
874
898
  }
875
- )
876
- },
877
- `thread-${threadId}`
878
- ) : /* @__PURE__ */ jsxRuntime.jsx(
879
- framerMotion.motion.div,
880
- {
881
- initial: { opacity: 0, x: isRtl ? 16 : -16 },
882
- animate: { opacity: 1, x: 0 },
883
- exit: { opacity: 0, x: isRtl ? -12 : 12 },
884
- transition: { duration: 0.22, ease: [0.22, 1, 0.36, 1] },
885
- style: { height: "100%" },
886
- children: /* @__PURE__ */ jsxRuntime.jsx(ThreadList, { onSelectThread })
899
+ ) })
900
+ ]
901
+ }
902
+ );
903
+ const emptyPane = /* @__PURE__ */ jsxRuntime.jsxs(
904
+ "div",
905
+ {
906
+ style: {
907
+ flex: 1,
908
+ minWidth: 0,
909
+ height: "100%",
910
+ display: "flex",
911
+ flexDirection: "column",
912
+ alignItems: "center",
913
+ justifyContent: "center",
914
+ gap: 10,
915
+ padding: 32,
916
+ background: `
917
+ radial-gradient(80% 60% at 50% 0%, color-mix(in srgb, ${theme.accentColor} 10%, transparent), transparent 60%),
918
+ ${theme.colors.surface}
919
+ `
887
920
  },
888
- "list"
889
- ) }) })
890
- ] });
921
+ children: [
922
+ /* @__PURE__ */ jsxRuntime.jsx(
923
+ "div",
924
+ {
925
+ "aria-hidden": true,
926
+ style: {
927
+ width: 64,
928
+ height: 64,
929
+ borderRadius: 20,
930
+ display: "grid",
931
+ placeItems: "center",
932
+ background: `color-mix(in srgb, ${theme.accentColor} 12%, ${theme.colors.surfaceSecondary})`,
933
+ color: theme.accentColor,
934
+ fontSize: 26,
935
+ marginBottom: 4
936
+ },
937
+ children: "\u2726"
938
+ }
939
+ ),
940
+ /* @__PURE__ */ jsxRuntime.jsx(
941
+ "div",
942
+ {
943
+ style: {
944
+ fontFamily: theme.fonts.displaySemiBold,
945
+ fontWeight: 600,
946
+ fontSize: 16,
947
+ color: theme.colors.text
948
+ },
949
+ children: t(chunk42TCO5DV_cjs.MessengerI18n.messages.key, chunk42TCO5DV_cjs.MessengerI18n.messages.fallback)
950
+ }
951
+ ),
952
+ /* @__PURE__ */ jsxRuntime.jsx(
953
+ "div",
954
+ {
955
+ style: {
956
+ fontFamily: theme.fonts.body,
957
+ fontSize: 13.5,
958
+ color: theme.colors.textMuted,
959
+ maxWidth: 280,
960
+ textAlign: "center",
961
+ lineHeight: 1.45
962
+ },
963
+ children: t(chunk42TCO5DV_cjs.MessengerI18n.messagesHint.key, chunk42TCO5DV_cjs.MessengerI18n.messagesHint.fallback)
964
+ }
965
+ )
966
+ ]
967
+ }
968
+ );
969
+ if (variant === "page" && pageSplit) {
970
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: shell, children: [
971
+ listPane,
972
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { flex: 1, minWidth: 0, minHeight: 0, height: "100%" }, children: inThread ? /* @__PURE__ */ jsxRuntime.jsx(Conversation, { threadId }) : emptyPane })
973
+ ] });
974
+ }
975
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: shell, children: !inThread ? listPane : /* @__PURE__ */ jsxRuntime.jsx("div", { style: { flex: 1, minHeight: 0, position: "relative", height: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { mode: "wait", initial: false, children: /* @__PURE__ */ jsxRuntime.jsx(
976
+ framerMotion.motion.div,
977
+ {
978
+ initial: { opacity: 0, x: isRtl ? -16 : 16 },
979
+ animate: { opacity: 1, x: 0 },
980
+ exit: { opacity: 0, x: isRtl ? 12 : -12 },
981
+ transition: { duration: 0.22, ease: [0.22, 1, 0.36, 1] },
982
+ style: { height: "100%" },
983
+ children: /* @__PURE__ */ jsxRuntime.jsx(
984
+ Conversation,
985
+ {
986
+ threadId,
987
+ onBack: onBackToList,
988
+ onClose
989
+ }
990
+ )
991
+ },
992
+ `thread-${threadId}`
993
+ ) }) }) });
891
994
  }
892
995
  function ChatDock() {
893
996
  const { enabled, isRtl, theme, t } = chunk42TCO5DV_cjs.useMessengerConfig();
894
- const ui = chunkM2F3K6UX_cjs.useMessengerUi();
895
- const unread = chunkM2F3K6UX_cjs.useUnreadTotal({ enabled });
997
+ const ui = chunkMH5UXWCD_cjs.useMessengerUi();
998
+ const unread = chunkMH5UXWCD_cjs.useUnreadTotal({ enabled });
896
999
  if (!enabled) return null;
897
1000
  const side = isRtl ? "left" : "right";
898
1001
  const open = ui.open;
@@ -1048,15 +1151,15 @@ function ChatDock() {
1048
1151
 
1049
1152
  Object.defineProperty(exports, "MessengerUiProvider", {
1050
1153
  enumerable: true,
1051
- get: function () { return chunkM2F3K6UX_cjs.MessengerUiProvider; }
1154
+ get: function () { return chunkMH5UXWCD_cjs.MessengerUiProvider; }
1052
1155
  });
1053
1156
  Object.defineProperty(exports, "useMessengerUi", {
1054
1157
  enumerable: true,
1055
- get: function () { return chunkM2F3K6UX_cjs.useMessengerUi; }
1158
+ get: function () { return chunkMH5UXWCD_cjs.useMessengerUi; }
1056
1159
  });
1057
1160
  Object.defineProperty(exports, "useOptionalMessengerUi", {
1058
1161
  enumerable: true,
1059
- get: function () { return chunkM2F3K6UX_cjs.useOptionalMessengerUi; }
1162
+ get: function () { return chunkMH5UXWCD_cjs.useOptionalMessengerUi; }
1060
1163
  });
1061
1164
  Object.defineProperty(exports, "MessengerProvider", {
1062
1165
  enumerable: true,