@versini/sassysaint 8.35.2 → 8.36.1

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.
@@ -1,446 +0,0 @@
1
- import { jsxs as a, jsx as e, Fragment as te } from "react/jsx-runtime";
2
- import { I as H, n as j, INFINITE_SCROLL_LIMIT as P, INFINITE_SCROLL_THRESHOLD as V, LOCAL_STORAGE_PREFIX as q, LOCAL_STORAGE_SORT as se, APP_CLASSNAME as ae, numberFormatter as re, ue as z, CARDS as oe, pluralize as ne, ACTION_SORT as $, isProbablyMobile as ce, TOAST_CHAT_DELETED as ie, TOAST_PROVIDER_CHANGED as le, LOCAL_STORAGE_SEARCH as de, HISTORY_TITLE as me, pe as he, debounce as ue, ACTION_SEARCH as pe } from "./index.Bx_do3Wo.js";
3
- import { HistoryContext as W, ChatContext as X, useAiChat as Ce, E as J, useUserPreferences as ge, ConfirmationPanel as ye, LazyToastContainerWrapper as Se, De as xe, He as fe, qe as R, Pe as n, Ye as F, Ge as Te, k as ve, a as we, p as De, p$1 as Ee, st as U, Fe as Ne, mutateCall as G, SERVICE_TYPES as Y, showErrorToast as Ae, E$1 as f, O as Ie, n as be, t as ke, setNewProvider as Re, CHAT_SET_PROVIDER as ze, showSuccessToast as _e, CHAT_SET_STATUS as Le, useChatsHistory as He, tt as Oe, a$1 as Me } from "./App.jScnP0cm.js";
4
- import { useRef as _, useState as A, useContext as I, useCallback as Be, useEffect as L, Fragment as Pe } from "react";
5
- const Ve = ({
6
- className: r,
7
- viewBox: c,
8
- title: l,
9
- monotone: d,
10
- ...o
11
- }) => /* @__PURE__ */ a(
12
- H,
13
- {
14
- defaultViewBox: "0 0 448 512",
15
- size: "size-5",
16
- viewBox: c,
17
- className: r,
18
- title: l || "Delete",
19
- ...o,
20
- children: [
21
- /* @__PURE__ */ e(
22
- "path",
23
- {
24
- d: "M32 96v352c0 35.3 28.7 64 64 64h256c35.3 0 64-28.7 64-64V96zm80 80c0-8.8 7.2-16 16-16s16 7.2 16 16v224c0 8.8-7.2 16-16 16s-16-7.2-16-16zm96 0c0-8.8 7.2-16 16-16s16 7.2 16 16v224c0 8.8-7.2 16-16 16s-16-7.2-16-16zm96 0c0-8.8 7.2-16 16-16s16 7.2 16 16v224c0 8.8-7.2 16-16 16s-16-7.2-16-16z",
25
- opacity: d ? "1" : "0.4"
26
- }
27
- ),
28
- /* @__PURE__ */ e("path", { d: "M163.8 0c-12.1 0-23.2 6.8-28.6 17.7L128 32H32C14.3 32 0 46.3 0 64s14.3 32 32 32h384c17.7 0 32-14.3 32-32s-14.3-32-32-32h-96l-7.2-14.3C307.4 6.8 296.3 0 284.2 0z" })
29
- ]
30
- }
31
- ), $e = ({
32
- className: r,
33
- viewBox: c,
34
- title: l,
35
- monotone: d,
36
- ...o
37
- }) => /* @__PURE__ */ a(
38
- H,
39
- {
40
- defaultViewBox: "0 0 512 512",
41
- size: "size-5",
42
- viewBox: c,
43
- className: r,
44
- title: l || "Restore",
45
- ...o,
46
- children: [
47
- /* @__PURE__ */ e(
48
- "path",
49
- {
50
- d: "M128 80v16h64V80c0-8.8 7.2-16 16-16h224c8.8 0 16 7.2 16 16v224c0 8.8-7.2 16-16 16h-16v64h16c44.2 0 80-35.8 80-80V80c0-44.2-35.8-80-80-80H208c-44.2 0-80 35.8-80 80",
51
- opacity: d ? "1" : "0.4"
52
- }
53
- ),
54
- /* @__PURE__ */ e("path", { d: "M64 128c-35.3 0-64 28.7-64 64v256c0 35.3 28.7 64 64 64h256c35.3 0 64-28.7 64-64V192c0-35.3-28.7-64-64-64zm32 64h192c17.7 0 32 14.3 32 32s-14.3 32-32 32H96c-17.7 0-32-14.3-32-32s14.3-32 32-32" })
55
- ]
56
- }
57
- ), Fe = ({
58
- className: r,
59
- viewBox: c,
60
- title: l,
61
- monotone: d,
62
- ...o
63
- }) => /* @__PURE__ */ a(
64
- H,
65
- {
66
- defaultViewBox: "0 0 512 512",
67
- size: "size-5",
68
- viewBox: c,
69
- className: r,
70
- title: l || "Search",
71
- ...o,
72
- children: [
73
- /* @__PURE__ */ e(
74
- "path",
75
- {
76
- d: "M0 208a208 208 0 1 0 416 0 208 208 0 1 0-416 0m352 0a144 144 0 1 1-288 0 144 144 0 1 1 288 0",
77
- opacity: d ? "1" : "0.4"
78
- }
79
- ),
80
- /* @__PURE__ */ e("path", { d: "m330.7 376 126.7 126.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L376 330.7c-12.7 17.3-28 32.6-45.3 45.3" })
81
- ]
82
- }
83
- ), Ue = {
84
- [ke]: Ee,
85
- [be]: De,
86
- [Ie]: we
87
- }, Ge = ({
88
- filteredHistory: r,
89
- dispatch: c,
90
- onOpenChange: l,
91
- mutate: d
92
- }) => {
93
- const { user: o, getAccessToken: y } = j(), T = ce(), h = _(null), s = _({
94
- id: "",
95
- timestamp: "",
96
- message: ""
97
- }), [v, C] = A(!1), [w, S] = A(
98
- P + V
99
- ), { state: u, dispatch: D } = I(W), {
100
- state: { provider: E },
101
- setChatId: b,
102
- setInitialMessages: O
103
- } = I(X), { setInput: p } = Ce(), [, M] = J({
104
- key: q + se,
105
- initialValue: u.sortDirection
106
- }), { refetch: K } = ge({
107
- user: o?.username,
108
- getAccessToken: y
109
- }), B = (t) => {
110
- switch (u.sortDirection) {
111
- case f.ASC:
112
- M(f.DESC), D({
113
- type: $,
114
- payload: {
115
- sortedCell: t,
116
- sortDirection: f.DESC
117
- }
118
- });
119
- break;
120
- default:
121
- M(f.ASC), D({
122
- type: $,
123
- payload: {
124
- sortedCell: t,
125
- sortDirection: f.ASC
126
- }
127
- });
128
- break;
129
- }
130
- }, Q = async () => {
131
- const t = s.current;
132
- try {
133
- await G({
134
- accessToken: await y(),
135
- type: Y.DELETE_CHAT,
136
- params: {
137
- userId: o?.username || "",
138
- id: t.id
139
- }
140
- }), d(""), await Ae(ie, {
141
- autoClose: 2e3,
142
- containerId: "history-table"
143
- });
144
- } catch {
145
- }
146
- }, Z = async (t, i, x, g, N, k) => {
147
- try {
148
- const m = await G({
149
- accessToken: g,
150
- type: Y.GET_CHAT,
151
- params: {
152
- id: t.id
153
- }
154
- });
155
- m.status === 200 && (m.data.provider !== k && (await Re({
156
- provider: m.data.provider,
157
- accessToken: g,
158
- username: N
159
- }), i({
160
- type: ze,
161
- payload: {
162
- provider: m.data.provider
163
- }
164
- }), K(), await _e(
165
- `${le} ${m.data.provider}`,
166
- {
167
- containerId: "toggle-provider"
168
- }
169
- )), i({
170
- type: Le,
171
- payload: {
172
- restoring: !0,
173
- restoredModel: m.data?.model || "",
174
- restoredUsage: m.data?.tokenUsage || 0
175
- }
176
- }), p(""), b(t.id), O(m.data.messages), x(!1));
177
- } catch {
178
- }
179
- }, ee = Be((t) => {
180
- t[0].isIntersecting && S((x) => x + P);
181
- }, []);
182
- return L(() => {
183
- const t = {
184
- // root: null,
185
- rootMargin: "20px"
186
- }, i = new IntersectionObserver(ee, t);
187
- h.current && i.observe(h.current);
188
- }), /* @__PURE__ */ a(te, { children: [
189
- /* @__PURE__ */ a(
190
- ye,
191
- {
192
- showConfirmation: v,
193
- setShowConfirmation: C,
194
- action: Q,
195
- customStrings: {
196
- confirmAction: "Delete",
197
- cancelAction: "Cancel",
198
- title: "Delete chat"
199
- },
200
- children: [
201
- /* @__PURE__ */ e("p", { className: "m-0", children: "Are you sure you want to delete the following chat:" }),
202
- /* @__PURE__ */ a("ul", { className: "m-0", children: [
203
- /* @__PURE__ */ a("li", { children: [
204
- "Timestamp:",
205
- " ",
206
- /* @__PURE__ */ e("span", { className: "text-lg", children: s.current && s.current.timestamp })
207
- ] }),
208
- /* @__PURE__ */ a("li", { children: [
209
- "First message:",
210
- " ",
211
- /* @__PURE__ */ e("span", { className: "text-lg", children: s.current?.message })
212
- ] })
213
- ] })
214
- ]
215
- }
216
- ),
217
- /* @__PURE__ */ e("div", { className: ae, children: /* @__PURE__ */ e(Se, { containerId: "history-table" }) }),
218
- /* @__PURE__ */ a(xe, { stickyHeader: !0, stickyFooter: !0, compact: !0, children: [
219
- /* @__PURE__ */ e(fe, { children: /* @__PURE__ */ a(R, { children: [
220
- /* @__PURE__ */ e(n, { className: "sr-only", children: "Row" }),
221
- /* @__PURE__ */ e(
222
- F,
223
- {
224
- buttonClassName: "text-xs sm:text-sm",
225
- cellId: "timestamp",
226
- align: "left",
227
- sortDirection: u.sortDirection,
228
- sortedCell: u.sortedCell,
229
- onClick: () => {
230
- B("timestamp");
231
- },
232
- children: "Date"
233
- }
234
- ),
235
- /* @__PURE__ */ e(n, { className: "text-xs sm:text-sm", children: "Summary" }),
236
- /* @__PURE__ */ e(n, { className: "text-xs sm:text-sm", children: "Provider" }),
237
- !T && /* @__PURE__ */ e(
238
- F,
239
- {
240
- buttonClassName: "text-xs sm:text-sm",
241
- cellId: "tokenUsage",
242
- align: "right",
243
- sortDirection: u.sortDirection,
244
- sortedCell: u.sortedCell,
245
- onClick: () => {
246
- B("tokenUsage");
247
- },
248
- children: "Tokens"
249
- }
250
- ),
251
- /* @__PURE__ */ e(n, { className: "text-xs sm:text-sm text-right", children: "Actions" })
252
- ] }) }),
253
- /* @__PURE__ */ e(Te, { children: r.slice(0, w).map((t, i) => {
254
- const x = t.summary || (t.messages.length > 0 ? t.messages[0]?.content : ""), g = t.model ? ve(t.model) : null, N = g ? Ue[g] : null;
255
- return t?.messages?.length > 0 ? /* @__PURE__ */ a(Pe, { children: [
256
- i === w - V && /* @__PURE__ */ e("tr", { ref: h }),
257
- /* @__PURE__ */ a(R, { children: [
258
- /* @__PURE__ */ e(n, { children: i + 1 }),
259
- /* @__PURE__ */ e(
260
- n,
261
- {
262
- component: "th",
263
- scope: "row",
264
- className: "text-gray-400 sm:whitespace-nowrap text-xs sm:text-sm max-w-20 sm:max-w-none",
265
- children: t.timestamp.split(",")[0]
266
- }
267
- ),
268
- /* @__PURE__ */ e(
269
- n,
270
- {
271
- className: "max-w-[100px] text-white sm:max-w-full text-xs sm:text-sm",
272
- style: {
273
- wordBreak: "break-word"
274
- },
275
- children: x
276
- }
277
- ),
278
- /* @__PURE__ */ e(
279
- n,
280
- {
281
- component: "th",
282
- scope: "row",
283
- className: "text-gray-400",
284
- align: "center",
285
- children: N ? /* @__PURE__ */ e(
286
- N,
287
- {
288
- size: "size-4 sm:size-5",
289
- semantic: !0,
290
- title: t.model || g
291
- }
292
- ) : null
293
- }
294
- ),
295
- !T && /* @__PURE__ */ e(
296
- n,
297
- {
298
- className: "text-gray-400 text-xs sm:text-sm",
299
- align: "right",
300
- children: t.tokenUsage ? re.format(t.tokenUsage) : "0"
301
- }
302
- ),
303
- /* @__PURE__ */ a(n, { align: "right", children: [
304
- /* @__PURE__ */ e(
305
- U,
306
- {
307
- label: "Restore chat",
308
- mode: "alt-system",
309
- placement: "top",
310
- trigger: /* @__PURE__ */ e(
311
- z,
312
- {
313
- className: "mr-2",
314
- focusMode: "alt-system",
315
- noBorder: !0,
316
- label: "Restore chat",
317
- onClick: async () => {
318
- const k = await y();
319
- Z(
320
- t,
321
- c,
322
- l,
323
- k,
324
- o?.username || "",
325
- E
326
- );
327
- },
328
- children: /* @__PURE__ */ e($e, { size: "size-3", monotone: !0 })
329
- }
330
- )
331
- }
332
- ),
333
- /* @__PURE__ */ e(
334
- U,
335
- {
336
- label: "Delete chat",
337
- mode: "alt-system",
338
- placement: "top",
339
- trigger: /* @__PURE__ */ e(
340
- z,
341
- {
342
- focusMode: "alt-system",
343
- noBorder: !0,
344
- label: "Delete chat",
345
- onClick: () => {
346
- s.current = {
347
- id: t.id,
348
- timestamp: t.timestamp,
349
- message: t.messages.length > 0 ? t.messages[0]?.content : ""
350
- }, C(!v);
351
- },
352
- children: /* @__PURE__ */ e("div", { className: "text-red-400", children: /* @__PURE__ */ e(Ve, { size: "size-3", monotone: !0 }) })
353
- }
354
- )
355
- }
356
- )
357
- ] })
358
- ] })
359
- ] }, `${oe.HISTORY.TITLE}-${t.id}-${i}`) : null;
360
- }) }),
361
- /* @__PURE__ */ e(Ne, { children: /* @__PURE__ */ e(R, { children: /* @__PURE__ */ e(n, { colSpan: 1e3, children: /* @__PURE__ */ e("div", { children: ne(
362
- `${r.length} chat`,
363
- r.length
364
- ) }) }) }) })
365
- ] })
366
- ] });
367
- }, Xe = ({
368
- open: r,
369
- onOpenChange: c
370
- }) => {
371
- const { getAccessToken: l, user: d } = j(), { dispatch: o } = I(X), [y, T] = A([]), h = _(null), { state: s, dispatch: v } = I(W), [C, w] = A(
372
- s.sortDirection
373
- ), { data: S, refetch: u } = He({
374
- enabled: r,
375
- user: d?.username || "",
376
- searchString: s.searchString,
377
- sortDirection: C,
378
- sortedCell: s.sortedCell,
379
- getAccessToken: l
380
- }), [, D] = J({
381
- key: q + de,
382
- initialValue: s.searchString
383
- });
384
- L(() => {
385
- s.sortDirection !== C && w(s.sortDirection);
386
- }, [s, C]), L(() => {
387
- S && T(S);
388
- }, [S]);
389
- const E = async (p) => {
390
- D(p), v({
391
- type: pe,
392
- payload: { searchString: p }
393
- });
394
- }, b = ue((p) => {
395
- E(p.target.value.trim());
396
- }, 500);
397
- return /* @__PURE__ */ a(Oe, { open: r, onOpenChange: c, title: me, children: [
398
- /* @__PURE__ */ e("form", { autoComplete: "off", onSubmit: async (p) => {
399
- p.preventDefault();
400
- }, children: /* @__PURE__ */ e(
401
- he,
402
- {
403
- placeholder: "Search",
404
- labelHidden: !0,
405
- noBorder: !0,
406
- autoCapitalize: "off",
407
- autoComplete: "off",
408
- autoCorrect: "off",
409
- ref: h,
410
- defaultValue: s.searchString,
411
- focusMode: "light",
412
- mode: "light",
413
- name: "Search",
414
- label: "Search",
415
- onChange: b,
416
- className: "my-2",
417
- rightElement: /* @__PURE__ */ e("div", { className: "text-copy-dark", children: /* @__PURE__ */ e(
418
- z,
419
- {
420
- mode: "dark",
421
- focusMode: "dark",
422
- label: "Search",
423
- size: "small",
424
- onClick: () => {
425
- E(""), h.current?.value && (h.current.value = "", h.current.focus());
426
- },
427
- disabled: s.searchString === "",
428
- children: s.searchString !== "" ? /* @__PURE__ */ e(Me, { monotone: !0, size: "size-3" }) : /* @__PURE__ */ e(Fe, { monotone: !0, size: "size-3" })
429
- }
430
- ) })
431
- }
432
- ) }),
433
- /* @__PURE__ */ e("div", { className: "flex flex-col sm:flex-row max-h-[60vh] min-h-[60vh]", children: /* @__PURE__ */ e(
434
- Ge,
435
- {
436
- mutate: u,
437
- filteredHistory: y,
438
- dispatch: o,
439
- onOpenChange: c
440
- }
441
- ) })
442
- ] });
443
- };
444
- export {
445
- Xe as HistoryPanel
446
- };