@epam/statgpt-conversation-list 0.7.0-dev.20 → 0.7.0-dev.21

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.
Files changed (4) hide show
  1. package/index.js +1 -1
  2. package/index.mjs +1703 -1915
  3. package/package.json +4 -4
  4. package/LICENSE +0 -21
package/index.mjs CHANGED
@@ -1,1927 +1,1715 @@
1
- import { jsxs as b, jsx as h, Fragment as Ee } from "react/jsx-runtime";
2
- import k from "classnames";
3
- import I, { createContext as Re, useContext as Se, useState as O, useRef as me, useMemo as Z, useCallback as D, useEffect as oe } from "react";
4
- import { cloneDeep as Xe, uniqBy as Ke, omit as Ze } from "lodash";
5
- import { Popup as ce, PopUpSize as ue, Button as W, Loader as be, InlineAlert as Je, InlineAlertType as qe, InputWithIcon as Me, Input as et, PopUpState as Y, Dropdown as Ae, HighlightText as tt, IconButton as nt } from "@epam/statgpt-ui-components";
6
- import { IconCheck as ot, IconCopy as rt, IconInfoCircle as st, IconDotsVertical as it, IconCaretRightFilled as at, IconX as lt, IconSearch as ct } from "@tabler/icons-react";
7
- import ut from "jszip";
8
- import { getConversationAttachments as dt, SHARE_CONVERSATION_ROUTE as Ie, getClearedConversationName as ve, ONBOARDING_MODEL_POSTFIX as ht, cleanConversationNames as q } from "@epam/statgpt-shared-toolkit";
9
- import { InvitationType as ft, getSharedConversationsRequest as ie, ShareTarget as ae } from "@epam/statgpt-dial-toolkit";
10
- var z = /* @__PURE__ */ ((t) => (t.DELETE = "delete", t.EXPORT = "export", t.SHARE = "share", t.RENAME = "rename", t))(z || {}), F = /* @__PURE__ */ ((t) => (t.SHARED = "shared", t.TODAY = "today", t.YESTERDAY = "yesterday", t.WEEK = "week", t.EARLIER = "earlier", t))(F || {});
11
- const pe = (t, s) => t?.resources?.filter((r) => r?.parentPath === s)?.map((r) => {
12
- const a = `${r?.bucket}/${s}`, u = r?.url?.split("/")?.slice(1)?.join("/");
13
- return {
14
- ...r,
15
- folderId: a,
16
- id: u,
17
- isShared: !0
18
- };
19
- }) || [], pt = (t) => ({
20
- [F.SHARED]: t
21
- }), mt = {
22
- [F.TODAY]: [],
23
- [F.YESTERDAY]: [],
24
- [F.WEEK]: [],
25
- [F.EARLIER]: []
26
- }, xe = (t, s) => t.toDateString() === s.toDateString(), gt = (t, s) => {
27
- const r = new Date(
28
- t.getFullYear(),
29
- t.getMonth(),
30
- t.getDate() - 1
31
- );
32
- return xe(s, r);
33
- }, Ct = (t, s) => {
34
- const r = t.getTime() - s.getTime();
35
- return Math.floor(r / (1e3 * 60 * 60 * 24));
36
- }, ye = (t) => t.updatedAt || Number(t.id?.split("-").pop()), Et = (t) => {
37
- const s = /* @__PURE__ */ new Date(), r = Xe(mt);
38
- for (const a of t)
39
- if (a.updatedAt) {
40
- const u = new Date(a.updatedAt);
41
- let c;
42
- xe(s, u) ? c = r[F.TODAY] : gt(s, u) ? c = r[F.YESTERDAY] : Ct(s, u) <= 7 ? c = r[F.WEEK] : c = r[F.EARLIER], c?.some(
43
- (C) => C.id === a.id
44
- ) || c.push(a);
45
- }
46
- return r;
47
- }, Pe = (t) => t?.sort(
48
- (s, r) => (ye(r) || 0) - (ye(s) || 0)
49
- ), vt = (t, s) => t === F.SHARED ? s?.shared || "Shared" : t === F.TODAY ? s?.today || "Today" : t === F.YESTERDAY ? s?.yesterday || "Yesterday" : t === F.WEEK ? s?.lastWeek || "Last week" : s?.earlier || "Earlier", De = Re(null);
50
- function K() {
51
- const t = Se(De);
52
- if (!t)
53
- throw new Error(
54
- "useConversationStyles must be used within ConversationStylesContext.Provider"
55
- );
56
- return t;
1
+ import e from "classnames";
2
+ import t, { createContext as n, useCallback as r, useContext as i, useEffect as a, useMemo as o, useRef as s, useState as c } from "react";
3
+ import { cloneDeep as l, omit as u, uniqBy as d } from "lodash";
4
+ import { Button as f, Dropdown as p, HighlightText as m, IconButton as h, InlineAlert as g, InlineAlertType as _, Input as v, InputWithIcon as y, Loader as b, PopUpSize as x, PopUpState as S, Popup as C } from "@epam/statgpt-ui-components";
5
+ import { IconCaretRightFilled as w, IconCheck as T, IconCopy as E, IconDotsVertical as D, IconInfoCircle as O, IconSearch as k, IconX as A } from "@tabler/icons-react";
6
+ import { Fragment as j, jsx as M, jsxs as N } from "react/jsx-runtime";
7
+ import P from "jszip";
8
+ import { ONBOARDING_MODEL_POSTFIX as F, SHARE_CONVERSATION_ROUTE as ee, cleanConversationNames as I, getClearedConversationName as L, getConversationAttachments as R } from "@epam/statgpt-shared-toolkit";
9
+ import { InvitationType as te, ShareTarget as z, getSharedConversationsRequest as ne } from "@epam/statgpt-dial-toolkit";
10
+ //#region libs/conversation-list/src/types/action-menu-item.ts
11
+ var B = /* @__PURE__ */ function(e) {
12
+ return e.DELETE = "delete", e.EXPORT = "export", e.SHARE = "share", e.RENAME = "rename", e;
13
+ }({}), V = /* @__PURE__ */ function(e) {
14
+ return e.SHARED = "shared", e.TODAY = "today", e.YESTERDAY = "yesterday", e.WEEK = "week", e.EARLIER = "earlier", e;
15
+ }({}), H = (e, t) => e?.resources?.filter((e) => e?.parentPath === t)?.map((e) => {
16
+ let n = `${e?.bucket}/${t}`, r = e?.url?.split("/")?.slice(1)?.join("/");
17
+ return {
18
+ ...e,
19
+ folderId: n,
20
+ id: r,
21
+ isShared: !0
22
+ };
23
+ }) || [], U = (e) => ({ [V.SHARED]: e }), re = {
24
+ [V.TODAY]: [],
25
+ [V.YESTERDAY]: [],
26
+ [V.WEEK]: [],
27
+ [V.EARLIER]: []
28
+ }, W = (e, t) => e.toDateString() === t.toDateString(), G = (e, t) => W(t, new Date(e.getFullYear(), e.getMonth(), e.getDate() - 1)), ie = (e, t) => {
29
+ let n = e.getTime() - t.getTime();
30
+ return Math.floor(n / (1e3 * 60 * 60 * 24));
31
+ }, ae = (e) => e.updatedAt || Number(e.id?.split("-").pop()), oe = (e) => {
32
+ let t = /* @__PURE__ */ new Date(), n = l(re);
33
+ for (let r of e) if (r.updatedAt) {
34
+ let e = new Date(r.updatedAt), i;
35
+ i = W(t, e) ? n[V.TODAY] : G(t, e) ? n[V.YESTERDAY] : ie(t, e) <= 7 ? n[V.WEEK] : n[V.EARLIER], i?.some((e) => e.id === r.id) || i.push(r);
36
+ }
37
+ return n;
38
+ }, K = (e) => e?.sort((e, t) => (ae(t) || 0) - (ae(e) || 0)), q = (e, t) => e === V.SHARED ? t?.shared || "Shared" : e === V.TODAY ? t?.today || "Today" : e === V.YESTERDAY ? t?.yesterday || "Yesterday" : e === V.WEEK ? t?.lastWeek || "Last week" : t?.earlier || "Earlier", J = n(null);
39
+ function Y() {
40
+ let e = i(J);
41
+ if (!e) throw Error("useConversationStyles must be used within ConversationStylesContext.Provider");
42
+ return e;
57
43
  }
58
- const wt = ({
59
- onCloseModal: t,
60
- deleteConversation: s,
61
- locale: r
62
- }) => {
63
- const { titles: a, disableModalDividers: u, isSmallModalButton: c } = K();
64
- return /* @__PURE__ */ b(
65
- ce,
66
- {
67
- heading: a?.deleteTitle ?? "Delete conversation",
68
- portalId: "delete-conversation",
69
- containerClassName: "delete-conversation-popup",
70
- size: ue.SM,
71
- dividers: !u,
72
- onClose: t,
73
- closeButtonTitle: a?.close ?? "Cancel",
74
- children: [
75
- /* @__PURE__ */ h("div", { className: "px-6 py-4 sm:px-0", lang: r, children: a?.deleteMessage ?? "Are you sure you want to delete this conversation? This action cannot be undone." }),
76
- /* @__PURE__ */ b("div", { className: "delete-conversation-popup-footer flex justify-end gap-x-2 px-6 py-3", children: [
77
- /* @__PURE__ */ h(
78
- W,
79
- {
80
- buttonClassName: "cancel-button",
81
- title: a?.cancel ?? "Cancel",
82
- isSmallButton: c,
83
- onClick: (C) => {
84
- C.stopPropagation(), t();
85
- }
86
- }
87
- ),
88
- /* @__PURE__ */ h(
89
- W,
90
- {
91
- buttonClassName: "text-button-primary text-button-primary-error",
92
- title: a?.delete ?? "Delete",
93
- isSmallButton: c,
94
- onClick: (C) => {
95
- C.stopPropagation(), s();
96
- }
97
- }
98
- )
99
- ] })
100
- ]
101
- }
102
- );
103
- }, yt = (t) => {
104
- const s = bt(
105
- dt(t)
106
- ).map((r) => ({
107
- ...r,
108
- relativePath: "",
109
- contentLength: 0
110
- }));
111
- return Ke(
112
- s,
113
- (r) => re(r.relativePath, r.name)
114
- );
115
- }, Nt = (t) => t.endsWith("/"), Rt = (t) => {
116
- const s = t.toLowerCase();
117
- return [
118
- "data:",
119
- "//",
120
- "http://",
121
- "https://",
122
- "file://",
123
- "ftp://",
124
- "mailto:",
125
- "telnet://",
126
- "api/files"
127
- ].some((r) => s.startsWith(r));
128
- }, St = (t) => {
129
- const s = re(
130
- ...t.split("/").map((a) => decodeURIComponent(a))
131
- ), r = s.lastIndexOf("/");
132
- return {
133
- absolutePath: s.slice(0, r),
134
- name: s.slice(r + 1)
135
- };
136
- }, bt = (t) => t ? t.map((s) => {
137
- if (!s.url || Rt(s.url) || Nt(s.url))
138
- return null;
139
- const { absolutePath: r, name: a } = St(s.url);
140
- return {
141
- id: s.url,
142
- name: a,
143
- contentType: s.type,
144
- folderId: r,
145
- absolutePath: r
146
- };
44
+ //#endregion
45
+ //#region libs/conversation-list/src/components/ConversationDelete/ConversationDelete.tsx
46
+ var X = ({ onCloseModal: e, deleteConversation: t, locale: n }) => {
47
+ let { titles: r, disableModalDividers: i, isSmallModalButton: a } = Y();
48
+ return /* @__PURE__ */ N(C, {
49
+ heading: r?.deleteTitle ?? "Delete conversation",
50
+ portalId: "delete-conversation",
51
+ containerClassName: "delete-conversation-popup",
52
+ size: x.SM,
53
+ dividers: !i,
54
+ onClose: e,
55
+ closeButtonTitle: r?.close ?? "Cancel",
56
+ children: [/* @__PURE__ */ M("div", {
57
+ className: "px-6 py-4 sm:px-0",
58
+ lang: n,
59
+ children: r?.deleteMessage ?? "Are you sure you want to delete this conversation? This action cannot be undone."
60
+ }), /* @__PURE__ */ N("div", {
61
+ className: "delete-conversation-popup-footer flex justify-end gap-x-2 px-6 py-3",
62
+ children: [/* @__PURE__ */ M(f, {
63
+ buttonClassName: "cancel-button",
64
+ title: r?.cancel ?? "Cancel",
65
+ isSmallButton: a,
66
+ onClick: (t) => {
67
+ t.stopPropagation(), e();
68
+ }
69
+ }), /* @__PURE__ */ M(f, {
70
+ buttonClassName: "text-button-primary text-button-primary-error",
71
+ title: r?.delete ?? "Delete",
72
+ isSmallButton: a,
73
+ onClick: (e) => {
74
+ e.stopPropagation(), t();
75
+ }
76
+ })]
77
+ })]
78
+ });
79
+ }, se = (e) => d(de(R(e)).map((e) => ({
80
+ ...e,
81
+ relativePath: "",
82
+ contentLength: 0
83
+ })), (e) => Z(e.relativePath, e.name)), ce = (e) => e.endsWith("/"), le = (e) => {
84
+ let t = e.toLowerCase();
85
+ return [
86
+ "data:",
87
+ "//",
88
+ "http://",
89
+ "https://",
90
+ "file://",
91
+ "ftp://",
92
+ "mailto:",
93
+ "telnet://",
94
+ "api/files"
95
+ ].some((e) => t.startsWith(e));
96
+ }, ue = (e) => {
97
+ let t = Z(...e.split("/").map((e) => decodeURIComponent(e))), n = t.lastIndexOf("/");
98
+ return {
99
+ absolutePath: t.slice(0, n),
100
+ name: t.slice(n + 1)
101
+ };
102
+ }, de = (e) => e ? e.map((e) => {
103
+ if (!e.url || le(e.url) || ce(e.url)) return null;
104
+ let { absolutePath: t, name: n } = ue(e.url);
105
+ return {
106
+ id: e.url,
107
+ name: n,
108
+ contentType: e.type,
109
+ folderId: t,
110
+ absolutePath: t
111
+ };
147
112
  }).filter(Boolean) : [];
148
- async function Mt(t, s) {
149
- const r = yt(t), a = new ut();
150
- r.forEach((p) => {
151
- const e = encodeURI(re(p.absolutePath, p.name)), o = s(`${e}`.replace("files/", "")), n = At(p.folderId), i = re("res", n, p.name);
152
- a.file(i, o);
153
- });
154
- const u = {
155
- version: 5,
156
- history: [t].map(It) || [],
157
- folders: []
158
- }, c = JSON.stringify(u, null, 2);
159
- return a.file("conversations/conversations_history.json", c), await a.generateAsync({ type: "base64" });
113
+ async function fe(e, t) {
114
+ let n = se(e), r = new P();
115
+ n.forEach((e) => {
116
+ let n = t(`${encodeURI(Z(e.absolutePath, e.name))}`.replace("files/", "")), i = Z("res", pe(e.folderId), e.name);
117
+ r.file(i, n);
118
+ });
119
+ let i = {
120
+ version: 5,
121
+ history: [e].map(me) || [],
122
+ folders: []
123
+ }, a = JSON.stringify(i, null, 2);
124
+ return r.file("conversations/conversations_history.json", a), await r.generateAsync({ type: "base64" });
160
125
  }
161
- const At = (t) => {
162
- const s = t.split("/");
163
- return s.length > 2 ? re(...s.slice(2)) : void 0;
164
- }, It = (t) => Ze(t, ["publicationInfo"]), re = (...t) => t.filter(Boolean).join("/");
165
- function xt(t, s) {
166
- const r = document.createElement("a");
167
- r.download = s, r.href = t, r.style.display = "none", document.body.appendChild(r), r.click(), document.body.removeChild(r), URL.revokeObjectURL(t);
126
+ var pe = (e) => {
127
+ let t = e.split("/");
128
+ return t.length > 2 ? Z(...t.slice(2)) : void 0;
129
+ }, me = (e) => u(e, ["publicationInfo"]), Z = (...e) => e.filter(Boolean).join("/");
130
+ //#endregion
131
+ //#region libs/conversation-list/src/utils/download.ts
132
+ function he(e, t) {
133
+ let n = document.createElement("a");
134
+ n.download = t, n.href = e, n.style.display = "none", document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(e);
168
135
  }
169
- var Pt = Object.defineProperty, le = Object.getOwnPropertySymbols, Te = Object.prototype.hasOwnProperty, Oe = Object.prototype.propertyIsEnumerable, Ne = (t, s, r) => s in t ? Pt(t, s, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[s] = r, ge = (t, s) => {
170
- for (var r in s || (s = {}))
171
- Te.call(s, r) && Ne(t, r, s[r]);
172
- if (le)
173
- for (var r of le(s))
174
- Oe.call(s, r) && Ne(t, r, s[r]);
175
- return t;
176
- }, Ce = (t, s) => {
177
- var r = {};
178
- for (var a in t)
179
- Te.call(t, a) && s.indexOf(a) < 0 && (r[a] = t[a]);
180
- if (t != null && le)
181
- for (var a of le(t))
182
- s.indexOf(a) < 0 && Oe.call(t, a) && (r[a] = t[a]);
183
- return r;
184
- };
185
- var J;
186
- ((t) => {
187
- const s = class v {
188
- /*-- Constructor (low level) and fields --*/
189
- // Creates a new QR Code with the given version number,
190
- // error correction level, data codeword bytes, and mask number.
191
- // This is a low-level API that most users should not use directly.
192
- // A mid-level API is the encodeSegments() function.
193
- constructor(e, o, n, i) {
194
- if (this.version = e, this.errorCorrectionLevel = o, this.modules = [], this.isFunction = [], e < v.MIN_VERSION || e > v.MAX_VERSION)
195
- throw new RangeError("Version value out of range");
196
- if (i < -1 || i > 7)
197
- throw new RangeError("Mask value out of range");
198
- this.size = e * 4 + 17;
199
- let l = [];
200
- for (let d = 0; d < this.size; d++)
201
- l.push(!1);
202
- for (let d = 0; d < this.size; d++)
203
- this.modules.push(l.slice()), this.isFunction.push(l.slice());
204
- this.drawFunctionPatterns();
205
- const f = this.addEccAndInterleave(n);
206
- if (this.drawCodewords(f), i == -1) {
207
- let d = 1e9;
208
- for (let E = 0; E < 8; E++) {
209
- this.applyMask(E), this.drawFormatBits(E);
210
- const m = this.getPenaltyScore();
211
- m < d && (i = E, d = m), this.applyMask(E);
212
- }
213
- }
214
- u(0 <= i && i <= 7), this.mask = i, this.applyMask(i), this.drawFormatBits(i), this.isFunction = [];
215
- }
216
- /*-- Static factory functions (high level) --*/
217
- // Returns a QR Code representing the given Unicode text string at the given error correction level.
218
- // As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer
219
- // Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible
220
- // QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the
221
- // ecl argument if it can be done without increasing the version.
222
- static encodeText(e, o) {
223
- const n = t.QrSegment.makeSegments(e);
224
- return v.encodeSegments(n, o);
225
- }
226
- // Returns a QR Code representing the given binary data at the given error correction level.
227
- // This function always encodes using the binary segment mode, not any text mode. The maximum number of
228
- // bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.
229
- // The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.
230
- static encodeBinary(e, o) {
231
- const n = t.QrSegment.makeBytes(e);
232
- return v.encodeSegments([n], o);
233
- }
234
- /*-- Static factory functions (mid level) --*/
235
- // Returns a QR Code representing the given segments with the given encoding parameters.
236
- // The smallest possible QR Code version within the given range is automatically
237
- // chosen for the output. Iff boostEcl is true, then the ECC level of the result
238
- // may be higher than the ecl argument if it can be done without increasing the
239
- // version. The mask number is either between 0 to 7 (inclusive) to force that
240
- // mask, or -1 to automatically choose an appropriate mask (which may be slow).
241
- // This function allows the user to create a custom sequence of segments that switches
242
- // between modes (such as alphanumeric and byte) to encode text in less space.
243
- // This is a mid-level API; the high-level API is encodeText() and encodeBinary().
244
- static encodeSegments(e, o, n = 1, i = 40, l = -1, f = !0) {
245
- if (!(v.MIN_VERSION <= n && n <= i && i <= v.MAX_VERSION) || l < -1 || l > 7)
246
- throw new RangeError("Invalid value");
247
- let d, E;
248
- for (d = n; ; d++) {
249
- const g = v.getNumDataCodewords(d, o) * 8, y = C.getTotalBits(e, d);
250
- if (y <= g) {
251
- E = y;
252
- break;
253
- }
254
- if (d >= i)
255
- throw new RangeError("Data too long");
256
- }
257
- for (const g of [v.Ecc.MEDIUM, v.Ecc.QUARTILE, v.Ecc.HIGH])
258
- f && E <= v.getNumDataCodewords(d, g) * 8 && (o = g);
259
- let m = [];
260
- for (const g of e) {
261
- r(g.mode.modeBits, 4, m), r(g.numChars, g.mode.numCharCountBits(d), m);
262
- for (const y of g.getData())
263
- m.push(y);
264
- }
265
- u(m.length == E);
266
- const N = v.getNumDataCodewords(d, o) * 8;
267
- u(m.length <= N), r(0, Math.min(4, N - m.length), m), r(0, (8 - m.length % 8) % 8, m), u(m.length % 8 == 0);
268
- for (let g = 236; m.length < N; g ^= 253)
269
- r(g, 8, m);
270
- let w = [];
271
- for (; w.length * 8 < m.length; )
272
- w.push(0);
273
- return m.forEach((g, y) => w[y >>> 3] |= g << 7 - (y & 7)), new v(d, o, w, l);
274
- }
275
- /*-- Accessor methods --*/
276
- // Returns the color of the module (pixel) at the given coordinates, which is false
277
- // for light or true for dark. The top left corner has the coordinates (x=0, y=0).
278
- // If the given coordinates are out of bounds, then false (light) is returned.
279
- getModule(e, o) {
280
- return 0 <= e && e < this.size && 0 <= o && o < this.size && this.modules[o][e];
281
- }
282
- // Modified to expose modules for easy access
283
- getModules() {
284
- return this.modules;
285
- }
286
- /*-- Private helper methods for constructor: Drawing function modules --*/
287
- // Reads this object's version field, and draws and marks all function modules.
288
- drawFunctionPatterns() {
289
- for (let n = 0; n < this.size; n++)
290
- this.setFunctionModule(6, n, n % 2 == 0), this.setFunctionModule(n, 6, n % 2 == 0);
291
- this.drawFinderPattern(3, 3), this.drawFinderPattern(this.size - 4, 3), this.drawFinderPattern(3, this.size - 4);
292
- const e = this.getAlignmentPatternPositions(), o = e.length;
293
- for (let n = 0; n < o; n++)
294
- for (let i = 0; i < o; i++)
295
- n == 0 && i == 0 || n == 0 && i == o - 1 || n == o - 1 && i == 0 || this.drawAlignmentPattern(e[n], e[i]);
296
- this.drawFormatBits(0), this.drawVersion();
297
- }
298
- // Draws two copies of the format bits (with its own error correction code)
299
- // based on the given mask and this object's error correction level field.
300
- drawFormatBits(e) {
301
- const o = this.errorCorrectionLevel.formatBits << 3 | e;
302
- let n = o;
303
- for (let l = 0; l < 10; l++)
304
- n = n << 1 ^ (n >>> 9) * 1335;
305
- const i = (o << 10 | n) ^ 21522;
306
- u(i >>> 15 == 0);
307
- for (let l = 0; l <= 5; l++)
308
- this.setFunctionModule(8, l, a(i, l));
309
- this.setFunctionModule(8, 7, a(i, 6)), this.setFunctionModule(8, 8, a(i, 7)), this.setFunctionModule(7, 8, a(i, 8));
310
- for (let l = 9; l < 15; l++)
311
- this.setFunctionModule(14 - l, 8, a(i, l));
312
- for (let l = 0; l < 8; l++)
313
- this.setFunctionModule(this.size - 1 - l, 8, a(i, l));
314
- for (let l = 8; l < 15; l++)
315
- this.setFunctionModule(8, this.size - 15 + l, a(i, l));
316
- this.setFunctionModule(8, this.size - 8, !0);
317
- }
318
- // Draws two copies of the version bits (with its own error correction code),
319
- // based on this object's version field, iff 7 <= version <= 40.
320
- drawVersion() {
321
- if (this.version < 7)
322
- return;
323
- let e = this.version;
324
- for (let n = 0; n < 12; n++)
325
- e = e << 1 ^ (e >>> 11) * 7973;
326
- const o = this.version << 12 | e;
327
- u(o >>> 18 == 0);
328
- for (let n = 0; n < 18; n++) {
329
- const i = a(o, n), l = this.size - 11 + n % 3, f = Math.floor(n / 3);
330
- this.setFunctionModule(l, f, i), this.setFunctionModule(f, l, i);
331
- }
332
- }
333
- // Draws a 9*9 finder pattern including the border separator,
334
- // with the center module at (x, y). Modules can be out of bounds.
335
- drawFinderPattern(e, o) {
336
- for (let n = -4; n <= 4; n++)
337
- for (let i = -4; i <= 4; i++) {
338
- const l = Math.max(Math.abs(i), Math.abs(n)), f = e + i, d = o + n;
339
- 0 <= f && f < this.size && 0 <= d && d < this.size && this.setFunctionModule(f, d, l != 2 && l != 4);
340
- }
341
- }
342
- // Draws a 5*5 alignment pattern, with the center module
343
- // at (x, y). All modules must be in bounds.
344
- drawAlignmentPattern(e, o) {
345
- for (let n = -2; n <= 2; n++)
346
- for (let i = -2; i <= 2; i++)
347
- this.setFunctionModule(e + i, o + n, Math.max(Math.abs(i), Math.abs(n)) != 1);
348
- }
349
- // Sets the color of a module and marks it as a function module.
350
- // Only used by the constructor. Coordinates must be in bounds.
351
- setFunctionModule(e, o, n) {
352
- this.modules[o][e] = n, this.isFunction[o][e] = !0;
353
- }
354
- /*-- Private helper methods for constructor: Codewords and masking --*/
355
- // Returns a new byte string representing the given data with the appropriate error correction
356
- // codewords appended to it, based on this object's version and error correction level.
357
- addEccAndInterleave(e) {
358
- const o = this.version, n = this.errorCorrectionLevel;
359
- if (e.length != v.getNumDataCodewords(o, n))
360
- throw new RangeError("Invalid argument");
361
- const i = v.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][o], l = v.ECC_CODEWORDS_PER_BLOCK[n.ordinal][o], f = Math.floor(v.getNumRawDataModules(o) / 8), d = i - f % i, E = Math.floor(f / i);
362
- let m = [];
363
- const N = v.reedSolomonComputeDivisor(l);
364
- for (let g = 0, y = 0; g < i; g++) {
365
- let A = e.slice(y, y + E - l + (g < d ? 0 : 1));
366
- y += A.length;
367
- const L = v.reedSolomonComputeRemainder(A, N);
368
- g < d && A.push(0), m.push(A.concat(L));
369
- }
370
- let w = [];
371
- for (let g = 0; g < m[0].length; g++)
372
- m.forEach((y, A) => {
373
- (g != E - l || A >= d) && w.push(y[g]);
374
- });
375
- return u(w.length == f), w;
376
- }
377
- // Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
378
- // data area of this QR Code. Function modules need to be marked off before this is called.
379
- drawCodewords(e) {
380
- if (e.length != Math.floor(v.getNumRawDataModules(this.version) / 8))
381
- throw new RangeError("Invalid argument");
382
- let o = 0;
383
- for (let n = this.size - 1; n >= 1; n -= 2) {
384
- n == 6 && (n = 5);
385
- for (let i = 0; i < this.size; i++)
386
- for (let l = 0; l < 2; l++) {
387
- const f = n - l, E = (n + 1 & 2) == 0 ? this.size - 1 - i : i;
388
- !this.isFunction[E][f] && o < e.length * 8 && (this.modules[E][f] = a(e[o >>> 3], 7 - (o & 7)), o++);
389
- }
390
- }
391
- u(o == e.length * 8);
392
- }
393
- // XORs the codeword modules in this QR Code with the given mask pattern.
394
- // The function modules must be marked and the codeword bits must be drawn
395
- // before masking. Due to the arithmetic of XOR, calling applyMask() with
396
- // the same mask value a second time will undo the mask. A final well-formed
397
- // QR Code needs exactly one (not zero, two, etc.) mask applied.
398
- applyMask(e) {
399
- if (e < 0 || e > 7)
400
- throw new RangeError("Mask value out of range");
401
- for (let o = 0; o < this.size; o++)
402
- for (let n = 0; n < this.size; n++) {
403
- let i;
404
- switch (e) {
405
- case 0:
406
- i = (n + o) % 2 == 0;
407
- break;
408
- case 1:
409
- i = o % 2 == 0;
410
- break;
411
- case 2:
412
- i = n % 3 == 0;
413
- break;
414
- case 3:
415
- i = (n + o) % 3 == 0;
416
- break;
417
- case 4:
418
- i = (Math.floor(n / 3) + Math.floor(o / 2)) % 2 == 0;
419
- break;
420
- case 5:
421
- i = n * o % 2 + n * o % 3 == 0;
422
- break;
423
- case 6:
424
- i = (n * o % 2 + n * o % 3) % 2 == 0;
425
- break;
426
- case 7:
427
- i = ((n + o) % 2 + n * o % 3) % 2 == 0;
428
- break;
429
- default:
430
- throw new Error("Unreachable");
431
- }
432
- !this.isFunction[o][n] && i && (this.modules[o][n] = !this.modules[o][n]);
433
- }
434
- }
435
- // Calculates and returns the penalty score based on state of this QR Code's current modules.
436
- // This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score.
437
- getPenaltyScore() {
438
- let e = 0;
439
- for (let l = 0; l < this.size; l++) {
440
- let f = !1, d = 0, E = [0, 0, 0, 0, 0, 0, 0];
441
- for (let m = 0; m < this.size; m++)
442
- this.modules[l][m] == f ? (d++, d == 5 ? e += v.PENALTY_N1 : d > 5 && e++) : (this.finderPenaltyAddHistory(d, E), f || (e += this.finderPenaltyCountPatterns(E) * v.PENALTY_N3), f = this.modules[l][m], d = 1);
443
- e += this.finderPenaltyTerminateAndCount(f, d, E) * v.PENALTY_N3;
444
- }
445
- for (let l = 0; l < this.size; l++) {
446
- let f = !1, d = 0, E = [0, 0, 0, 0, 0, 0, 0];
447
- for (let m = 0; m < this.size; m++)
448
- this.modules[m][l] == f ? (d++, d == 5 ? e += v.PENALTY_N1 : d > 5 && e++) : (this.finderPenaltyAddHistory(d, E), f || (e += this.finderPenaltyCountPatterns(E) * v.PENALTY_N3), f = this.modules[m][l], d = 1);
449
- e += this.finderPenaltyTerminateAndCount(f, d, E) * v.PENALTY_N3;
450
- }
451
- for (let l = 0; l < this.size - 1; l++)
452
- for (let f = 0; f < this.size - 1; f++) {
453
- const d = this.modules[l][f];
454
- d == this.modules[l][f + 1] && d == this.modules[l + 1][f] && d == this.modules[l + 1][f + 1] && (e += v.PENALTY_N2);
455
- }
456
- let o = 0;
457
- for (const l of this.modules)
458
- o = l.reduce((f, d) => f + (d ? 1 : 0), o);
459
- const n = this.size * this.size, i = Math.ceil(Math.abs(o * 20 - n * 10) / n) - 1;
460
- return u(0 <= i && i <= 9), e += i * v.PENALTY_N4, u(0 <= e && e <= 2568888), e;
461
- }
462
- /*-- Private helper functions --*/
463
- // Returns an ascending list of positions of alignment patterns for this version number.
464
- // Each position is in the range [0,177), and are used on both the x and y axes.
465
- // This could be implemented as lookup table of 40 variable-length lists of integers.
466
- getAlignmentPatternPositions() {
467
- if (this.version == 1)
468
- return [];
469
- {
470
- const e = Math.floor(this.version / 7) + 2, o = this.version == 32 ? 26 : Math.ceil((this.version * 4 + 4) / (e * 2 - 2)) * 2;
471
- let n = [6];
472
- for (let i = this.size - 7; n.length < e; i -= o)
473
- n.splice(1, 0, i);
474
- return n;
475
- }
476
- }
477
- // Returns the number of data bits that can be stored in a QR Code of the given version number, after
478
- // all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8.
479
- // The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.
480
- static getNumRawDataModules(e) {
481
- if (e < v.MIN_VERSION || e > v.MAX_VERSION)
482
- throw new RangeError("Version number out of range");
483
- let o = (16 * e + 128) * e + 64;
484
- if (e >= 2) {
485
- const n = Math.floor(e / 7) + 2;
486
- o -= (25 * n - 10) * n - 55, e >= 7 && (o -= 36);
487
- }
488
- return u(208 <= o && o <= 29648), o;
489
- }
490
- // Returns the number of 8-bit data (i.e. not error correction) codewords contained in any
491
- // QR Code of the given version number and error correction level, with remainder bits discarded.
492
- // This stateless pure function could be implemented as a (40*4)-cell lookup table.
493
- static getNumDataCodewords(e, o) {
494
- return Math.floor(v.getNumRawDataModules(e) / 8) - v.ECC_CODEWORDS_PER_BLOCK[o.ordinal][e] * v.NUM_ERROR_CORRECTION_BLOCKS[o.ordinal][e];
495
- }
496
- // Returns a Reed-Solomon ECC generator polynomial for the given degree. This could be
497
- // implemented as a lookup table over all possible parameter values, instead of as an algorithm.
498
- static reedSolomonComputeDivisor(e) {
499
- if (e < 1 || e > 255)
500
- throw new RangeError("Degree out of range");
501
- let o = [];
502
- for (let i = 0; i < e - 1; i++)
503
- o.push(0);
504
- o.push(1);
505
- let n = 1;
506
- for (let i = 0; i < e; i++) {
507
- for (let l = 0; l < o.length; l++)
508
- o[l] = v.reedSolomonMultiply(o[l], n), l + 1 < o.length && (o[l] ^= o[l + 1]);
509
- n = v.reedSolomonMultiply(n, 2);
510
- }
511
- return o;
512
- }
513
- // Returns the Reed-Solomon error correction codeword for the given data and divisor polynomials.
514
- static reedSolomonComputeRemainder(e, o) {
515
- let n = o.map((i) => 0);
516
- for (const i of e) {
517
- const l = i ^ n.shift();
518
- n.push(0), o.forEach((f, d) => n[d] ^= v.reedSolomonMultiply(f, l));
519
- }
520
- return n;
521
- }
522
- // Returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and result
523
- // are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8.
524
- static reedSolomonMultiply(e, o) {
525
- if (e >>> 8 || o >>> 8)
526
- throw new RangeError("Byte out of range");
527
- let n = 0;
528
- for (let i = 7; i >= 0; i--)
529
- n = n << 1 ^ (n >>> 7) * 285, n ^= (o >>> i & 1) * e;
530
- return u(n >>> 8 == 0), n;
531
- }
532
- // Can only be called immediately after a light run is added, and
533
- // returns either 0, 1, or 2. A helper function for getPenaltyScore().
534
- finderPenaltyCountPatterns(e) {
535
- const o = e[1];
536
- u(o <= this.size * 3);
537
- const n = o > 0 && e[2] == o && e[3] == o * 3 && e[4] == o && e[5] == o;
538
- return (n && e[0] >= o * 4 && e[6] >= o ? 1 : 0) + (n && e[6] >= o * 4 && e[0] >= o ? 1 : 0);
539
- }
540
- // Must be called at the end of a line (row or column) of modules. A helper function for getPenaltyScore().
541
- finderPenaltyTerminateAndCount(e, o, n) {
542
- return e && (this.finderPenaltyAddHistory(o, n), o = 0), o += this.size, this.finderPenaltyAddHistory(o, n), this.finderPenaltyCountPatterns(n);
543
- }
544
- // Pushes the given value to the front and drops the last value. A helper function for getPenaltyScore().
545
- finderPenaltyAddHistory(e, o) {
546
- o[0] == 0 && (e += this.size), o.pop(), o.unshift(e);
547
- }
548
- };
549
- s.MIN_VERSION = 1, s.MAX_VERSION = 40, s.PENALTY_N1 = 3, s.PENALTY_N2 = 3, s.PENALTY_N3 = 40, s.PENALTY_N4 = 10, s.ECC_CODEWORDS_PER_BLOCK = [
550
- // Version: (note that index 0 is for padding, and is set to an illegal value)
551
- //0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
552
- [-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
553
- // Low
554
- [-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28],
555
- // Medium
556
- [-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
557
- // Quartile
558
- [-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]
559
- // High
560
- ], s.NUM_ERROR_CORRECTION_BLOCKS = [
561
- // Version: (note that index 0 is for padding, and is set to an illegal value)
562
- //0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
563
- [-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25],
564
- // Low
565
- [-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49],
566
- // Medium
567
- [-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68],
568
- // Quartile
569
- [-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81]
570
- // High
571
- ], t.QrCode = s;
572
- function r(p, e, o) {
573
- if (e < 0 || e > 31 || p >>> e)
574
- throw new RangeError("Value out of range");
575
- for (let n = e - 1; n >= 0; n--)
576
- o.push(p >>> n & 1);
577
- }
578
- function a(p, e) {
579
- return (p >>> e & 1) != 0;
580
- }
581
- function u(p) {
582
- if (!p)
583
- throw new Error("Assertion error");
584
- }
585
- const c = class M {
586
- /*-- Constructor (low level) and fields --*/
587
- // Creates a new QR Code segment with the given attributes and data.
588
- // The character count (numChars) must agree with the mode and the bit buffer length,
589
- // but the constraint isn't checked. The given bit buffer is cloned and stored.
590
- constructor(e, o, n) {
591
- if (this.mode = e, this.numChars = o, this.bitData = n, o < 0)
592
- throw new RangeError("Invalid argument");
593
- this.bitData = n.slice();
594
- }
595
- /*-- Static factory functions (mid level) --*/
596
- // Returns a segment representing the given binary data encoded in
597
- // byte mode. All input byte arrays are acceptable. Any text string
598
- // can be converted to UTF-8 bytes and encoded as a byte mode segment.
599
- static makeBytes(e) {
600
- let o = [];
601
- for (const n of e)
602
- r(n, 8, o);
603
- return new M(M.Mode.BYTE, e.length, o);
604
- }
605
- // Returns a segment representing the given string of decimal digits encoded in numeric mode.
606
- static makeNumeric(e) {
607
- if (!M.isNumeric(e))
608
- throw new RangeError("String contains non-numeric characters");
609
- let o = [];
610
- for (let n = 0; n < e.length; ) {
611
- const i = Math.min(e.length - n, 3);
612
- r(parseInt(e.substring(n, n + i), 10), i * 3 + 1, o), n += i;
613
- }
614
- return new M(M.Mode.NUMERIC, e.length, o);
615
- }
616
- // Returns a segment representing the given text string encoded in alphanumeric mode.
617
- // The characters allowed are: 0 to 9, A to Z (uppercase only), space,
618
- // dollar, percent, asterisk, plus, hyphen, period, slash, colon.
619
- static makeAlphanumeric(e) {
620
- if (!M.isAlphanumeric(e))
621
- throw new RangeError("String contains unencodable characters in alphanumeric mode");
622
- let o = [], n;
623
- for (n = 0; n + 2 <= e.length; n += 2) {
624
- let i = M.ALPHANUMERIC_CHARSET.indexOf(e.charAt(n)) * 45;
625
- i += M.ALPHANUMERIC_CHARSET.indexOf(e.charAt(n + 1)), r(i, 11, o);
626
- }
627
- return n < e.length && r(M.ALPHANUMERIC_CHARSET.indexOf(e.charAt(n)), 6, o), new M(M.Mode.ALPHANUMERIC, e.length, o);
628
- }
629
- // Returns a new mutable list of zero or more segments to represent the given Unicode text string.
630
- // The result may use various segment modes and switch modes to optimize the length of the bit stream.
631
- static makeSegments(e) {
632
- return e == "" ? [] : M.isNumeric(e) ? [M.makeNumeric(e)] : M.isAlphanumeric(e) ? [M.makeAlphanumeric(e)] : [M.makeBytes(M.toUtf8ByteArray(e))];
633
- }
634
- // Returns a segment representing an Extended Channel Interpretation
635
- // (ECI) designator with the given assignment value.
636
- static makeEci(e) {
637
- let o = [];
638
- if (e < 0)
639
- throw new RangeError("ECI assignment value out of range");
640
- if (e < 128)
641
- r(e, 8, o);
642
- else if (e < 16384)
643
- r(2, 2, o), r(e, 14, o);
644
- else if (e < 1e6)
645
- r(6, 3, o), r(e, 21, o);
646
- else
647
- throw new RangeError("ECI assignment value out of range");
648
- return new M(M.Mode.ECI, 0, o);
649
- }
650
- // Tests whether the given string can be encoded as a segment in numeric mode.
651
- // A string is encodable iff each character is in the range 0 to 9.
652
- static isNumeric(e) {
653
- return M.NUMERIC_REGEX.test(e);
654
- }
655
- // Tests whether the given string can be encoded as a segment in alphanumeric mode.
656
- // A string is encodable iff each character is in the following set: 0 to 9, A to Z
657
- // (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.
658
- static isAlphanumeric(e) {
659
- return M.ALPHANUMERIC_REGEX.test(e);
660
- }
661
- /*-- Methods --*/
662
- // Returns a new copy of the data bits of this segment.
663
- getData() {
664
- return this.bitData.slice();
665
- }
666
- // (Package-private) Calculates and returns the number of bits needed to encode the given segments at
667
- // the given version. The result is infinity if a segment has too many characters to fit its length field.
668
- static getTotalBits(e, o) {
669
- let n = 0;
670
- for (const i of e) {
671
- const l = i.mode.numCharCountBits(o);
672
- if (i.numChars >= 1 << l)
673
- return 1 / 0;
674
- n += 4 + l + i.bitData.length;
675
- }
676
- return n;
677
- }
678
- // Returns a new array of bytes representing the given string encoded in UTF-8.
679
- static toUtf8ByteArray(e) {
680
- e = encodeURI(e);
681
- let o = [];
682
- for (let n = 0; n < e.length; n++)
683
- e.charAt(n) != "%" ? o.push(e.charCodeAt(n)) : (o.push(parseInt(e.substring(n + 1, n + 3), 16)), n += 2);
684
- return o;
685
- }
686
- };
687
- c.NUMERIC_REGEX = /^[0-9]*$/, c.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/, c.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
688
- let C = c;
689
- t.QrSegment = c;
690
- })(J || (J = {}));
691
- ((t) => {
692
- ((s) => {
693
- const r = class {
694
- // The QR Code can tolerate about 30% erroneous codewords
695
- /*-- Constructor and fields --*/
696
- constructor(u, c) {
697
- this.ordinal = u, this.formatBits = c;
698
- }
699
- };
700
- r.LOW = new r(0, 1), r.MEDIUM = new r(1, 0), r.QUARTILE = new r(2, 3), r.HIGH = new r(3, 2), s.Ecc = r;
701
- })(t.QrCode || (t.QrCode = {}));
702
- })(J || (J = {}));
703
- ((t) => {
704
- ((s) => {
705
- const r = class {
706
- /*-- Constructor and fields --*/
707
- constructor(u, c) {
708
- this.modeBits = u, this.numBitsCharCount = c;
709
- }
710
- /*-- Method --*/
711
- // (Package-private) Returns the bit width of the character count field for a segment in
712
- // this mode in a QR Code at the given version number. The result is in the range [0, 16].
713
- numCharCountBits(u) {
714
- return this.numBitsCharCount[Math.floor((u + 7) / 17)];
715
- }
716
- };
717
- r.NUMERIC = new r(1, [10, 12, 14]), r.ALPHANUMERIC = new r(2, [9, 11, 13]), r.BYTE = new r(4, [8, 16, 16]), r.KANJI = new r(8, [8, 10, 12]), r.ECI = new r(7, [0, 0, 0]), s.Mode = r;
718
- })(t.QrSegment || (t.QrSegment = {}));
719
- })(J || (J = {}));
720
- var ee = J;
721
- var Dt = {
722
- L: ee.QrCode.Ecc.LOW,
723
- M: ee.QrCode.Ecc.MEDIUM,
724
- Q: ee.QrCode.Ecc.QUARTILE,
725
- H: ee.QrCode.Ecc.HIGH
726
- }, Le = 128, Be = "L", ke = "#FFFFFF", Fe = "#000000", Ue = !1, ze = 1, Tt = 4, Ot = 0, Lt = 0.1;
727
- function _e(t, s = 0) {
728
- const r = [];
729
- return t.forEach(function(a, u) {
730
- let c = null;
731
- a.forEach(function(C, p) {
732
- if (!C && c !== null) {
733
- r.push(
734
- `M${c + s} ${u + s}h${p - c}v1H${c + s}z`
735
- ), c = null;
736
- return;
737
- }
738
- if (p === a.length - 1) {
739
- if (!C)
740
- return;
741
- c === null ? r.push(`M${p + s},${u + s} h1v1H${p + s}z`) : r.push(
742
- `M${c + s},${u + s} h${p + 1 - c}v1H${c + s}z`
743
- );
744
- return;
745
- }
746
- C && c === null && (c = p);
747
- });
748
- }), r.join("");
136
+ //#endregion
137
+ //#region node_modules/qrcode.react/lib/esm/index.js
138
+ var ge = Object.defineProperty, Q = Object.getOwnPropertySymbols, _e = Object.prototype.hasOwnProperty, ve = Object.prototype.propertyIsEnumerable, ye = (e, t, n) => t in e ? ge(e, t, {
139
+ enumerable: !0,
140
+ configurable: !0,
141
+ writable: !0,
142
+ value: n
143
+ }) : e[t] = n, be = (e, t) => {
144
+ for (var n in t ||= {}) _e.call(t, n) && ye(e, n, t[n]);
145
+ if (Q) for (var n of Q(t)) ve.call(t, n) && ye(e, n, t[n]);
146
+ return e;
147
+ }, xe = (e, t) => {
148
+ var n = {};
149
+ for (var r in e) _e.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]);
150
+ if (e != null && Q) for (var r of Q(e)) t.indexOf(r) < 0 && ve.call(e, r) && (n[r] = e[r]);
151
+ return n;
152
+ }, Se;
153
+ ((e) => {
154
+ let t = class t {
155
+ constructor(e, n, r, a) {
156
+ if (this.version = e, this.errorCorrectionLevel = n, this.modules = [], this.isFunction = [], e < t.MIN_VERSION || e > t.MAX_VERSION) throw RangeError("Version value out of range");
157
+ if (a < -1 || a > 7) throw RangeError("Mask value out of range");
158
+ this.size = e * 4 + 17;
159
+ let o = [];
160
+ for (let e = 0; e < this.size; e++) o.push(!1);
161
+ for (let e = 0; e < this.size; e++) this.modules.push(o.slice()), this.isFunction.push(o.slice());
162
+ this.drawFunctionPatterns();
163
+ let s = this.addEccAndInterleave(r);
164
+ if (this.drawCodewords(s), a == -1) {
165
+ let e = 1e9;
166
+ for (let t = 0; t < 8; t++) {
167
+ this.applyMask(t), this.drawFormatBits(t);
168
+ let n = this.getPenaltyScore();
169
+ n < e && (a = t, e = n), this.applyMask(t);
170
+ }
171
+ }
172
+ i(0 <= a && a <= 7), this.mask = a, this.applyMask(a), this.drawFormatBits(a), this.isFunction = [];
173
+ }
174
+ static encodeText(n, r) {
175
+ let i = e.QrSegment.makeSegments(n);
176
+ return t.encodeSegments(i, r);
177
+ }
178
+ static encodeBinary(n, r) {
179
+ let i = e.QrSegment.makeBytes(n);
180
+ return t.encodeSegments([i], r);
181
+ }
182
+ static encodeSegments(e, r, a = 1, s = 40, c = -1, l = !0) {
183
+ if (!(t.MIN_VERSION <= a && a <= s && s <= t.MAX_VERSION) || c < -1 || c > 7) throw RangeError("Invalid value");
184
+ let u, d;
185
+ for (u = a;; u++) {
186
+ let n = t.getNumDataCodewords(u, r) * 8, i = o.getTotalBits(e, u);
187
+ if (i <= n) {
188
+ d = i;
189
+ break;
190
+ }
191
+ if (u >= s) throw RangeError("Data too long");
192
+ }
193
+ for (let e of [
194
+ t.Ecc.MEDIUM,
195
+ t.Ecc.QUARTILE,
196
+ t.Ecc.HIGH
197
+ ]) l && d <= t.getNumDataCodewords(u, e) * 8 && (r = e);
198
+ let f = [];
199
+ for (let t of e) {
200
+ n(t.mode.modeBits, 4, f), n(t.numChars, t.mode.numCharCountBits(u), f);
201
+ for (let e of t.getData()) f.push(e);
202
+ }
203
+ i(f.length == d);
204
+ let p = t.getNumDataCodewords(u, r) * 8;
205
+ i(f.length <= p), n(0, Math.min(4, p - f.length), f), n(0, (8 - f.length % 8) % 8, f), i(f.length % 8 == 0);
206
+ for (let e = 236; f.length < p; e ^= 253) n(e, 8, f);
207
+ let m = [];
208
+ for (; m.length * 8 < f.length;) m.push(0);
209
+ return f.forEach((e, t) => m[t >>> 3] |= e << 7 - (t & 7)), new t(u, r, m, c);
210
+ }
211
+ getModule(e, t) {
212
+ return 0 <= e && e < this.size && 0 <= t && t < this.size && this.modules[t][e];
213
+ }
214
+ getModules() {
215
+ return this.modules;
216
+ }
217
+ drawFunctionPatterns() {
218
+ for (let e = 0; e < this.size; e++) this.setFunctionModule(6, e, e % 2 == 0), this.setFunctionModule(e, 6, e % 2 == 0);
219
+ this.drawFinderPattern(3, 3), this.drawFinderPattern(this.size - 4, 3), this.drawFinderPattern(3, this.size - 4);
220
+ let e = this.getAlignmentPatternPositions(), t = e.length;
221
+ for (let n = 0; n < t; n++) for (let r = 0; r < t; r++) n == 0 && r == 0 || n == 0 && r == t - 1 || n == t - 1 && r == 0 || this.drawAlignmentPattern(e[n], e[r]);
222
+ this.drawFormatBits(0), this.drawVersion();
223
+ }
224
+ drawFormatBits(e) {
225
+ let t = this.errorCorrectionLevel.formatBits << 3 | e, n = t;
226
+ for (let e = 0; e < 10; e++) n = n << 1 ^ (n >>> 9) * 1335;
227
+ let a = (t << 10 | n) ^ 21522;
228
+ i(a >>> 15 == 0);
229
+ for (let e = 0; e <= 5; e++) this.setFunctionModule(8, e, r(a, e));
230
+ this.setFunctionModule(8, 7, r(a, 6)), this.setFunctionModule(8, 8, r(a, 7)), this.setFunctionModule(7, 8, r(a, 8));
231
+ for (let e = 9; e < 15; e++) this.setFunctionModule(14 - e, 8, r(a, e));
232
+ for (let e = 0; e < 8; e++) this.setFunctionModule(this.size - 1 - e, 8, r(a, e));
233
+ for (let e = 8; e < 15; e++) this.setFunctionModule(8, this.size - 15 + e, r(a, e));
234
+ this.setFunctionModule(8, this.size - 8, !0);
235
+ }
236
+ drawVersion() {
237
+ if (this.version < 7) return;
238
+ let e = this.version;
239
+ for (let t = 0; t < 12; t++) e = e << 1 ^ (e >>> 11) * 7973;
240
+ let t = this.version << 12 | e;
241
+ i(t >>> 18 == 0);
242
+ for (let e = 0; e < 18; e++) {
243
+ let n = r(t, e), i = this.size - 11 + e % 3, a = Math.floor(e / 3);
244
+ this.setFunctionModule(i, a, n), this.setFunctionModule(a, i, n);
245
+ }
246
+ }
247
+ drawFinderPattern(e, t) {
248
+ for (let n = -4; n <= 4; n++) for (let r = -4; r <= 4; r++) {
249
+ let i = Math.max(Math.abs(r), Math.abs(n)), a = e + r, o = t + n;
250
+ 0 <= a && a < this.size && 0 <= o && o < this.size && this.setFunctionModule(a, o, i != 2 && i != 4);
251
+ }
252
+ }
253
+ drawAlignmentPattern(e, t) {
254
+ for (let n = -2; n <= 2; n++) for (let r = -2; r <= 2; r++) this.setFunctionModule(e + r, t + n, Math.max(Math.abs(r), Math.abs(n)) != 1);
255
+ }
256
+ setFunctionModule(e, t, n) {
257
+ this.modules[t][e] = n, this.isFunction[t][e] = !0;
258
+ }
259
+ addEccAndInterleave(e) {
260
+ let n = this.version, r = this.errorCorrectionLevel;
261
+ if (e.length != t.getNumDataCodewords(n, r)) throw RangeError("Invalid argument");
262
+ let a = t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n], o = t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n], s = Math.floor(t.getNumRawDataModules(n) / 8), c = a - s % a, l = Math.floor(s / a), u = [], d = t.reedSolomonComputeDivisor(o);
263
+ for (let n = 0, r = 0; n < a; n++) {
264
+ let i = e.slice(r, r + l - o + (n < c ? 0 : 1));
265
+ r += i.length;
266
+ let a = t.reedSolomonComputeRemainder(i, d);
267
+ n < c && i.push(0), u.push(i.concat(a));
268
+ }
269
+ let f = [];
270
+ for (let e = 0; e < u[0].length; e++) u.forEach((t, n) => {
271
+ (e != l - o || n >= c) && f.push(t[e]);
272
+ });
273
+ return i(f.length == s), f;
274
+ }
275
+ drawCodewords(e) {
276
+ if (e.length != Math.floor(t.getNumRawDataModules(this.version) / 8)) throw RangeError("Invalid argument");
277
+ let n = 0;
278
+ for (let t = this.size - 1; t >= 1; t -= 2) {
279
+ t == 6 && (t = 5);
280
+ for (let i = 0; i < this.size; i++) for (let a = 0; a < 2; a++) {
281
+ let o = t - a, s = t + 1 & 2 ? i : this.size - 1 - i;
282
+ !this.isFunction[s][o] && n < e.length * 8 && (this.modules[s][o] = r(e[n >>> 3], 7 - (n & 7)), n++);
283
+ }
284
+ }
285
+ i(n == e.length * 8);
286
+ }
287
+ applyMask(e) {
288
+ if (e < 0 || e > 7) throw RangeError("Mask value out of range");
289
+ for (let t = 0; t < this.size; t++) for (let n = 0; n < this.size; n++) {
290
+ let r;
291
+ switch (e) {
292
+ case 0:
293
+ r = (n + t) % 2 == 0;
294
+ break;
295
+ case 1:
296
+ r = t % 2 == 0;
297
+ break;
298
+ case 2:
299
+ r = n % 3 == 0;
300
+ break;
301
+ case 3:
302
+ r = (n + t) % 3 == 0;
303
+ break;
304
+ case 4:
305
+ r = (Math.floor(n / 3) + Math.floor(t / 2)) % 2 == 0;
306
+ break;
307
+ case 5:
308
+ r = n * t % 2 + n * t % 3 == 0;
309
+ break;
310
+ case 6:
311
+ r = (n * t % 2 + n * t % 3) % 2 == 0;
312
+ break;
313
+ case 7:
314
+ r = ((n + t) % 2 + n * t % 3) % 2 == 0;
315
+ break;
316
+ default: throw Error("Unreachable");
317
+ }
318
+ !this.isFunction[t][n] && r && (this.modules[t][n] = !this.modules[t][n]);
319
+ }
320
+ }
321
+ getPenaltyScore() {
322
+ let e = 0;
323
+ for (let n = 0; n < this.size; n++) {
324
+ let r = !1, i = 0, a = [
325
+ 0,
326
+ 0,
327
+ 0,
328
+ 0,
329
+ 0,
330
+ 0,
331
+ 0
332
+ ];
333
+ for (let o = 0; o < this.size; o++) this.modules[n][o] == r ? (i++, i == 5 ? e += t.PENALTY_N1 : i > 5 && e++) : (this.finderPenaltyAddHistory(i, a), r || (e += this.finderPenaltyCountPatterns(a) * t.PENALTY_N3), r = this.modules[n][o], i = 1);
334
+ e += this.finderPenaltyTerminateAndCount(r, i, a) * t.PENALTY_N3;
335
+ }
336
+ for (let n = 0; n < this.size; n++) {
337
+ let r = !1, i = 0, a = [
338
+ 0,
339
+ 0,
340
+ 0,
341
+ 0,
342
+ 0,
343
+ 0,
344
+ 0
345
+ ];
346
+ for (let o = 0; o < this.size; o++) this.modules[o][n] == r ? (i++, i == 5 ? e += t.PENALTY_N1 : i > 5 && e++) : (this.finderPenaltyAddHistory(i, a), r || (e += this.finderPenaltyCountPatterns(a) * t.PENALTY_N3), r = this.modules[o][n], i = 1);
347
+ e += this.finderPenaltyTerminateAndCount(r, i, a) * t.PENALTY_N3;
348
+ }
349
+ for (let n = 0; n < this.size - 1; n++) for (let r = 0; r < this.size - 1; r++) {
350
+ let i = this.modules[n][r];
351
+ i == this.modules[n][r + 1] && i == this.modules[n + 1][r] && i == this.modules[n + 1][r + 1] && (e += t.PENALTY_N2);
352
+ }
353
+ let n = 0;
354
+ for (let e of this.modules) n = e.reduce((e, t) => e + +!!t, n);
355
+ let r = this.size * this.size, a = Math.ceil(Math.abs(n * 20 - r * 10) / r) - 1;
356
+ return i(0 <= a && a <= 9), e += a * t.PENALTY_N4, i(0 <= e && e <= 2568888), e;
357
+ }
358
+ getAlignmentPatternPositions() {
359
+ if (this.version == 1) return [];
360
+ {
361
+ let e = Math.floor(this.version / 7) + 2, t = this.version == 32 ? 26 : Math.ceil((this.version * 4 + 4) / (e * 2 - 2)) * 2, n = [6];
362
+ for (let r = this.size - 7; n.length < e; r -= t) n.splice(1, 0, r);
363
+ return n;
364
+ }
365
+ }
366
+ static getNumRawDataModules(e) {
367
+ if (e < t.MIN_VERSION || e > t.MAX_VERSION) throw RangeError("Version number out of range");
368
+ let n = (16 * e + 128) * e + 64;
369
+ if (e >= 2) {
370
+ let t = Math.floor(e / 7) + 2;
371
+ n -= (25 * t - 10) * t - 55, e >= 7 && (n -= 36);
372
+ }
373
+ return i(208 <= n && n <= 29648), n;
374
+ }
375
+ static getNumDataCodewords(e, n) {
376
+ return Math.floor(t.getNumRawDataModules(e) / 8) - t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e] * t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e];
377
+ }
378
+ static reedSolomonComputeDivisor(e) {
379
+ if (e < 1 || e > 255) throw RangeError("Degree out of range");
380
+ let n = [];
381
+ for (let t = 0; t < e - 1; t++) n.push(0);
382
+ n.push(1);
383
+ let r = 1;
384
+ for (let i = 0; i < e; i++) {
385
+ for (let e = 0; e < n.length; e++) n[e] = t.reedSolomonMultiply(n[e], r), e + 1 < n.length && (n[e] ^= n[e + 1]);
386
+ r = t.reedSolomonMultiply(r, 2);
387
+ }
388
+ return n;
389
+ }
390
+ static reedSolomonComputeRemainder(e, n) {
391
+ let r = n.map((e) => 0);
392
+ for (let i of e) {
393
+ let e = i ^ r.shift();
394
+ r.push(0), n.forEach((n, i) => r[i] ^= t.reedSolomonMultiply(n, e));
395
+ }
396
+ return r;
397
+ }
398
+ static reedSolomonMultiply(e, t) {
399
+ if (e >>> 8 || t >>> 8) throw RangeError("Byte out of range");
400
+ let n = 0;
401
+ for (let r = 7; r >= 0; r--) n = n << 1 ^ (n >>> 7) * 285, n ^= (t >>> r & 1) * e;
402
+ return i(n >>> 8 == 0), n;
403
+ }
404
+ finderPenaltyCountPatterns(e) {
405
+ let t = e[1];
406
+ i(t <= this.size * 3);
407
+ let n = t > 0 && e[2] == t && e[3] == t * 3 && e[4] == t && e[5] == t;
408
+ return (n && e[0] >= t * 4 && e[6] >= t ? 1 : 0) + (n && e[6] >= t * 4 && e[0] >= t ? 1 : 0);
409
+ }
410
+ finderPenaltyTerminateAndCount(e, t, n) {
411
+ return e && (this.finderPenaltyAddHistory(t, n), t = 0), t += this.size, this.finderPenaltyAddHistory(t, n), this.finderPenaltyCountPatterns(n);
412
+ }
413
+ finderPenaltyAddHistory(e, t) {
414
+ t[0] == 0 && (e += this.size), t.pop(), t.unshift(e);
415
+ }
416
+ };
417
+ t.MIN_VERSION = 1, t.MAX_VERSION = 40, t.PENALTY_N1 = 3, t.PENALTY_N2 = 3, t.PENALTY_N3 = 40, t.PENALTY_N4 = 10, t.ECC_CODEWORDS_PER_BLOCK = [
418
+ [
419
+ -1,
420
+ 7,
421
+ 10,
422
+ 15,
423
+ 20,
424
+ 26,
425
+ 18,
426
+ 20,
427
+ 24,
428
+ 30,
429
+ 18,
430
+ 20,
431
+ 24,
432
+ 26,
433
+ 30,
434
+ 22,
435
+ 24,
436
+ 28,
437
+ 30,
438
+ 28,
439
+ 28,
440
+ 28,
441
+ 28,
442
+ 30,
443
+ 30,
444
+ 26,
445
+ 28,
446
+ 30,
447
+ 30,
448
+ 30,
449
+ 30,
450
+ 30,
451
+ 30,
452
+ 30,
453
+ 30,
454
+ 30,
455
+ 30,
456
+ 30,
457
+ 30,
458
+ 30,
459
+ 30
460
+ ],
461
+ [
462
+ -1,
463
+ 10,
464
+ 16,
465
+ 26,
466
+ 18,
467
+ 24,
468
+ 16,
469
+ 18,
470
+ 22,
471
+ 22,
472
+ 26,
473
+ 30,
474
+ 22,
475
+ 22,
476
+ 24,
477
+ 24,
478
+ 28,
479
+ 28,
480
+ 26,
481
+ 26,
482
+ 26,
483
+ 26,
484
+ 28,
485
+ 28,
486
+ 28,
487
+ 28,
488
+ 28,
489
+ 28,
490
+ 28,
491
+ 28,
492
+ 28,
493
+ 28,
494
+ 28,
495
+ 28,
496
+ 28,
497
+ 28,
498
+ 28,
499
+ 28,
500
+ 28,
501
+ 28,
502
+ 28
503
+ ],
504
+ [
505
+ -1,
506
+ 13,
507
+ 22,
508
+ 18,
509
+ 26,
510
+ 18,
511
+ 24,
512
+ 18,
513
+ 22,
514
+ 20,
515
+ 24,
516
+ 28,
517
+ 26,
518
+ 24,
519
+ 20,
520
+ 30,
521
+ 24,
522
+ 28,
523
+ 28,
524
+ 26,
525
+ 30,
526
+ 28,
527
+ 30,
528
+ 30,
529
+ 30,
530
+ 30,
531
+ 28,
532
+ 30,
533
+ 30,
534
+ 30,
535
+ 30,
536
+ 30,
537
+ 30,
538
+ 30,
539
+ 30,
540
+ 30,
541
+ 30,
542
+ 30,
543
+ 30,
544
+ 30,
545
+ 30
546
+ ],
547
+ [
548
+ -1,
549
+ 17,
550
+ 28,
551
+ 22,
552
+ 16,
553
+ 22,
554
+ 28,
555
+ 26,
556
+ 26,
557
+ 24,
558
+ 28,
559
+ 24,
560
+ 28,
561
+ 22,
562
+ 24,
563
+ 24,
564
+ 30,
565
+ 28,
566
+ 28,
567
+ 26,
568
+ 28,
569
+ 30,
570
+ 24,
571
+ 30,
572
+ 30,
573
+ 30,
574
+ 30,
575
+ 30,
576
+ 30,
577
+ 30,
578
+ 30,
579
+ 30,
580
+ 30,
581
+ 30,
582
+ 30,
583
+ 30,
584
+ 30,
585
+ 30,
586
+ 30,
587
+ 30,
588
+ 30
589
+ ]
590
+ ], t.NUM_ERROR_CORRECTION_BLOCKS = [
591
+ [
592
+ -1,
593
+ 1,
594
+ 1,
595
+ 1,
596
+ 1,
597
+ 1,
598
+ 2,
599
+ 2,
600
+ 2,
601
+ 2,
602
+ 4,
603
+ 4,
604
+ 4,
605
+ 4,
606
+ 4,
607
+ 6,
608
+ 6,
609
+ 6,
610
+ 6,
611
+ 7,
612
+ 8,
613
+ 8,
614
+ 9,
615
+ 9,
616
+ 10,
617
+ 12,
618
+ 12,
619
+ 12,
620
+ 13,
621
+ 14,
622
+ 15,
623
+ 16,
624
+ 17,
625
+ 18,
626
+ 19,
627
+ 19,
628
+ 20,
629
+ 21,
630
+ 22,
631
+ 24,
632
+ 25
633
+ ],
634
+ [
635
+ -1,
636
+ 1,
637
+ 1,
638
+ 1,
639
+ 2,
640
+ 2,
641
+ 4,
642
+ 4,
643
+ 4,
644
+ 5,
645
+ 5,
646
+ 5,
647
+ 8,
648
+ 9,
649
+ 9,
650
+ 10,
651
+ 10,
652
+ 11,
653
+ 13,
654
+ 14,
655
+ 16,
656
+ 17,
657
+ 17,
658
+ 18,
659
+ 20,
660
+ 21,
661
+ 23,
662
+ 25,
663
+ 26,
664
+ 28,
665
+ 29,
666
+ 31,
667
+ 33,
668
+ 35,
669
+ 37,
670
+ 38,
671
+ 40,
672
+ 43,
673
+ 45,
674
+ 47,
675
+ 49
676
+ ],
677
+ [
678
+ -1,
679
+ 1,
680
+ 1,
681
+ 2,
682
+ 2,
683
+ 4,
684
+ 4,
685
+ 6,
686
+ 6,
687
+ 8,
688
+ 8,
689
+ 8,
690
+ 10,
691
+ 12,
692
+ 16,
693
+ 12,
694
+ 17,
695
+ 16,
696
+ 18,
697
+ 21,
698
+ 20,
699
+ 23,
700
+ 23,
701
+ 25,
702
+ 27,
703
+ 29,
704
+ 34,
705
+ 34,
706
+ 35,
707
+ 38,
708
+ 40,
709
+ 43,
710
+ 45,
711
+ 48,
712
+ 51,
713
+ 53,
714
+ 56,
715
+ 59,
716
+ 62,
717
+ 65,
718
+ 68
719
+ ],
720
+ [
721
+ -1,
722
+ 1,
723
+ 1,
724
+ 2,
725
+ 4,
726
+ 4,
727
+ 4,
728
+ 5,
729
+ 6,
730
+ 8,
731
+ 8,
732
+ 11,
733
+ 11,
734
+ 16,
735
+ 16,
736
+ 18,
737
+ 16,
738
+ 19,
739
+ 21,
740
+ 25,
741
+ 25,
742
+ 25,
743
+ 34,
744
+ 30,
745
+ 32,
746
+ 35,
747
+ 37,
748
+ 40,
749
+ 42,
750
+ 45,
751
+ 48,
752
+ 51,
753
+ 54,
754
+ 57,
755
+ 60,
756
+ 63,
757
+ 66,
758
+ 70,
759
+ 74,
760
+ 77,
761
+ 81
762
+ ]
763
+ ], e.QrCode = t;
764
+ function n(e, t, n) {
765
+ if (t < 0 || t > 31 || e >>> t) throw RangeError("Value out of range");
766
+ for (let r = t - 1; r >= 0; r--) n.push(e >>> r & 1);
767
+ }
768
+ function r(e, t) {
769
+ return (e >>> t & 1) != 0;
770
+ }
771
+ function i(e) {
772
+ if (!e) throw Error("Assertion error");
773
+ }
774
+ let a = class e {
775
+ constructor(e, t, n) {
776
+ if (this.mode = e, this.numChars = t, this.bitData = n, t < 0) throw RangeError("Invalid argument");
777
+ this.bitData = n.slice();
778
+ }
779
+ static makeBytes(t) {
780
+ let r = [];
781
+ for (let e of t) n(e, 8, r);
782
+ return new e(e.Mode.BYTE, t.length, r);
783
+ }
784
+ static makeNumeric(t) {
785
+ if (!e.isNumeric(t)) throw RangeError("String contains non-numeric characters");
786
+ let r = [];
787
+ for (let e = 0; e < t.length;) {
788
+ let i = Math.min(t.length - e, 3);
789
+ n(parseInt(t.substring(e, e + i), 10), i * 3 + 1, r), e += i;
790
+ }
791
+ return new e(e.Mode.NUMERIC, t.length, r);
792
+ }
793
+ static makeAlphanumeric(t) {
794
+ if (!e.isAlphanumeric(t)) throw RangeError("String contains unencodable characters in alphanumeric mode");
795
+ let r = [], i;
796
+ for (i = 0; i + 2 <= t.length; i += 2) {
797
+ let a = e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)) * 45;
798
+ a += e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i + 1)), n(a, 11, r);
799
+ }
800
+ return i < t.length && n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)), 6, r), new e(e.Mode.ALPHANUMERIC, t.length, r);
801
+ }
802
+ static makeSegments(t) {
803
+ return t == "" ? [] : e.isNumeric(t) ? [e.makeNumeric(t)] : e.isAlphanumeric(t) ? [e.makeAlphanumeric(t)] : [e.makeBytes(e.toUtf8ByteArray(t))];
804
+ }
805
+ static makeEci(t) {
806
+ let r = [];
807
+ if (t < 0) throw RangeError("ECI assignment value out of range");
808
+ if (t < 128) n(t, 8, r);
809
+ else if (t < 16384) n(2, 2, r), n(t, 14, r);
810
+ else if (t < 1e6) n(6, 3, r), n(t, 21, r);
811
+ else throw RangeError("ECI assignment value out of range");
812
+ return new e(e.Mode.ECI, 0, r);
813
+ }
814
+ static isNumeric(t) {
815
+ return e.NUMERIC_REGEX.test(t);
816
+ }
817
+ static isAlphanumeric(t) {
818
+ return e.ALPHANUMERIC_REGEX.test(t);
819
+ }
820
+ getData() {
821
+ return this.bitData.slice();
822
+ }
823
+ static getTotalBits(e, t) {
824
+ let n = 0;
825
+ for (let r of e) {
826
+ let e = r.mode.numCharCountBits(t);
827
+ if (r.numChars >= 1 << e) return Infinity;
828
+ n += 4 + e + r.bitData.length;
829
+ }
830
+ return n;
831
+ }
832
+ static toUtf8ByteArray(e) {
833
+ e = encodeURI(e);
834
+ let t = [];
835
+ for (let n = 0; n < e.length; n++) e.charAt(n) == "%" ? (t.push(parseInt(e.substring(n + 1, n + 3), 16)), n += 2) : t.push(e.charCodeAt(n));
836
+ return t;
837
+ }
838
+ };
839
+ a.NUMERIC_REGEX = /^[0-9]*$/, a.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/, a.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
840
+ let o = a;
841
+ e.QrSegment = a;
842
+ })(Se ||= {}), ((e) => {
843
+ ((e) => {
844
+ let t = class {
845
+ constructor(e, t) {
846
+ this.ordinal = e, this.formatBits = t;
847
+ }
848
+ };
849
+ t.LOW = new t(0, 1), t.MEDIUM = new t(1, 0), t.QUARTILE = new t(2, 3), t.HIGH = new t(3, 2), e.Ecc = t;
850
+ })(e.QrCode ||= {});
851
+ })(Se ||= {}), ((e) => {
852
+ ((e) => {
853
+ let t = class {
854
+ constructor(e, t) {
855
+ this.modeBits = e, this.numBitsCharCount = t;
856
+ }
857
+ numCharCountBits(e) {
858
+ return this.numBitsCharCount[Math.floor((e + 7) / 17)];
859
+ }
860
+ };
861
+ t.NUMERIC = new t(1, [
862
+ 10,
863
+ 12,
864
+ 14
865
+ ]), t.ALPHANUMERIC = new t(2, [
866
+ 9,
867
+ 11,
868
+ 13
869
+ ]), t.BYTE = new t(4, [
870
+ 8,
871
+ 16,
872
+ 16
873
+ ]), t.KANJI = new t(8, [
874
+ 8,
875
+ 10,
876
+ 12
877
+ ]), t.ECI = new t(7, [
878
+ 0,
879
+ 0,
880
+ 0
881
+ ]), e.Mode = t;
882
+ })(e.QrSegment ||= {});
883
+ })(Se ||= {});
884
+ var $ = Se, Ce = {
885
+ L: $.QrCode.Ecc.LOW,
886
+ M: $.QrCode.Ecc.MEDIUM,
887
+ Q: $.QrCode.Ecc.QUARTILE,
888
+ H: $.QrCode.Ecc.HIGH
889
+ }, we = 128, Te = "L", Ee = "#FFFFFF", De = "#000000", Oe = !1, ke = 1, Ae = 4, je = 0, Me = .1;
890
+ function Ne(e, t = 0) {
891
+ let n = [];
892
+ return e.forEach(function(e, r) {
893
+ let i = null;
894
+ e.forEach(function(a, o) {
895
+ if (!a && i !== null) {
896
+ n.push(`M${i + t} ${r + t}h${o - i}v1H${i + t}z`), i = null;
897
+ return;
898
+ }
899
+ if (o === e.length - 1) {
900
+ if (!a) return;
901
+ i === null ? n.push(`M${o + t},${r + t} h1v1H${o + t}z`) : n.push(`M${i + t},${r + t} h${o + 1 - i}v1H${i + t}z`);
902
+ return;
903
+ }
904
+ a && i === null && (i = o);
905
+ });
906
+ }), n.join("");
749
907
  }
750
- function $e(t, s) {
751
- return t.slice().map((r, a) => a < s.y || a >= s.y + s.h ? r : r.map((u, c) => c < s.x || c >= s.x + s.w ? u : !1));
908
+ function Pe(e, t) {
909
+ return e.slice().map((e, n) => n < t.y || n >= t.y + t.h ? e : e.map((e, n) => n < t.x || n >= t.x + t.w ? e : !1));
752
910
  }
753
- function Bt(t, s, r, a) {
754
- if (a == null)
755
- return null;
756
- const u = t.length + r * 2, c = Math.floor(s * Lt), C = u / s, p = (a.width || c) * C, e = (a.height || c) * C, o = a.x == null ? t.length / 2 - p / 2 : a.x * C, n = a.y == null ? t.length / 2 - e / 2 : a.y * C, i = a.opacity == null ? 1 : a.opacity;
757
- let l = null;
758
- if (a.excavate) {
759
- let d = Math.floor(o), E = Math.floor(n), m = Math.ceil(p + o - d), N = Math.ceil(e + n - E);
760
- l = { x: d, y: E, w: m, h: N };
761
- }
762
- const f = a.crossOrigin;
763
- return { x: o, y: n, h: e, w: p, excavation: l, opacity: i, crossOrigin: f };
911
+ function Fe(e, t, n, r) {
912
+ if (r == null) return null;
913
+ let i = e.length + n * 2, a = Math.floor(t * Me), o = i / t, s = (r.width || a) * o, c = (r.height || a) * o, l = r.x == null ? e.length / 2 - s / 2 : r.x * o, u = r.y == null ? e.length / 2 - c / 2 : r.y * o, d = r.opacity == null ? 1 : r.opacity, f = null;
914
+ if (r.excavate) {
915
+ let e = Math.floor(l), t = Math.floor(u);
916
+ f = {
917
+ x: e,
918
+ y: t,
919
+ w: Math.ceil(s + l - e),
920
+ h: Math.ceil(c + u - t)
921
+ };
922
+ }
923
+ let p = r.crossOrigin;
924
+ return {
925
+ x: l,
926
+ y: u,
927
+ h: c,
928
+ w: s,
929
+ excavation: f,
930
+ opacity: d,
931
+ crossOrigin: p
932
+ };
764
933
  }
765
- function kt(t, s) {
766
- return s != null ? Math.max(Math.floor(s), 0) : t ? Tt : Ot;
934
+ function Ie(e, t) {
935
+ return t == null ? e ? Ae : je : Math.max(Math.floor(t), 0);
767
936
  }
768
- function He({
769
- value: t,
770
- level: s,
771
- minVersion: r,
772
- includeMargin: a,
773
- marginSize: u,
774
- imageSettings: c,
775
- size: C,
776
- boostLevel: p
777
- }) {
778
- let e = I.useMemo(() => {
779
- const d = (Array.isArray(t) ? t : [t]).reduce((E, m) => (E.push(...ee.QrSegment.makeSegments(m)), E), []);
780
- return ee.QrCode.encodeSegments(
781
- d,
782
- Dt[s],
783
- r,
784
- void 0,
785
- void 0,
786
- p
787
- );
788
- }, [t, s, r, p]);
789
- const { cells: o, margin: n, numCells: i, calculatedImageSettings: l } = I.useMemo(() => {
790
- let f = e.getModules();
791
- const d = kt(a, u), E = f.length + d * 2, m = Bt(
792
- f,
793
- C,
794
- d,
795
- c
796
- );
797
- return {
798
- cells: f,
799
- margin: d,
800
- numCells: E,
801
- calculatedImageSettings: m
802
- };
803
- }, [e, C, c, a, u]);
804
- return {
805
- qrcode: e,
806
- margin: n,
807
- cells: o,
808
- numCells: i,
809
- calculatedImageSettings: l
810
- };
937
+ function Le({ value: e, level: n, minVersion: r, includeMargin: i, marginSize: a, imageSettings: o, size: s, boostLevel: c }) {
938
+ let l = t.useMemo(() => {
939
+ let t = (Array.isArray(e) ? e : [e]).reduce((e, t) => (e.push(...$.QrSegment.makeSegments(t)), e), []);
940
+ return $.QrCode.encodeSegments(t, Ce[n], r, void 0, void 0, c);
941
+ }, [
942
+ e,
943
+ n,
944
+ r,
945
+ c
946
+ ]), { cells: u, margin: d, numCells: f, calculatedImageSettings: p } = t.useMemo(() => {
947
+ let e = l.getModules(), t = Ie(i, a);
948
+ return {
949
+ cells: e,
950
+ margin: t,
951
+ numCells: e.length + t * 2,
952
+ calculatedImageSettings: Fe(e, s, t, o)
953
+ };
954
+ }, [
955
+ l,
956
+ s,
957
+ o,
958
+ i,
959
+ a
960
+ ]);
961
+ return {
962
+ qrcode: l,
963
+ margin: d,
964
+ cells: u,
965
+ numCells: f,
966
+ calculatedImageSettings: p
967
+ };
811
968
  }
812
- var Ft = (function() {
813
- try {
814
- new Path2D().addPath(new Path2D());
815
- } catch {
816
- return !1;
817
- }
818
- return !0;
819
- })(), Ut = I.forwardRef(
820
- function(s, r) {
821
- const a = s, {
822
- value: u,
823
- size: c = Le,
824
- level: C = Be,
825
- bgColor: p = ke,
826
- fgColor: e = Fe,
827
- includeMargin: o = Ue,
828
- minVersion: n = ze,
829
- boostLevel: i,
830
- marginSize: l,
831
- imageSettings: f
832
- } = a, E = Ce(a, [
833
- "value",
834
- "size",
835
- "level",
836
- "bgColor",
837
- "fgColor",
838
- "includeMargin",
839
- "minVersion",
840
- "boostLevel",
841
- "marginSize",
842
- "imageSettings"
843
- ]), { style: m } = E, N = Ce(E, ["style"]), w = f?.src, g = I.useRef(null), y = I.useRef(null), A = I.useCallback(
844
- ($) => {
845
- g.current = $, typeof r == "function" ? r($) : r && (r.current = $);
846
- },
847
- [r]
848
- ), [L, S] = I.useState(!1), { margin: B, cells: _, numCells: j, calculatedImageSettings: T } = He({
849
- value: u,
850
- level: C,
851
- minVersion: n,
852
- boostLevel: i,
853
- includeMargin: o,
854
- marginSize: l,
855
- imageSettings: f,
856
- size: c
857
- });
858
- I.useEffect(() => {
859
- if (g.current != null) {
860
- const $ = g.current, R = $.getContext("2d");
861
- if (!R)
862
- return;
863
- let x = _;
864
- const P = y.current, G = T != null && P !== null && P.complete && P.naturalHeight !== 0 && P.naturalWidth !== 0;
865
- G && T.excavation != null && (x = $e(
866
- _,
867
- T.excavation
868
- ));
869
- const H = window.devicePixelRatio || 1;
870
- $.height = $.width = c * H;
871
- const X = c / j * H;
872
- R.scale(X, X), R.fillStyle = p, R.fillRect(0, 0, j, j), R.fillStyle = e, Ft ? R.fill(new Path2D(_e(x, B))) : _.forEach(function(te, de) {
873
- te.forEach(function(se, he) {
874
- se && R.fillRect(he + B, de + B, 1, 1);
875
- });
876
- }), T && (R.globalAlpha = T.opacity), G && R.drawImage(
877
- P,
878
- T.x + B,
879
- T.y + B,
880
- T.w,
881
- T.h
882
- );
883
- }
884
- }), I.useEffect(() => {
885
- S(!1);
886
- }, [w]);
887
- const V = ge({ height: c, width: c }, m);
888
- let Q = null;
889
- return w != null && (Q = /* @__PURE__ */ I.createElement(
890
- "img",
891
- {
892
- src: w,
893
- key: w,
894
- style: { display: "none" },
895
- onLoad: () => {
896
- S(!0);
897
- },
898
- ref: y,
899
- crossOrigin: T?.crossOrigin
900
- }
901
- )), /* @__PURE__ */ I.createElement(I.Fragment, null, /* @__PURE__ */ I.createElement(
902
- "canvas",
903
- ge({
904
- style: V,
905
- height: c,
906
- width: c,
907
- ref: A,
908
- role: "img"
909
- }, N)
910
- ), Q);
911
- }
912
- );
913
- Ut.displayName = "QRCodeCanvas";
914
- var Ye = I.forwardRef(
915
- function(s, r) {
916
- const a = s, {
917
- value: u,
918
- size: c = Le,
919
- level: C = Be,
920
- bgColor: p = ke,
921
- fgColor: e = Fe,
922
- includeMargin: o = Ue,
923
- minVersion: n = ze,
924
- boostLevel: i,
925
- title: l,
926
- marginSize: f,
927
- imageSettings: d
928
- } = a, E = Ce(a, [
929
- "value",
930
- "size",
931
- "level",
932
- "bgColor",
933
- "fgColor",
934
- "includeMargin",
935
- "minVersion",
936
- "boostLevel",
937
- "title",
938
- "marginSize",
939
- "imageSettings"
940
- ]), { margin: m, cells: N, numCells: w, calculatedImageSettings: g } = He({
941
- value: u,
942
- level: C,
943
- minVersion: n,
944
- boostLevel: i,
945
- includeMargin: o,
946
- marginSize: f,
947
- imageSettings: d,
948
- size: c
949
- });
950
- let y = N, A = null;
951
- d != null && g != null && (g.excavation != null && (y = $e(
952
- N,
953
- g.excavation
954
- )), A = /* @__PURE__ */ I.createElement(
955
- "image",
956
- {
957
- href: d.src,
958
- height: g.h,
959
- width: g.w,
960
- x: g.x + m,
961
- y: g.y + m,
962
- preserveAspectRatio: "none",
963
- opacity: g.opacity,
964
- crossOrigin: g.crossOrigin
965
- }
966
- ));
967
- const L = _e(y, m);
968
- return /* @__PURE__ */ I.createElement(
969
- "svg",
970
- ge({
971
- height: c,
972
- width: c,
973
- viewBox: `0 0 ${w} ${w}`,
974
- ref: r,
975
- role: "img"
976
- }, E),
977
- !!l && /* @__PURE__ */ I.createElement("title", null, l),
978
- /* @__PURE__ */ I.createElement(
979
- "path",
980
- {
981
- fill: p,
982
- d: `M0,0 h${w}v${w}H0z`,
983
- shapeRendering: "crispEdges"
984
- }
985
- ),
986
- /* @__PURE__ */ I.createElement("path", { fill: e, d: L, shapeRendering: "crispEdges" }),
987
- A
988
- );
989
- }
990
- );
991
- Ye.displayName = "QRCodeSVG";
992
- const zt = (t, s) => ({
993
- invitationType: ft.LINK,
994
- resources: [
995
- {
996
- url: `conversations/${encodeURI(t)}`
997
- },
998
- ...s
999
- ]
1000
- }), _t = (t) => {
1001
- const s = t?.invitationLink?.split("/").at(-1) || "";
1002
- return `/${Ie}/${s}`;
1003
- }, $t = (t, s) => s?.find((r) => {
1004
- const a = t?.id?.split("/")?.pop(), u = r?.url?.split("/")?.pop() || "";
1005
- return u === a || decodeURI(u) === a;
1006
- }), Ht = (t) => t?.messages?.filter(
1007
- (r) => !!r?.custom_content?.attachments
1008
- )?.flatMap((r) => r?.custom_content?.attachments?.map((a) => ({
1009
- url: a?.url || ""
1010
- })) || [])?.filter((r) => !!r?.url) || [], Yt = ({
1011
- conversation: t,
1012
- locale: s,
1013
- onCloseModal: r,
1014
- modalDividers: a,
1015
- getConversation: u,
1016
- generateConversationLink: c,
1017
- chatExpiration: C,
1018
- chatExpirationDays: p,
1019
- close: e,
1020
- chatWarning: o,
1021
- shareLink: n,
1022
- shareCopyLink: i,
1023
- shareCopiedLink: l,
1024
- shareDescription: f,
1025
- shareRemoveAccessToUsers: d,
1026
- chatName: E,
1027
- getSharedConversations: m,
1028
- revokeSharedConversations: N,
1029
- baseUrl: w,
1030
- id: g,
1031
- clientSharedPage: y,
1032
- clientSharedProp: A,
1033
- shareAlertMessage: L
1034
- }) => {
1035
- const [S, B] = O(null), [_, j] = O(), [T, V] = O(!1), [Q, $] = O(!1), [R, x] = O(), P = me(null), G = me(null), H = Z(() => t?.id ? decodeURI(t.id) : g?.[0] && g?.[1] && s ? decodeURI(`${g[0]}/${s}/${g[1]}`) : null, [t?.id, g, s]), X = Z(() => {
1036
- if (!S)
1037
- return "";
1038
- const U = w || window.location.origin;
1039
- if (w && w !== window.location.origin && y && A) {
1040
- const ne = S.split(
1041
- `/${Ie}/`
1042
- )?.[1];
1043
- return `${U}/${y}?${A}=${ne}`;
1044
- }
1045
- return `${U}/${s}${S}`;
1046
- }, [w, S, s, y, A]), te = D(
1047
- async (U) => {
1048
- const ne = await m?.(
1049
- ie(ae.OTHERS)
1050
- );
1051
- if (ne)
1052
- return $t(
1053
- { id: U },
1054
- ne.resources
1055
- );
1056
- },
1057
- [m]
1058
- );
1059
- oe(() => {
1060
- if (!H || P.current === H)
1061
- return;
1062
- P.current = H, V(!1), G.current?.abort();
1063
- const U = new AbortController();
1064
- return G.current = U, (async () => {
1065
- try {
1066
- const fe = await u?.(H), We = zt(
1067
- H,
1068
- Ht(fe)
1069
- ), we = await c?.(We), Ve = await te(H);
1070
- if (U.signal.aborted || !we)
1071
- return;
1072
- B(_t(we)), j(Ve), V(!0);
1073
- } catch (fe) {
1074
- if (U.signal.aborted)
1075
- return;
1076
- V(!1), console.error("Error sharing conversation", fe);
1077
- }
1078
- })(), () => {
1079
- U.abort(), P.current = null;
1080
- };
1081
- }, [
1082
- H,
1083
- c,
1084
- u,
1085
- te
1086
- ]);
1087
- const de = D(() => {
1088
- G.current?.abort(), P.current = null, r(), B(null), V(!1), $(!1);
1089
- }, [r]), se = D(() => {
1090
- $(!0), navigator.clipboard.writeText(X || "");
1091
- }, [X]), he = async () => {
1092
- try {
1093
- if (x(!0), _ && await N?.({
1094
- resources: [_]
1095
- }), H) {
1096
- const U = await te(H);
1097
- G.current?.signal.aborted || j(U);
1098
- }
1099
- } catch (U) {
1100
- console.error("Error revoking shared conversation", U);
1101
- } finally {
1102
- G.current?.signal.aborted || x(!1);
1103
- }
1104
- }, je = D(() => /* @__PURE__ */ h(
1105
- W,
1106
- {
1107
- buttonClassName: Q ? "text-button-secondary" : "text-button-primary",
1108
- iconBefore: Q ? /* @__PURE__ */ h(ot, { width: 20, height: 20 }) : /* @__PURE__ */ h(rt, { width: 20, height: 20 }),
1109
- title: Q ? l ?? "Copied" : i ?? "Copy link",
1110
- disabled: Q,
1111
- onClick: se
1112
- }
1113
- ), [Q, se, l, i]);
1114
- return /* @__PURE__ */ b(
1115
- ce,
1116
- {
1117
- heading: n ?? "Share link",
1118
- portalId: "share",
1119
- size: ue.SM,
1120
- dividers: a,
1121
- onClose: de,
1122
- closeButtonTitle: e ?? "Close",
1123
- children: [
1124
- T ? /* @__PURE__ */ b("div", { className: "share flex flex-col gap-y-4 overflow-auto px-6 pb-6 sm:p-0", children: [
1125
- L ? /* @__PURE__ */ h(
1126
- Je,
1127
- {
1128
- type: qe.Note,
1129
- icon: /* @__PURE__ */ h(st, { width: 16, height: 16 }),
1130
- children: L
1131
- }
1132
- ) : null,
1133
- t?.name ? /* @__PURE__ */ b("div", { className: "share-info flex w-full", children: [
1134
- /* @__PURE__ */ h("p", { className: "share-info-title body-1 mr-1 text-neutrals-800", children: E ?? "Chat name:" }),
1135
- /* @__PURE__ */ h(
1136
- "h3",
1137
- {
1138
- className: "min-w-0 flex-1 truncate",
1139
- title: t?.name,
1140
- children: t?.name
1141
- }
1142
- )
1143
- ] }) : null,
1144
- /* @__PURE__ */ b("div", { className: "share-info flex", children: [
1145
- /* @__PURE__ */ h("p", { className: "share-info-title body-1 mr-1 text-neutrals-800", children: C ?? "Link expiration date:" }),
1146
- /* @__PURE__ */ b("h3", { children: [
1147
- "3 ",
1148
- p ?? "days"
1149
- ] })
1150
- ] }),
1151
- /* @__PURE__ */ h(
1152
- Ye,
1153
- {
1154
- className: "min-h-[200px] self-center rounded border border-neutrals-600 p-2",
1155
- value: X,
1156
- size: 200
1157
- }
1158
- ),
1159
- /* @__PURE__ */ h("p", { className: "body-2 text-neutrals-1000", children: f ?? "Your name, special instructions, and any messages you add after sharing remain confidential." }),
1160
- /* @__PURE__ */ h(
1161
- Me,
1162
- {
1163
- containerClasses: "share-input-container",
1164
- cssClass: "share-input",
1165
- readonly: !0,
1166
- placeholder: X,
1167
- value: X,
1168
- inputId: "conversationLink",
1169
- iconAfterInput: je()
1170
- }
1171
- )
1172
- ] }) : /* @__PURE__ */ h("div", { className: "flex items-center justify-center p-6", children: /* @__PURE__ */ h(be, {}) }),
1173
- T ? t && _ ? /* @__PURE__ */ h("div", { className: "remove-access", children: /* @__PURE__ */ h(
1174
- W,
1175
- {
1176
- title: d ?? "Remove access to all users",
1177
- buttonClassName: "remove-access-button py-3 px-4",
1178
- isSmallButton: !0,
1179
- disabled: R,
1180
- onClick: he
1181
- }
1182
- ) }) : /* @__PURE__ */ h("p", { className: "body-2 share-footer text-neutrals-800", children: o ?? "This chat has not been shared with anyone yet." }) : /* @__PURE__ */ h("div", {})
1183
- ]
1184
- }
1185
- );
1186
- }, Qt = ({
1187
- conversation: t,
1188
- onCloseModal: s,
1189
- renameConversation: r,
1190
- locale: a
1191
- }) => {
1192
- const { titles: u, disableModalDividers: c, isSmallModalButton: C } = K(), [p, e] = O(t?.name || ""), o = (i) => {
1193
- e(i);
1194
- }, n = () => {
1195
- const i = `${t?.folderId}/${encodeURIComponent(ve(p))}-${(/* @__PURE__ */ new Date()).getTime()}`;
1196
- r(
1197
- `conversations/${t.id}`,
1198
- `conversations/${i}`
1199
- );
1200
- };
1201
- return /* @__PURE__ */ b(
1202
- ce,
1203
- {
1204
- heading: u?.renameTitle ?? "Rename conversation",
1205
- portalId: "rename-conversation",
1206
- containerClassName: "rename-conversation-popup",
1207
- size: ue.SM,
1208
- dividers: !c,
1209
- onClose: s,
1210
- closeButtonTitle: u?.close ?? "Cancel",
1211
- children: [
1212
- /* @__PURE__ */ h("div", { className: "px-6 py-4 sm:px-0", lang: a, children: /* @__PURE__ */ h(
1213
- et,
1214
- {
1215
- inputId: "rename",
1216
- value: p,
1217
- onChange: o,
1218
- cssClass: "w-full"
1219
- }
1220
- ) }),
1221
- /* @__PURE__ */ b("div", { className: "delete-conversation-popup-footer flex justify-end gap-x-2 px-6 py-3", children: [
1222
- /* @__PURE__ */ h(
1223
- W,
1224
- {
1225
- buttonClassName: "cancel-button",
1226
- title: u?.cancel ?? "Cancel",
1227
- isSmallButton: C,
1228
- onClick: (i) => {
1229
- i.stopPropagation(), s();
1230
- }
1231
- }
1232
- ),
1233
- /* @__PURE__ */ h(
1234
- W,
1235
- {
1236
- buttonClassName: "text-button-primary text-button-primary",
1237
- title: u?.save ?? "Rename",
1238
- isSmallButton: C,
1239
- disabled: !p,
1240
- onClick: (i) => {
1241
- i.stopPropagation(), n();
1242
- }
1243
- }
1244
- )
1245
- ] })
1246
- ]
1247
- }
1248
- );
1249
- }, Qe = Re(null);
1250
- function Gt({
1251
- children: t,
1252
- value: s
1253
- }) {
1254
- return /* @__PURE__ */ h(Qe.Provider, { value: s, children: t });
969
+ var Re = function() {
970
+ try {
971
+ new Path2D().addPath(new Path2D());
972
+ } catch {
973
+ return !1;
974
+ }
975
+ return !0;
976
+ }(), ze = t.forwardRef(function(e, n) {
977
+ let r = e, { value: i, size: a = we, level: o = Te, bgColor: s = Ee, fgColor: c = De, includeMargin: l = Oe, minVersion: u = ke, boostLevel: d, marginSize: f, imageSettings: p } = r, m = xe(r, [
978
+ "value",
979
+ "size",
980
+ "level",
981
+ "bgColor",
982
+ "fgColor",
983
+ "includeMargin",
984
+ "minVersion",
985
+ "boostLevel",
986
+ "marginSize",
987
+ "imageSettings"
988
+ ]), { style: h } = m, g = xe(m, ["style"]), _ = p?.src, v = t.useRef(null), y = t.useRef(null), b = t.useCallback((e) => {
989
+ v.current = e, typeof n == "function" ? n(e) : n && (n.current = e);
990
+ }, [n]), [x, S] = t.useState(!1), { margin: C, cells: w, numCells: T, calculatedImageSettings: E } = Le({
991
+ value: i,
992
+ level: o,
993
+ minVersion: u,
994
+ boostLevel: d,
995
+ includeMargin: l,
996
+ marginSize: f,
997
+ imageSettings: p,
998
+ size: a
999
+ });
1000
+ t.useEffect(() => {
1001
+ if (v.current != null) {
1002
+ let e = v.current, t = e.getContext("2d");
1003
+ if (!t) return;
1004
+ let n = w, r = y.current, i = E != null && r !== null && r.complete && r.naturalHeight !== 0 && r.naturalWidth !== 0;
1005
+ i && E.excavation != null && (n = Pe(w, E.excavation));
1006
+ let o = window.devicePixelRatio || 1;
1007
+ e.height = e.width = a * o;
1008
+ let l = a / T * o;
1009
+ t.scale(l, l), t.fillStyle = s, t.fillRect(0, 0, T, T), t.fillStyle = c, Re ? t.fill(new Path2D(Ne(n, C))) : w.forEach(function(e, n) {
1010
+ e.forEach(function(e, r) {
1011
+ e && t.fillRect(r + C, n + C, 1, 1);
1012
+ });
1013
+ }), E && (t.globalAlpha = E.opacity), i && t.drawImage(r, E.x + C, E.y + C, E.w, E.h);
1014
+ }
1015
+ }), t.useEffect(() => {
1016
+ S(!1);
1017
+ }, [_]);
1018
+ let D = be({
1019
+ height: a,
1020
+ width: a
1021
+ }, h), O = null;
1022
+ return _ != null && (O = /* @__PURE__ */ t.createElement("img", {
1023
+ src: _,
1024
+ key: _,
1025
+ style: { display: "none" },
1026
+ onLoad: () => {
1027
+ S(!0);
1028
+ },
1029
+ ref: y,
1030
+ crossOrigin: E?.crossOrigin
1031
+ })), /* @__PURE__ */ t.createElement(t.Fragment, null, /* @__PURE__ */ t.createElement("canvas", be({
1032
+ style: D,
1033
+ height: a,
1034
+ width: a,
1035
+ ref: b,
1036
+ role: "img"
1037
+ }, g)), O);
1038
+ });
1039
+ ze.displayName = "QRCodeCanvas";
1040
+ var Be = t.forwardRef(function(e, n) {
1041
+ let r = e, { value: i, size: a = we, level: o = Te, bgColor: s = Ee, fgColor: c = De, includeMargin: l = Oe, minVersion: u = ke, boostLevel: d, title: f, marginSize: p, imageSettings: m } = r, h = xe(r, [
1042
+ "value",
1043
+ "size",
1044
+ "level",
1045
+ "bgColor",
1046
+ "fgColor",
1047
+ "includeMargin",
1048
+ "minVersion",
1049
+ "boostLevel",
1050
+ "title",
1051
+ "marginSize",
1052
+ "imageSettings"
1053
+ ]), { margin: g, cells: _, numCells: v, calculatedImageSettings: y } = Le({
1054
+ value: i,
1055
+ level: o,
1056
+ minVersion: u,
1057
+ boostLevel: d,
1058
+ includeMargin: l,
1059
+ marginSize: p,
1060
+ imageSettings: m,
1061
+ size: a
1062
+ }), b = _, x = null;
1063
+ m != null && y != null && (y.excavation != null && (b = Pe(_, y.excavation)), x = /* @__PURE__ */ t.createElement("image", {
1064
+ href: m.src,
1065
+ height: y.h,
1066
+ width: y.w,
1067
+ x: y.x + g,
1068
+ y: y.y + g,
1069
+ preserveAspectRatio: "none",
1070
+ opacity: y.opacity,
1071
+ crossOrigin: y.crossOrigin
1072
+ }));
1073
+ let S = Ne(b, g);
1074
+ return /* @__PURE__ */ t.createElement("svg", be({
1075
+ height: a,
1076
+ width: a,
1077
+ viewBox: `0 0 ${v} ${v}`,
1078
+ ref: n,
1079
+ role: "img"
1080
+ }, h), !!f && /* @__PURE__ */ t.createElement("title", null, f), /* @__PURE__ */ t.createElement("path", {
1081
+ fill: s,
1082
+ d: `M0,0 h${v}v${v}H0z`,
1083
+ shapeRendering: "crispEdges"
1084
+ }), /* @__PURE__ */ t.createElement("path", {
1085
+ fill: c,
1086
+ d: S,
1087
+ shapeRendering: "crispEdges"
1088
+ }), x);
1089
+ });
1090
+ Be.displayName = "QRCodeSVG";
1091
+ //#endregion
1092
+ //#region libs/share-conversation/src/utils/shared-conversations.ts
1093
+ var Ve = (e, t) => ({
1094
+ invitationType: te.LINK,
1095
+ resources: [{ url: `conversations/${encodeURI(e)}` }, ...t]
1096
+ }), He = (e) => `/${ee}/${e?.invitationLink?.split("/").at(-1) || ""}`, Ue = (e, t) => t?.find((t) => {
1097
+ let n = e?.id?.split("/")?.pop(), r = t?.url?.split("/")?.pop() || "";
1098
+ return r === n || decodeURI(r) === n;
1099
+ }), We = (e) => (e?.messages?.filter((e) => !!e?.custom_content?.attachments))?.flatMap((e) => e?.custom_content?.attachments?.map((e) => ({ url: e?.url || "" })) || [])?.filter((e) => !!e?.url) || [], Ge = ({ conversation: e, locale: t, onCloseModal: n, modalDividers: i, getConversation: l, generateConversationLink: u, chatExpiration: d, chatExpirationDays: p, close: m, chatWarning: h, shareLink: v, shareCopyLink: S, shareCopiedLink: w, shareDescription: D, shareRemoveAccessToUsers: k, chatName: A, getSharedConversations: j, revokeSharedConversations: P, baseUrl: F, id: I, clientSharedPage: L, clientSharedProp: R, shareAlertMessage: te }) => {
1100
+ let [B, V] = c(null), [H, U] = c(), [re, W] = c(!1), [G, ie] = c(!1), [ae, oe] = c(), K = s(null), q = s(null), J = o(() => e?.id ? decodeURI(e.id) : I?.[0] && I?.[1] && t ? decodeURI(`${I[0]}/${t}/${I[1]}`) : null, [
1101
+ e?.id,
1102
+ I,
1103
+ t
1104
+ ]), Y = o(() => {
1105
+ if (!B) return "";
1106
+ let e = F || window.location.origin;
1107
+ return F && F !== window.location.origin && L && R ? `${e}/${L}?${R}=${B.split(`/${ee}/`)?.[1]}` : `${e}/${t}${B}`;
1108
+ }, [
1109
+ F,
1110
+ B,
1111
+ t,
1112
+ L,
1113
+ R
1114
+ ]), X = r(async (e) => {
1115
+ let t = await j?.(ne(z.OTHERS));
1116
+ if (t) return Ue({ id: e }, t.resources);
1117
+ }, [j]);
1118
+ a(() => {
1119
+ if (!J || K.current === J) return;
1120
+ K.current = J, W(!1), q.current?.abort();
1121
+ let e = new AbortController();
1122
+ return q.current = e, (async () => {
1123
+ try {
1124
+ let t = Ve(J, We(await l?.(J))), n = await u?.(t), r = await X(J);
1125
+ if (e.signal.aborted || !n) return;
1126
+ V(He(n)), U(r), W(!0);
1127
+ } catch (t) {
1128
+ if (e.signal.aborted) return;
1129
+ W(!1), console.error("Error sharing conversation", t);
1130
+ }
1131
+ })(), () => {
1132
+ e.abort(), K.current = null;
1133
+ };
1134
+ }, [
1135
+ J,
1136
+ u,
1137
+ l,
1138
+ X
1139
+ ]);
1140
+ let se = r(() => {
1141
+ q.current?.abort(), K.current = null, n(), V(null), W(!1), ie(!1);
1142
+ }, [n]), ce = r(() => {
1143
+ ie(!0), navigator.clipboard.writeText(Y || "");
1144
+ }, [Y]), le = async () => {
1145
+ try {
1146
+ if (oe(!0), H && await P?.({ resources: [H] }), J) {
1147
+ let e = await X(J);
1148
+ q.current?.signal.aborted || U(e);
1149
+ }
1150
+ } catch (e) {
1151
+ console.error("Error revoking shared conversation", e);
1152
+ } finally {
1153
+ q.current?.signal.aborted || oe(!1);
1154
+ }
1155
+ }, ue = r(() => /* @__PURE__ */ M(f, {
1156
+ buttonClassName: G ? "text-button-secondary" : "text-button-primary",
1157
+ iconBefore: M(G ? T : E, {
1158
+ width: 20,
1159
+ height: 20
1160
+ }),
1161
+ title: G ? w ?? "Copied" : S ?? "Copy link",
1162
+ disabled: G,
1163
+ onClick: ce
1164
+ }), [
1165
+ G,
1166
+ ce,
1167
+ w,
1168
+ S
1169
+ ]);
1170
+ return /* @__PURE__ */ N(C, {
1171
+ heading: v ?? "Share link",
1172
+ portalId: "share",
1173
+ size: x.SM,
1174
+ dividers: i,
1175
+ onClose: se,
1176
+ closeButtonTitle: m ?? "Close",
1177
+ children: [re ? /* @__PURE__ */ N("div", {
1178
+ className: "share flex flex-col gap-y-4 overflow-auto px-6 pb-6 sm:p-0",
1179
+ children: [
1180
+ te ? /* @__PURE__ */ M(g, {
1181
+ type: _.Note,
1182
+ icon: /* @__PURE__ */ M(O, {
1183
+ width: 16,
1184
+ height: 16
1185
+ }),
1186
+ children: te
1187
+ }) : null,
1188
+ e?.name ? /* @__PURE__ */ N("div", {
1189
+ className: "share-info flex w-full",
1190
+ children: [/* @__PURE__ */ M("p", {
1191
+ className: "share-info-title body-1 mr-1 text-neutrals-800",
1192
+ children: A ?? "Chat name:"
1193
+ }), /* @__PURE__ */ M("h3", {
1194
+ className: "min-w-0 flex-1 truncate",
1195
+ title: e?.name,
1196
+ children: e?.name
1197
+ })]
1198
+ }) : null,
1199
+ /* @__PURE__ */ N("div", {
1200
+ className: "share-info flex",
1201
+ children: [/* @__PURE__ */ M("p", {
1202
+ className: "share-info-title body-1 mr-1 text-neutrals-800",
1203
+ children: d ?? "Link expiration date:"
1204
+ }), /* @__PURE__ */ N("h3", { children: ["3 ", p ?? "days"] })]
1205
+ }),
1206
+ /* @__PURE__ */ M(Be, {
1207
+ className: "min-h-[200px] self-center rounded border border-neutrals-600 p-2",
1208
+ value: Y,
1209
+ size: 200
1210
+ }),
1211
+ /* @__PURE__ */ M("p", {
1212
+ className: "body-2 text-neutrals-1000",
1213
+ children: D ?? "Your name, special instructions, and any messages you add after sharing remain confidential."
1214
+ }),
1215
+ /* @__PURE__ */ M(y, {
1216
+ containerClasses: "share-input-container",
1217
+ cssClass: "share-input",
1218
+ readonly: !0,
1219
+ placeholder: Y,
1220
+ value: Y,
1221
+ inputId: "conversationLink",
1222
+ iconAfterInput: ue()
1223
+ })
1224
+ ]
1225
+ }) : /* @__PURE__ */ M("div", {
1226
+ className: "flex items-center justify-center p-6",
1227
+ children: /* @__PURE__ */ M(b, {})
1228
+ }), re ? e && H ? /* @__PURE__ */ M("div", {
1229
+ className: "remove-access",
1230
+ children: /* @__PURE__ */ M(f, {
1231
+ title: k ?? "Remove access to all users",
1232
+ buttonClassName: "remove-access-button py-3 px-4",
1233
+ isSmallButton: !0,
1234
+ disabled: ae,
1235
+ onClick: le
1236
+ })
1237
+ }) : /* @__PURE__ */ M("p", {
1238
+ className: "body-2 share-footer text-neutrals-800",
1239
+ children: h ?? "This chat has not been shared with anyone yet."
1240
+ }) : /* @__PURE__ */ M("div", {})]
1241
+ });
1242
+ }, Ke = ({ conversation: e, onCloseModal: t, renameConversation: n, locale: r }) => {
1243
+ let { titles: i, disableModalDividers: a, isSmallModalButton: o } = Y(), [s, l] = c(e?.name || ""), u = (e) => {
1244
+ l(e);
1245
+ }, d = () => {
1246
+ let t = `${e?.folderId}/${encodeURIComponent(L(s))}-${(/* @__PURE__ */ new Date()).getTime()}`;
1247
+ n(`conversations/${e.id}`, `conversations/${t}`);
1248
+ };
1249
+ return /* @__PURE__ */ N(C, {
1250
+ heading: i?.renameTitle ?? "Rename conversation",
1251
+ portalId: "rename-conversation",
1252
+ containerClassName: "rename-conversation-popup",
1253
+ size: x.SM,
1254
+ dividers: !a,
1255
+ onClose: t,
1256
+ closeButtonTitle: i?.close ?? "Cancel",
1257
+ children: [/* @__PURE__ */ M("div", {
1258
+ className: "px-6 py-4 sm:px-0",
1259
+ lang: r,
1260
+ children: /* @__PURE__ */ M(v, {
1261
+ inputId: "rename",
1262
+ value: s,
1263
+ onChange: u,
1264
+ cssClass: "w-full"
1265
+ })
1266
+ }), /* @__PURE__ */ N("div", {
1267
+ className: "delete-conversation-popup-footer flex justify-end gap-x-2 px-6 py-3",
1268
+ children: [/* @__PURE__ */ M(f, {
1269
+ buttonClassName: "cancel-button",
1270
+ title: i?.cancel ?? "Cancel",
1271
+ isSmallButton: o,
1272
+ onClick: (e) => {
1273
+ e.stopPropagation(), t();
1274
+ }
1275
+ }), /* @__PURE__ */ M(f, {
1276
+ buttonClassName: "text-button-primary text-button-primary",
1277
+ title: i?.save ?? "Rename",
1278
+ isSmallButton: o,
1279
+ disabled: !s,
1280
+ onClick: (e) => {
1281
+ e.stopPropagation(), d();
1282
+ }
1283
+ })]
1284
+ })]
1285
+ });
1286
+ }, qe = n(null);
1287
+ function Je({ children: e, value: t }) {
1288
+ return /* @__PURE__ */ M(qe.Provider, {
1289
+ value: t,
1290
+ children: e
1291
+ });
1255
1292
  }
1256
- function jt() {
1257
- const t = Se(Qe);
1258
- if (!t)
1259
- throw new Error(
1260
- "useConversationListActions must be used within ConversationListActionsProvider"
1261
- );
1262
- return t;
1293
+ function Ye() {
1294
+ let e = i(qe);
1295
+ if (!e) throw Error("useConversationListActions must be used within ConversationListActionsProvider");
1296
+ return e;
1263
1297
  }
1264
- const Wt = ({
1265
- conversation: t,
1266
- triggerButton: s,
1267
- isDisabled: r
1268
- }) => {
1269
- const a = K(), {
1270
- locale: u,
1271
- deleteConversation: c,
1272
- renameConversation: C,
1273
- getConversation: p,
1274
- getFileBlob: e,
1275
- shareConversationProps: o
1276
- } = jt(), n = Z(() => {
1277
- const S = [
1278
- {
1279
- key: z.DELETE,
1280
- title: a?.titles?.delete ?? "Delete",
1281
- icon: a.actionsIcons?.[z.DELETE]
1282
- }
1283
- ];
1284
- return t?.model?.id?.endsWith(ht) ? S : [
1285
- ...t.isShared ? [] : [
1286
- {
1287
- key: z.SHARE,
1288
- title: a?.titles?.share ?? "Share",
1289
- icon: a.actionsIcons?.[z.SHARE]
1290
- },
1291
- {
1292
- key: z.RENAME,
1293
- title: a?.titles?.rename ?? "Rename",
1294
- icon: a.actionsIcons?.[z.RENAME]
1295
- }
1296
- ],
1297
- {
1298
- key: z.EXPORT,
1299
- title: a?.titles?.export ?? "Export",
1300
- icon: a.actionsIcons?.[z.EXPORT]
1301
- },
1302
- ...S
1303
- ];
1304
- }, [
1305
- t.isShared,
1306
- t?.model?.id,
1307
- a.titles,
1308
- a.actionsIcons
1309
- ]), [i, l] = O(Y.Closed), [f, d] = O(Y.Closed), [E, m] = O(Y.Closed), N = D(() => {
1310
- l(Y.Closed);
1311
- }, [l]), w = D(() => {
1312
- d(Y.Closed);
1313
- }, [d]), g = D(() => {
1314
- m(Y.Closed);
1315
- }, [m]), y = D(() => {
1316
- c(t), N();
1317
- }, [t, c, N]), A = D(
1318
- (S, B) => {
1319
- C(S, B), g();
1320
- },
1321
- [C, g]
1322
- );
1323
- return /* @__PURE__ */ b(Ee, { children: [
1324
- /* @__PURE__ */ h(
1325
- Ae,
1326
- {
1327
- containerClassName: "ml-3 hidden group-hover:flex",
1328
- triggerButton: s ?? /* @__PURE__ */ h(Vt, { disabled: r }),
1329
- options: n,
1330
- openedClassName: "!flex action-menu-opened",
1331
- onOptionSelect: (S) => {
1332
- S === z.DELETE && l(Y.Opened), S === z.SHARE && d(Y.Opened), S === z.RENAME && m(Y.Opened), S === z.EXPORT && p(decodeURI(t.id)).then((B) => {
1333
- Mt(B, e).then((_) => {
1334
- xt(
1335
- `data:application/zip;base64,${_}`,
1336
- `chat_with_attachments_${(/* @__PURE__ */ new Date()).toLocaleDateString()}.dial`
1337
- );
1338
- });
1339
- });
1340
- },
1341
- disabled: r
1342
- }
1343
- ),
1344
- i === Y.Opened && /* @__PURE__ */ h(
1345
- wt,
1346
- {
1347
- locale: u,
1348
- deleteConversation: y,
1349
- onCloseModal: N
1350
- }
1351
- ),
1352
- f === Y.Opened && /* @__PURE__ */ h(
1353
- Yt,
1354
- {
1355
- conversation: t,
1356
- locale: u,
1357
- onCloseModal: w,
1358
- ...o
1359
- }
1360
- ),
1361
- E === Y.Opened && /* @__PURE__ */ h(
1362
- Qt,
1363
- {
1364
- conversation: t,
1365
- locale: u,
1366
- renameConversation: A,
1367
- onCloseModal: g
1368
- }
1369
- )
1370
- ] });
1371
- }, Vt = ({ disabled: t }) => /* @__PURE__ */ h(
1372
- "div",
1373
- {
1374
- className: k(
1375
- "flex items-center justify-center w-[24px]",
1376
- t ? "cursor-not-allowed" : "cursor-pointer"
1377
- ),
1378
- children: /* @__PURE__ */ h(
1379
- it,
1380
- {
1381
- width: 20,
1382
- height: 20,
1383
- stroke: 2,
1384
- className: "text-primary"
1385
- }
1386
- )
1387
- }
1388
- ), Ge = ({
1389
- conversation: t,
1390
- selectedConversationId: s,
1391
- searchQuery: r,
1392
- onConversationClick: a,
1393
- isDisabled: u
1394
- }) => {
1395
- const { titles: c, conversationItemIcon: C } = K(), p = me(null), e = ve(t?.name);
1396
- return oe(() => {
1397
- if (t?.id === s && p?.current) {
1398
- const o = p.current.parentElement?.parentElement?.parentElement;
1399
- if (o) {
1400
- const n = p.current.getBoundingClientRect(), i = o.getBoundingClientRect(), l = n.height, f = i.height, E = n.top - i.top + o.scrollTop - (f / 2 - l / 2);
1401
- o.scrollTo({
1402
- top: E,
1403
- behavior: "smooth"
1404
- });
1405
- }
1406
- }
1407
- }, [t, s]), /* @__PURE__ */ b(
1408
- "div",
1409
- {
1410
- ref: p,
1411
- className: k(
1412
- "flex justify-between items-center py-2 px-3 border-transparent relative group border",
1413
- "conversation-item",
1414
- s === t?.id && "bg-hues-100 conversation-item-active",
1415
- u ? "cursor-not-allowed" : "cursor-pointer hover:border-hues-600"
1416
- ),
1417
- onClick: () => !u && a(t.folderId, t?.id),
1418
- title: u ? c?.noActionsAllowed : e,
1419
- children: [
1420
- /* @__PURE__ */ b("div", { className: "flex min-w-0 flex-1 items-center", children: [
1421
- C || null,
1422
- /* @__PURE__ */ h(
1423
- "h3",
1424
- {
1425
- className: k(
1426
- "truncate font-semibold text-neutrals-1000 sm:body-2",
1427
- "conversation-item-text",
1428
- s === t?.id ? "conversation-item-text-active" : ""
1429
- ),
1430
- title: u ? c?.noActionsAllowed : e,
1431
- children: r?.length ? /* @__PURE__ */ h(
1432
- tt,
1433
- {
1434
- text: e,
1435
- highlightText: r
1436
- }
1437
- ) : e
1438
- }
1439
- )
1440
- ] }),
1441
- /* @__PURE__ */ h(Wt, { conversation: t, isDisabled: u })
1442
- ]
1443
- }
1444
- );
1445
- }, Xt = ({
1446
- handleConversationClick: t,
1447
- selectedConversationId: s,
1448
- groupLabel: r,
1449
- groupedConversations: a,
1450
- isDisabled: u
1451
- }) => {
1452
- const { titles: c } = K(), [C, p] = O(!1), e = D(() => {
1453
- p((o) => !o);
1454
- }, [p]);
1455
- return /* @__PURE__ */ b("div", { children: [
1456
- /* @__PURE__ */ b(
1457
- "div",
1458
- {
1459
- className: "conversation-group-items-title mb-3 inline-flex cursor-pointer items-center gap-1 text-neutrals-700",
1460
- onClick: e,
1461
- children: [
1462
- /* @__PURE__ */ h(
1463
- at,
1464
- {
1465
- className: k(
1466
- "w-3 h-3 conversation-group-items-arrow",
1467
- C ? "rotate-[90deg]" : "rotate-0"
1468
- )
1469
- }
1470
- ),
1471
- /* @__PURE__ */ h("span", { className: "body-3 conversation-group-items-title-text", children: vt(r, c) })
1472
- ]
1473
- }
1474
- ),
1475
- !C && /* @__PURE__ */ h(
1476
- "div",
1477
- {
1478
- className: k(
1479
- "flex flex-col gap-y-3",
1480
- "conversation-group-items"
1481
- ),
1482
- children: Pe(a).map(
1483
- (o) => /* @__PURE__ */ h(
1484
- Ge,
1485
- {
1486
- isDisabled: u,
1487
- conversation: o,
1488
- selectedConversationId: s,
1489
- onConversationClick: t
1490
- },
1491
- o.id || o.name
1492
- )
1493
- )
1494
- }
1495
- )
1496
- ] }, r);
1497
- }, Kt = ({
1498
- searchQuery: t,
1499
- isExpandedSearch: s,
1500
- onSearchConversations: r,
1501
- toggleSearchField: a
1502
- }) => {
1503
- const { titles: u, searchIcon: c } = K();
1504
- return /* @__PURE__ */ h(Ee, { children: s ? /* @__PURE__ */ h(
1505
- Me,
1506
- {
1507
- inputId: "conversations-search",
1508
- placeholder: u?.searchPlaceholder ?? "Search",
1509
- containerClasses: "conversation-list-search-input h-[40px] bg-transparent px-4 py-2 rounded-full border-neutrals-400 shadow-none",
1510
- cssClass: "h-auto",
1511
- value: t,
1512
- iconAfterInput: /* @__PURE__ */ h(
1513
- nt,
1514
- {
1515
- buttonClassName: "text-button-tertiary items-center p-0 ml-4 border-0 w-5 h-5",
1516
- onClick: a,
1517
- icon: /* @__PURE__ */ h(lt, {})
1518
- }
1519
- ),
1520
- onChange: r
1521
- }
1522
- ) : /* @__PURE__ */ h(
1523
- W,
1524
- {
1525
- buttonClassName: "text-button-tertiary p-0 search-button",
1526
- iconBefore: c || /* @__PURE__ */ h(ct, { className: "size-5" }),
1527
- onClick: a
1528
- }
1529
- ) });
1530
- }, Zt = ({
1531
- conversations: t,
1532
- selectedConversationId: s,
1533
- searchQuery: r,
1534
- handleConversationClick: a,
1535
- isDisabled: u
1536
- }) => {
1537
- const { titles: c } = K(), [C, p] = O([]);
1538
- return oe(() => {
1539
- p(
1540
- Pe(
1541
- t?.filter(
1542
- (e) => ve(e?.name)?.includes(
1543
- r || ""
1544
- )
1545
- )
1546
- )
1547
- );
1548
- }, [t, r]), /* @__PURE__ */ h(Ee, { children: C?.length ? C.map((e) => /* @__PURE__ */ h(
1549
- Ge,
1550
- {
1551
- conversation: e,
1552
- searchQuery: r,
1553
- selectedConversationId: s,
1554
- onConversationClick: a,
1555
- isDisabled: u
1556
- },
1557
- e.id
1558
- )) : /* @__PURE__ */ h("h3", { className: "text-neutrals-800", children: c?.noConversation ?? "No conversations yet" }) });
1559
- }, Jt = () => {
1560
- const { titles: t } = K();
1561
- return /* @__PURE__ */ b("div", { className: "flex flex-col p-8 text-center", children: [
1562
- /* @__PURE__ */ h("p", { className: "text-neutrals-800", children: t?.noConversation ?? "No conversations yet" }),
1563
- /* @__PURE__ */ h("p", { className: "mt-2 text-sm text-neutrals-800", children: t?.clickNewChat ?? 'Click "New Chat" to start a conversation' })
1564
- ] });
1565
- }, hn = ({
1566
- handleConversationClick: t,
1567
- selectedConversationId: s,
1568
- actions: r,
1569
- children: a,
1570
- isCollapsed: u,
1571
- isStreaming: c,
1572
- conversationStyles: C,
1573
- conversations: p,
1574
- locale: e,
1575
- sharedConversations: o,
1576
- setConversations: n,
1577
- setSharedConversations: i,
1578
- shareConversationProps: l,
1579
- handleSelectedConversationRemove: f
1580
- }) => {
1581
- const [d, E] = O({}), [m, N] = O(!0), [w, g] = O(""), [y, A] = O(!1), {
1582
- getConversations: L,
1583
- getSharedConversations: S,
1584
- deleteConversation: B,
1585
- renameConversation: _
1586
- } = r, j = Z(() => !!w?.length, [w]);
1587
- oe(() => {
1588
- E({
1589
- ...pt(o),
1590
- ...Et(p)
1591
- });
1592
- }, [p, o]), oe(() => {
1593
- async function R() {
1594
- try {
1595
- N(!0);
1596
- const x = await L(e), P = await S(
1597
- ie(ae.ME)
1598
- );
1599
- n(q(x)), i(
1600
- q(
1601
- pe(P, e)
1602
- )
1603
- );
1604
- } catch (x) {
1605
- console.error("Error loading conversation", x);
1606
- } finally {
1607
- N(!1);
1608
- }
1609
- }
1610
- R();
1611
- }, [
1612
- L,
1613
- n,
1614
- e,
1615
- S,
1616
- i
1617
- ]);
1618
- const T = D(
1619
- async (R) => {
1620
- try {
1621
- await B(R);
1622
- const x = await L(e), P = await S(
1623
- ie(ae.ME)
1624
- );
1625
- n(q(x)), i(
1626
- q(
1627
- pe(P, e)
1628
- )
1629
- ), s === R?.id && f();
1630
- } catch (x) {
1631
- console.error("Error deleting conversation", x);
1632
- }
1633
- },
1634
- [
1635
- B,
1636
- L,
1637
- e,
1638
- S,
1639
- n,
1640
- i,
1641
- s,
1642
- f
1643
- ]
1644
- ), V = D(
1645
- async (R, x) => {
1646
- try {
1647
- N(!0), await _(R, x);
1648
- const P = await L(e), G = await S(
1649
- ie(ae.ME)
1650
- );
1651
- n(q(P)), i(
1652
- q(
1653
- pe(G, e)
1654
- )
1655
- );
1656
- } catch (P) {
1657
- console.error("Error renaming conversation", P);
1658
- } finally {
1659
- N(!1);
1660
- }
1661
- },
1662
- [
1663
- L,
1664
- e,
1665
- S,
1666
- n,
1667
- i,
1668
- _
1669
- ]
1670
- ), Q = D(
1671
- (R) => {
1672
- g(R);
1673
- },
1674
- [g]
1675
- ), $ = D(() => {
1676
- A((R) => !R), g("");
1677
- }, [A]);
1678
- return m ? /* @__PURE__ */ h(be, {}) : /* @__PURE__ */ h(
1679
- Gt,
1680
- {
1681
- value: {
1682
- locale: e,
1683
- deleteConversation: T,
1684
- renameConversation: V,
1685
- getConversation: r.getConversation,
1686
- getFileBlob: r.getFileBlob,
1687
- shareConversationProps: l
1688
- },
1689
- children: /* @__PURE__ */ b(De.Provider, { value: C, children: [
1690
- !u && /* @__PURE__ */ b(
1691
- "div",
1692
- {
1693
- className: k(
1694
- "flex justify-between items-center pr-6",
1695
- y ? " pt-4 pb-0 sm:pt-10" : " pt-6 pb-2 sm:pt-10"
1696
- ),
1697
- children: [
1698
- !y && /* @__PURE__ */ h("h3", { className: "sm:body-2 text-neutrals-700", children: C?.titles?.allChats ?? "All Chats" }),
1699
- /* @__PURE__ */ h(
1700
- Kt,
1701
- {
1702
- searchQuery: w,
1703
- isExpandedSearch: y,
1704
- onSearchConversations: Q,
1705
- toggleSearchField: $
1706
- }
1707
- )
1708
- ]
1709
- }
1710
- ),
1711
- /* @__PURE__ */ h("div", { className: "scroll-hidden-container flex flex-col mt-4 flex-1 min-h-0", children: u ? null : /* @__PURE__ */ h(
1712
- "div",
1713
- {
1714
- className: k(
1715
- "flex flex-col pr-4",
1716
- j ? "gap-y-1" : "gap-y-6"
1717
- ),
1718
- children: p?.length === 0 && o?.length === 0 ? /* @__PURE__ */ h(Jt, {}) : j ? /* @__PURE__ */ h(
1719
- Zt,
1720
- {
1721
- conversations: [...o, ...p],
1722
- searchQuery: w,
1723
- selectedConversationId: s,
1724
- handleConversationClick: t,
1725
- isDisabled: c
1726
- }
1727
- ) : Object.entries(d).map(
1728
- ([R, x]) => x?.length > 0 && /* @__PURE__ */ h(
1729
- Xt,
1730
- {
1731
- isDisabled: c,
1732
- groupLabel: R,
1733
- groupedConversations: x,
1734
- handleConversationClick: t,
1735
- selectedConversationId: s
1736
- },
1737
- R
1738
- )
1739
- )
1740
- }
1741
- ) }),
1742
- a
1743
- ] })
1744
- }
1745
- );
1746
- }, qt = ({
1747
- onCloseModal: t,
1748
- disableModalDividers: s,
1749
- signOut: r,
1750
- isSmallButton: a,
1751
- locale: u,
1752
- titles: c
1753
- }) => /* @__PURE__ */ b(
1754
- ce,
1755
- {
1756
- heading: c?.popupTitle || "Log out?",
1757
- portalId: "sign-out",
1758
- containerClassName: "sign-out-popup",
1759
- size: ue.SM,
1760
- dividers: !s,
1761
- onClose: t,
1762
- closeButtonTitle: "Cancel",
1763
- children: [
1764
- /* @__PURE__ */ h("div", { className: "px-6 py-4 sm:px-0", lang: u, children: c?.popupText }),
1765
- /* @__PURE__ */ b("div", { className: "delete-conversation-popup-footer flex justify-end gap-x-2 px-6 py-3", children: [
1766
- /* @__PURE__ */ h(
1767
- W,
1768
- {
1769
- buttonClassName: "cancel-button",
1770
- title: c?.popupCancel || "Cancel",
1771
- isSmallButton: a,
1772
- onClick: (C) => {
1773
- C.stopPropagation(), t();
1774
- }
1775
- }
1776
- ),
1777
- /* @__PURE__ */ h(
1778
- W,
1779
- {
1780
- buttonClassName: "text-button-primary",
1781
- title: c?.popupApply || "Sign Out",
1782
- isSmallButton: a,
1783
- onClick: (C) => {
1784
- C.stopPropagation(), r?.();
1785
- }
1786
- }
1787
- )
1788
- ] })
1789
- ]
1790
- }
1791
- ), fn = ({
1792
- userInfo: t,
1793
- signOutAction: s,
1794
- contactSupportUrl: r,
1795
- styles: a,
1796
- locale: u,
1797
- titles: c
1798
- }) => {
1799
- const C = (N) => N?.split(" ")?.map((w, g) => g < 2 ? w[0].toUpperCase() : "")?.join("") ?? "", p = Z(
1800
- () => t?.name ? C(t?.name) : t?.email?.[0].toUpperCase() ?? "",
1801
- [t]
1802
- ), [e, o] = O(!1), n = t?.name?.split(" "), i = n ? `${n?.[0] ?? ""} ${n?.[1]?.[0] ? n?.[1]?.[0] + "." : ""}` : t?.email ?? "", l = D(() => {
1803
- o(!0);
1804
- }, []), f = D(() => {
1805
- o(!1);
1806
- }, []), d = D(() => {
1807
- window.open(r || "#", "_blank", "noopener,noreferrer");
1808
- }, [r]), E = Z(() => /* @__PURE__ */ b("div", { className: "flex items-center gap-2", children: [
1809
- /* @__PURE__ */ h(
1810
- "div",
1811
- {
1812
- className: k(
1813
- "cursor-pointer flex items-center justify-center size-11 rounded-[100px] p-[10px] sm:h-[32px] sm:w-[32px] flex-shrink-0",
1814
- a?.initialStyles
1815
- ),
1816
- children: p
1817
- }
1818
- ),
1819
- /* @__PURE__ */ h(
1820
- "p",
1821
- {
1822
- className: k(
1823
- "h3 cursor-pointer overflow-hidden text-ellipsis",
1824
- a?.userNameStyles
1825
- ),
1826
- children: (a?.showShortName ? i : t?.name) ?? t?.email ?? ""
1827
- }
1828
- )
1829
- ] }), [p, i, a, t]), m = Z(() => /* @__PURE__ */ b("div", { className: k("py-1", a?.dropDownStyles), children: [
1830
- a?.settingsIcon && /* @__PURE__ */ b(
1831
- "button",
1832
- {
1833
- className: k(
1834
- "p-2 items-center flex gap-1 text-primary fill-primary",
1835
- a?.dropdownButtonTypographyStyles || "body-1",
1836
- a?.dropdownButtonStyles
1837
- ),
1838
- title: c?.settings,
1839
- children: [
1840
- /* @__PURE__ */ h("span", { className: "shrink-0", children: a?.settingsIcon }),
1841
- /* @__PURE__ */ h("span", { className: "min-w-0 break-words", children: c?.settings || "Settings" })
1842
- ]
1843
- }
1844
- ),
1845
- a?.contactSupportIcon && /* @__PURE__ */ b(
1846
- "button",
1847
- {
1848
- className: k(
1849
- "p-2 items-center flex gap-1 text-primary fill-primary",
1850
- a?.dropdownButtonTypographyStyles || "body-1",
1851
- a?.dropdownButtonStyles
1852
- ),
1853
- title: c?.contactSupport,
1854
- onClick: d,
1855
- children: [
1856
- /* @__PURE__ */ h("span", { className: "shrink-0", children: a?.contactSupportIcon }),
1857
- /* @__PURE__ */ h("span", { className: "min-w-0 break-words", children: c?.contactSupport || "Contact support" })
1858
- ]
1859
- }
1860
- ),
1861
- /* @__PURE__ */ h(
1862
- "div",
1863
- {
1864
- className: k(
1865
- "h-0 border-t border-neutrals-600 my-2",
1866
- a?.showSeparator ? "block" : "hidden"
1867
- )
1868
- }
1869
- ),
1870
- /* @__PURE__ */ b(
1871
- "button",
1872
- {
1873
- className: k(
1874
- "p-2 items-center flex gap-1 text-primary fill-primary",
1875
- a?.dropdownButtonTypographyStyles || "body-1",
1876
- a?.dropdownButtonStyles
1877
- ),
1878
- title: c?.signOut,
1879
- onClick: l,
1880
- children: [
1881
- /* @__PURE__ */ h("span", { className: "shrink-0", children: a?.signOutIcon }),
1882
- /* @__PURE__ */ h("span", { className: "min-w-0 break-words", children: c?.signOut || "Sign out" }),
1883
- e && /* @__PURE__ */ h(
1884
- qt,
1885
- {
1886
- onCloseModal: f,
1887
- signOut: () => s?.(),
1888
- locale: u,
1889
- disableModalDividers: a?.disableModalDividers,
1890
- titles: c
1891
- }
1892
- )
1893
- ]
1894
- }
1895
- )
1896
- ] }), [
1897
- a,
1898
- c,
1899
- l,
1900
- d,
1901
- e,
1902
- f,
1903
- u,
1904
- s
1905
- ]);
1906
- if (t)
1907
- return /* @__PURE__ */ h(
1908
- Ae,
1909
- {
1910
- containerClassName: k(
1911
- "transition-opacity group-hover:opacity-100 shrink w-full",
1912
- a?.dropdownContainerClassName
1913
- ),
1914
- triggerButton: E,
1915
- content: m,
1916
- openedClassName: "action-menu-opened"
1917
- }
1918
- );
1919
- };
1920
- export {
1921
- Wt as ActionMenu,
1922
- z as ActionMenuItem,
1923
- hn as ConversationList,
1924
- fn as User,
1925
- pt as getSharedConversationsGroup,
1926
- pe as transformSharedConversations
1298
+ //#endregion
1299
+ //#region libs/conversation-list/src/components/ActionMenu/ActionMenu.tsx
1300
+ var Xe = ({ conversation: e, triggerButton: t, isDisabled: n }) => {
1301
+ let i = Y(), { locale: a, deleteConversation: s, renameConversation: l, getConversation: u, getFileBlob: d, shareConversationProps: f } = Ye(), m = o(() => {
1302
+ let t = [{
1303
+ key: B.DELETE,
1304
+ title: i?.titles?.delete ?? "Delete",
1305
+ icon: i.actionsIcons?.[B.DELETE]
1306
+ }];
1307
+ return e?.model?.id?.endsWith(F) ? t : [
1308
+ ...e.isShared ? [] : [{
1309
+ key: B.SHARE,
1310
+ title: i?.titles?.share ?? "Share",
1311
+ icon: i.actionsIcons?.[B.SHARE]
1312
+ }, {
1313
+ key: B.RENAME,
1314
+ title: i?.titles?.rename ?? "Rename",
1315
+ icon: i.actionsIcons?.[B.RENAME]
1316
+ }],
1317
+ {
1318
+ key: B.EXPORT,
1319
+ title: i?.titles?.export ?? "Export",
1320
+ icon: i.actionsIcons?.[B.EXPORT]
1321
+ },
1322
+ ...t
1323
+ ];
1324
+ }, [
1325
+ e.isShared,
1326
+ e?.model?.id,
1327
+ i.titles,
1328
+ i.actionsIcons
1329
+ ]), [h, g] = c(S.Closed), [_, v] = c(S.Closed), [y, b] = c(S.Closed), x = r(() => {
1330
+ g(S.Closed);
1331
+ }, [g]), C = r(() => {
1332
+ v(S.Closed);
1333
+ }, [v]), w = r(() => {
1334
+ b(S.Closed);
1335
+ }, [b]), T = r(() => {
1336
+ s(e), x();
1337
+ }, [
1338
+ e,
1339
+ s,
1340
+ x
1341
+ ]), E = r((e, t) => {
1342
+ l(e, t), w();
1343
+ }, [l, w]);
1344
+ return /* @__PURE__ */ N(j, { children: [
1345
+ /* @__PURE__ */ M(p, {
1346
+ containerClassName: "ml-3 hidden group-hover:flex",
1347
+ triggerButton: t ?? /* @__PURE__ */ M(Ze, { disabled: n }),
1348
+ options: m,
1349
+ openedClassName: "!flex action-menu-opened",
1350
+ onOptionSelect: (t) => {
1351
+ t === B.DELETE && g(S.Opened), t === B.SHARE && v(S.Opened), t === B.RENAME && b(S.Opened), t === B.EXPORT && u(decodeURI(e.id)).then((e) => {
1352
+ fe(e, d).then((e) => {
1353
+ he(`data:application/zip;base64,${e}`, `chat_with_attachments_${(/* @__PURE__ */ new Date()).toLocaleDateString()}.dial`);
1354
+ });
1355
+ });
1356
+ },
1357
+ disabled: n
1358
+ }),
1359
+ h === S.Opened && /* @__PURE__ */ M(X, {
1360
+ locale: a,
1361
+ deleteConversation: T,
1362
+ onCloseModal: x
1363
+ }),
1364
+ _ === S.Opened && /* @__PURE__ */ M(Ge, {
1365
+ conversation: e,
1366
+ locale: a,
1367
+ onCloseModal: C,
1368
+ ...f
1369
+ }),
1370
+ y === S.Opened && /* @__PURE__ */ M(Ke, {
1371
+ conversation: e,
1372
+ locale: a,
1373
+ renameConversation: E,
1374
+ onCloseModal: w
1375
+ })
1376
+ ] });
1377
+ }, Ze = ({ disabled: t }) => /* @__PURE__ */ M("div", {
1378
+ className: e("flex items-center justify-center w-[24px]", t ? "cursor-not-allowed" : "cursor-pointer"),
1379
+ children: /* @__PURE__ */ M(D, {
1380
+ width: 20,
1381
+ height: 20,
1382
+ stroke: 2,
1383
+ className: "text-primary"
1384
+ })
1385
+ }), Qe = ({ conversation: t, selectedConversationId: n, searchQuery: r, onConversationClick: i, isDisabled: o }) => {
1386
+ let { titles: c, conversationItemIcon: l } = Y(), u = s(null), d = L(t?.name);
1387
+ return a(() => {
1388
+ if (t?.id === n && u?.current) {
1389
+ let e = u.current.parentElement?.parentElement?.parentElement;
1390
+ if (e) {
1391
+ let t = u.current.getBoundingClientRect(), n = e.getBoundingClientRect(), r = t.height, i = n.height, a = t.top - n.top + e.scrollTop - (i / 2 - r / 2);
1392
+ e.scrollTo({
1393
+ top: a,
1394
+ behavior: "smooth"
1395
+ });
1396
+ }
1397
+ }
1398
+ }, [t, n]), /* @__PURE__ */ N("div", {
1399
+ ref: u,
1400
+ className: e("flex justify-between items-center py-2 px-3 border-transparent relative group border", "conversation-item", n === t?.id && "bg-hues-100 conversation-item-active", o ? "cursor-not-allowed" : "cursor-pointer hover:border-hues-600"),
1401
+ onClick: () => !o && i(t.folderId, t?.id),
1402
+ title: o ? c?.noActionsAllowed : d,
1403
+ children: [/* @__PURE__ */ N("div", {
1404
+ className: "flex min-w-0 flex-1 items-center",
1405
+ children: [l || null, /* @__PURE__ */ M("h3", {
1406
+ className: e("truncate font-semibold text-neutrals-1000 sm:body-2", "conversation-item-text", n === t?.id ? "conversation-item-text-active" : ""),
1407
+ title: o ? c?.noActionsAllowed : d,
1408
+ children: r?.length ? /* @__PURE__ */ M(m, {
1409
+ text: d,
1410
+ highlightText: r
1411
+ }) : d
1412
+ })]
1413
+ }), /* @__PURE__ */ M(Xe, {
1414
+ conversation: t,
1415
+ isDisabled: o
1416
+ })]
1417
+ });
1418
+ }, $e = ({ handleConversationClick: t, selectedConversationId: n, groupLabel: i, groupedConversations: a, isDisabled: o }) => {
1419
+ let { titles: s } = Y(), [l, u] = c(!1);
1420
+ return /* @__PURE__ */ N("div", { children: [/* @__PURE__ */ N("div", {
1421
+ className: "conversation-group-items-title mb-3 inline-flex cursor-pointer items-center gap-1 text-neutrals-700",
1422
+ onClick: r(() => {
1423
+ u((e) => !e);
1424
+ }, [u]),
1425
+ children: [/* @__PURE__ */ M(w, { className: e("w-3 h-3 conversation-group-items-arrow", l ? "rotate-[90deg]" : "rotate-0") }), /* @__PURE__ */ M("span", {
1426
+ className: "body-3 conversation-group-items-title-text",
1427
+ children: q(i, s)
1428
+ })]
1429
+ }), !l && /* @__PURE__ */ M("div", {
1430
+ className: e("flex flex-col gap-y-3", "conversation-group-items"),
1431
+ children: K(a).map((e) => /* @__PURE__ */ M(Qe, {
1432
+ isDisabled: o,
1433
+ conversation: e,
1434
+ selectedConversationId: n,
1435
+ onConversationClick: t
1436
+ }, e.id || e.name))
1437
+ })] }, i);
1438
+ }, et = ({ searchQuery: e, isExpandedSearch: t, onSearchConversations: n, toggleSearchField: r }) => {
1439
+ let { titles: i, searchIcon: a } = Y();
1440
+ return /* @__PURE__ */ M(j, { children: t ? /* @__PURE__ */ M(y, {
1441
+ inputId: "conversations-search",
1442
+ placeholder: i?.searchPlaceholder ?? "Search",
1443
+ containerClasses: "conversation-list-search-input h-[40px] bg-transparent px-4 py-2 rounded-full border-neutrals-400 shadow-none",
1444
+ cssClass: "h-auto",
1445
+ value: e,
1446
+ iconAfterInput: /* @__PURE__ */ M(h, {
1447
+ buttonClassName: "text-button-tertiary items-center p-0 ml-4 border-0 w-5 h-5",
1448
+ onClick: r,
1449
+ icon: /* @__PURE__ */ M(A, {})
1450
+ }),
1451
+ onChange: n
1452
+ }) : /* @__PURE__ */ M(f, {
1453
+ buttonClassName: "text-button-tertiary p-0 search-button",
1454
+ iconBefore: a || /* @__PURE__ */ M(k, { className: "size-5" }),
1455
+ onClick: r
1456
+ }) });
1457
+ }, tt = ({ conversations: e, selectedConversationId: t, searchQuery: n, handleConversationClick: r, isDisabled: i }) => {
1458
+ let { titles: o } = Y(), [s, l] = c([]);
1459
+ return a(() => {
1460
+ l(K(e?.filter((e) => L(e?.name)?.includes(n || ""))));
1461
+ }, [e, n]), /* @__PURE__ */ M(j, { children: s?.length ? s.map((e) => /* @__PURE__ */ M(Qe, {
1462
+ conversation: e,
1463
+ searchQuery: n,
1464
+ selectedConversationId: t,
1465
+ onConversationClick: r,
1466
+ isDisabled: i
1467
+ }, e.id)) : /* @__PURE__ */ M("h3", {
1468
+ className: "text-neutrals-800",
1469
+ children: o?.noConversation ?? "No conversations yet"
1470
+ }) });
1471
+ }, nt = () => {
1472
+ let { titles: e } = Y();
1473
+ return /* @__PURE__ */ N("div", {
1474
+ className: "flex flex-col p-8 text-center",
1475
+ children: [/* @__PURE__ */ M("p", {
1476
+ className: "text-neutrals-800",
1477
+ children: e?.noConversation ?? "No conversations yet"
1478
+ }), /* @__PURE__ */ M("p", {
1479
+ className: "mt-2 text-sm text-neutrals-800",
1480
+ children: e?.clickNewChat ?? "Click \"New Chat\" to start a conversation"
1481
+ })]
1482
+ });
1483
+ }, rt = ({ handleConversationClick: t, selectedConversationId: n, actions: i, children: s, isCollapsed: l, isStreaming: u, conversationStyles: d, conversations: f, locale: p, sharedConversations: m, setConversations: h, setSharedConversations: g, shareConversationProps: _, handleSelectedConversationRemove: v }) => {
1484
+ let [y, x] = c({}), [S, C] = c(!0), [w, T] = c(""), [E, D] = c(!1), { getConversations: O, getSharedConversations: k, deleteConversation: A, renameConversation: j } = i, P = o(() => !!w?.length, [w]);
1485
+ a(() => {
1486
+ x({
1487
+ ...U(m),
1488
+ ...oe(f)
1489
+ });
1490
+ }, [f, m]), a(() => {
1491
+ async function e() {
1492
+ try {
1493
+ C(!0);
1494
+ let e = await O(p), t = await k(ne(z.ME));
1495
+ h(I(e)), g(I(H(t, p)));
1496
+ } catch (e) {
1497
+ console.error("Error loading conversation", e);
1498
+ } finally {
1499
+ C(!1);
1500
+ }
1501
+ }
1502
+ e();
1503
+ }, [
1504
+ O,
1505
+ h,
1506
+ p,
1507
+ k,
1508
+ g
1509
+ ]);
1510
+ let F = r(async (e) => {
1511
+ try {
1512
+ await A(e);
1513
+ let t = await O(p), r = await k(ne(z.ME));
1514
+ h(I(t)), g(I(H(r, p))), n === e?.id && v();
1515
+ } catch (e) {
1516
+ console.error("Error deleting conversation", e);
1517
+ }
1518
+ }, [
1519
+ A,
1520
+ O,
1521
+ p,
1522
+ k,
1523
+ h,
1524
+ g,
1525
+ n,
1526
+ v
1527
+ ]), ee = r(async (e, t) => {
1528
+ try {
1529
+ C(!0), await j(e, t);
1530
+ let n = await O(p), r = await k(ne(z.ME));
1531
+ h(I(n)), g(I(H(r, p)));
1532
+ } catch (e) {
1533
+ console.error("Error renaming conversation", e);
1534
+ } finally {
1535
+ C(!1);
1536
+ }
1537
+ }, [
1538
+ O,
1539
+ p,
1540
+ k,
1541
+ h,
1542
+ g,
1543
+ j
1544
+ ]), L = r((e) => {
1545
+ T(e);
1546
+ }, [T]), R = r(() => {
1547
+ D((e) => !e), T("");
1548
+ }, [D]);
1549
+ return S ? /* @__PURE__ */ M(b, {}) : /* @__PURE__ */ M(Je, {
1550
+ value: {
1551
+ locale: p,
1552
+ deleteConversation: F,
1553
+ renameConversation: ee,
1554
+ getConversation: i.getConversation,
1555
+ getFileBlob: i.getFileBlob,
1556
+ shareConversationProps: _
1557
+ },
1558
+ children: /* @__PURE__ */ N(J.Provider, {
1559
+ value: d,
1560
+ children: [
1561
+ !l && /* @__PURE__ */ N("div", {
1562
+ className: e("flex justify-between items-center pr-6", E ? " pt-4 pb-0 sm:pt-10" : " pt-6 pb-2 sm:pt-10"),
1563
+ children: [!E && /* @__PURE__ */ M("h3", {
1564
+ className: "sm:body-2 text-neutrals-700",
1565
+ children: d?.titles?.allChats ?? "All Chats"
1566
+ }), /* @__PURE__ */ M(et, {
1567
+ searchQuery: w,
1568
+ isExpandedSearch: E,
1569
+ onSearchConversations: L,
1570
+ toggleSearchField: R
1571
+ })]
1572
+ }),
1573
+ /* @__PURE__ */ M("div", {
1574
+ className: "scroll-hidden-container flex flex-col mt-4 flex-1 min-h-0",
1575
+ children: l ? null : /* @__PURE__ */ M("div", {
1576
+ className: e("flex flex-col pr-4", P ? "gap-y-1" : "gap-y-6"),
1577
+ children: f?.length === 0 && m?.length === 0 ? /* @__PURE__ */ M(nt, {}) : P ? /* @__PURE__ */ M(tt, {
1578
+ conversations: [...m, ...f],
1579
+ searchQuery: w,
1580
+ selectedConversationId: n,
1581
+ handleConversationClick: t,
1582
+ isDisabled: u
1583
+ }) : Object.entries(y).map(([e, r]) => r?.length > 0 && /* @__PURE__ */ M($e, {
1584
+ isDisabled: u,
1585
+ groupLabel: e,
1586
+ groupedConversations: r,
1587
+ handleConversationClick: t,
1588
+ selectedConversationId: n
1589
+ }, e))
1590
+ })
1591
+ }),
1592
+ s
1593
+ ]
1594
+ })
1595
+ });
1596
+ }, it = ({ onCloseModal: e, disableModalDividers: t, signOut: n, isSmallButton: r, locale: i, titles: a }) => /* @__PURE__ */ N(C, {
1597
+ heading: a?.popupTitle || "Log out?",
1598
+ portalId: "sign-out",
1599
+ containerClassName: "sign-out-popup",
1600
+ size: x.SM,
1601
+ dividers: !t,
1602
+ onClose: e,
1603
+ closeButtonTitle: "Cancel",
1604
+ children: [/* @__PURE__ */ M("div", {
1605
+ className: "px-6 py-4 sm:px-0",
1606
+ lang: i,
1607
+ children: a?.popupText
1608
+ }), /* @__PURE__ */ N("div", {
1609
+ className: "delete-conversation-popup-footer flex justify-end gap-x-2 px-6 py-3",
1610
+ children: [/* @__PURE__ */ M(f, {
1611
+ buttonClassName: "cancel-button",
1612
+ title: a?.popupCancel || "Cancel",
1613
+ isSmallButton: r,
1614
+ onClick: (t) => {
1615
+ t.stopPropagation(), e();
1616
+ }
1617
+ }), /* @__PURE__ */ M(f, {
1618
+ buttonClassName: "text-button-primary",
1619
+ title: a?.popupApply || "Sign Out",
1620
+ isSmallButton: r,
1621
+ onClick: (e) => {
1622
+ e.stopPropagation(), n?.();
1623
+ }
1624
+ })]
1625
+ })]
1626
+ }), at = ({ userInfo: t, signOutAction: n, contactSupportUrl: i, styles: a, locale: s, titles: l }) => {
1627
+ let u = (e) => e?.split(" ")?.map((e, t) => t < 2 ? e[0].toUpperCase() : "")?.join("") ?? "", d = o(() => t?.name ? u(t?.name) : t?.email?.[0].toUpperCase() ?? "", [t]), [f, m] = c(!1), h = t?.name?.split(" "), g = h ? `${h?.[0] ?? ""} ${h?.[1]?.[0] ? h?.[1]?.[0] + "." : ""}` : t?.email ?? "", _ = r(() => {
1628
+ m(!0);
1629
+ }, []), v = r(() => {
1630
+ m(!1);
1631
+ }, []), y = r(() => {
1632
+ window.open(i || "#", "_blank", "noopener,noreferrer");
1633
+ }, [i]), b = o(() => /* @__PURE__ */ N("div", {
1634
+ className: "flex items-center gap-2",
1635
+ children: [/* @__PURE__ */ M("div", {
1636
+ className: e("cursor-pointer flex items-center justify-center size-11 rounded-[100px] p-[10px] sm:h-[32px] sm:w-[32px] flex-shrink-0", a?.initialStyles),
1637
+ children: d
1638
+ }), /* @__PURE__ */ M("p", {
1639
+ className: e("h3 cursor-pointer overflow-hidden text-ellipsis", a?.userNameStyles),
1640
+ children: (a?.showShortName ? g : t?.name) ?? t?.email ?? ""
1641
+ })]
1642
+ }), [
1643
+ d,
1644
+ g,
1645
+ a,
1646
+ t
1647
+ ]), x = o(() => /* @__PURE__ */ N("div", {
1648
+ className: e("py-1", a?.dropDownStyles),
1649
+ children: [
1650
+ a?.settingsIcon && /* @__PURE__ */ N("button", {
1651
+ className: e("p-2 items-center flex gap-1 text-primary fill-primary", a?.dropdownButtonTypographyStyles || "body-1", a?.dropdownButtonStyles),
1652
+ title: l?.settings,
1653
+ children: [/* @__PURE__ */ M("span", {
1654
+ className: "shrink-0",
1655
+ children: a?.settingsIcon
1656
+ }), /* @__PURE__ */ M("span", {
1657
+ className: "min-w-0 break-words",
1658
+ children: l?.settings || "Settings"
1659
+ })]
1660
+ }),
1661
+ a?.contactSupportIcon && /* @__PURE__ */ N("button", {
1662
+ className: e("p-2 items-center flex gap-1 text-primary fill-primary", a?.dropdownButtonTypographyStyles || "body-1", a?.dropdownButtonStyles),
1663
+ title: l?.contactSupport,
1664
+ onClick: y,
1665
+ children: [/* @__PURE__ */ M("span", {
1666
+ className: "shrink-0",
1667
+ children: a?.contactSupportIcon
1668
+ }), /* @__PURE__ */ M("span", {
1669
+ className: "min-w-0 break-words",
1670
+ children: l?.contactSupport || "Contact support"
1671
+ })]
1672
+ }),
1673
+ /* @__PURE__ */ M("div", { className: e("h-0 border-t border-neutrals-600 my-2", a?.showSeparator ? "block" : "hidden") }),
1674
+ /* @__PURE__ */ N("button", {
1675
+ className: e("p-2 items-center flex gap-1 text-primary fill-primary", a?.dropdownButtonTypographyStyles || "body-1", a?.dropdownButtonStyles),
1676
+ title: l?.signOut,
1677
+ onClick: _,
1678
+ children: [
1679
+ /* @__PURE__ */ M("span", {
1680
+ className: "shrink-0",
1681
+ children: a?.signOutIcon
1682
+ }),
1683
+ /* @__PURE__ */ M("span", {
1684
+ className: "min-w-0 break-words",
1685
+ children: l?.signOut || "Sign out"
1686
+ }),
1687
+ f && /* @__PURE__ */ M(it, {
1688
+ onCloseModal: v,
1689
+ signOut: () => n?.(),
1690
+ locale: s,
1691
+ disableModalDividers: a?.disableModalDividers,
1692
+ titles: l
1693
+ })
1694
+ ]
1695
+ })
1696
+ ]
1697
+ }), [
1698
+ a,
1699
+ l,
1700
+ _,
1701
+ y,
1702
+ f,
1703
+ v,
1704
+ s,
1705
+ n
1706
+ ]);
1707
+ if (t) return /* @__PURE__ */ M(p, {
1708
+ containerClassName: e("transition-opacity group-hover:opacity-100 shrink w-full", a?.dropdownContainerClassName),
1709
+ triggerButton: b,
1710
+ content: x,
1711
+ openedClassName: "action-menu-opened"
1712
+ });
1927
1713
  };
1714
+ //#endregion
1715
+ export { Xe as ActionMenu, B as ActionMenuItem, rt as ConversationList, at as User, U as getSharedConversationsGroup, H as transformSharedConversations };