@linktr.ee/messaging-react 1.5.3 → 1.6.0
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/assets/index.css +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +532 -510
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ChannelView.tsx +1 -1
- package/src/components/FaqList/FaqList.stories.tsx +49 -0
- package/src/components/FaqList/FaqListItem.tsx +3 -2
- package/src/components/FaqList/index.tsx +38 -10
- package/src/components/MessagingShell/index.tsx +9 -4
- package/src/types.ts +7 -0
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as e, jsxs as c, Fragment as oe } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import X, { createContext as
|
|
4
|
-
import { StreamChatService as
|
|
5
|
-
import { Chat as Ie, useChatContext as
|
|
6
|
-
import { NotePencilIcon as
|
|
7
|
-
const he =
|
|
2
|
+
import D from "classnames";
|
|
3
|
+
import X, { createContext as ve, useContext as we, useCallback as U, useState as I, useRef as H, useEffect as G } from "react";
|
|
4
|
+
import { StreamChatService as Ee } from "@linktr.ee/messaging-core";
|
|
5
|
+
import { Chat as Ie, useChatContext as ye, ChannelList as Se, Channel as Re, useChannelStateContext as ue, Window as ke, MessageList as Te, MessageInput as Pe } from "stream-chat-react";
|
|
6
|
+
import { NotePencilIcon as De, XIcon as me, ArrowLeftIcon as Me, DotsThreeIcon as Oe, SpinnerGapIcon as ee, SignOutIcon as Ue, ProhibitInsetIcon as ie, FlagIcon as Fe, MagnifyingGlassIcon as pe, ChatCircleDotsIcon as ce } from "@phosphor-icons/react";
|
|
7
|
+
const he = ve({
|
|
8
8
|
service: null,
|
|
9
9
|
client: null,
|
|
10
10
|
isConnected: !1,
|
|
@@ -15,109 +15,109 @@ const he = Ce({
|
|
|
15
15
|
refreshConnection: async () => {
|
|
16
16
|
},
|
|
17
17
|
debug: !1
|
|
18
|
-
}),
|
|
18
|
+
}), se = () => we(he), ts = ({
|
|
19
19
|
children: t,
|
|
20
20
|
user: s,
|
|
21
21
|
serviceConfig: n,
|
|
22
22
|
apiKey: l,
|
|
23
|
-
capabilities:
|
|
23
|
+
capabilities: a = {},
|
|
24
24
|
customization: d = {},
|
|
25
|
-
debug:
|
|
25
|
+
debug: i = !1
|
|
26
26
|
}) => {
|
|
27
|
-
const r =
|
|
28
|
-
(
|
|
29
|
-
|
|
27
|
+
const r = U(
|
|
28
|
+
(v, ...M) => {
|
|
29
|
+
i && console.log(`🔥 [MessagingProvider] ${v}`, ...M);
|
|
30
30
|
},
|
|
31
|
-
[
|
|
31
|
+
[i]
|
|
32
32
|
);
|
|
33
33
|
r("🔄 RENDER START", {
|
|
34
34
|
userId: s == null ? void 0 : s.id,
|
|
35
35
|
apiKey: (l == null ? void 0 : l.substring(0, 8)) + "...",
|
|
36
36
|
serviceConfig: !!n,
|
|
37
|
-
capabilities: Object.keys(
|
|
37
|
+
capabilities: Object.keys(a),
|
|
38
38
|
customization: Object.keys(d)
|
|
39
39
|
});
|
|
40
|
-
const [o,
|
|
40
|
+
const [o, w] = I(null), [u, N] = I(null), [m, E] = I(!1), [x, h] = I(!1), [C, S] = I(null), O = H(!1), y = H({
|
|
41
41
|
userId: s == null ? void 0 : s.id,
|
|
42
42
|
apiKey: l,
|
|
43
43
|
serviceConfig: n,
|
|
44
|
-
capabilities:
|
|
44
|
+
capabilities: a,
|
|
45
45
|
customization: d
|
|
46
|
-
}), k =
|
|
46
|
+
}), k = H(0);
|
|
47
47
|
k.current++, r("📊 RENDER INFO", {
|
|
48
48
|
renderCount: k.current,
|
|
49
49
|
currentProps: { userId: s == null ? void 0 : s.id, apiKey: (l == null ? void 0 : l.substring(0, 8)) + "..." },
|
|
50
50
|
propChanges: {
|
|
51
|
-
userChanged:
|
|
52
|
-
apiKeyChanged:
|
|
53
|
-
serviceConfigChanged:
|
|
54
|
-
capabilitiesChanged:
|
|
55
|
-
customizationChanged:
|
|
51
|
+
userChanged: y.current.userId !== (s == null ? void 0 : s.id),
|
|
52
|
+
apiKeyChanged: y.current.apiKey !== l,
|
|
53
|
+
serviceConfigChanged: y.current.serviceConfig !== n,
|
|
54
|
+
capabilitiesChanged: y.current.capabilities !== a,
|
|
55
|
+
customizationChanged: y.current.customization !== d
|
|
56
56
|
}
|
|
57
|
-
}),
|
|
57
|
+
}), y.current = {
|
|
58
58
|
userId: s == null ? void 0 : s.id,
|
|
59
59
|
apiKey: l,
|
|
60
60
|
serviceConfig: n,
|
|
61
|
-
capabilities:
|
|
61
|
+
capabilities: a,
|
|
62
62
|
customization: d
|
|
63
|
-
},
|
|
64
|
-
const
|
|
63
|
+
}, G(() => {
|
|
64
|
+
const v = k.current;
|
|
65
65
|
if (r("🔧 SERVICE INIT EFFECT TRIGGERED", {
|
|
66
|
-
renderCount:
|
|
66
|
+
renderCount: v,
|
|
67
67
|
apiKey: !!l,
|
|
68
68
|
serviceConfig: !!n,
|
|
69
69
|
dependencies: {
|
|
70
70
|
apiKey: (l == null ? void 0 : l.substring(0, 8)) + "...",
|
|
71
71
|
serviceConfigRef: n,
|
|
72
|
-
serviceConfigStable:
|
|
73
|
-
apiKeyStable:
|
|
72
|
+
serviceConfigStable: y.current.serviceConfig === n,
|
|
73
|
+
apiKeyStable: y.current.apiKey === l
|
|
74
74
|
}
|
|
75
75
|
}), !l || !n) {
|
|
76
76
|
r("⚠️ SERVICE INIT SKIPPED", {
|
|
77
|
-
renderCount:
|
|
77
|
+
renderCount: v,
|
|
78
78
|
reason: "Missing apiKey or serviceConfig"
|
|
79
79
|
});
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
82
|
r("🚀 CREATING NEW SERVICE", {
|
|
83
|
-
renderCount:
|
|
83
|
+
renderCount: v,
|
|
84
84
|
apiKey: (l == null ? void 0 : l.substring(0, 8)) + "...",
|
|
85
|
-
serviceConfigChanged:
|
|
85
|
+
serviceConfigChanged: y.current.serviceConfig !== n
|
|
86
86
|
});
|
|
87
|
-
const
|
|
87
|
+
const M = new Ee({
|
|
88
88
|
...n,
|
|
89
89
|
apiKey: l,
|
|
90
|
-
debug:
|
|
90
|
+
debug: i
|
|
91
91
|
});
|
|
92
|
-
return
|
|
93
|
-
renderCount:
|
|
94
|
-
serviceInstance: !!
|
|
92
|
+
return w(M), r("✅ SERVICE SET", {
|
|
93
|
+
renderCount: v,
|
|
94
|
+
serviceInstance: !!M
|
|
95
95
|
}), () => {
|
|
96
96
|
r("🧹 SERVICE CLEANUP", {
|
|
97
|
-
renderCount:
|
|
97
|
+
renderCount: v,
|
|
98
98
|
reason: "Effect cleanup"
|
|
99
|
-
}),
|
|
99
|
+
}), M.disconnectUser().catch(console.error);
|
|
100
100
|
};
|
|
101
|
-
}, [l, n,
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
var
|
|
101
|
+
}, [l, n, i, r]);
|
|
102
|
+
const T = H(null);
|
|
103
|
+
G(() => {
|
|
104
|
+
var M, p;
|
|
105
105
|
if (r("🔗 USER CONNECTION EFFECT TRIGGERED", {
|
|
106
106
|
hasService: !!o,
|
|
107
107
|
hasUser: !!s,
|
|
108
108
|
userId: s == null ? void 0 : s.id,
|
|
109
|
-
isConnecting:
|
|
110
|
-
isConnected:
|
|
109
|
+
isConnecting: O.current,
|
|
110
|
+
isConnected: m,
|
|
111
111
|
dependencies: { service: !!o, userId: s == null ? void 0 : s.id }
|
|
112
112
|
}), !o || !s) {
|
|
113
113
|
r("⚠️ USER CONNECTION SKIPPED", "Missing service or user");
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
|
-
if (
|
|
116
|
+
if (O.current) {
|
|
117
117
|
r("⚠️ USER CONNECTION SKIPPED", "Already connecting");
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
120
|
-
if (((
|
|
120
|
+
if (((M = T.current) == null ? void 0 : M.serviceId) === o && ((p = T.current) == null ? void 0 : p.userId) === s.id) {
|
|
121
121
|
r(
|
|
122
122
|
"⚠️ USER CONNECTION SKIPPED",
|
|
123
123
|
"Already connected this user with this service"
|
|
@@ -125,40 +125,40 @@ const he = Ce({
|
|
|
125
125
|
return;
|
|
126
126
|
}
|
|
127
127
|
(async () => {
|
|
128
|
-
r("🚀 STARTING USER CONNECTION", { userId: s.id }),
|
|
128
|
+
r("🚀 STARTING USER CONNECTION", { userId: s.id }), O.current = !0, h(!0), S(null);
|
|
129
129
|
try {
|
|
130
130
|
r("📞 CALLING SERVICE.CONNECTUSER", { userId: s.id });
|
|
131
|
-
const
|
|
132
|
-
|
|
131
|
+
const L = await o.connectUser(s);
|
|
132
|
+
N(L), E(!0), T.current = { serviceId: o, userId: s.id }, r("✅ USER CONNECTION SUCCESS", {
|
|
133
133
|
userId: s.id,
|
|
134
|
-
clientId:
|
|
134
|
+
clientId: L.userID
|
|
135
135
|
});
|
|
136
|
-
} catch (
|
|
137
|
-
const
|
|
138
|
-
|
|
136
|
+
} catch (L) {
|
|
137
|
+
const $ = L instanceof Error ? L.message : "Connection failed";
|
|
138
|
+
S($), r("❌ USER CONNECTION ERROR", {
|
|
139
139
|
userId: s.id,
|
|
140
|
-
error:
|
|
140
|
+
error: $
|
|
141
141
|
});
|
|
142
142
|
} finally {
|
|
143
|
-
|
|
143
|
+
h(!1), O.current = !1, r("🔄 USER CONNECTION FINISHED", {
|
|
144
144
|
userId: s.id,
|
|
145
|
-
isConnected:
|
|
145
|
+
isConnected: m
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
148
|
})();
|
|
149
|
-
}, [o, s, r,
|
|
149
|
+
}, [o, s, r, m]), G(() => (r("🔌 CLEANUP EFFECT REGISTERED", {
|
|
150
150
|
hasService: !!o,
|
|
151
|
-
isConnected:
|
|
151
|
+
isConnected: m
|
|
152
152
|
}), () => {
|
|
153
|
-
o &&
|
|
153
|
+
o && m ? (r(
|
|
154
154
|
"🧹 CLEANUP EFFECT TRIGGERED",
|
|
155
155
|
"Cleaning up connection on unmount"
|
|
156
|
-
),
|
|
156
|
+
), T.current = null, o.disconnectUser().catch(console.error)) : r("🔇 CLEANUP EFFECT SKIPPED", {
|
|
157
157
|
hasService: !!o,
|
|
158
|
-
isConnected:
|
|
158
|
+
isConnected: m
|
|
159
159
|
});
|
|
160
|
-
}), [o,
|
|
161
|
-
const f =
|
|
160
|
+
}), [o, m, r]);
|
|
161
|
+
const f = U(async () => {
|
|
162
162
|
if (r("🔄 REFRESH CONNECTION CALLED", {
|
|
163
163
|
hasService: !!o,
|
|
164
164
|
hasUser: !!s
|
|
@@ -166,62 +166,62 @@ const he = Ce({
|
|
|
166
166
|
r("⚠️ REFRESH CONNECTION SKIPPED", "Missing service or user");
|
|
167
167
|
return;
|
|
168
168
|
}
|
|
169
|
-
r("🚀 STARTING CONNECTION REFRESH", { userId: s.id }),
|
|
169
|
+
r("🚀 STARTING CONNECTION REFRESH", { userId: s.id }), h(!0);
|
|
170
170
|
try {
|
|
171
171
|
r("🔌 DISCONNECTING FOR REFRESH"), await o.disconnectUser(), r("📞 RECONNECTING FOR REFRESH");
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
} catch (
|
|
175
|
-
const
|
|
176
|
-
|
|
172
|
+
const v = await o.connectUser(s);
|
|
173
|
+
N(v), E(!0), S(null), r("✅ CONNECTION REFRESH SUCCESS", { userId: s.id });
|
|
174
|
+
} catch (v) {
|
|
175
|
+
const M = v instanceof Error ? v.message : "Refresh failed";
|
|
176
|
+
S(M), r("❌ CONNECTION REFRESH ERROR", {
|
|
177
177
|
userId: s.id,
|
|
178
|
-
error:
|
|
178
|
+
error: M
|
|
179
179
|
});
|
|
180
180
|
} finally {
|
|
181
|
-
|
|
181
|
+
h(!1), r("🔄 CONNECTION REFRESH FINISHED", { userId: s.id });
|
|
182
182
|
}
|
|
183
183
|
}, [o, s, r]), g = X.useMemo(() => (r("💫 CONTEXT VALUE MEMOIZATION", {
|
|
184
184
|
hasService: !!o,
|
|
185
|
-
hasClient: !!
|
|
186
|
-
isConnected:
|
|
187
|
-
isLoading:
|
|
188
|
-
hasError: !!
|
|
189
|
-
capabilitiesKeys: Object.keys(
|
|
185
|
+
hasClient: !!u,
|
|
186
|
+
isConnected: m,
|
|
187
|
+
isLoading: x,
|
|
188
|
+
hasError: !!C,
|
|
189
|
+
capabilitiesKeys: Object.keys(a),
|
|
190
190
|
customizationKeys: Object.keys(d)
|
|
191
191
|
}), {
|
|
192
192
|
service: o,
|
|
193
|
-
client:
|
|
194
|
-
isConnected:
|
|
195
|
-
isLoading:
|
|
196
|
-
error:
|
|
197
|
-
capabilities:
|
|
193
|
+
client: u,
|
|
194
|
+
isConnected: m,
|
|
195
|
+
isLoading: x,
|
|
196
|
+
error: C,
|
|
197
|
+
capabilities: a,
|
|
198
198
|
customization: d,
|
|
199
199
|
refreshConnection: f,
|
|
200
|
-
debug:
|
|
200
|
+
debug: i
|
|
201
201
|
}), [
|
|
202
202
|
o,
|
|
203
|
-
m,
|
|
204
|
-
h,
|
|
205
203
|
u,
|
|
206
|
-
|
|
207
|
-
|
|
204
|
+
m,
|
|
205
|
+
x,
|
|
206
|
+
C,
|
|
207
|
+
a,
|
|
208
208
|
d,
|
|
209
209
|
f,
|
|
210
|
-
|
|
210
|
+
i,
|
|
211
211
|
r
|
|
212
212
|
]);
|
|
213
213
|
return r("🔄 RENDER END", {
|
|
214
214
|
renderCount: k.current,
|
|
215
|
-
willRenderChat: !!(
|
|
215
|
+
willRenderChat: !!(u && m),
|
|
216
216
|
contextValueReady: !!g
|
|
217
|
-
}), /* @__PURE__ */ e(he.Provider, { value: g, children:
|
|
218
|
-
},
|
|
219
|
-
function
|
|
217
|
+
}), /* @__PURE__ */ e(he.Provider, { value: g, children: u && m ? /* @__PURE__ */ e(Ie, { client: u, children: t }) : t });
|
|
218
|
+
}, Le = () => se();
|
|
219
|
+
function ne({ label: t, className: s, children: n, ...l }) {
|
|
220
220
|
return /* @__PURE__ */ c(
|
|
221
221
|
"button",
|
|
222
222
|
{
|
|
223
223
|
type: "button",
|
|
224
|
-
className:
|
|
224
|
+
className: D(
|
|
225
225
|
"rounded-full p-2 transition-colors focus-ring",
|
|
226
226
|
{
|
|
227
227
|
"cursor-not-allowed opacity-50": l.disabled,
|
|
@@ -237,7 +237,7 @@ function se({ label: t, className: s, children: n, ...l }) {
|
|
|
237
237
|
}
|
|
238
238
|
);
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function je(t) {
|
|
241
241
|
const s = [
|
|
242
242
|
{ color: "#8129D9" },
|
|
243
243
|
// purple
|
|
@@ -265,25 +265,25 @@ function pe(t) {
|
|
|
265
265
|
// olive green
|
|
266
266
|
];
|
|
267
267
|
let n = 0;
|
|
268
|
-
for (let
|
|
269
|
-
n = (n << 5) - n + t.charCodeAt(
|
|
268
|
+
for (let a = 0; a < t.length; a++)
|
|
269
|
+
n = (n << 5) - n + t.charCodeAt(a), n = n & n;
|
|
270
270
|
const l = Math.abs(n) % s.length;
|
|
271
271
|
return s[l];
|
|
272
272
|
}
|
|
273
|
-
const
|
|
273
|
+
const Y = ({
|
|
274
274
|
id: t,
|
|
275
275
|
name: s,
|
|
276
276
|
image: n,
|
|
277
277
|
size: l = 40,
|
|
278
|
-
className:
|
|
278
|
+
className: a
|
|
279
279
|
}) => {
|
|
280
|
-
const { color: d } =
|
|
280
|
+
const { color: d } = je(t), i = s.charAt(0).toUpperCase(), o = l < 32 ? "text-xs" : l < 56 ? "text-sm" : "text-lg";
|
|
281
281
|
return /* @__PURE__ */ e(
|
|
282
282
|
"div",
|
|
283
283
|
{
|
|
284
|
-
className:
|
|
284
|
+
className: D(
|
|
285
285
|
"flex-shrink-0 overflow-hidden rounded-full",
|
|
286
|
-
|
|
286
|
+
a
|
|
287
287
|
),
|
|
288
288
|
style: { width: `${l}px`, height: `${l}px` },
|
|
289
289
|
children: n ? /* @__PURE__ */ e(
|
|
@@ -297,7 +297,7 @@ const ne = ({
|
|
|
297
297
|
"div",
|
|
298
298
|
{
|
|
299
299
|
"aria-hidden": "true",
|
|
300
|
-
className:
|
|
300
|
+
className: D(
|
|
301
301
|
"flex h-full w-full items-center justify-center font-semibold",
|
|
302
302
|
o
|
|
303
303
|
),
|
|
@@ -305,49 +305,49 @@ const ne = ({
|
|
|
305
305
|
color: d,
|
|
306
306
|
backgroundColor: `color-mix(in srgb, ${d} 20%, transparent)`
|
|
307
307
|
},
|
|
308
|
-
children:
|
|
308
|
+
children: i
|
|
309
309
|
}
|
|
310
310
|
)
|
|
311
311
|
}
|
|
312
312
|
);
|
|
313
|
-
},
|
|
314
|
-
var
|
|
315
|
-
const
|
|
313
|
+
}, Ae = ({ channel: t, selectedChannel: s, onChannelSelect: n, debug: l = !1 }) => {
|
|
314
|
+
var x, h, C, S, O, y, k;
|
|
315
|
+
const a = (s == null ? void 0 : s.id) === (t == null ? void 0 : t.id), d = () => {
|
|
316
316
|
t && n(t);
|
|
317
|
-
}, r = Object.values(((
|
|
318
|
-
(
|
|
317
|
+
}, r = Object.values(((x = t == null ? void 0 : t.state) == null ? void 0 : x.members) || {}).find(
|
|
318
|
+
(T) => {
|
|
319
319
|
var f, g;
|
|
320
|
-
return ((f =
|
|
320
|
+
return ((f = T.user) == null ? void 0 : f.id) && T.user.id !== ((g = t == null ? void 0 : t._client) == null ? void 0 : g.userID);
|
|
321
321
|
}
|
|
322
|
-
), o = ((
|
|
322
|
+
), o = ((h = r == null ? void 0 : r.user) == null ? void 0 : h.name) || "Conversation", w = (C = r == null ? void 0 : r.user) == null ? void 0 : C.image, u = (O = (S = t == null ? void 0 : t.state) == null ? void 0 : S.messages) == null ? void 0 : O[t.state.messages.length - 1], N = (u == null ? void 0 : u.text) || "No messages yet", m = u != null && u.created_at ? new Date(u.created_at).toLocaleTimeString([], {
|
|
323
323
|
hour: "2-digit",
|
|
324
324
|
minute: "2-digit"
|
|
325
|
-
}) : "",
|
|
325
|
+
}) : "", E = ((y = t == null ? void 0 : t.state) == null ? void 0 : y.unreadCount) || 0;
|
|
326
326
|
return l && console.log("📺 [ChannelList] 📋 CHANNEL PREVIEW RENDER", {
|
|
327
327
|
channelId: t == null ? void 0 : t.id,
|
|
328
|
-
isSelected:
|
|
328
|
+
isSelected: a,
|
|
329
329
|
participantName: o,
|
|
330
|
-
unread:
|
|
331
|
-
hasTimestamp: !!
|
|
330
|
+
unread: E,
|
|
331
|
+
hasTimestamp: !!m
|
|
332
332
|
}), /* @__PURE__ */ e(
|
|
333
333
|
"button",
|
|
334
334
|
{
|
|
335
335
|
type: "button",
|
|
336
336
|
onClick: d,
|
|
337
|
-
className:
|
|
337
|
+
className: D(
|
|
338
338
|
"w-full px-4 py-3 transition-colors border-b border-sand text-left max-w-full overflow-hidden focus-ring",
|
|
339
339
|
{
|
|
340
|
-
"bg-primary-alt/10 border-l-4 border-l-primary":
|
|
341
|
-
"hover:bg-sand": !
|
|
340
|
+
"bg-primary-alt/10 border-l-4 border-l-primary": a,
|
|
341
|
+
"hover:bg-sand": !a
|
|
342
342
|
}
|
|
343
343
|
),
|
|
344
344
|
children: /* @__PURE__ */ c("div", { className: "flex items-start gap-3", children: [
|
|
345
345
|
/* @__PURE__ */ e(
|
|
346
|
-
|
|
346
|
+
Y,
|
|
347
347
|
{
|
|
348
348
|
id: ((k = r == null ? void 0 : r.user) == null ? void 0 : k.id) || t.id || "unknown",
|
|
349
349
|
name: o,
|
|
350
|
-
image:
|
|
350
|
+
image: w,
|
|
351
351
|
size: 44
|
|
352
352
|
}
|
|
353
353
|
),
|
|
@@ -356,18 +356,18 @@ const ne = ({
|
|
|
356
356
|
/* @__PURE__ */ e(
|
|
357
357
|
"h3",
|
|
358
358
|
{
|
|
359
|
-
className:
|
|
359
|
+
className: D(
|
|
360
360
|
"text-sm font-medium truncate",
|
|
361
|
-
|
|
361
|
+
a ? "text-primary" : "text-charcoal"
|
|
362
362
|
),
|
|
363
363
|
children: o
|
|
364
364
|
}
|
|
365
365
|
),
|
|
366
|
-
|
|
366
|
+
m && /* @__PURE__ */ e("span", { className: "text-xs text-stone flex-shrink-0", children: m })
|
|
367
367
|
] }),
|
|
368
368
|
/* @__PURE__ */ c("div", { className: "flex items-center justify-between gap-2 min-w-0", children: [
|
|
369
|
-
/* @__PURE__ */ e("p", { className: "text-xs text-stone mr-2 flex-1 line-clamp-2", children:
|
|
370
|
-
|
|
369
|
+
/* @__PURE__ */ e("p", { className: "text-xs text-stone mr-2 flex-1 line-clamp-2", children: N }),
|
|
370
|
+
E > 0 && /* @__PURE__ */ e("span", { className: "bg-primary text-white text-xs px-2 py-0.5 rounded-full min-w-[20px] text-center flex-shrink-0", children: E > 99 ? "99+" : E })
|
|
371
371
|
] })
|
|
372
372
|
] })
|
|
373
373
|
] })
|
|
@@ -378,38 +378,38 @@ const ne = ({
|
|
|
378
378
|
selectedChannel: s,
|
|
379
379
|
showStartConversation: n = !1,
|
|
380
380
|
onStartConversation: l,
|
|
381
|
-
participantLabel:
|
|
381
|
+
participantLabel: a = "participants",
|
|
382
382
|
className: d
|
|
383
383
|
}) => {
|
|
384
|
-
var
|
|
385
|
-
const
|
|
386
|
-
|
|
387
|
-
const { debug: r = !1 } =
|
|
384
|
+
var u;
|
|
385
|
+
const i = X.useRef(0);
|
|
386
|
+
i.current++;
|
|
387
|
+
const { debug: r = !1 } = se();
|
|
388
388
|
r && console.log("📺 [ChannelList] 🔄 RENDER START", {
|
|
389
|
-
renderCount:
|
|
389
|
+
renderCount: i.current,
|
|
390
390
|
selectedChannelId: s == null ? void 0 : s.id,
|
|
391
391
|
showStartConversation: n,
|
|
392
|
-
participantLabel:
|
|
392
|
+
participantLabel: a
|
|
393
393
|
});
|
|
394
|
-
const { client: o } =
|
|
394
|
+
const { client: o } = ye();
|
|
395
395
|
r && console.log("📺 [ChannelList] 📡 CHAT CONTEXT", {
|
|
396
|
-
renderCount:
|
|
396
|
+
renderCount: i.current,
|
|
397
397
|
hasClient: !!o,
|
|
398
398
|
clientUserId: o == null ? void 0 : o.userID,
|
|
399
|
-
clientConnected: (
|
|
399
|
+
clientConnected: (u = o == null ? void 0 : o.wsConnection) == null ? void 0 : u.isHealthy
|
|
400
400
|
});
|
|
401
|
-
const
|
|
402
|
-
const
|
|
401
|
+
const w = X.useMemo(() => {
|
|
402
|
+
const N = o.userID, m = N ? { type: "messaging", members: { $in: [N] }, hidden: !1 } : { type: "messaging" };
|
|
403
403
|
return r && console.log("📺 [ChannelList] 🔍 FILTERS MEMOIZED", {
|
|
404
|
-
renderCount:
|
|
405
|
-
userId:
|
|
406
|
-
filters:
|
|
407
|
-
}),
|
|
404
|
+
renderCount: i.current,
|
|
405
|
+
userId: N,
|
|
406
|
+
filters: m
|
|
407
|
+
}), m;
|
|
408
408
|
}, [o.userID, r]);
|
|
409
409
|
return /* @__PURE__ */ c(
|
|
410
410
|
"div",
|
|
411
411
|
{
|
|
412
|
-
className:
|
|
412
|
+
className: D(
|
|
413
413
|
"messaging-channel-list h-full flex flex-col min-w-0 overflow-hidden",
|
|
414
414
|
d
|
|
415
415
|
),
|
|
@@ -417,36 +417,36 @@ const ne = ({
|
|
|
417
417
|
/* @__PURE__ */ e("div", { className: "px-4 py-4 border-b border-sand bg-chalk", children: /* @__PURE__ */ c("div", { className: "flex items-center justify-between gap-3 min-h-10 min-w-0", children: [
|
|
418
418
|
/* @__PURE__ */ e("h2", { className: "text-lg font-semibold text-charcoal", children: "Conversations" }),
|
|
419
419
|
/* @__PURE__ */ e("div", { className: "flex items-center gap-2", children: n && l && /* @__PURE__ */ e(
|
|
420
|
-
|
|
420
|
+
ne,
|
|
421
421
|
{
|
|
422
422
|
label: "Start a new conversation",
|
|
423
423
|
onClick: l,
|
|
424
424
|
className: "inline-flex size-10 items-center justify-center",
|
|
425
|
-
children: /* @__PURE__ */ e(
|
|
425
|
+
children: /* @__PURE__ */ e(De, { className: "h-5 w-5" })
|
|
426
426
|
}
|
|
427
427
|
) })
|
|
428
428
|
] }) }),
|
|
429
429
|
/* @__PURE__ */ e("div", { className: "flex-1 overflow-hidden min-w-0", children: (r && console.log("📺 [ChannelList] 🎬 RENDERING STREAM CHANNEL LIST", {
|
|
430
|
-
renderCount:
|
|
431
|
-
filters:
|
|
430
|
+
renderCount: i.current,
|
|
431
|
+
filters: w,
|
|
432
432
|
hasClient: !!o,
|
|
433
433
|
clientUserId: o == null ? void 0 : o.userID
|
|
434
434
|
}), /* @__PURE__ */ e(
|
|
435
|
-
|
|
435
|
+
Se,
|
|
436
436
|
{
|
|
437
|
-
filters:
|
|
437
|
+
filters: w,
|
|
438
438
|
sort: { last_message_at: -1 },
|
|
439
439
|
options: { limit: 30 },
|
|
440
|
-
Preview: (
|
|
441
|
-
var
|
|
440
|
+
Preview: (N) => {
|
|
441
|
+
var m, E;
|
|
442
442
|
return r && console.log("📺 [ChannelList] 📋 CHANNEL PREVIEW RENDER", {
|
|
443
|
-
channelId: (
|
|
443
|
+
channelId: (m = N.channel) == null ? void 0 : m.id,
|
|
444
444
|
selectedChannelId: s == null ? void 0 : s.id,
|
|
445
|
-
isSelected: (s == null ? void 0 : s.id) === ((
|
|
445
|
+
isSelected: (s == null ? void 0 : s.id) === ((E = N.channel) == null ? void 0 : E.id)
|
|
446
446
|
}), /* @__PURE__ */ e(
|
|
447
|
-
|
|
447
|
+
Ae,
|
|
448
448
|
{
|
|
449
|
-
...
|
|
449
|
+
...N,
|
|
450
450
|
selectedChannel: s,
|
|
451
451
|
onChannelSelect: t,
|
|
452
452
|
debug: r
|
|
@@ -458,7 +458,7 @@ const ne = ({
|
|
|
458
458
|
]
|
|
459
459
|
}
|
|
460
460
|
);
|
|
461
|
-
},
|
|
461
|
+
}, K = ({
|
|
462
462
|
variant: t = "default",
|
|
463
463
|
className: s,
|
|
464
464
|
children: n,
|
|
@@ -467,7 +467,7 @@ const ne = ({
|
|
|
467
467
|
"button",
|
|
468
468
|
{
|
|
469
469
|
type: "button",
|
|
470
|
-
className:
|
|
470
|
+
className: D(
|
|
471
471
|
"flex w-full items-center gap-3 rounded-lg px-4 py-3 text-left text-sm transition-colors focus-ring disabled:cursor-not-allowed disabled:opacity-60",
|
|
472
472
|
t === "danger" ? "text-danger hover:bg-danger/50" : "text-charcoal hover:bg-sand",
|
|
473
473
|
s
|
|
@@ -477,19 +477,19 @@ const ne = ({
|
|
|
477
477
|
}
|
|
478
478
|
);
|
|
479
479
|
function fe({ onClick: t }) {
|
|
480
|
-
return /* @__PURE__ */ e(
|
|
480
|
+
return /* @__PURE__ */ e(ne, { label: "Close", onClick: t, className: "p-1", children: /* @__PURE__ */ e(me, { className: "h-5 w-5 text-stone", weight: "bold" }) });
|
|
481
481
|
}
|
|
482
|
-
const
|
|
482
|
+
const He = ({ renderActions: t }) => /* @__PURE__ */ c("div", { className: "message-input flex items-center gap-2 p-4", children: [
|
|
483
483
|
t && t(),
|
|
484
|
-
/* @__PURE__ */ e("div", { className: "flex-1", children: /* @__PURE__ */ e(
|
|
485
|
-
] }),
|
|
486
|
-
var o,
|
|
487
|
-
const { channel:
|
|
488
|
-
(
|
|
489
|
-
var
|
|
490
|
-
return ((
|
|
484
|
+
/* @__PURE__ */ e("div", { className: "flex-1", children: /* @__PURE__ */ e(Pe, { focus: !0, maxRows: 4 }) })
|
|
485
|
+
] }), Ge = ({ onBack: t, showBackButton: s, onShowInfo: n, canShowInfo: l }) => {
|
|
486
|
+
var o, w, u, N;
|
|
487
|
+
const { channel: a } = ue(), d = X.useMemo(() => Object.values(a.state.members || {}).find(
|
|
488
|
+
(E) => {
|
|
489
|
+
var x;
|
|
490
|
+
return ((x = E.user) == null ? void 0 : x.id) && E.user.id !== a._client.userID;
|
|
491
491
|
}
|
|
492
|
-
), [
|
|
492
|
+
), [a._client.userID, a.state.members]), i = ((o = d == null ? void 0 : d.user) == null ? void 0 : o.name) || ((w = d == null ? void 0 : d.user) == null ? void 0 : w.id) || "Unknown member", r = (u = d == null ? void 0 : d.user) == null ? void 0 : u.image;
|
|
493
493
|
return /* @__PURE__ */ c("div", { className: "flex items-center justify-between gap-3 min-h-12", children: [
|
|
494
494
|
/* @__PURE__ */ c("div", { className: "flex items-center gap-3 min-w-0", children: [
|
|
495
495
|
s && t && /* @__PURE__ */ e(
|
|
@@ -499,93 +499,93 @@ const Ae = ({ renderActions: t }) => /* @__PURE__ */ c("div", { className: "mess
|
|
|
499
499
|
onClick: t,
|
|
500
500
|
className: "inline-flex items-center justify-center w-8 h-8 rounded-lg hover:bg-sand focus:outline-none focus:ring-2 focus:ring-primary transition-colors lg:hidden",
|
|
501
501
|
"aria-label": "Back to conversations",
|
|
502
|
-
children: /* @__PURE__ */ e(
|
|
502
|
+
children: /* @__PURE__ */ e(Me, { className: "h-5 w-5 text-stone", weight: "bold" })
|
|
503
503
|
}
|
|
504
504
|
),
|
|
505
505
|
/* @__PURE__ */ e(
|
|
506
|
-
|
|
506
|
+
Y,
|
|
507
507
|
{
|
|
508
|
-
id: ((
|
|
509
|
-
name:
|
|
508
|
+
id: ((N = d == null ? void 0 : d.user) == null ? void 0 : N.id) || a.id || "unknown",
|
|
509
|
+
name: i,
|
|
510
510
|
image: r,
|
|
511
511
|
size: 40
|
|
512
512
|
}
|
|
513
513
|
),
|
|
514
|
-
/* @__PURE__ */ e("div", { className: "min-w-0", children: /* @__PURE__ */ e("h1", { className: "text-lg font-semibold text-charcoal truncate", children:
|
|
514
|
+
/* @__PURE__ */ e("div", { className: "min-w-0", children: /* @__PURE__ */ e("h1", { className: "text-lg font-semibold text-charcoal truncate", children: i }) })
|
|
515
515
|
] }),
|
|
516
|
-
l && n && /* @__PURE__ */ e(
|
|
516
|
+
l && n && /* @__PURE__ */ e(ne, { label: "Chat info", onClick: n, children: /* @__PURE__ */ e(Oe, { className: "h-6 w-6 text-charcoal", weight: "bold" }) })
|
|
517
517
|
] });
|
|
518
|
-
},
|
|
518
|
+
}, $e = ({
|
|
519
519
|
isOpen: t,
|
|
520
520
|
onClose: s,
|
|
521
521
|
participant: n,
|
|
522
522
|
channel: l,
|
|
523
|
-
followerStatusLabel:
|
|
523
|
+
followerStatusLabel: a,
|
|
524
524
|
onLeaveConversation: d,
|
|
525
|
-
onBlockParticipant:
|
|
525
|
+
onBlockParticipant: i
|
|
526
526
|
}) => {
|
|
527
|
-
var
|
|
528
|
-
const { service: r, debug: o } =
|
|
529
|
-
|
|
530
|
-
const
|
|
531
|
-
|
|
527
|
+
var L, $, _, V, Q, W, z;
|
|
528
|
+
const { service: r, debug: o } = se(), w = H(null), [u, N] = I(!1), [m, E] = I(!1), [x, h] = I(!1);
|
|
529
|
+
G(() => {
|
|
530
|
+
const R = w.current;
|
|
531
|
+
R && (t ? R.showModal() : R.close());
|
|
532
532
|
}, [t]);
|
|
533
|
-
const
|
|
534
|
-
var
|
|
535
|
-
if (!(!r || !((
|
|
533
|
+
const C = U(async () => {
|
|
534
|
+
var R;
|
|
535
|
+
if (!(!r || !((R = n == null ? void 0 : n.user) != null && R.id)))
|
|
536
536
|
try {
|
|
537
537
|
const A = (await r.getBlockedUsers()).some(
|
|
538
|
-
(
|
|
538
|
+
(q) => {
|
|
539
539
|
var Z;
|
|
540
|
-
return
|
|
540
|
+
return q.blocked_user_id === ((Z = n == null ? void 0 : n.user) == null ? void 0 : Z.id);
|
|
541
541
|
}
|
|
542
542
|
);
|
|
543
|
-
|
|
544
|
-
} catch (
|
|
543
|
+
N(A);
|
|
544
|
+
} catch (P) {
|
|
545
545
|
console.error(
|
|
546
546
|
"[ChannelInfoDialog] Failed to check blocked status:",
|
|
547
|
-
|
|
547
|
+
P
|
|
548
548
|
);
|
|
549
549
|
}
|
|
550
|
-
}, [r, (
|
|
551
|
-
|
|
552
|
-
t &&
|
|
553
|
-
}, [t,
|
|
554
|
-
const
|
|
555
|
-
var
|
|
556
|
-
if (!
|
|
557
|
-
o && console.log("[ChannelInfoDialog] Leave conversation", l.cid),
|
|
550
|
+
}, [r, (L = n == null ? void 0 : n.user) == null ? void 0 : L.id]);
|
|
551
|
+
G(() => {
|
|
552
|
+
t && C();
|
|
553
|
+
}, [t, C]);
|
|
554
|
+
const S = async () => {
|
|
555
|
+
var R;
|
|
556
|
+
if (!m) {
|
|
557
|
+
o && console.log("[ChannelInfoDialog] Leave conversation", l.cid), E(!0);
|
|
558
558
|
try {
|
|
559
|
-
const
|
|
560
|
-
await l.hide(
|
|
561
|
-
} catch (
|
|
562
|
-
console.error("[ChannelInfoDialog] Failed to leave conversation",
|
|
559
|
+
const P = ((R = l._client) == null ? void 0 : R.userID) ?? null;
|
|
560
|
+
await l.hide(P, !1), d && await d(l), s();
|
|
561
|
+
} catch (P) {
|
|
562
|
+
console.error("[ChannelInfoDialog] Failed to leave conversation", P);
|
|
563
563
|
} finally {
|
|
564
|
-
|
|
564
|
+
E(!1);
|
|
565
565
|
}
|
|
566
566
|
}
|
|
567
|
-
},
|
|
568
|
-
var
|
|
569
|
-
if (!(
|
|
570
|
-
o && console.log("[ChannelInfoDialog] Block member", (
|
|
567
|
+
}, O = async () => {
|
|
568
|
+
var R, P, A;
|
|
569
|
+
if (!(x || !r)) {
|
|
570
|
+
o && console.log("[ChannelInfoDialog] Block member", (R = n == null ? void 0 : n.user) == null ? void 0 : R.id), h(!0);
|
|
571
571
|
try {
|
|
572
|
-
await r.blockUser((
|
|
573
|
-
} catch (
|
|
574
|
-
console.error("[ChannelInfoDialog] Failed to block member",
|
|
572
|
+
await r.blockUser((P = n == null ? void 0 : n.user) == null ? void 0 : P.id), i && await i((A = n == null ? void 0 : n.user) == null ? void 0 : A.id), s();
|
|
573
|
+
} catch (q) {
|
|
574
|
+
console.error("[ChannelInfoDialog] Failed to block member", q);
|
|
575
575
|
} finally {
|
|
576
|
-
|
|
576
|
+
h(!1);
|
|
577
577
|
}
|
|
578
578
|
}
|
|
579
|
-
},
|
|
580
|
-
var
|
|
581
|
-
if (!(
|
|
582
|
-
o && console.log("[ChannelInfoDialog] Unblock member", (
|
|
579
|
+
}, y = async () => {
|
|
580
|
+
var R, P, A;
|
|
581
|
+
if (!(x || !r)) {
|
|
582
|
+
o && console.log("[ChannelInfoDialog] Unblock member", (R = n == null ? void 0 : n.user) == null ? void 0 : R.id), h(!0);
|
|
583
583
|
try {
|
|
584
|
-
await r.unBlockUser((
|
|
585
|
-
} catch (
|
|
586
|
-
console.error("[ChannelInfoDialog] Failed to unblock member",
|
|
584
|
+
await r.unBlockUser((P = n == null ? void 0 : n.user) == null ? void 0 : P.id), i && await i((A = n == null ? void 0 : n.user) == null ? void 0 : A.id), s();
|
|
585
|
+
} catch (q) {
|
|
586
|
+
console.error("[ChannelInfoDialog] Failed to unblock member", q);
|
|
587
587
|
} finally {
|
|
588
|
-
|
|
588
|
+
h(!1);
|
|
589
589
|
}
|
|
590
590
|
}
|
|
591
591
|
}, k = () => {
|
|
@@ -596,17 +596,17 @@ const Ae = ({ renderActions: t }) => /* @__PURE__ */ c("div", { className: "mess
|
|
|
596
596
|
);
|
|
597
597
|
};
|
|
598
598
|
if (!n) return null;
|
|
599
|
-
const
|
|
599
|
+
const T = (($ = n.user) == null ? void 0 : $.name) || ((_ = n.user) == null ? void 0 : _.id) || "Unknown member", f = (V = n.user) == null ? void 0 : V.image, g = (Q = n.user) == null ? void 0 : Q.email, v = (W = n.user) == null ? void 0 : W.username, M = g || (v ? `linktr.ee/${v}` : void 0), p = ((z = n.user) == null ? void 0 : z.id) || "unknown";
|
|
600
600
|
return (
|
|
601
601
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
|
|
602
602
|
/* @__PURE__ */ e(
|
|
603
603
|
"dialog",
|
|
604
604
|
{
|
|
605
|
-
ref:
|
|
605
|
+
ref: w,
|
|
606
606
|
className: "mes-dialog",
|
|
607
607
|
onClose: s,
|
|
608
|
-
onClick: (
|
|
609
|
-
|
|
608
|
+
onClick: (R) => {
|
|
609
|
+
R.target === w.current && s();
|
|
610
610
|
},
|
|
611
611
|
children: /* @__PURE__ */ c("div", { className: "ml-auto flex h-full w-full flex-col bg-white shadow-max-elevation-light", children: [
|
|
612
612
|
/* @__PURE__ */ c("div", { className: "flex items-center justify-between border-b border-sand px-4 py-3", children: [
|
|
@@ -616,58 +616,58 @@ const Ae = ({ renderActions: t }) => /* @__PURE__ */ c("div", { className: "mess
|
|
|
616
616
|
/* @__PURE__ */ c("div", { className: "flex-1 overflow-y-auto px-6 py-6", children: [
|
|
617
617
|
/* @__PURE__ */ e("div", { className: "rounded-2xl bg-chalk p-4", children: /* @__PURE__ */ c("div", { className: "flex items-center gap-4", children: [
|
|
618
618
|
/* @__PURE__ */ e(
|
|
619
|
-
|
|
619
|
+
Y,
|
|
620
620
|
{
|
|
621
|
-
id:
|
|
622
|
-
name:
|
|
621
|
+
id: p,
|
|
622
|
+
name: T,
|
|
623
623
|
image: f,
|
|
624
624
|
size: 64
|
|
625
625
|
}
|
|
626
626
|
),
|
|
627
627
|
/* @__PURE__ */ c("div", { className: "min-w-0 flex-1", children: [
|
|
628
|
-
/* @__PURE__ */ e("p", { className: "truncate text-base font-semibold text-charcoal", children:
|
|
629
|
-
|
|
630
|
-
|
|
628
|
+
/* @__PURE__ */ e("p", { className: "truncate text-base font-semibold text-charcoal", children: T }),
|
|
629
|
+
M && /* @__PURE__ */ e("p", { className: "truncate text-sm text-stone", children: M }),
|
|
630
|
+
a && /* @__PURE__ */ e("span", { className: "mt-2 inline-flex items-center rounded-full bg-green-100 px-2 py-0.5 text-xs font-medium text-green-700", children: a })
|
|
631
631
|
] })
|
|
632
632
|
] }) }),
|
|
633
633
|
/* @__PURE__ */ c("ul", { className: "flex flex-col gap-2 mt-2", children: [
|
|
634
634
|
/* @__PURE__ */ e("li", { children: /* @__PURE__ */ c(
|
|
635
|
-
|
|
635
|
+
K,
|
|
636
636
|
{
|
|
637
|
-
onClick:
|
|
638
|
-
disabled:
|
|
639
|
-
"aria-busy":
|
|
637
|
+
onClick: S,
|
|
638
|
+
disabled: m,
|
|
639
|
+
"aria-busy": m,
|
|
640
640
|
children: [
|
|
641
|
-
|
|
641
|
+
m ? /* @__PURE__ */ e(ee, { className: "h-5 w-5 animate-spin" }) : /* @__PURE__ */ e(Ue, { className: "h-5 w-5" }),
|
|
642
642
|
/* @__PURE__ */ e("span", { children: "Leave Conversation" })
|
|
643
643
|
]
|
|
644
644
|
}
|
|
645
645
|
) }),
|
|
646
|
-
/* @__PURE__ */ e("li", { children:
|
|
647
|
-
|
|
646
|
+
/* @__PURE__ */ e("li", { children: u ? /* @__PURE__ */ c(
|
|
647
|
+
K,
|
|
648
648
|
{
|
|
649
|
-
onClick:
|
|
650
|
-
disabled:
|
|
651
|
-
"aria-busy":
|
|
649
|
+
onClick: y,
|
|
650
|
+
disabled: x,
|
|
651
|
+
"aria-busy": x,
|
|
652
652
|
children: [
|
|
653
|
-
|
|
653
|
+
x ? /* @__PURE__ */ e(ee, { className: "h-5 w-5 animate-spin" }) : /* @__PURE__ */ e(ie, { className: "h-5 w-5" }),
|
|
654
654
|
/* @__PURE__ */ e("span", { children: "Unblock" })
|
|
655
655
|
]
|
|
656
656
|
}
|
|
657
657
|
) : /* @__PURE__ */ c(
|
|
658
|
-
|
|
658
|
+
K,
|
|
659
659
|
{
|
|
660
|
-
onClick:
|
|
661
|
-
disabled:
|
|
662
|
-
"aria-busy":
|
|
660
|
+
onClick: O,
|
|
661
|
+
disabled: x,
|
|
662
|
+
"aria-busy": x,
|
|
663
663
|
children: [
|
|
664
|
-
|
|
664
|
+
x ? /* @__PURE__ */ e(ee, { className: "h-5 w-5 animate-spin" }) : /* @__PURE__ */ e(ie, { className: "h-5 w-5" }),
|
|
665
665
|
/* @__PURE__ */ e("span", { children: "Block" })
|
|
666
666
|
]
|
|
667
667
|
}
|
|
668
668
|
) }),
|
|
669
|
-
/* @__PURE__ */ e("li", { children: /* @__PURE__ */ c(
|
|
670
|
-
/* @__PURE__ */ e(
|
|
669
|
+
/* @__PURE__ */ e("li", { children: /* @__PURE__ */ c(K, { variant: "danger", onClick: k, children: [
|
|
670
|
+
/* @__PURE__ */ e(Fe, { className: "h-5 w-5" }),
|
|
671
671
|
/* @__PURE__ */ e("span", { children: "Report" })
|
|
672
672
|
] }) })
|
|
673
673
|
] })
|
|
@@ -676,97 +676,97 @@ const Ae = ({ renderActions: t }) => /* @__PURE__ */ c("div", { className: "mess
|
|
|
676
676
|
}
|
|
677
677
|
)
|
|
678
678
|
);
|
|
679
|
-
},
|
|
679
|
+
}, _e = ({
|
|
680
680
|
onBack: t,
|
|
681
681
|
showBackButton: s,
|
|
682
682
|
renderMessageInputActions: n,
|
|
683
683
|
onLeaveConversation: l,
|
|
684
|
-
onBlockParticipant:
|
|
684
|
+
onBlockParticipant: a,
|
|
685
685
|
CustomChannelEmptyState: d
|
|
686
686
|
}) => {
|
|
687
|
-
var
|
|
688
|
-
const { channel:
|
|
689
|
-
(
|
|
690
|
-
var
|
|
691
|
-
return ((
|
|
687
|
+
var m, E;
|
|
688
|
+
const { channel: i } = ue(), [r, o] = I(!1), w = (((E = (m = i == null ? void 0 : i.state) == null ? void 0 : m.messages) == null ? void 0 : E.length) ?? 0) > 0, u = X.useMemo(() => Object.values(i.state.members || {}).find(
|
|
689
|
+
(h) => {
|
|
690
|
+
var C;
|
|
691
|
+
return ((C = h.user) == null ? void 0 : C.id) && h.user.id !== i._client.userID;
|
|
692
692
|
}
|
|
693
|
-
), [
|
|
694
|
-
const
|
|
695
|
-
return
|
|
696
|
-
}, [
|
|
693
|
+
), [i._client.userID, i.state.members]), N = X.useMemo(() => {
|
|
694
|
+
const x = i.data ?? {};
|
|
695
|
+
return x.followerStatus ? String(x.followerStatus) : x.isFollower ? "Subscribed to you" : void 0;
|
|
696
|
+
}, [i.data]);
|
|
697
697
|
return /* @__PURE__ */ c(oe, { children: [
|
|
698
|
-
/* @__PURE__ */ c(
|
|
698
|
+
/* @__PURE__ */ c(ke, { children: [
|
|
699
699
|
/* @__PURE__ */ e("div", { className: "border-b border-sand bg-white px-4 py-3", children: /* @__PURE__ */ e(
|
|
700
|
-
|
|
700
|
+
Ge,
|
|
701
701
|
{
|
|
702
702
|
onBack: t,
|
|
703
703
|
showBackButton: s,
|
|
704
704
|
onShowInfo: () => o(!0),
|
|
705
|
-
canShowInfo: !!
|
|
705
|
+
canShowInfo: !!u
|
|
706
706
|
}
|
|
707
707
|
) }),
|
|
708
708
|
/* @__PURE__ */ c("div", { className: "flex-1 overflow-hidden relative", children: [
|
|
709
|
-
/* @__PURE__ */ e(
|
|
710
|
-
!
|
|
709
|
+
/* @__PURE__ */ e(Te, { hideDeletedMessages: !0, hideNewMessageSeparator: !1 }),
|
|
710
|
+
!w && d && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex bg-white", children: /* @__PURE__ */ e(d, {}) })
|
|
711
711
|
] }),
|
|
712
712
|
/* @__PURE__ */ e(
|
|
713
|
-
|
|
713
|
+
He,
|
|
714
714
|
{
|
|
715
|
-
renderActions: () => n == null ? void 0 : n(
|
|
715
|
+
renderActions: () => n == null ? void 0 : n(i)
|
|
716
716
|
}
|
|
717
717
|
)
|
|
718
718
|
] }),
|
|
719
719
|
/* @__PURE__ */ e(
|
|
720
|
-
|
|
720
|
+
$e,
|
|
721
721
|
{
|
|
722
722
|
isOpen: r,
|
|
723
723
|
onClose: () => o(!1),
|
|
724
|
-
participant:
|
|
725
|
-
channel:
|
|
726
|
-
followerStatusLabel:
|
|
724
|
+
participant: u,
|
|
725
|
+
channel: i,
|
|
726
|
+
followerStatusLabel: N,
|
|
727
727
|
onLeaveConversation: l,
|
|
728
|
-
onBlockParticipant:
|
|
728
|
+
onBlockParticipant: a
|
|
729
729
|
}
|
|
730
730
|
)
|
|
731
731
|
] });
|
|
732
|
-
},
|
|
732
|
+
}, Ve = ({
|
|
733
733
|
channel: t,
|
|
734
734
|
onBack: s,
|
|
735
735
|
showBackButton: n = !1,
|
|
736
736
|
renderMessageInputActions: l,
|
|
737
|
-
onLeaveConversation:
|
|
737
|
+
onLeaveConversation: a,
|
|
738
738
|
onBlockParticipant: d,
|
|
739
|
-
className:
|
|
739
|
+
className: i,
|
|
740
740
|
CustomChannelEmptyState: r
|
|
741
741
|
}) => /* @__PURE__ */ e(
|
|
742
742
|
"div",
|
|
743
743
|
{
|
|
744
|
-
className:
|
|
744
|
+
className: D(
|
|
745
745
|
"messaging-channel-view h-full flex flex-col",
|
|
746
|
-
|
|
746
|
+
i
|
|
747
747
|
),
|
|
748
|
-
children: /* @__PURE__ */ e(
|
|
749
|
-
|
|
748
|
+
children: /* @__PURE__ */ e(Re, { channel: t, children: /* @__PURE__ */ e(
|
|
749
|
+
_e,
|
|
750
750
|
{
|
|
751
751
|
onBack: s,
|
|
752
752
|
showBackButton: n,
|
|
753
753
|
renderMessageInputActions: l,
|
|
754
|
-
onLeaveConversation:
|
|
754
|
+
onLeaveConversation: a,
|
|
755
755
|
onBlockParticipant: d,
|
|
756
756
|
CustomChannelEmptyState: r
|
|
757
757
|
}
|
|
758
758
|
) })
|
|
759
759
|
}
|
|
760
760
|
);
|
|
761
|
-
function
|
|
761
|
+
function We({
|
|
762
762
|
searchQuery: t,
|
|
763
763
|
setSearchQuery: s,
|
|
764
764
|
placeholder: n
|
|
765
765
|
}) {
|
|
766
|
-
const l =
|
|
766
|
+
const l = H(null);
|
|
767
767
|
return /* @__PURE__ */ c("div", { className: "relative", children: [
|
|
768
768
|
/* @__PURE__ */ e(
|
|
769
|
-
|
|
769
|
+
pe,
|
|
770
770
|
{
|
|
771
771
|
className: "pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-stone",
|
|
772
772
|
weight: "bold"
|
|
@@ -779,17 +779,17 @@ function Ve({
|
|
|
779
779
|
type: "text",
|
|
780
780
|
placeholder: n,
|
|
781
781
|
value: t,
|
|
782
|
-
onChange: (
|
|
782
|
+
onChange: (a) => s(a.target.value),
|
|
783
783
|
className: "w-full pl-10 pr-10 py-3 text-sm border border-sand rounded-xl focus:outline-none focus:ring-2 focus:ring-black focus:border-transparent"
|
|
784
784
|
}
|
|
785
785
|
),
|
|
786
786
|
t && /* @__PURE__ */ e(
|
|
787
|
-
|
|
787
|
+
ne,
|
|
788
788
|
{
|
|
789
789
|
label: "Clear search",
|
|
790
790
|
onClick: () => {
|
|
791
|
-
var
|
|
792
|
-
s(""), (
|
|
791
|
+
var a;
|
|
792
|
+
s(""), (a = l.current) == null || a.focus();
|
|
793
793
|
},
|
|
794
794
|
className: "absolute right-3 top-1/2 -translate-y-1/2 p-1 text-stone hover:text-charcoal",
|
|
795
795
|
children: /* @__PURE__ */ e(me, { className: "h-4 w-4", weight: "bold" })
|
|
@@ -797,67 +797,67 @@ function Ve({
|
|
|
797
797
|
)
|
|
798
798
|
] });
|
|
799
799
|
}
|
|
800
|
-
const
|
|
800
|
+
const ze = ({
|
|
801
801
|
participantSource: t,
|
|
802
802
|
onSelectParticipant: s,
|
|
803
803
|
onClose: n,
|
|
804
804
|
existingParticipantIds: l = /* @__PURE__ */ new Set(),
|
|
805
|
-
participantLabel:
|
|
805
|
+
participantLabel: a = "participants",
|
|
806
806
|
searchPlaceholder: d = "Search participants...",
|
|
807
|
-
className:
|
|
807
|
+
className: i
|
|
808
808
|
}) => {
|
|
809
|
-
const { debug: r } =
|
|
809
|
+
const { debug: r } = se(), [o, w] = I(""), [u, N] = I([]), [m, E] = I(!1), [x, h] = I(null), [C, S] = I(
|
|
810
810
|
null
|
|
811
|
-
),
|
|
812
|
-
|
|
811
|
+
), O = H(!1);
|
|
812
|
+
G(() => {
|
|
813
813
|
if (t.loading) {
|
|
814
814
|
r && console.log(
|
|
815
815
|
"[ParticipantPicker] Waiting for participant source to finish loading..."
|
|
816
816
|
);
|
|
817
817
|
return;
|
|
818
818
|
}
|
|
819
|
-
if (
|
|
819
|
+
if (O.current) return;
|
|
820
820
|
(async () => {
|
|
821
|
-
r && console.log("[ParticipantPicker] Loading initial participants..."),
|
|
821
|
+
r && console.log("[ParticipantPicker] Loading initial participants..."), E(!0), h(null);
|
|
822
822
|
try {
|
|
823
823
|
const g = await t.loadParticipants({
|
|
824
824
|
search: "",
|
|
825
825
|
// Load all participants initially
|
|
826
826
|
limit: 100
|
|
827
827
|
});
|
|
828
|
-
|
|
828
|
+
N(g.participants), O.current = !0, r && console.log(
|
|
829
829
|
"[ParticipantPicker] Participants loaded successfully:",
|
|
830
830
|
g.participants.length
|
|
831
831
|
);
|
|
832
832
|
} catch (g) {
|
|
833
|
-
const
|
|
834
|
-
v
|
|
833
|
+
const v = g instanceof Error ? g.message : "Failed to load participants";
|
|
834
|
+
h(v), console.error("[ParticipantPicker] Failed to load participants:", g);
|
|
835
835
|
} finally {
|
|
836
|
-
|
|
836
|
+
E(!1);
|
|
837
837
|
}
|
|
838
838
|
})();
|
|
839
839
|
}, [t.loading, r]);
|
|
840
|
-
const
|
|
841
|
-
var
|
|
840
|
+
const y = u.filter((f) => !l.has(f.id)).filter((f) => {
|
|
841
|
+
var v;
|
|
842
842
|
if (!o) return !0;
|
|
843
843
|
const g = o.toLowerCase();
|
|
844
|
-
return f.name.toLowerCase().includes(g) || ((
|
|
845
|
-
}), k =
|
|
844
|
+
return f.name.toLowerCase().includes(g) || ((v = f.email) == null ? void 0 : v.toLowerCase().includes(g)) || !1;
|
|
845
|
+
}), k = U(
|
|
846
846
|
async (f) => {
|
|
847
|
-
if (!
|
|
848
|
-
|
|
847
|
+
if (!C) {
|
|
848
|
+
S(f.id);
|
|
849
849
|
try {
|
|
850
850
|
await s(f);
|
|
851
851
|
} catch (g) {
|
|
852
|
-
console.error("[ParticipantPicker] Failed to start chat:", g),
|
|
852
|
+
console.error("[ParticipantPicker] Failed to start chat:", g), S(null);
|
|
853
853
|
}
|
|
854
854
|
}
|
|
855
855
|
},
|
|
856
|
-
[s,
|
|
857
|
-
),
|
|
856
|
+
[s, C]
|
|
857
|
+
), T = (f, g) => {
|
|
858
858
|
(f.key === "Enter" || f.key === " ") && (f.preventDefault(), k(g));
|
|
859
859
|
};
|
|
860
|
-
return /* @__PURE__ */ c("div", { className:
|
|
860
|
+
return /* @__PURE__ */ c("div", { className: D("flex flex-col h-full", i), children: [
|
|
861
861
|
/* @__PURE__ */ c("div", { className: "px-4 py-4 border-b border-sand bg-chalk", children: [
|
|
862
862
|
/* @__PURE__ */ c("div", { className: "flex items-center justify-between mb-3", children: [
|
|
863
863
|
/* @__PURE__ */ e("h2", { className: "text-lg font-semibold text-charcoal", children: "Start a new Conversation" }),
|
|
@@ -865,52 +865,52 @@ const We = ({
|
|
|
865
865
|
] }),
|
|
866
866
|
/* @__PURE__ */ c("p", { className: "text-xs text-stone mb-3", children: [
|
|
867
867
|
"Select a ",
|
|
868
|
-
|
|
868
|
+
a.slice(0, -1),
|
|
869
869
|
" to start messaging (",
|
|
870
|
-
|
|
870
|
+
y.length,
|
|
871
871
|
" available)",
|
|
872
|
-
t.totalCount !== void 0 && ` • ${t.totalCount} ${
|
|
872
|
+
t.totalCount !== void 0 && ` • ${t.totalCount} ${a} total`
|
|
873
873
|
] }),
|
|
874
874
|
/* @__PURE__ */ e(
|
|
875
|
-
|
|
875
|
+
We,
|
|
876
876
|
{
|
|
877
877
|
searchQuery: o,
|
|
878
|
-
setSearchQuery:
|
|
878
|
+
setSearchQuery: w,
|
|
879
879
|
placeholder: d
|
|
880
880
|
}
|
|
881
881
|
)
|
|
882
882
|
] }),
|
|
883
|
-
|
|
883
|
+
x && /* @__PURE__ */ c("div", { className: "p-4 text-sm text-danger bg-danger-alt", children: [
|
|
884
884
|
"Error loading ",
|
|
885
|
-
|
|
885
|
+
a,
|
|
886
886
|
": ",
|
|
887
|
-
|
|
887
|
+
x
|
|
888
888
|
] }),
|
|
889
|
-
/* @__PURE__ */ e("div", { className: "flex-1 overflow-auto", children:
|
|
889
|
+
/* @__PURE__ */ e("div", { className: "flex-1 overflow-auto", children: m && y.length === 0 ? /* @__PURE__ */ e("div", { className: "h-32 flex items-center justify-center", children: /* @__PURE__ */ c("div", { className: "flex items-center space-x-2", children: [
|
|
890
890
|
/* @__PURE__ */ e("div", { className: "w-4 h-4 animate-spin rounded-full border-2 border-primary border-t-transparent" }),
|
|
891
891
|
/* @__PURE__ */ c("span", { className: "text-sm text-stone", children: [
|
|
892
892
|
"Loading ",
|
|
893
|
-
|
|
893
|
+
a,
|
|
894
894
|
"..."
|
|
895
895
|
] })
|
|
896
|
-
] }) }) :
|
|
896
|
+
] }) }) : y.length === 0 ? /* @__PURE__ */ c("div", { className: "p-6 text-center", children: [
|
|
897
897
|
/* @__PURE__ */ e("div", { className: "mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-sand", children: /* @__PURE__ */ e(ce, { className: "h-8 w-8 text-charcoal" }) }),
|
|
898
|
-
/* @__PURE__ */ e("h3", { className: "text-sm font-semibold text-charcoal mb-2", children: o ? `No ${
|
|
899
|
-
/* @__PURE__ */ e("p", { className: "text-xs text-stone", children: o ? "Try a different search term" :
|
|
898
|
+
/* @__PURE__ */ e("h3", { className: "text-sm font-semibold text-charcoal mb-2", children: o ? `No ${a} found` : u.length > 0 ? `Already chatting with all ${a}` : `No ${a} yet` }),
|
|
899
|
+
/* @__PURE__ */ e("p", { className: "text-xs text-stone", children: o ? "Try a different search term" : u.length > 0 ? `You have existing conversations with all your ${a}` : `${a.charAt(0).toUpperCase() + a.slice(1)} will appear here` })
|
|
900
900
|
] }) : /* @__PURE__ */ c("ul", { className: "space-y-0", children: [
|
|
901
|
-
|
|
902
|
-
const g = f.name || f.email || f.id,
|
|
901
|
+
y.map((f) => {
|
|
902
|
+
const g = f.name || f.email || f.id, v = f.email && f.name ? f.email : f.phone;
|
|
903
903
|
return /* @__PURE__ */ e("li", { children: /* @__PURE__ */ e(
|
|
904
904
|
"button",
|
|
905
905
|
{
|
|
906
906
|
type: "button",
|
|
907
907
|
onClick: () => k(f),
|
|
908
|
-
onKeyDown: (
|
|
908
|
+
onKeyDown: (M) => T(M, f),
|
|
909
909
|
className: "w-full px-4 py-3 hover:bg-sand transition-colors border-b border-sand text-left focus:outline-none focus:ring-2 focus:ring-black",
|
|
910
910
|
children: /* @__PURE__ */ c("div", { className: "flex items-center justify-between", children: [
|
|
911
911
|
/* @__PURE__ */ c("div", { className: "flex items-center space-x-3 flex-1 min-w-0", children: [
|
|
912
912
|
/* @__PURE__ */ e(
|
|
913
|
-
|
|
913
|
+
Y,
|
|
914
914
|
{
|
|
915
915
|
id: f.id,
|
|
916
916
|
name: g,
|
|
@@ -920,21 +920,21 @@ const We = ({
|
|
|
920
920
|
),
|
|
921
921
|
/* @__PURE__ */ c("div", { className: "flex-1 min-w-0", children: [
|
|
922
922
|
/* @__PURE__ */ e("h4", { className: "text-sm font-medium text-charcoal truncate", children: g }),
|
|
923
|
-
|
|
923
|
+
v && /* @__PURE__ */ e("p", { className: "text-xs text-stone truncate", children: v })
|
|
924
924
|
] })
|
|
925
925
|
] }),
|
|
926
|
-
/* @__PURE__ */ e("div", { className: "flex-shrink-0", children:
|
|
926
|
+
/* @__PURE__ */ e("div", { className: "flex-shrink-0", children: C === f.id ? /* @__PURE__ */ e(ee, { className: "h-5 w-5 text-primary animate-spin" }) : /* @__PURE__ */ e(ce, { className: "h-5 w-5 text-stone" }) })
|
|
927
927
|
] })
|
|
928
928
|
}
|
|
929
929
|
) }, f.id);
|
|
930
930
|
}),
|
|
931
|
-
|
|
931
|
+
m && /* @__PURE__ */ e("li", { className: "p-4 flex justify-center", children: /* @__PURE__ */ c("div", { className: "flex items-center space-x-2", children: [
|
|
932
932
|
/* @__PURE__ */ e("div", { className: "w-4 h-4 animate-spin rounded-full border-2 border-primary border-t-transparent" }),
|
|
933
933
|
/* @__PURE__ */ e("span", { className: "text-sm text-stone", children: "Loading more..." })
|
|
934
934
|
] }) })
|
|
935
935
|
] }) })
|
|
936
936
|
] });
|
|
937
|
-
},
|
|
937
|
+
}, qe = ({ hasChannels: t, onStartConversation: s, participantLabel: n }) => /* @__PURE__ */ e("div", { className: "messaging-empty-state flex items-center justify-center h-full p-8 text-balance", children: /* @__PURE__ */ c("div", { className: "text-center max-w-sm", children: [
|
|
938
938
|
/* @__PURE__ */ e("div", { className: "w-24 h-24 bg-primary-alt/10 rounded-full flex items-center justify-center mx-auto mb-6", children: /* @__PURE__ */ e("span", { className: "text-4xl", children: "💬" }) }),
|
|
939
939
|
/* @__PURE__ */ e("h2", { className: "font-semibold text-charcoal", children: "Welcome to Messages" }),
|
|
940
940
|
/* @__PURE__ */ e("p", { className: "text-stone text-sm mb-6", children: t ? /* @__PURE__ */ c(oe, { children: [
|
|
@@ -977,10 +977,10 @@ const We = ({
|
|
|
977
977
|
children: "Go Back"
|
|
978
978
|
}
|
|
979
979
|
)
|
|
980
|
-
] }) }),
|
|
980
|
+
] }) }), Xe = ({ className: t, message: s }) => /* @__PURE__ */ c(
|
|
981
981
|
"div",
|
|
982
982
|
{
|
|
983
|
-
className:
|
|
983
|
+
className: D("flex items-center justify-center h-full", t),
|
|
984
984
|
children: [
|
|
985
985
|
/* @__PURE__ */ c("svg", { viewBox: "0 0 100 100", className: "size-8 fill-pebble", stroke: "none", children: [
|
|
986
986
|
/* @__PURE__ */ e("circle", { cx: "6", cy: "50", r: "6", children: /* @__PURE__ */ e(
|
|
@@ -1020,192 +1020,193 @@ const We = ({
|
|
|
1020
1020
|
s && /* @__PURE__ */ e("span", { className: "text-stone", children: s })
|
|
1021
1021
|
]
|
|
1022
1022
|
}
|
|
1023
|
-
),
|
|
1024
|
-
/* @__PURE__ */ e(
|
|
1023
|
+
), Qe = () => /* @__PURE__ */ e("div", { className: "messaging-loading-state flex items-center justify-center h-full", children: /* @__PURE__ */ c("div", { className: "flex items-center", children: [
|
|
1024
|
+
/* @__PURE__ */ e(Xe, { className: "w-6 h-6" }),
|
|
1025
1025
|
/* @__PURE__ */ e("span", { className: "text-sm text-stone", children: "Loading messages" })
|
|
1026
|
-
] }) }),
|
|
1026
|
+
] }) }), rs = ({
|
|
1027
1027
|
capabilities: t = {},
|
|
1028
1028
|
className: s,
|
|
1029
1029
|
renderMessageInputActions: n,
|
|
1030
1030
|
onChannelSelect: l,
|
|
1031
|
-
onParticipantSelect:
|
|
1031
|
+
onParticipantSelect: a,
|
|
1032
1032
|
initialParticipantFilter: d,
|
|
1033
|
-
initialParticipantData:
|
|
1034
|
-
CustomChannelEmptyState: r
|
|
1033
|
+
initialParticipantData: i,
|
|
1034
|
+
CustomChannelEmptyState: r,
|
|
1035
|
+
showChannelList: o = !0
|
|
1035
1036
|
}) => {
|
|
1036
1037
|
const {
|
|
1037
|
-
service:
|
|
1038
|
-
client:
|
|
1039
|
-
isConnected:
|
|
1040
|
-
isLoading:
|
|
1041
|
-
error:
|
|
1042
|
-
refreshConnection:
|
|
1043
|
-
debug:
|
|
1044
|
-
} =
|
|
1038
|
+
service: w,
|
|
1039
|
+
client: u,
|
|
1040
|
+
isConnected: N,
|
|
1041
|
+
isLoading: m,
|
|
1042
|
+
error: E,
|
|
1043
|
+
refreshConnection: x,
|
|
1044
|
+
debug: h
|
|
1045
|
+
} = Le(), [C, S] = I(null), [O, y] = I(!1), [k, T] = I(!1), [f, g] = I(/* @__PURE__ */ new Set()), [v, M] = I(0), [p, L] = I(!1), [$, _] = I(null), V = H(null), {
|
|
1045
1046
|
showStartConversation: Q = !1,
|
|
1046
|
-
participantSource:
|
|
1047
|
+
participantSource: W,
|
|
1047
1048
|
participantLabel: z = "participants"
|
|
1048
|
-
} = t,
|
|
1049
|
-
if (!
|
|
1050
|
-
const b =
|
|
1049
|
+
} = t, R = H(null), P = U(async () => {
|
|
1050
|
+
if (!u || !N) return;
|
|
1051
|
+
const b = u.userID;
|
|
1051
1052
|
if (b)
|
|
1052
1053
|
try {
|
|
1053
|
-
|
|
1054
|
-
const
|
|
1054
|
+
h && console.log("[MessagingShell] Syncing channels for user:", b);
|
|
1055
|
+
const j = await u.queryChannels(
|
|
1055
1056
|
{
|
|
1056
1057
|
type: "messaging",
|
|
1057
1058
|
members: { $in: [b] }
|
|
1058
1059
|
},
|
|
1059
1060
|
{},
|
|
1060
1061
|
{ limit: 100 }
|
|
1061
|
-
),
|
|
1062
|
-
|
|
1063
|
-
const
|
|
1064
|
-
Object.values(
|
|
1062
|
+
), F = /* @__PURE__ */ new Set();
|
|
1063
|
+
j.forEach((B) => {
|
|
1064
|
+
const be = B.state.members;
|
|
1065
|
+
Object.values(be).forEach((Ce) => {
|
|
1065
1066
|
var ae;
|
|
1066
|
-
const re = (ae =
|
|
1067
|
-
re && re !== b &&
|
|
1067
|
+
const re = (ae = Ce.user) == null ? void 0 : ae.id;
|
|
1068
|
+
re && re !== b && F.add(re);
|
|
1068
1069
|
});
|
|
1069
|
-
}),
|
|
1070
|
-
channelCount:
|
|
1071
|
-
memberCount:
|
|
1070
|
+
}), g(F), y(j.length > 0), R.current = b, h && console.log("[MessagingShell] Channels synced successfully:", {
|
|
1071
|
+
channelCount: j.length,
|
|
1072
|
+
memberCount: F.size
|
|
1072
1073
|
});
|
|
1073
|
-
} catch (
|
|
1074
|
-
console.error("[MessagingShell] Failed to sync channels:",
|
|
1074
|
+
} catch (j) {
|
|
1075
|
+
console.error("[MessagingShell] Failed to sync channels:", j);
|
|
1075
1076
|
}
|
|
1076
|
-
}, [
|
|
1077
|
-
|
|
1078
|
-
if (!
|
|
1079
|
-
const b =
|
|
1080
|
-
b &&
|
|
1081
|
-
}, [
|
|
1082
|
-
if (!d || !
|
|
1077
|
+
}, [u, N, h]);
|
|
1078
|
+
G(() => {
|
|
1079
|
+
if (!u || !N) return;
|
|
1080
|
+
const b = u.userID;
|
|
1081
|
+
b && R.current !== b && P();
|
|
1082
|
+
}, [u, N, P]), G(() => {
|
|
1083
|
+
if (!d || !u || !N) return;
|
|
1083
1084
|
(async () => {
|
|
1084
|
-
const
|
|
1085
|
-
if (
|
|
1085
|
+
const j = u.userID;
|
|
1086
|
+
if (j)
|
|
1086
1087
|
try {
|
|
1087
|
-
|
|
1088
|
+
h && console.log(
|
|
1088
1089
|
"[MessagingShell] Loading initial conversation with:",
|
|
1089
1090
|
d
|
|
1090
1091
|
);
|
|
1091
|
-
const
|
|
1092
|
+
const F = await u.queryChannels(
|
|
1092
1093
|
{
|
|
1093
1094
|
type: "messaging",
|
|
1094
|
-
members: { $eq: [
|
|
1095
|
+
members: { $eq: [j, d] }
|
|
1095
1096
|
},
|
|
1096
1097
|
{},
|
|
1097
1098
|
{ limit: 1 }
|
|
1098
1099
|
);
|
|
1099
|
-
if (
|
|
1100
|
-
|
|
1100
|
+
if (F.length > 0)
|
|
1101
|
+
S(F[0]), L(!0), _(null), l && l(F[0]), h && console.log(
|
|
1101
1102
|
"[MessagingShell] Initial conversation loaded:",
|
|
1102
|
-
|
|
1103
|
+
F[0].id
|
|
1103
1104
|
);
|
|
1104
|
-
else if (
|
|
1105
|
-
|
|
1105
|
+
else if (i && w) {
|
|
1106
|
+
h && console.log(
|
|
1106
1107
|
"[MessagingShell] No conversation found, creating one for:",
|
|
1107
|
-
|
|
1108
|
+
i
|
|
1108
1109
|
);
|
|
1109
1110
|
try {
|
|
1110
|
-
const
|
|
1111
|
-
id:
|
|
1112
|
-
name:
|
|
1113
|
-
email:
|
|
1114
|
-
phone:
|
|
1111
|
+
const B = await w.startChannelWithParticipant({
|
|
1112
|
+
id: i.id,
|
|
1113
|
+
name: i.name,
|
|
1114
|
+
email: i.email,
|
|
1115
|
+
phone: i.phone
|
|
1115
1116
|
});
|
|
1116
|
-
|
|
1117
|
+
S(B), L(!0), _(null), l && l(B), h && console.log(
|
|
1117
1118
|
"[MessagingShell] Channel created and loaded:",
|
|
1118
|
-
|
|
1119
|
+
B.id
|
|
1119
1120
|
);
|
|
1120
|
-
} catch (
|
|
1121
|
+
} catch (B) {
|
|
1121
1122
|
console.error(
|
|
1122
1123
|
"[MessagingShell] Failed to create conversation:",
|
|
1123
|
-
|
|
1124
|
-
),
|
|
1124
|
+
B
|
|
1125
|
+
), _("Failed to create conversation");
|
|
1125
1126
|
}
|
|
1126
1127
|
} else
|
|
1127
|
-
|
|
1128
|
+
_(
|
|
1128
1129
|
"No conversation found with this account"
|
|
1129
|
-
),
|
|
1130
|
+
), h && console.log(
|
|
1130
1131
|
"[MessagingShell] No conversation found for:",
|
|
1131
1132
|
d
|
|
1132
1133
|
);
|
|
1133
|
-
} catch (
|
|
1134
|
+
} catch (F) {
|
|
1134
1135
|
console.error(
|
|
1135
1136
|
"[MessagingShell] Failed to load initial conversation:",
|
|
1136
|
-
|
|
1137
|
-
),
|
|
1137
|
+
F
|
|
1138
|
+
), _("Failed to load conversation");
|
|
1138
1139
|
}
|
|
1139
1140
|
})();
|
|
1140
1141
|
}, [
|
|
1141
1142
|
d,
|
|
1142
|
-
|
|
1143
|
-
x,
|
|
1144
|
-
m,
|
|
1145
|
-
o,
|
|
1143
|
+
i,
|
|
1146
1144
|
u,
|
|
1145
|
+
N,
|
|
1146
|
+
w,
|
|
1147
|
+
h,
|
|
1147
1148
|
l
|
|
1148
1149
|
]);
|
|
1149
|
-
const
|
|
1150
|
+
const A = U(
|
|
1150
1151
|
(b) => {
|
|
1151
|
-
|
|
1152
|
+
S(b), l == null || l(b);
|
|
1152
1153
|
},
|
|
1153
1154
|
[l]
|
|
1154
|
-
),
|
|
1155
|
-
|
|
1156
|
-
}, [
|
|
1155
|
+
), q = U(() => {
|
|
1156
|
+
p || S(null);
|
|
1157
|
+
}, [p]), Z = U(() => {
|
|
1157
1158
|
var b;
|
|
1158
|
-
|
|
1159
|
-
}, [
|
|
1159
|
+
W && (M((j) => j + 1), T(!0), (b = V.current) == null || b.showModal());
|
|
1160
|
+
}, [W]), ge = U(
|
|
1160
1161
|
async (b) => {
|
|
1161
|
-
var
|
|
1162
|
-
if (
|
|
1162
|
+
var j;
|
|
1163
|
+
if (w)
|
|
1163
1164
|
try {
|
|
1164
|
-
|
|
1165
|
+
h && console.log(
|
|
1165
1166
|
"[MessagingShell] Starting conversation with:",
|
|
1166
1167
|
b.id
|
|
1167
1168
|
);
|
|
1168
|
-
const
|
|
1169
|
+
const F = await w.startChannelWithParticipant({
|
|
1169
1170
|
id: b.id,
|
|
1170
1171
|
name: b.name,
|
|
1171
1172
|
email: b.email,
|
|
1172
1173
|
phone: b.phone
|
|
1173
1174
|
});
|
|
1174
1175
|
try {
|
|
1175
|
-
await
|
|
1176
|
-
} catch (
|
|
1177
|
-
console.warn("[MessagingShell] Failed to unhide channel:",
|
|
1176
|
+
await F.show();
|
|
1177
|
+
} catch (B) {
|
|
1178
|
+
console.warn("[MessagingShell] Failed to unhide channel:", B);
|
|
1178
1179
|
}
|
|
1179
|
-
|
|
1180
|
-
} catch (
|
|
1181
|
-
console.error("[MessagingShell] Failed to start conversation:",
|
|
1180
|
+
S(F), T(!1), (j = V.current) == null || j.close(), a == null || a(b);
|
|
1181
|
+
} catch (F) {
|
|
1182
|
+
console.error("[MessagingShell] Failed to start conversation:", F);
|
|
1182
1183
|
}
|
|
1183
1184
|
},
|
|
1184
|
-
[
|
|
1185
|
-
), te =
|
|
1185
|
+
[w, a, h]
|
|
1186
|
+
), te = U(() => {
|
|
1186
1187
|
var b;
|
|
1187
|
-
|
|
1188
|
-
}, []),
|
|
1188
|
+
T(!1), (b = V.current) == null || b.close();
|
|
1189
|
+
}, []), xe = U(
|
|
1189
1190
|
async (b) => {
|
|
1190
|
-
|
|
1191
|
+
h && console.log("[MessagingShell] Leaving conversation:", b.id), S(null), L(!1), R.current = null, await P();
|
|
1191
1192
|
},
|
|
1192
|
-
[
|
|
1193
|
-
),
|
|
1193
|
+
[P, h]
|
|
1194
|
+
), Ne = U(
|
|
1194
1195
|
async (b) => {
|
|
1195
|
-
|
|
1196
|
+
h && console.log("[MessagingShell] Blocking participant:", b), S(null), L(!1), R.current = null, await P();
|
|
1196
1197
|
},
|
|
1197
|
-
[
|
|
1198
|
-
),
|
|
1199
|
-
return
|
|
1198
|
+
[P, h]
|
|
1199
|
+
), J = !!C;
|
|
1200
|
+
return m ? /* @__PURE__ */ e("div", { className: D("h-full", s), children: /* @__PURE__ */ e(Qe, {}) }) : E ? /* @__PURE__ */ e("div", { className: D("h-full", s), children: /* @__PURE__ */ e(le, { message: E, onBack: x }) }) : !N || !u ? /* @__PURE__ */ e("div", { className: D("h-full", s), children: /* @__PURE__ */ e(
|
|
1200
1201
|
le,
|
|
1201
1202
|
{
|
|
1202
1203
|
message: "Not connected to messaging service",
|
|
1203
|
-
onBack:
|
|
1204
|
+
onBack: x
|
|
1204
1205
|
}
|
|
1205
|
-
) }) :
|
|
1206
|
+
) }) : $ ? /* @__PURE__ */ e("div", { className: D("h-full", s), children: /* @__PURE__ */ e(le, { message: $ }) }) : /* @__PURE__ */ c(
|
|
1206
1207
|
"div",
|
|
1207
1208
|
{
|
|
1208
|
-
className:
|
|
1209
|
+
className: D(
|
|
1209
1210
|
"messaging-shell h-full bg-white overflow-hidden",
|
|
1210
1211
|
s
|
|
1211
1212
|
),
|
|
@@ -1214,24 +1215,24 @@ const We = ({
|
|
|
1214
1215
|
/* @__PURE__ */ e(
|
|
1215
1216
|
"div",
|
|
1216
1217
|
{
|
|
1217
|
-
className:
|
|
1218
|
+
className: D(
|
|
1218
1219
|
"messaging-channel-list-sidebar min-h-0 min-w-0 bg-white lg:bg-chalk lg:flex lg:flex-col lg:border-r lg:border-sand",
|
|
1219
1220
|
{
|
|
1220
|
-
//
|
|
1221
|
-
"!hidden":
|
|
1221
|
+
// Explicitly hidden via prop or in direct conversation mode
|
|
1222
|
+
"!hidden": o === !1 || p,
|
|
1222
1223
|
// Normal mode: hide on mobile when channel selected, show on desktop
|
|
1223
|
-
"hidden lg:flex lg:w-80 lg:min-w-[280px] lg:max-w-[360px]": !
|
|
1224
|
+
"hidden lg:flex lg:w-80 lg:min-w-[280px] lg:max-w-[360px]": o !== !1 && !p && J,
|
|
1224
1225
|
// Normal mode: show when no channel selected
|
|
1225
|
-
"flex flex-col w-full lg:flex-1 lg:max-w-2xl": !
|
|
1226
|
+
"flex flex-col w-full lg:flex-1 lg:max-w-2xl": o !== !1 && !p && !J
|
|
1226
1227
|
}
|
|
1227
1228
|
),
|
|
1228
1229
|
children: /* @__PURE__ */ e(
|
|
1229
1230
|
Be,
|
|
1230
1231
|
{
|
|
1231
|
-
onChannelSelect:
|
|
1232
|
-
selectedChannel:
|
|
1233
|
-
showStartConversation: Q && !!
|
|
1234
|
-
onStartConversation:
|
|
1232
|
+
onChannelSelect: A,
|
|
1233
|
+
selectedChannel: C || void 0,
|
|
1234
|
+
showStartConversation: Q && !!W,
|
|
1235
|
+
onStartConversation: Z,
|
|
1235
1236
|
participantLabel: z
|
|
1236
1237
|
}
|
|
1237
1238
|
)
|
|
@@ -1240,66 +1241,66 @@ const We = ({
|
|
|
1240
1241
|
/* @__PURE__ */ e(
|
|
1241
1242
|
"div",
|
|
1242
1243
|
{
|
|
1243
|
-
className:
|
|
1244
|
+
className: D(
|
|
1244
1245
|
"messaging-conversation-view flex-1 flex-col min-w-0 min-h-0",
|
|
1245
1246
|
{
|
|
1246
1247
|
// In direct conversation mode, always show (full width)
|
|
1247
|
-
flex:
|
|
1248
|
+
flex: p || J,
|
|
1248
1249
|
// Normal mode: hide on mobile when no channel selected
|
|
1249
|
-
"hidden lg:flex": !
|
|
1250
|
+
"hidden lg:flex": !p && !J
|
|
1250
1251
|
}
|
|
1251
1252
|
),
|
|
1252
|
-
children:
|
|
1253
|
-
|
|
1253
|
+
children: C ? /* @__PURE__ */ e("div", { className: "flex-1 min-h-0 flex flex-col", children: /* @__PURE__ */ e(
|
|
1254
|
+
Ve,
|
|
1254
1255
|
{
|
|
1255
|
-
channel:
|
|
1256
|
-
onBack:
|
|
1257
|
-
showBackButton: !
|
|
1256
|
+
channel: C,
|
|
1257
|
+
onBack: q,
|
|
1258
|
+
showBackButton: !p,
|
|
1258
1259
|
renderMessageInputActions: n,
|
|
1259
|
-
onLeaveConversation:
|
|
1260
|
-
onBlockParticipant:
|
|
1260
|
+
onLeaveConversation: xe,
|
|
1261
|
+
onBlockParticipant: Ne,
|
|
1261
1262
|
CustomChannelEmptyState: r
|
|
1262
1263
|
},
|
|
1263
|
-
|
|
1264
|
+
C.id
|
|
1264
1265
|
) }) : /* @__PURE__ */ e(
|
|
1265
|
-
|
|
1266
|
+
qe,
|
|
1266
1267
|
{
|
|
1267
|
-
hasChannels:
|
|
1268
|
-
onStartConversation: Q ?
|
|
1268
|
+
hasChannels: O,
|
|
1269
|
+
onStartConversation: Q ? Z : void 0,
|
|
1269
1270
|
participantLabel: z
|
|
1270
1271
|
}
|
|
1271
1272
|
)
|
|
1272
1273
|
}
|
|
1273
1274
|
)
|
|
1274
1275
|
] }),
|
|
1275
|
-
|
|
1276
|
+
W && // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
|
|
1276
1277
|
/* @__PURE__ */ e(
|
|
1277
1278
|
"dialog",
|
|
1278
1279
|
{
|
|
1279
|
-
ref:
|
|
1280
|
+
ref: V,
|
|
1280
1281
|
className: "mes-dialog",
|
|
1281
1282
|
onClick: (b) => {
|
|
1282
|
-
b.target ===
|
|
1283
|
+
b.target === V.current && te();
|
|
1283
1284
|
},
|
|
1284
1285
|
onClose: te,
|
|
1285
1286
|
children: /* @__PURE__ */ e("div", { className: "h-full w-full bg-white shadow-max-elevation-light", children: /* @__PURE__ */ e(
|
|
1286
|
-
|
|
1287
|
+
ze,
|
|
1287
1288
|
{
|
|
1288
|
-
participantSource:
|
|
1289
|
-
onSelectParticipant:
|
|
1289
|
+
participantSource: W,
|
|
1290
|
+
onSelectParticipant: ge,
|
|
1290
1291
|
onClose: te,
|
|
1291
|
-
existingParticipantIds:
|
|
1292
|
+
existingParticipantIds: f,
|
|
1292
1293
|
participantLabel: z,
|
|
1293
1294
|
searchPlaceholder: `Search ${z}...`
|
|
1294
1295
|
},
|
|
1295
|
-
|
|
1296
|
+
v
|
|
1296
1297
|
) })
|
|
1297
1298
|
}
|
|
1298
1299
|
)
|
|
1299
1300
|
]
|
|
1300
1301
|
}
|
|
1301
1302
|
);
|
|
1302
|
-
},
|
|
1303
|
+
}, Ze = ({
|
|
1303
1304
|
question: t,
|
|
1304
1305
|
onClick: s,
|
|
1305
1306
|
loading: n = !1,
|
|
@@ -1310,87 +1311,108 @@ const We = ({
|
|
|
1310
1311
|
type: "button",
|
|
1311
1312
|
onClick: s,
|
|
1312
1313
|
disabled: n,
|
|
1313
|
-
|
|
1314
|
-
|
|
1314
|
+
style: { backgroundColor: "#E6E5E3" },
|
|
1315
|
+
className: D(
|
|
1316
|
+
"w-full text-center p-4 rounded-xl text-charcoal font-medium transition-colors",
|
|
1315
1317
|
{
|
|
1316
|
-
"hover:
|
|
1318
|
+
"hover:brightness-95 active:brightness-90": !n,
|
|
1317
1319
|
"opacity-50 cursor-not-allowed": n
|
|
1318
1320
|
},
|
|
1319
1321
|
l
|
|
1320
1322
|
),
|
|
1321
1323
|
children: t
|
|
1322
1324
|
}
|
|
1323
|
-
),
|
|
1325
|
+
), ls = ({
|
|
1324
1326
|
faqs: t,
|
|
1325
1327
|
onFaqClick: s,
|
|
1326
1328
|
loadingFaqId: n,
|
|
1327
1329
|
headerText: l,
|
|
1328
|
-
className:
|
|
1330
|
+
className: a,
|
|
1331
|
+
avatarImage: d,
|
|
1332
|
+
avatarName: i
|
|
1329
1333
|
}) => {
|
|
1330
|
-
const
|
|
1331
|
-
return
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
Qe,
|
|
1334
|
+
const r = t.filter((o) => o.enabled).sort((o, w) => (o.order ?? 0) - (w.order ?? 0));
|
|
1335
|
+
return r.length === 0 ? null : /* @__PURE__ */ e("div", { className: D("px-4 py-6", a), children: /* @__PURE__ */ c("div", { className: "flex gap-3 items-end", children: [
|
|
1336
|
+
(d || i) && /* @__PURE__ */ e("div", { className: "flex-none", children: /* @__PURE__ */ e(
|
|
1337
|
+
Y,
|
|
1335
1338
|
{
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
))
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1339
|
+
id: i || "account",
|
|
1340
|
+
name: i || "Account",
|
|
1341
|
+
image: d,
|
|
1342
|
+
size: 24
|
|
1343
|
+
}
|
|
1344
|
+
) }),
|
|
1345
|
+
/* @__PURE__ */ c(
|
|
1346
|
+
"div",
|
|
1347
|
+
{
|
|
1348
|
+
className: "flex-1 rounded-lg p-4 space-y-3",
|
|
1349
|
+
style: { backgroundColor: "#F1F0EE" },
|
|
1350
|
+
children: [
|
|
1351
|
+
l && /* @__PURE__ */ e("p", { className: "text-md text-charcoal mb-4", children: l }),
|
|
1352
|
+
r.map((o) => /* @__PURE__ */ e(
|
|
1353
|
+
Ze,
|
|
1354
|
+
{
|
|
1355
|
+
question: o.question,
|
|
1356
|
+
onClick: () => s(o.id),
|
|
1357
|
+
loading: n === o.id
|
|
1358
|
+
},
|
|
1359
|
+
o.id
|
|
1360
|
+
))
|
|
1361
|
+
]
|
|
1362
|
+
}
|
|
1363
|
+
)
|
|
1364
|
+
] }) });
|
|
1365
|
+
}, os = (t, s = {}) => {
|
|
1366
|
+
const { initialSearch: n = "", pageSize: l = 20 } = s, [a, d] = I([]), [i, r] = I(!1), [o, w] = I(null), [u, N] = I(n), [m, E] = I(!0), [x, h] = I(), C = U(async (k = !1, T) => {
|
|
1367
|
+
if (i) return;
|
|
1368
|
+
const f = T !== void 0 ? T : u;
|
|
1369
|
+
r(!0), w(null);
|
|
1348
1370
|
try {
|
|
1349
1371
|
const g = await t.loadParticipants({
|
|
1350
1372
|
search: f || void 0,
|
|
1351
1373
|
limit: l,
|
|
1352
|
-
cursor: k ? void 0 :
|
|
1374
|
+
cursor: k ? void 0 : x
|
|
1353
1375
|
});
|
|
1354
1376
|
d(
|
|
1355
|
-
(
|
|
1356
|
-
),
|
|
1377
|
+
(v) => k ? g.participants : [...v, ...g.participants]
|
|
1378
|
+
), E(g.hasMore), h(g.nextCursor);
|
|
1357
1379
|
} catch (g) {
|
|
1358
|
-
const
|
|
1359
|
-
|
|
1380
|
+
const v = g instanceof Error ? g.message : "Failed to load participants";
|
|
1381
|
+
w(v), console.error("[useParticipants] Load error:", g);
|
|
1360
1382
|
} finally {
|
|
1361
1383
|
r(!1);
|
|
1362
1384
|
}
|
|
1363
|
-
}, [t,
|
|
1364
|
-
|
|
1365
|
-
}, [
|
|
1366
|
-
|
|
1367
|
-
}, [
|
|
1368
|
-
|
|
1369
|
-
}, [
|
|
1370
|
-
return
|
|
1371
|
-
|
|
1385
|
+
}, [t, u, x, l, i]), S = U(() => {
|
|
1386
|
+
m && !i && C(!1);
|
|
1387
|
+
}, [m, i, C]), O = U((k) => {
|
|
1388
|
+
N(k), h(void 0), C(!0, k);
|
|
1389
|
+
}, [C]), y = U(() => {
|
|
1390
|
+
h(void 0), C(!0);
|
|
1391
|
+
}, [C]);
|
|
1392
|
+
return G(() => {
|
|
1393
|
+
C(!0);
|
|
1372
1394
|
}, [t.loadParticipants]), {
|
|
1373
|
-
participants:
|
|
1374
|
-
loading:
|
|
1395
|
+
participants: a,
|
|
1396
|
+
loading: i,
|
|
1375
1397
|
error: o,
|
|
1376
|
-
searchQuery:
|
|
1377
|
-
hasMore:
|
|
1398
|
+
searchQuery: u,
|
|
1399
|
+
hasMore: m,
|
|
1378
1400
|
totalCount: t.totalCount,
|
|
1379
|
-
loadMore:
|
|
1380
|
-
search:
|
|
1381
|
-
refresh:
|
|
1401
|
+
loadMore: S,
|
|
1402
|
+
search: O,
|
|
1403
|
+
refresh: y
|
|
1382
1404
|
};
|
|
1383
1405
|
};
|
|
1384
1406
|
export {
|
|
1385
|
-
|
|
1407
|
+
Y as Avatar,
|
|
1386
1408
|
Be as ChannelList,
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1409
|
+
Ve as ChannelView,
|
|
1410
|
+
ls as FaqList,
|
|
1411
|
+
Ze as FaqListItem,
|
|
1412
|
+
ts as MessagingProvider,
|
|
1413
|
+
rs as MessagingShell,
|
|
1414
|
+
ze as ParticipantPicker,
|
|
1415
|
+
Le as useMessaging,
|
|
1416
|
+
os as useParticipants
|
|
1395
1417
|
};
|
|
1396
1418
|
//# sourceMappingURL=index.js.map
|