@paramms/chat-widget 1.0.33 → 1.0.35

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/react.js CHANGED
@@ -1,280 +1,328 @@
1
- import { jsxs as W, jsx as p, Fragment as k } from "react/jsx-runtime";
2
- import { useState as D, useRef as M, useEffect as z } from "react";
3
- import { mount as H } from "./index.js";
4
- function P({
5
- url: g,
6
- apiUrl: l,
7
- profileId: v,
8
- token: d,
9
- refreshToken: w,
10
- userId: n,
11
- userName: c,
12
- userEmail: s,
13
- userAvatar: f,
14
- contextTitle: x,
15
- contextSubtitle: y,
16
- contextStatus: R,
17
- subjectId: t,
18
- accent: b,
19
- launcher: h,
20
- position: i,
21
- quickReplies: u,
22
- height: m = "100%",
23
- i18n: a,
24
- translateLang: C
1
+ import { jsxs as L, jsx as h, Fragment as F } from "react/jsx-runtime";
2
+ import { useState as _, useRef as $, useEffect as k } from "react";
3
+ import { mount as D } from "./index.js";
4
+ function J({
5
+ url: u,
6
+ apiUrl: n,
7
+ profileId: i,
8
+ token: t,
9
+ refreshToken: r,
10
+ userId: o,
11
+ userName: l,
12
+ userEmail: p,
13
+ userAvatar: g,
14
+ contextTitle: m,
15
+ contextSubtitle: b,
16
+ contextStatus: y,
17
+ subjectId: M,
18
+ accent: S,
19
+ launcher: R,
20
+ position: e,
21
+ quickReplies: d,
22
+ height: x = "100%",
23
+ i18n: v,
24
+ translateLang: a
25
25
  }) {
26
- const r = M(null), o = M(null);
27
- return z(() => {
28
- var e;
29
- if (r.current)
30
- return (e = o.current) == null || e.close(), o.current = H({
31
- el: r.current,
32
- url: g,
33
- ...l ? { apiUrl: l } : {},
34
- profileId: v,
35
- ...t ? { subjectId: t } : {},
36
- ...d ? { token: d } : {},
37
- ...w ? { refreshToken: w } : {},
38
- ...n ? { userId: n } : {},
39
- ...n || c || s || f ? {
26
+ const C = $(null), c = $(null);
27
+ return k(() => {
28
+ var s;
29
+ if (C.current)
30
+ return (s = c.current) == null || s.close(), c.current = D({
31
+ el: C.current,
32
+ url: u,
33
+ ...n ? { apiUrl: n } : {},
34
+ profileId: i,
35
+ ...M ? { subjectId: M } : {},
36
+ ...t ? { token: t } : {},
37
+ ...r ? { refreshToken: r } : {},
38
+ ...o ? { userId: o } : {},
39
+ ...o || l || p || g ? {
40
40
  user: {
41
- ...c ? { name: c } : {},
42
- ...s ? { email: s } : {},
43
- ...f ? { avatar: f } : {}
41
+ ...l ? { name: l } : {},
42
+ ...p ? { email: p } : {},
43
+ ...g ? { avatar: g } : {}
44
44
  }
45
45
  } : {},
46
- ...x ? {
46
+ ...m ? {
47
47
  subject: {
48
- title: x,
49
- ...y ? { subtitle: y } : {},
50
- ...R ? { status: R } : {}
48
+ title: m,
49
+ ...b ? { subtitle: b } : {},
50
+ ...y ? { status: y } : {}
51
51
  }
52
52
  } : {},
53
- ...u ? { quickReplies: u } : {},
54
- ...b ? { accent: b } : {},
55
- ...C ? { translateLang: C } : {},
56
- ...a ? { i18n: a } : {},
57
- ...h ? { launcher: h, position: i ?? "bottom-right" } : {}
53
+ ...d ? { quickReplies: d } : {},
54
+ ...S ? { accent: S } : {},
55
+ ...a ? { translateLang: a } : {},
56
+ ...v ? { i18n: v } : {},
57
+ ...R ? { launcher: R, position: e ?? "bottom-right" } : {}
58
58
  }), () => {
59
- var j;
60
- (j = o.current) == null || j.close(), o.current = null;
59
+ var w;
60
+ (w = c.current) == null || w.close(), c.current = null;
61
61
  };
62
- }, [g, l, v, t, d, n, c, s, b, h, i, C]), /* @__PURE__ */ p(
62
+ }, [u, n, i, M, t, o, l, p, S, R, e, a]), /* @__PURE__ */ h(
63
63
  "div",
64
64
  {
65
- ref: r,
66
- style: h ? { width: 0, height: 0, overflow: "hidden" } : { width: "100%", height: m, minHeight: m === "100%" ? "480px" : void 0 }
65
+ ref: C,
66
+ style: R ? { width: 0, height: 0, overflow: "hidden" } : { width: "100%", height: x, minHeight: x === "100%" ? "480px" : void 0 }
67
67
  }
68
68
  );
69
69
  }
70
- const O = [
70
+ const Y = [
71
71
  "Is this still available?",
72
72
  "Can I schedule a viewing?",
73
73
  "What is your best price?"
74
74
  ];
75
- function G({
76
- url: g,
77
- apiUrl: l,
78
- profileId: v,
79
- token: d,
80
- refreshToken: w,
81
- listingId: n,
82
- listingTitle: c,
83
- listingMeta: s,
84
- listingPrice: f,
85
- listingStatus: x,
86
- userId: y,
87
- userName: R,
88
- userEmail: t,
89
- userAvatar: b,
90
- accent: h,
91
- launcher: i,
92
- position: u,
93
- quickReplies: m,
94
- height: a = "100%",
95
- i18n: C,
96
- translateLang: r
75
+ function P({
76
+ url: u,
77
+ apiUrl: n,
78
+ profileId: i,
79
+ token: t,
80
+ refreshToken: r,
81
+ listingId: o,
82
+ listingTitle: l,
83
+ listingMeta: p,
84
+ listingPrice: g,
85
+ listingStatus: m,
86
+ userId: b,
87
+ userName: y,
88
+ userEmail: M,
89
+ userAvatar: S,
90
+ accent: R,
91
+ launcher: e,
92
+ position: d,
93
+ quickReplies: x,
94
+ height: v = "100%",
95
+ i18n: a,
96
+ translateLang: C
97
97
  }) {
98
- const o = M(null), e = M(null);
99
- return z(() => {
100
- if (!o.current) return;
101
- let j = !1;
102
- const $ = setTimeout(() => {
103
- var L;
104
- j || !o.current || ((L = e.current) == null || L.close(), e.current = H({
105
- el: o.current,
106
- url: g,
107
- ...l ? { apiUrl: l } : {},
108
- profileId: v,
109
- ...n ? { subjectId: `listing_${n}` } : {},
110
- ...d ? { token: d } : {},
111
- ...w ? { refreshToken: w } : {},
112
- ...y ? { userId: y } : {},
113
- ...y || R || t || b ? {
98
+ const c = $(null), s = $(null);
99
+ return k(() => {
100
+ if (!c.current) return;
101
+ let w = !1;
102
+ const f = setTimeout(() => {
103
+ var j;
104
+ w || !c.current || ((j = s.current) == null || j.close(), s.current = D({
105
+ el: c.current,
106
+ url: u,
107
+ ...n ? { apiUrl: n } : {},
108
+ profileId: i,
109
+ ...o ? { subjectId: `listing_${o}` } : {},
110
+ ...t ? { token: t } : {},
111
+ ...r ? { refreshToken: r } : {},
112
+ ...b ? { userId: b } : {},
113
+ ...b || y || M || S ? {
114
114
  user: {
115
- ...R ? { name: R } : {},
116
- ...t ? { email: t } : {},
117
- ...b ? { avatar: b } : {},
118
- ...n ? { meta: { listingId: n } } : {}
115
+ ...y ? { name: y } : {},
116
+ ...M ? { email: M } : {},
117
+ ...S ? { avatar: S } : {},
118
+ ...o ? { meta: { listingId: o } } : {}
119
119
  }
120
120
  } : {},
121
- ...c ? {
121
+ ...l ? {
122
122
  subject: {
123
- title: c,
124
- ...s ? { subtitle: s } : {},
125
- ...f ? { tags: [`$${f.toLocaleString()}`] } : {},
126
- ...x ? { status: x } : {}
123
+ title: l,
124
+ ...p ? { subtitle: p } : {},
125
+ ...g ? { tags: [`$${g.toLocaleString()}`] } : {},
126
+ ...m ? { status: m } : {}
127
127
  }
128
128
  } : {},
129
- quickReplies: m ?? O,
130
- ...h ? { accent: h } : {},
131
- ...r ? { translateLang: r } : {},
132
- ...C ? { i18n: C } : {},
133
- ...i ? { launcher: i, position: u ?? "bottom-right" } : {}
129
+ quickReplies: x ?? Y,
130
+ ...R ? { accent: R } : {},
131
+ ...C ? { translateLang: C } : {},
132
+ ...a ? { i18n: a } : {},
133
+ ...e ? { launcher: e, position: d ?? "bottom-right" } : {}
134
134
  }));
135
135
  }, 0);
136
136
  return () => {
137
- var L;
138
- j = !0, clearTimeout($), (L = e.current) == null || L.close(), e.current = null;
137
+ var j;
138
+ w = !0, clearTimeout(f), (j = s.current) == null || j.close(), s.current = null;
139
139
  };
140
- }, [g, l, v, n, d, y, h, i, u, r]), /* @__PURE__ */ p(
140
+ }, [u, n, i, o, t, b, R, e, d, C]), /* @__PURE__ */ h(
141
141
  "div",
142
142
  {
143
- ref: o,
144
- style: i ? { width: 0, height: 0, overflow: "hidden" } : { width: "100%", height: a, minHeight: a === "100%" ? "480px" : void 0 }
143
+ ref: c,
144
+ style: e ? { width: 0, height: 0, overflow: "hidden" } : { width: "100%", height: v, minHeight: v === "100%" ? "480px" : void 0 }
145
145
  }
146
146
  );
147
147
  }
148
- function B({
149
- url: g,
150
- apiUrl: l,
151
- profileId: v,
152
- token: d,
153
- refreshToken: w,
154
- userId: n,
155
- userName: c,
156
- userEmail: s,
157
- accent: f,
158
- height: x = "100%",
148
+ function A(u) {
149
+ const [n, i] = _(
150
+ typeof window < "u" && window.innerWidth <= u
151
+ );
152
+ return k(() => {
153
+ if (typeof window > "u" || !window.matchMedia) return;
154
+ const t = window.matchMedia(`(max-width: ${u}px)`), r = (o) => i(o.matches);
155
+ return i(t.matches), t.addEventListener("change", r), () => t.removeEventListener("change", r);
156
+ }, [u]), n;
157
+ }
158
+ function H({
159
+ url: u,
160
+ apiUrl: n,
161
+ profileId: i,
162
+ tenantId: t,
163
+ token: r,
164
+ refreshToken: o,
165
+ userId: l,
166
+ userName: p,
167
+ userEmail: g,
168
+ accent: m,
169
+ height: b = "100%",
159
170
  i18n: y,
160
- scope: R = "tenant"
171
+ onClose: M,
172
+ scope: S = "tenant"
161
173
  }) {
162
- const [t, b] = D(null), h = M(null), i = M(null), u = M(null), m = M(null);
163
- z(() => {
164
- if (!h.current) return;
165
- let r = !1;
166
- return import("./chatlist.js").then(({ mountChatList: o }) => {
167
- r || !h.current || (u.current = o({
168
- el: h.current,
169
- url: g,
170
- ...l ? { apiUrl: l } : {},
171
- profileId: v,
172
- scope: R,
173
- onSelect: (e) => b(e),
174
+ const R = !i && !t, [e, d] = _(null), x = $(null), v = $(null), a = $(null), C = $(null);
175
+ k(() => {
176
+ if (!x.current) return;
177
+ let s = !1;
178
+ return import("./chatlist.js").then(({ mountChatList: w }) => {
179
+ s || !x.current || (a.current = w({
180
+ el: x.current,
181
+ url: u,
182
+ ...n ? { apiUrl: n } : {},
183
+ ...i ? { profileId: i } : {},
184
+ ...t ? { tenantId: t } : {},
185
+ scope: S,
186
+ onSelect: (f) => d(f),
174
187
  // Compose (✎) opens the chatroom's general support thread — without
175
188
  // this a user with no conversations yet had an empty list and no way
176
189
  // to ever start one, which is what made ChatApp feel broken.
177
- onNewChat: () => b({ id: "__new__", state: "open", updatedAt: Date.now() }),
178
- ...d ? { token: d } : {},
179
- ...n ? { userId: n } : {},
180
- ...f ? { accent: f } : {},
190
+ // Compose target: the configured chatroom, else the tenant's default
191
+ // (oldest chatroom, reported by the server on the first list fetch).
192
+ onNewChat: () => {
193
+ var j;
194
+ const f = (j = a.current) == null ? void 0 : j.defaultProfileId();
195
+ f && d({ id: "__new__", profileId: f, state: "open", updatedAt: Date.now() });
196
+ },
197
+ ...r ? { token: r } : {},
198
+ ...l ? { userId: l } : {},
199
+ ...m ? { accent: m } : {},
181
200
  ...y ? { i18n: y } : {}
182
201
  }));
183
202
  }), () => {
184
- var o;
185
- r = !0, (o = u.current) == null || o.close(), u.current = null;
203
+ var w;
204
+ s = !0, (w = a.current) == null || w.close(), a.current = null;
186
205
  };
187
- }, [g, l, v, d, n, R]), z(() => {
188
- var o;
189
- if (!i.current || !t) return;
190
- (o = m.current) == null || o.close(), m.current = H({
191
- el: i.current,
192
- url: g,
193
- ...l ? { apiUrl: l } : {},
194
- profileId: t.profileId ?? v,
206
+ }, [u, n, i, t, r, l, S]), k(() => {
207
+ var w;
208
+ if (!v.current || !e) return;
209
+ (w = C.current) == null || w.close(), C.current = D({
210
+ el: v.current,
211
+ url: u,
212
+ ...n ? { apiUrl: n } : {},
213
+ profileId: e.profileId ?? i,
214
+ // rows always carry theirs; compose sets one explicitly
195
215
  // DM rows open as direct conversations (kind + peer). Opening them via
196
216
  // their dm:… subjectId only works for the participant that OWNS the
197
217
  // thread key — the other side would silently fork a duplicate.
198
- ...t.kind === "direct" && t.peerId ? { kind: "direct", peerId: t.peerId } : t.subjectId ? { subjectId: t.subjectId } : {},
199
- ...d ? { token: d } : {},
200
- ...w ? { refreshToken: w } : {},
201
- ...n ? { userId: n } : {},
202
- ...n || c || s ? {
218
+ ...e.kind === "direct" && e.peerId ? { kind: "direct", peerId: e.peerId } : e.subjectId ? { subjectId: e.subjectId } : {},
219
+ ...r ? { token: r } : {},
220
+ ...o ? { refreshToken: o } : {},
221
+ ...l ? { userId: l } : {},
222
+ ...l || p || g ? {
203
223
  user: {
204
- ...c ? { name: c } : {},
205
- ...s ? { email: s } : {}
224
+ ...p ? { name: p } : {},
225
+ ...g ? { email: g } : {}
206
226
  }
207
227
  } : {},
208
- ...t.subjectTitle ? {
228
+ ...e.subjectTitle ? {
209
229
  subject: {
210
- title: t.subjectTitle,
211
- ...t.subjectMeta ? { subtitle: t.subjectMeta } : {}
230
+ title: e.subjectTitle,
231
+ ...e.subjectMeta ? { subtitle: e.subjectMeta } : {}
212
232
  }
213
233
  } : {},
214
- ...f ? { accent: f } : {}
234
+ ...m ? { accent: m } : {}
215
235
  });
216
- const r = setInterval(() => {
217
- var e;
218
- return (e = u.current) == null ? void 0 : e.refresh();
236
+ const s = setInterval(() => {
237
+ var f;
238
+ return (f = a.current) == null ? void 0 : f.refresh();
219
239
  }, 2e4);
220
240
  return () => {
221
- var e, j;
222
- clearInterval(r), (e = m.current) == null || e.close(), m.current = null, (j = u.current) == null || j.refresh();
241
+ var f, j;
242
+ clearInterval(s), (f = C.current) == null || f.close(), C.current = null, (j = a.current) == null || j.refresh();
223
243
  };
224
- }, [t == null ? void 0 : t.id]);
225
- const [a, C] = D(typeof window < "u" && window.innerWidth < 768);
226
- return z(() => {
227
- if (typeof window > "u" || !window.matchMedia) return;
228
- const r = window.matchMedia("(max-width: 767px)"), o = (e) => C(e.matches);
229
- return C(r.matches), r.addEventListener("change", o), () => r.removeEventListener("change", o);
230
- }, []), /* @__PURE__ */ W("div", { style: { display: "flex", width: "100%", height: x, minHeight: "400px", overflow: "hidden" }, children: [
231
- /* @__PURE__ */ p("div", { style: {
232
- width: a ? "100%" : "360px",
233
- flex: a && t ? "none" : void 0,
234
- display: a && t ? "none" : "flex",
244
+ }, [e == null ? void 0 : e.id]);
245
+ const c = A(767);
246
+ return R ? /* @__PURE__ */ L("div", { style: { padding: 16, font: "13px system-ui", color: "#b91c1c", background: "#fef2f2", borderRadius: 8 }, children: [
247
+ "[relay] <ChatApp/> needs a ",
248
+ /* @__PURE__ */ h("code", { children: "profileId" }),
249
+ " or a ",
250
+ /* @__PURE__ */ h("code", { children: "tenantId" }),
251
+ "."
252
+ ] }) : /* @__PURE__ */ L("div", { style: { display: "flex", width: "100%", height: b, minHeight: "400px", overflow: "hidden", position: "relative" }, children: [
253
+ M && /* @__PURE__ */ h(
254
+ "button",
255
+ {
256
+ onClick: M,
257
+ "aria-label": (y == null ? void 0 : y.close) ?? "Close",
258
+ style: {
259
+ position: "absolute",
260
+ top: 8,
261
+ right: 8,
262
+ zIndex: 20,
263
+ width: 32,
264
+ height: 32,
265
+ borderRadius: "50%",
266
+ display: "flex",
267
+ alignItems: "center",
268
+ justifyContent: "center",
269
+ background: "rgba(0,0,0,.05)",
270
+ border: "none",
271
+ color: "#1c1b1a",
272
+ fontSize: 18,
273
+ lineHeight: 1,
274
+ cursor: "pointer"
275
+ },
276
+ children: "✕"
277
+ }
278
+ ),
279
+ /* @__PURE__ */ h("div", { style: {
280
+ width: c ? "100%" : "360px",
281
+ flex: c && e ? "none" : void 0,
282
+ display: c && e ? "none" : "flex",
235
283
  flexDirection: "column",
236
- borderRight: a ? "none" : "1px solid #e8eaed",
284
+ borderRight: c ? "none" : "1px solid #e8eaed",
237
285
  minWidth: 0
238
- }, children: /* @__PURE__ */ p("div", { ref: h, style: { width: "100%", height: "100%" } }) }),
239
- t ? /* @__PURE__ */ W("div", { style: { flex: 1, display: "flex", flexDirection: "column", minWidth: 0, position: "relative" }, children: [
240
- a && /* @__PURE__ */ p(
286
+ }, children: /* @__PURE__ */ h("div", { ref: x, style: { width: "100%", height: "100%" } }) }),
287
+ e ? /* @__PURE__ */ L("div", { style: { flex: 1, display: "flex", flexDirection: "column", minWidth: 0, position: "relative" }, children: [
288
+ c && /* @__PURE__ */ h(
241
289
  "button",
242
290
  {
243
- onClick: () => b(null),
291
+ onClick: () => d(null),
244
292
  style: { position: "absolute", top: 12, left: 12, zIndex: 10, background: "none", border: "none", fontSize: 22, cursor: "pointer", color: "#1c1b1a" },
245
293
  children: "←"
246
294
  }
247
295
  ),
248
- /* @__PURE__ */ p("div", { ref: i, style: { width: "100%", height: "100%" } })
249
- ] }) : /* @__PURE__ */ p("div", { style: { flex: 1, display: a ? "none" : "flex", alignItems: "center", justifyContent: "center", color: "#9b9690", fontSize: 14 }, children: "Select a conversation" })
296
+ /* @__PURE__ */ h("div", { ref: v, style: { width: "100%", height: "100%" } })
297
+ ] }) : /* @__PURE__ */ h("div", { style: { flex: 1, display: c ? "none" : "flex", alignItems: "center", justifyContent: "center", color: "#9b9690", fontSize: 14 }, children: "Select a conversation" })
250
298
  ] });
251
299
  }
252
- function J({
253
- url: g,
254
- apiUrl: l,
255
- profileId: v,
256
- token: d,
257
- refreshToken: w,
258
- userId: n,
259
- userName: c,
260
- userEmail: s,
261
- scope: f,
262
- accent: x = "#4F63F5",
300
+ function Q({
301
+ url: u,
302
+ apiUrl: n,
303
+ profileId: i,
304
+ tenantId: t,
305
+ token: r,
306
+ refreshToken: o,
307
+ userId: l,
308
+ userName: p,
309
+ userEmail: g,
310
+ scope: m,
311
+ accent: b = "#4F63F5",
263
312
  floating: y = !0,
264
- position: R = "bottom-right",
265
- label: t,
266
- panelWidth: b,
267
- panelHeight: h = "600px"
313
+ position: M = "bottom-right",
314
+ label: S,
315
+ panelWidth: R,
316
+ panelHeight: e = "600px"
268
317
  }) {
269
- const [i, u] = D(!1), m = M(null), a = R === "bottom-right", r = t ?? (y ? "💬" : "Messages");
270
- if (z(() => {
271
- const S = (F) => {
272
- F.key === "Escape" && u(!1);
318
+ const [d, x] = _(!1), v = $(null), a = M === "bottom-right", c = S ?? (y ? "💬" : "Messages"), s = A(479);
319
+ if (k(() => {
320
+ const z = (O) => {
321
+ O.key === "Escape" && x(!1);
273
322
  };
274
- return document.addEventListener("keydown", S), () => document.removeEventListener("keydown", S);
275
- }, []), y) {
276
- const S = typeof window < "u" && window.innerWidth < 480, F = S ? "100vw" : b ?? "420px", E = S ? "100dvh" : h;
277
- return /* @__PURE__ */ W("div", { style: {
323
+ return document.addEventListener("keydown", z), () => document.removeEventListener("keydown", z);
324
+ }, []), y)
325
+ return /* @__PURE__ */ L("div", { style: {
278
326
  position: "fixed",
279
327
  [a ? "right" : "left"]: "20px",
280
328
  bottom: "20px",
@@ -284,81 +332,92 @@ function J({
284
332
  alignItems: a ? "flex-end" : "flex-start",
285
333
  gap: "12px"
286
334
  }, children: [
287
- /* @__PURE__ */ p("div", { style: {
288
- width: F,
289
- height: E,
290
- borderRadius: S ? "0" : "16px",
335
+ /* @__PURE__ */ h("div", { style: {
336
+ ...s ? {
337
+ position: "fixed",
338
+ inset: 0,
339
+ width: "100%",
340
+ height: "100dvh",
341
+ borderRadius: "0",
342
+ zIndex: 9998
343
+ } : {
344
+ width: `min(${R ?? "420px"}, calc(100vw - 40px))`,
345
+ height: `min(${e}, calc(100dvh - 108px))`,
346
+ borderRadius: "16px"
347
+ },
291
348
  overflow: "hidden",
292
- boxShadow: "0 8px 40px rgba(0,0,0,.18)",
349
+ boxShadow: s ? "none" : "0 8px 40px rgba(0,0,0,.18)",
293
350
  background: "#fff",
294
- display: i ? "flex" : "none",
351
+ display: d ? "flex" : "none",
295
352
  flexDirection: "column",
296
353
  transformOrigin: `bottom ${a ? "right" : "left"}`,
297
- animation: i ? "ocl-pop-in .18s ease" : "none"
298
- }, children: /* @__PURE__ */ p(
299
- B,
354
+ animation: d ? "ocl-pop-in .18s ease" : "none"
355
+ }, children: /* @__PURE__ */ h(
356
+ H,
300
357
  {
301
- url: g,
302
- ...l ? { apiUrl: l } : {},
303
- profileId: v,
304
- ...d ? { token: d } : {},
305
- ...w ? { refreshToken: w } : {},
306
- ...n ? { userId: n } : {},
307
- ...c ? { userName: c } : {},
308
- ...s ? { userEmail: s } : {},
309
- ...f ? { scope: f } : {},
310
- accent: x,
311
- height: "100%"
358
+ url: u,
359
+ ...n ? { apiUrl: n } : {},
360
+ ...i ? { profileId: i } : {},
361
+ ...t ? { tenantId: t } : {},
362
+ ...r ? { token: r } : {},
363
+ ...o ? { refreshToken: o } : {},
364
+ ...l ? { userId: l } : {},
365
+ ...p ? { userName: p } : {},
366
+ ...g ? { userEmail: g } : {},
367
+ ...m ? { scope: m } : {},
368
+ accent: b,
369
+ height: "100%",
370
+ onClose: () => x(!1)
312
371
  }
313
372
  ) }),
314
- /* @__PURE__ */ p(
373
+ /* @__PURE__ */ h(
315
374
  "button",
316
375
  {
317
- ref: m,
318
- onClick: () => u((_) => !_),
376
+ ref: v,
377
+ onClick: () => x((z) => !z),
319
378
  style: {
320
379
  width: "56px",
321
380
  height: "56px",
322
381
  borderRadius: "50%",
323
- background: x,
382
+ background: b,
324
383
  color: "#fff",
325
384
  border: "none",
326
385
  fontSize: "24px",
327
386
  cursor: "pointer",
328
387
  flexShrink: 0,
329
388
  boxShadow: "0 4px 16px rgba(0,0,0,.25)",
330
- transition: "transform .15s"
389
+ transition: "transform .15s",
390
+ display: d && s ? "none" : "block"
331
391
  },
332
- onMouseEnter: (_) => {
333
- _.target.style.transform = "scale(1.08)";
392
+ onMouseEnter: (z) => {
393
+ z.target.style.transform = "scale(1.08)";
334
394
  },
335
- onMouseLeave: (_) => {
336
- _.target.style.transform = "scale(1)";
395
+ onMouseLeave: (z) => {
396
+ z.target.style.transform = "scale(1)";
337
397
  },
338
- children: i ? "✕" : r
398
+ children: d ? "✕" : c
339
399
  }
340
400
  ),
341
- /* @__PURE__ */ p("style", { children: "@keyframes ocl-pop-in { from { opacity:0; transform:scale(.95) } to { opacity:1; transform:scale(1) } }" })
401
+ /* @__PURE__ */ h("style", { children: "@keyframes ocl-pop-in { from { opacity:0; transform:scale(.95) } to { opacity:1; transform:scale(1) } }" })
342
402
  ] });
343
- }
344
- const o = b ?? "420px", [e, j] = D(null), $ = () => {
345
- !i && m.current && j(m.current.getBoundingClientRect()), u((S) => !S);
346
- }, L = e ? e.bottom + 8 : 0, A = e ? window.innerWidth - e.right : 0;
347
- return /* @__PURE__ */ W(k, { children: [
348
- /* @__PURE__ */ W(
403
+ const w = `min(${R ?? "420px"}, calc(100vw - 16px))`, [f, j] = _(null), B = () => {
404
+ !d && v.current && j(v.current.getBoundingClientRect()), x((z) => !z);
405
+ }, W = f ? f.bottom + 8 : 0, E = f ? Math.max(8, window.innerWidth - f.right) : 0;
406
+ return /* @__PURE__ */ L(F, { children: [
407
+ /* @__PURE__ */ L(
349
408
  "button",
350
409
  {
351
- ref: m,
352
- onClick: $,
410
+ ref: v,
411
+ onClick: B,
353
412
  style: {
354
413
  display: "inline-flex",
355
414
  alignItems: "center",
356
415
  gap: "6px",
357
416
  padding: "8px 16px",
358
417
  borderRadius: "8px",
359
- background: i ? x : "transparent",
360
- color: i ? "#fff" : x,
361
- border: `2px solid ${x}`,
418
+ background: d ? b : "transparent",
419
+ color: d ? "#fff" : b,
420
+ border: `2px solid ${b}`,
362
421
  fontSize: "14px",
363
422
  fontWeight: 600,
364
423
  cursor: "pointer",
@@ -366,54 +425,63 @@ function J({
366
425
  },
367
426
  children: [
368
427
  "💬 ",
369
- r
428
+ c
370
429
  ]
371
430
  }
372
431
  ),
373
- i && e && /* @__PURE__ */ W(k, { children: [
374
- /* @__PURE__ */ p(
432
+ d && f && /* @__PURE__ */ L(F, { children: [
433
+ /* @__PURE__ */ h(
375
434
  "div",
376
435
  {
377
- onClick: () => u(!1),
436
+ onClick: () => x(!1),
378
437
  style: { position: "fixed", inset: 0, zIndex: 9998 }
379
438
  }
380
439
  ),
381
- /* @__PURE__ */ p("div", { style: {
440
+ /* @__PURE__ */ h("div", { style: {
382
441
  position: "fixed",
383
- top: L,
384
- right: A,
385
- width: o,
386
- height: h,
387
- borderRadius: "16px",
442
+ ...s ? {
443
+ inset: 0,
444
+ width: "100%",
445
+ height: "100dvh",
446
+ borderRadius: "0"
447
+ } : {
448
+ top: W,
449
+ right: E,
450
+ width: w,
451
+ height: `min(${e}, calc(100dvh - ${W}px - 12px))`,
452
+ borderRadius: "16px"
453
+ },
388
454
  overflow: "hidden",
389
- boxShadow: "0 8px 40px rgba(0,0,0,.2)",
455
+ boxShadow: s ? "none" : "0 8px 40px rgba(0,0,0,.2)",
390
456
  background: "#fff",
391
457
  zIndex: 9999,
392
458
  animation: "ocl-slide-in .18s ease"
393
- }, children: /* @__PURE__ */ p(
394
- B,
459
+ }, children: /* @__PURE__ */ h(
460
+ H,
395
461
  {
396
- url: g,
397
- ...l ? { apiUrl: l } : {},
398
- profileId: v,
399
- ...d ? { token: d } : {},
400
- ...w ? { refreshToken: w } : {},
401
- ...n ? { userId: n } : {},
402
- ...c ? { userName: c } : {},
403
- ...s ? { userEmail: s } : {},
404
- ...f ? { scope: f } : {},
405
- accent: x,
406
- height: "100%"
462
+ url: u,
463
+ ...n ? { apiUrl: n } : {},
464
+ ...i ? { profileId: i } : {},
465
+ ...t ? { tenantId: t } : {},
466
+ ...r ? { token: r } : {},
467
+ ...o ? { refreshToken: o } : {},
468
+ ...l ? { userId: l } : {},
469
+ ...p ? { userName: p } : {},
470
+ ...g ? { userEmail: g } : {},
471
+ ...m ? { scope: m } : {},
472
+ accent: b,
473
+ height: "100%",
474
+ onClose: () => x(!1)
407
475
  }
408
476
  ) }),
409
- /* @__PURE__ */ p("style", { children: "@keyframes ocl-slide-in { from { opacity:0; transform:translateY(-8px) } to { opacity:1; transform:translateY(0) } }" })
477
+ /* @__PURE__ */ h("style", { children: "@keyframes ocl-slide-in { from { opacity:0; transform:translateY(-8px) } to { opacity:1; transform:translateY(0) } }" })
410
478
  ] })
411
479
  ] });
412
480
  }
413
481
  export {
414
- B as ChatApp,
415
- J as ChatAppLauncher,
416
- P as ChatWidget,
417
- G as MarketplaceChat
482
+ H as ChatApp,
483
+ Q as ChatAppLauncher,
484
+ J as ChatWidget,
485
+ P as MarketplaceChat
418
486
  };
419
487
  //# sourceMappingURL=react.js.map