@versini/sassysaint 8.33.4 → 8.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versini/sassysaint",
3
- "version": "8.33.4",
3
+ "version": "8.34.0",
4
4
  "license": "MIT",
5
5
  "author": "Arno Versini",
6
6
  "publishConfig": {
@@ -31,7 +31,7 @@
31
31
  "react-dom": "^18.3.1 || ^19.0.0"
32
32
  },
33
33
  "devDependencies": {
34
- "@sassysaint/client": "8.33.4",
34
+ "@sassysaint/client": "8.34.0",
35
35
  "@tailwindcss/vite": "4.1.11",
36
36
  "@versini/ui-styles": "5.0.7"
37
37
  },
@@ -43,5 +43,5 @@
43
43
  "sideEffects": [
44
44
  "**/*.css"
45
45
  ],
46
- "gitHead": "70c4aaf8a3a49c05d73ccce03c26cb809c07e8e1"
46
+ "gitHead": "1bc9915131e84f173f4d855377e233346e6c84e3"
47
47
  }
@@ -1,423 +0,0 @@
1
- import { jsxs as s, jsx as e, Fragment as Z } from "react/jsx-runtime";
2
- import { I as H, n as G, INFINITE_SCROLL_LIMIT as M, INFINITE_SCROLL_THRESHOLD as B, LOCAL_STORAGE_PREFIX as U, LOCAL_STORAGE_SORT as ee, APP_CLASSNAME as te, le as b, CARDS as se, pluralize as ae, ACTION_SORT as V, TOAST_CHAT_DELETED as re, TOAST_PROVIDER_CHANGED as oe, LOCAL_STORAGE_SEARCH as ce, HISTORY_TITLE as ne, fe as ie, debounce as le, ACTION_SEARCH as de } from "./index.Czf9axok.js";
3
- import { HistoryContext as Y, ChatContext as j, useAiChat as me, E as q, useUserPreferences as he, ConfirmationPanel as ue, LazyToastContainerWrapper as pe, He as Ce, $e as Se, qe as _, Pe as l, Ye as ge, Ge as ye, k as fe, a as xe, p as Te, p$1 as ve, at as $, Fe as we, mutateCall as P, SERVICE_TYPES as F, showErrorToast as Ee, R as x, O as De, n as Ne, o as Ae, setNewProvider as Ie, CHAT_SET_PROVIDER as Re, showSuccessToast as ze, CHAT_SET_STATUS as _e, useChatsHistory as be, rr as ke, a$1 as Le } from "./App.B8I-Bynx.js";
4
- import { useRef as k, useState as D, useContext as N, useCallback as He, useEffect as L, Fragment as Oe } from "react";
5
- const Me = ({
6
- className: a,
7
- viewBox: c,
8
- title: d,
9
- monotone: m,
10
- ...o
11
- }) => /* @__PURE__ */ s(
12
- H,
13
- {
14
- defaultViewBox: "0 0 448 512",
15
- size: "size-5",
16
- viewBox: c,
17
- className: a,
18
- title: d || "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: m ? "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
- ), Be = ({
32
- className: a,
33
- viewBox: c,
34
- title: d,
35
- monotone: m,
36
- ...o
37
- }) => /* @__PURE__ */ s(
38
- H,
39
- {
40
- defaultViewBox: "0 0 512 512",
41
- size: "size-5",
42
- viewBox: c,
43
- className: a,
44
- title: d || "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: m ? "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
- ), Ve = ({
58
- className: a,
59
- viewBox: c,
60
- title: d,
61
- monotone: m,
62
- ...o
63
- }) => /* @__PURE__ */ s(
64
- H,
65
- {
66
- defaultViewBox: "0 0 512 512",
67
- size: "size-5",
68
- viewBox: c,
69
- className: a,
70
- title: d || "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: m ? "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
- ), $e = {
84
- [Ae]: ve,
85
- [Ne]: Te,
86
- [De]: xe
87
- }, Pe = ({
88
- filteredHistory: a,
89
- dispatch: c,
90
- onOpenChange: d,
91
- mutate: m
92
- }) => {
93
- const { user: o, getAccessToken: g } = G(), y = k(null), n = k({
94
- id: "",
95
- timestamp: "",
96
- message: ""
97
- }), [r, T] = D(!1), [C, A] = D(
98
- M + B
99
- ), { state: p, dispatch: v } = N(Y), {
100
- state: { provider: I },
101
- setChatId: w,
102
- setInitialMessages: R
103
- } = N(j), { setInput: O } = me(), [, h] = q({
104
- key: U + ee,
105
- initialValue: p.sortDirection
106
- }), { refetch: W } = he({
107
- user: o?.username,
108
- getAccessToken: g
109
- }), X = (t) => {
110
- switch (p.sortDirection) {
111
- case x.ASC:
112
- h(x.DESC), v({
113
- type: V,
114
- payload: {
115
- sortedCell: t,
116
- sortDirection: x.DESC
117
- }
118
- });
119
- break;
120
- default:
121
- h(x.ASC), v({
122
- type: V,
123
- payload: {
124
- sortedCell: t,
125
- sortDirection: x.ASC
126
- }
127
- });
128
- break;
129
- }
130
- }, J = async () => {
131
- const t = n.current;
132
- try {
133
- await P({
134
- accessToken: await g(),
135
- type: F.DELETE_CHAT,
136
- params: {
137
- userId: o?.username || "",
138
- id: t.id
139
- }
140
- }), m(""), await Ee(re, {
141
- autoClose: 2e3,
142
- containerId: "history-table"
143
- });
144
- } catch {
145
- }
146
- }, K = async (t, i, f, S, E, z) => {
147
- try {
148
- const u = await P({
149
- accessToken: S,
150
- type: F.GET_CHAT,
151
- params: {
152
- id: t.id
153
- }
154
- });
155
- u.status === 200 && (u.data.provider !== z && (await Ie({
156
- provider: u.data.provider,
157
- accessToken: S,
158
- username: E
159
- }), i({
160
- type: Re,
161
- payload: {
162
- provider: u.data.provider
163
- }
164
- }), W(), await ze(
165
- `${oe} ${u.data.provider}`,
166
- {
167
- containerId: "toggle-provider"
168
- }
169
- )), i({
170
- type: _e,
171
- payload: {
172
- restoring: !0,
173
- restoredModel: u.data?.model || "",
174
- restoredUsage: u.data?.tokenUsage || 0
175
- }
176
- }), O(""), w(t.id), R(u.data.messages), f(!1));
177
- } catch {
178
- }
179
- }, Q = He((t) => {
180
- t[0].isIntersecting && A((f) => f + M);
181
- }, []);
182
- return L(() => {
183
- const t = {
184
- // root: null,
185
- rootMargin: "20px"
186
- }, i = new IntersectionObserver(Q, t);
187
- y.current && i.observe(y.current);
188
- }), /* @__PURE__ */ s(Z, { children: [
189
- /* @__PURE__ */ s(
190
- ue,
191
- {
192
- showConfirmation: r,
193
- setShowConfirmation: T,
194
- action: J,
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__ */ s("ul", { className: "m-0", children: [
203
- /* @__PURE__ */ s("li", { children: [
204
- "Timestamp:",
205
- " ",
206
- /* @__PURE__ */ e("span", { className: "text-lg", children: n.current && n.current.timestamp })
207
- ] }),
208
- /* @__PURE__ */ s("li", { children: [
209
- "First message:",
210
- " ",
211
- /* @__PURE__ */ e("span", { className: "text-lg", children: n.current?.message })
212
- ] })
213
- ] })
214
- ]
215
- }
216
- ),
217
- /* @__PURE__ */ e("div", { className: te, children: /* @__PURE__ */ e(pe, { containerId: "history-table" }) }),
218
- /* @__PURE__ */ s(Ce, { stickyHeader: !0, stickyFooter: !0, compact: !0, children: [
219
- /* @__PURE__ */ e(Se, { children: /* @__PURE__ */ s(_, { children: [
220
- /* @__PURE__ */ e(l, { className: "sr-only", children: "Row" }),
221
- /* @__PURE__ */ e(
222
- ge,
223
- {
224
- buttonClassName: "text-xs sm:text-sm",
225
- cellId: "timestamp",
226
- align: "left",
227
- sortDirection: p.sortDirection,
228
- sortedCell: p.sortedCell,
229
- onClick: () => {
230
- X("timestamp");
231
- },
232
- children: "Date"
233
- }
234
- ),
235
- /* @__PURE__ */ e(l, { className: "text-xs sm:text-sm", children: "Summary" }),
236
- /* @__PURE__ */ e(l, { className: "text-xs sm:text-sm", children: "Provider" }),
237
- /* @__PURE__ */ e(l, { className: "text-xs sm:text-sm text-right", children: "Actions" })
238
- ] }) }),
239
- /* @__PURE__ */ e(ye, { children: a.slice(0, C).map((t, i) => {
240
- const f = t.summary || (t.messages.length > 0 ? t.messages[0]?.content : ""), S = t.model ? fe(t.model) : null, E = S ? $e[S] : null;
241
- return t?.messages?.length > 0 ? /* @__PURE__ */ s(Oe, { children: [
242
- i === C - B && /* @__PURE__ */ e("tr", { ref: y }),
243
- /* @__PURE__ */ s(_, { children: [
244
- /* @__PURE__ */ e(l, { children: i + 1 }),
245
- /* @__PURE__ */ e(
246
- l,
247
- {
248
- component: "th",
249
- scope: "row",
250
- className: "text-gray-400 sm:whitespace-nowrap text-xs sm:text-sm max-w-20 sm:max-w-none",
251
- children: t.timestamp.split(",")[0]
252
- }
253
- ),
254
- /* @__PURE__ */ e(
255
- l,
256
- {
257
- className: "max-w-[100px] text-white sm:max-w-full text-xs sm:text-sm",
258
- style: {
259
- wordBreak: "break-word"
260
- },
261
- children: f
262
- }
263
- ),
264
- /* @__PURE__ */ e(
265
- l,
266
- {
267
- component: "th",
268
- scope: "row",
269
- className: "text-gray-400",
270
- align: "center",
271
- children: E ? /* @__PURE__ */ e(
272
- E,
273
- {
274
- size: "size-4 sm:size-5",
275
- semantic: !0,
276
- title: t.model || S
277
- }
278
- ) : null
279
- }
280
- ),
281
- /* @__PURE__ */ s(l, { align: "right", children: [
282
- /* @__PURE__ */ e(
283
- $,
284
- {
285
- label: "Restore chat",
286
- mode: "alt-system",
287
- placement: "top",
288
- trigger: /* @__PURE__ */ e(
289
- b,
290
- {
291
- className: "mr-2",
292
- focusMode: "alt-system",
293
- noBorder: !0,
294
- label: "Restore chat",
295
- onClick: async () => {
296
- const z = await g();
297
- K(
298
- t,
299
- c,
300
- d,
301
- z,
302
- o?.username || "",
303
- I
304
- );
305
- },
306
- children: /* @__PURE__ */ e(Be, { size: "size-3", monotone: !0 })
307
- }
308
- )
309
- }
310
- ),
311
- /* @__PURE__ */ e(
312
- $,
313
- {
314
- label: "Delete chat",
315
- mode: "alt-system",
316
- placement: "top",
317
- trigger: /* @__PURE__ */ e(
318
- b,
319
- {
320
- focusMode: "alt-system",
321
- noBorder: !0,
322
- label: "Delete chat",
323
- onClick: () => {
324
- n.current = {
325
- id: t.id,
326
- timestamp: t.timestamp,
327
- message: t.messages.length > 0 ? t.messages[0]?.content : ""
328
- }, T(!r);
329
- },
330
- children: /* @__PURE__ */ e("div", { className: "text-red-400", children: /* @__PURE__ */ e(Me, { size: "size-3", monotone: !0 }) })
331
- }
332
- )
333
- }
334
- )
335
- ] })
336
- ] })
337
- ] }, `${se.HISTORY.TITLE}-${t.id}-${i}`) : null;
338
- }) }),
339
- /* @__PURE__ */ e(we, { children: /* @__PURE__ */ e(_, { children: /* @__PURE__ */ e(l, { colSpan: 1e3, children: /* @__PURE__ */ e("div", { children: ae(
340
- `${a.length} chat`,
341
- a.length
342
- ) }) }) }) })
343
- ] })
344
- ] });
345
- }, je = ({
346
- open: a,
347
- onOpenChange: c
348
- }) => {
349
- const { getAccessToken: d, user: m } = G(), { dispatch: o } = N(j), [g, y] = D([]), n = k(null), { state: r, dispatch: T } = N(Y), [C, A] = D(
350
- r.sortDirection
351
- ), { data: p, refetch: v } = be({
352
- enabled: a,
353
- user: m?.username || "",
354
- searchString: r.searchString,
355
- sortDirection: C,
356
- getAccessToken: d
357
- }), [, I] = q({
358
- key: U + ce,
359
- initialValue: r.searchString
360
- });
361
- L(() => {
362
- r.sortDirection !== C && A(r.sortDirection);
363
- }, [r, C]), L(() => {
364
- p && y(p);
365
- }, [p]);
366
- const w = async (h) => {
367
- I(h), T({
368
- type: de,
369
- payload: { searchString: h }
370
- });
371
- }, R = le((h) => {
372
- w(h.target.value.trim());
373
- }, 500);
374
- return /* @__PURE__ */ s(ke, { open: a, onOpenChange: c, title: ne, children: [
375
- /* @__PURE__ */ e("form", { autoComplete: "off", onSubmit: async (h) => {
376
- h.preventDefault();
377
- }, children: /* @__PURE__ */ e(
378
- ie,
379
- {
380
- placeholder: "Search",
381
- labelHidden: !0,
382
- noBorder: !0,
383
- autoCapitalize: "off",
384
- autoComplete: "off",
385
- autoCorrect: "off",
386
- ref: n,
387
- defaultValue: r.searchString,
388
- focusMode: "light",
389
- mode: "light",
390
- name: "Search",
391
- label: "Search",
392
- onChange: R,
393
- className: "my-2",
394
- rightElement: /* @__PURE__ */ e("div", { className: "text-copy-dark", children: /* @__PURE__ */ e(
395
- b,
396
- {
397
- mode: "dark",
398
- focusMode: "dark",
399
- label: "Search",
400
- size: "small",
401
- onClick: () => {
402
- w(""), n.current?.value && (n.current.value = "", n.current.focus());
403
- },
404
- disabled: r.searchString === "",
405
- children: r.searchString !== "" ? /* @__PURE__ */ e(Le, { monotone: !0, size: "size-3" }) : /* @__PURE__ */ e(Ve, { monotone: !0, size: "size-3" })
406
- }
407
- ) })
408
- }
409
- ) }),
410
- /* @__PURE__ */ e("div", { className: "flex flex-col sm:flex-row max-h-[60vh] min-h-[60vh]", children: /* @__PURE__ */ e(
411
- Pe,
412
- {
413
- mutate: v,
414
- filteredHistory: g,
415
- dispatch: o,
416
- onOpenChange: c
417
- }
418
- ) })
419
- ] });
420
- };
421
- export {
422
- je as HistoryPanel
423
- };