@singlebase/elements 0.6.0 → 0.8.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.
Files changed (50) hide show
  1. package/dist/authui-display-C2o9gApg.cjs +961 -0
  2. package/dist/authui-display-C2o9gApg.cjs.map +1 -0
  3. package/dist/{authui-display-CKfGK5va.js → authui-display-CRUABt43.js} +1034 -913
  4. package/dist/authui-display-CRUABt43.js.map +1 -0
  5. package/dist/authui.cjs +1 -1
  6. package/dist/authui.js +2 -2
  7. package/dist/{chat-C-gsskho.cjs → chat-BWcGH9lr.cjs} +310 -287
  8. package/dist/chat-BWcGH9lr.cjs.map +1 -0
  9. package/dist/chat-messages.d.ts +8 -1
  10. package/dist/{chat-CEh6RygY.js → chat-t4o5FsxM.js} +796 -656
  11. package/dist/chat-t4o5FsxM.js.map +1 -0
  12. package/dist/chat.cjs +1 -1
  13. package/dist/chat.d.ts +1 -1
  14. package/dist/chat.js +1 -1
  15. package/dist/elements/authui-account.d.ts +0 -1
  16. package/dist/elements/authui-buttons.d.ts +1 -1
  17. package/dist/elements/authui.d.ts +25 -5
  18. package/dist/elements/chat.d.ts +46 -8
  19. package/dist/elements/uploader.d.ts +0 -6
  20. package/dist/files-4T62wkwj.cjs +77 -0
  21. package/dist/files-4T62wkwj.cjs.map +1 -0
  22. package/dist/{files-DDJWPzZW.js → files-DS-H-3yN.js} +56 -57
  23. package/dist/files-DS-H-3yN.js.map +1 -0
  24. package/dist/index.cjs +1 -1
  25. package/dist/index.js +4 -4
  26. package/dist/messages.d.ts +34 -5
  27. package/dist/singlebase-elements.min.js +2555 -2292
  28. package/dist/singlebase-elements.min.js.map +1 -1
  29. package/dist/upload-messages.d.ts +0 -1
  30. package/dist/{uploader-660JIgIN.cjs → uploader-C57vgFME.cjs} +33 -7
  31. package/dist/uploader-C57vgFME.cjs.map +1 -0
  32. package/dist/{uploader-vfczkX51.js → uploader-Cz9yfzfV.js} +261 -262
  33. package/dist/uploader-Cz9yfzfV.js.map +1 -0
  34. package/dist/uploader.cjs +1 -1
  35. package/dist/uploader.js +2 -2
  36. package/dist/utils/auth-errors.d.ts +7 -0
  37. package/dist/utils/branding.d.ts +5 -5
  38. package/dist/utils/oauth.d.ts +24 -0
  39. package/dist/utils/password.d.ts +16 -0
  40. package/package.json +3 -3
  41. package/dist/authui-display-CKfGK5va.js.map +0 -1
  42. package/dist/authui-display-aWNht0cW.cjs +0 -956
  43. package/dist/authui-display-aWNht0cW.cjs.map +0 -1
  44. package/dist/chat-C-gsskho.cjs.map +0 -1
  45. package/dist/chat-CEh6RygY.js.map +0 -1
  46. package/dist/files-DDJWPzZW.js.map +0 -1
  47. package/dist/files-DyxcjZsx.cjs +0 -75
  48. package/dist/files-DyxcjZsx.cjs.map +0 -1
  49. package/dist/uploader-660JIgIN.cjs.map +0 -1
  50. package/dist/uploader-vfczkX51.js.map +0 -1
@@ -1,15 +1,15 @@
1
- var Ft = Object.defineProperty;
2
- var bt = (n) => {
1
+ var Ut = Object.defineProperty;
2
+ var wt = (n) => {
3
3
  throw TypeError(n);
4
4
  };
5
- var Ut = (n, e, t) => e in n ? Ft(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
6
- var M = (n, e, t) => Ut(n, typeof e != "symbol" ? e + "" : e, t), xt = (n, e, t) => e.has(n) || bt("Cannot " + t);
7
- var p = (n, e, t) => (xt(n, e, "read from private field"), t ? t.call(n) : e.get(n)), h = (n, e, t) => e.has(n) ? bt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), u = (n, e, t, s) => (xt(n, e, "write to private field"), s ? s.call(n, t) : e.set(n, t), t);
8
- import { css as Pt, LitElement as Kt, html as o, nothing as f, svg as I } from "lit";
9
- import { property as v, state as y, customElement as Wt } from "lit/decorators.js";
10
- import { repeat as Jt } from "lit/directives/repeat.js";
11
- import { getDefaultClient as Ht } from "@singlebase/core";
12
- import { a as L, e as vt, j as Gt, t as qt, b as Vt } from "./files-DDJWPzZW.js";
5
+ var Wt = (n, e, t) => e in n ? Ut(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
6
+ var M = (n, e, t) => Wt(n, typeof e != "symbol" ? e + "" : e, t), yt = (n, e, t) => e.has(n) || wt("Cannot " + t);
7
+ var p = (n, e, t) => (yt(n, e, "read from private field"), t ? t.call(n) : e.get(n)), h = (n, e, t) => e.has(n) ? wt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), u = (n, e, t, s) => (yt(n, e, "write to private field"), s ? s.call(n, t) : e.set(n, t), t);
8
+ import { css as Ht, LitElement as Jt, html as o, nothing as m, svg as O } from "lit";
9
+ import { property as v, state as y, customElement as Gt } from "lit/decorators.js";
10
+ import { repeat as qt } from "lit/directives/repeat.js";
11
+ import { getDefaultClient as Vt } from "@singlebase/core";
12
+ import { a as _, e as kt, j as Xt, t as Yt, b as Qt } from "./files-DS-H-3yN.js";
13
13
  if (typeof CSS < "u" && "registerProperty" in CSS)
14
14
  try {
15
15
  CSS.registerProperty({
@@ -20,7 +20,7 @@ if (typeof CSS < "u" && "registerProperty" in CSS)
20
20
  });
21
21
  } catch {
22
22
  }
23
- const Xt = Pt`
23
+ const Zt = Ht`
24
24
  :host {
25
25
  --c-ink: var(--sb-ink, #16181a);
26
26
  --c-ink2: var(--sb-ink-2, #41464b);
@@ -2056,6 +2056,11 @@ const Xt = Pt`
2056
2056
  min-width: 0;
2057
2057
  }
2058
2058
 
2059
+ .pending-file.kept {
2060
+ background: var(--c-bg);
2061
+ border-style: dashed;
2062
+ }
2063
+
2059
2064
  .pending-file .name {
2060
2065
  max-width: 160px;
2061
2066
  overflow: hidden;
@@ -2451,20 +2456,27 @@ const Xt = Pt`
2451
2456
  height: auto;
2452
2457
  }
2453
2458
  }
2454
- `, Yt = {
2459
+ `, es = {
2455
2460
  eyebrowChat: "Chat",
2456
2461
  eyebrowRag: "Grounded answers",
2457
2462
  headingChat: "What can I help with?",
2458
2463
  headingRag: "Ask your knowledge base",
2459
2464
  descriptionChat: "Ask anything. Attach text files to give it more context.",
2460
2465
  descriptionRag: "Answers are grounded in your sources, with a citation for every claim. Attach text files to search them too.",
2466
+ eyebrowKb: "Knowledge base",
2467
+ headingKb: "Ask the knowledge base",
2468
+ descriptionKb: "Answers come only from the knowledge base, with a citation for every claim.",
2461
2469
  placeholderChat: "Message {name}…",
2462
2470
  placeholderRag: "Ask about your sources…",
2471
+ placeholderKb: "Ask the knowledge base…",
2463
2472
  footnote: "{name} can make mistakes. Check important details.",
2464
2473
  attach: "Attach files",
2465
2474
  send: "Send message",
2466
2475
  stop: "Stop generating",
2467
2476
  removeFile: "Remove file",
2477
+ inThisChat: "In this chat",
2478
+ removeFromChat: "Remove from this chat",
2479
+ attachmentFailed: "Couldn't read {name}.",
2468
2480
  dropTitle: "Drop files to attach",
2469
2481
  dropSub: "Text, Markdown, CSV and JSON files are added as context.",
2470
2482
  thinking: "Thinking",
@@ -2548,6 +2560,7 @@ const Xt = Pt`
2548
2560
  tooManyFiles: "Attach up to {n} files at a time.",
2549
2561
  errGeneric: "Something went wrong.",
2550
2562
  errNotFound: "This chat no longer exists. Retry to start a new one.",
2563
+ errKbSource: "No knowledge base is set up for this chat.",
2551
2564
  errNoClient: "Chat isn't connected. Create a SinglebaseClient() on this page.",
2552
2565
  errLoad: "Couldn't load this chat.",
2553
2566
  retry: "Retry",
@@ -2555,36 +2568,35 @@ const Xt = Pt`
2555
2568
  bubbleText: "Hi! Questions? Ask me here.",
2556
2569
  openChat: "Open chat",
2557
2570
  closeChat: "Close chat",
2558
- dismiss: "Dismiss",
2559
- brandingLabel: "Chat by Singlebase"
2571
+ dismiss: "Dismiss"
2560
2572
  };
2561
- function Qt(n) {
2562
- return { ...Yt, ...n ?? {} };
2573
+ function ts(n) {
2574
+ return { ...es, ...n ?? {} };
2563
2575
  }
2564
- const Zt = /^\|.*\|$/, wt = /^\|[\s:|-]+\|$/, yt = /^!\[([^\]]*)\]\(([^)]*)\)$/, kt = /^(\s*)([-*+]|\d+[.)])\s+(.*)$/, $t = /^\[( |x|X)\]\s+/, es = /^(-{3,}|\*{3,}|_{3,})$/, ts = /^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*(.*)$/i, ss = ["note", "tip", "important", "warning", "caution"];
2565
- function is(n) {
2576
+ const ss = /^\|.*\|$/, $t = /^\|[\s:|-]+\|$/, Ct = /^!\[([^\]]*)\]\(([^)]*)\)$/, Tt = /^(\s*)([-*+]|\d+[.)])\s+(.*)$/, St = /^\[( |x|X)\]\s+/, is = /^(-{3,}|\*{3,}|_{3,})$/, as = /^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*(.*)$/i, rs = ["note", "tip", "important", "warning", "caution"];
2577
+ function os(n) {
2566
2578
  const e = [], t = (n ?? "").replace(/\r/g, "").split("```");
2567
2579
  return t.forEach((s, i) => {
2568
2580
  if (i % 2 === 1) {
2569
2581
  const a = s.indexOf(`
2570
- `), r = (a > -1 ? s.slice(0, a) : s).trim(), l = (a > -1 ? s.slice(a + 1) : "").replace(/\n$/, "");
2571
- e.push(as(r, l, i === t.length - 1));
2582
+ `), r = (a > -1 ? s.slice(0, a) : s).trim(), c = (a > -1 ? s.slice(a + 1) : "").replace(/\n$/, "");
2583
+ e.push(ns(r, c, i === t.length - 1));
2572
2584
  return;
2573
2585
  }
2574
2586
  for (const a of s.split(/\n{2,}/))
2575
- a.trim() && e.push(...Bt(a));
2587
+ a.trim() && e.push(...Kt(a));
2576
2588
  }), e;
2577
2589
  }
2578
- function as(n, e, t) {
2590
+ function ns(n, e, t) {
2579
2591
  const [s = "", ...i] = n.split(/\s+/), a = s.toLowerCase();
2580
2592
  if (a === "chart") {
2581
- const r = t ? null : os(e);
2593
+ const r = t ? null : cs(e);
2582
2594
  return r ? { type: "chart", spec: r } : { type: "pending", kind: "chart" };
2583
2595
  }
2584
2596
  if (a === "svg")
2585
2597
  return t || !/<svg[\s>]/i.test(e) ? { type: "pending", kind: "svg" } : { type: "svg", source: e.trim() };
2586
2598
  if (!t && (a === "csv" || a === "tsv")) {
2587
- const r = rs(e, a === "tsv" ? " " : ",");
2599
+ const r = ls(e, a === "tsv" ? " " : ",");
2588
2600
  if (r.length > 1)
2589
2601
  return { type: "table", head: r[0], rows: r.slice(1), align: r[0].map(() => null) };
2590
2602
  }
@@ -2594,40 +2606,40 @@ function as(n, e, t) {
2594
2606
  } catch {
2595
2607
  }
2596
2608
  if (a === "callout") {
2597
- const r = (i[0] ?? "").toLowerCase(), l = ss.includes(r);
2609
+ const r = (i[0] ?? "").toLowerCase(), c = rs.includes(r);
2598
2610
  return {
2599
2611
  type: "callout",
2600
- kind: l ? r : "note",
2601
- title: (l ? i.slice(1) : i).join(" "),
2612
+ kind: c ? r : "note",
2613
+ title: (c ? i.slice(1) : i).join(" "),
2602
2614
  text: e.trim()
2603
2615
  };
2604
2616
  }
2605
2617
  return { type: "code", lang: a || "code", text: e };
2606
2618
  }
2607
- function Bt(n) {
2619
+ function Kt(n) {
2608
2620
  const e = n.split(`
2609
2621
  `).filter((i) => i.trim()), t = e.map((i) => i.trim());
2610
- if (t.length > 1 && t.every((i) => Zt.test(i))) {
2611
- const i = (m) => m.replace(/^\||\|$/g, "").split("|").map((b) => b.trim()), a = t.findIndex((m) => wt.test(m)), r = a > -1 ? i(t[a]).map(
2612
- (m) => /^:-+:$/.test(m) ? "center" : /^-+:$/.test(m) ? "right" : /^:-+$/.test(m) ? "left" : null
2613
- ) : [], l = t.filter((m) => !wt.test(m)).map(i), c = l[0] ?? [];
2622
+ if (t.length > 1 && t.every((i) => ss.test(i))) {
2623
+ const i = (f) => f.replace(/^\||\|$/g, "").split("|").map((b) => b.trim()), a = t.findIndex((f) => $t.test(f)), r = a > -1 ? i(t[a]).map(
2624
+ (f) => /^:-+:$/.test(f) ? "center" : /^-+:$/.test(f) ? "right" : /^:-+$/.test(f) ? "left" : null
2625
+ ) : [], c = t.filter((f) => !$t.test(f)).map(i), l = c[0] ?? [];
2614
2626
  return [
2615
- { type: "table", head: c, rows: l.slice(1), align: c.map((m, b) => r[b] ?? null) }
2627
+ { type: "table", head: l, rows: c.slice(1), align: l.map((f, b) => r[b] ?? null) }
2616
2628
  ];
2617
2629
  }
2618
- if (t.length === 1 && es.test(t[0])) return [{ type: "hr" }];
2619
- if (t.every((i) => yt.test(i)))
2630
+ if (t.length === 1 && is.test(t[0])) return [{ type: "hr" }];
2631
+ if (t.every((i) => Ct.test(i)))
2620
2632
  return [
2621
2633
  {
2622
2634
  type: "img",
2623
2635
  images: t.map((i) => {
2624
- const a = i.match(yt);
2636
+ const a = i.match(Ct);
2625
2637
  return { alt: a[1], src: a[2] };
2626
2638
  })
2627
2639
  }
2628
2640
  ];
2629
2641
  if (t.every((i) => i.startsWith(">"))) {
2630
- const i = t.map((r) => r.replace(/^>\s?/, "")), a = i[0].match(ts);
2642
+ const i = t.map((r) => r.replace(/^>\s?/, "")), a = i[0].match(as);
2631
2643
  return a ? [
2632
2644
  {
2633
2645
  type: "callout",
@@ -2638,16 +2650,16 @@ function Bt(n) {
2638
2650
  }
2639
2651
  ] : [{ type: "quote", text: i.join(" ") }];
2640
2652
  }
2641
- if (kt.test(e[0])) {
2653
+ if (Tt.test(e[0])) {
2642
2654
  const i = [];
2643
2655
  for (const a of e) {
2644
- const r = a.match(kt);
2656
+ const r = a.match(Tt);
2645
2657
  if (r) {
2646
- const l = r[3].match($t);
2658
+ const c = r[3].match(St);
2647
2659
  i.push({
2648
- text: l ? r[3].replace($t, "") : r[3],
2660
+ text: c ? r[3].replace(St, "") : r[3],
2649
2661
  depth: Math.min(3, Math.floor(r[1].replace(/\t/g, " ").length / 2)),
2650
- checked: l ? l[1] !== " " : null
2662
+ checked: c ? c[1] !== " " : null
2651
2663
  });
2652
2664
  } else
2653
2665
  i[i.length - 1].text += ` ${a.trim()}`;
@@ -2660,26 +2672,26 @@ function Bt(n) {
2660
2672
  `);
2661
2673
  return [
2662
2674
  { type: "h", level: s[1].length, text: s[2] },
2663
- ...i ? Bt(i) : []
2675
+ ...i ? Kt(i) : []
2664
2676
  ];
2665
2677
  }
2666
2678
  return [{ type: "p", text: t.join(" ") }];
2667
2679
  }
2668
- function rs(n, e = ",") {
2669
- var c;
2680
+ function ls(n, e = ",") {
2681
+ var l;
2670
2682
  const t = [];
2671
2683
  let s = [], i = "", a = !1;
2672
2684
  const r = n.replace(/\r/g, "");
2673
- for (let m = 0; m < r.length; m++) {
2674
- const b = r[m];
2675
- a ? b === '"' && r[m + 1] === '"' ? (i += '"', m++) : b === '"' ? a = !1 : i += b : b === '"' && i === "" ? a = !0 : b === e ? (s.push(i.trim()), i = "") : b === `
2685
+ for (let f = 0; f < r.length; f++) {
2686
+ const b = r[f];
2687
+ a ? b === '"' && r[f + 1] === '"' ? (i += '"', f++) : b === '"' ? a = !1 : i += b : b === '"' && i === "" ? a = !0 : b === e ? (s.push(i.trim()), i = "") : b === `
2676
2688
  ` ? (s.push(i.trim()), s.some(Boolean) && t.push(s), s = [], i = "") : i += b;
2677
2689
  }
2678
2690
  s.push(i.trim()), s.some(Boolean) && t.push(s);
2679
- const l = ((c = t[0]) == null ? void 0 : c.length) ?? 0;
2680
- return t.map((m) => m.length < l ? [...m, ...Array(l - m.length).fill("")] : m);
2691
+ const c = ((l = t[0]) == null ? void 0 : l.length) ?? 0;
2692
+ return t.map((f) => f.length < c ? [...f, ...Array(c - f.length).fill("")] : f);
2681
2693
  }
2682
- function os(n) {
2694
+ function cs(n) {
2683
2695
  let e;
2684
2696
  try {
2685
2697
  e = JSON.parse(n);
@@ -2701,7 +2713,7 @@ function os(n) {
2701
2713
  series: t
2702
2714
  };
2703
2715
  }
2704
- const Ct = new RegExp(
2716
+ const It = new RegExp(
2705
2717
  [
2706
2718
  /\*\*([^*]+)\*\*/.source,
2707
2719
  // 1 bold
@@ -2722,16 +2734,16 @@ const Ct = new RegExp(
2722
2734
  ].join("|"),
2723
2735
  "g"
2724
2736
  );
2725
- function ns(n, e = 0) {
2737
+ function ds(n, e = 0) {
2726
2738
  const t = [];
2727
2739
  let s = 0, i;
2728
- Ct.lastIndex = 0;
2740
+ It.lastIndex = 0;
2729
2741
  const a = (r) => {
2730
2742
  if (!r) return;
2731
- const l = t[t.length - 1];
2732
- (l == null ? void 0 : l.type) === "text" ? l.text += r : t.push({ type: "text", text: r });
2743
+ const c = t[t.length - 1];
2744
+ (c == null ? void 0 : c.type) === "text" ? c.text += r : t.push({ type: "text", text: r });
2733
2745
  };
2734
- for (; i = Ct.exec(n); ) {
2746
+ for (; i = It.exec(n); ) {
2735
2747
  if (a(n.slice(s, i.index)), i[1] !== void 0) t.push({ type: "bold", text: i[1] });
2736
2748
  else if (i[2] !== void 0) t.push({ type: "strike", text: i[2] });
2737
2749
  else if (i[3] !== void 0) t.push({ type: "code", text: i[3] });
@@ -2740,14 +2752,14 @@ function ns(n, e = 0) {
2740
2752
  else if (i[7] !== void 0) t.push({ type: "italic", text: i[7] });
2741
2753
  else if (i[8] !== void 0) t.push({ type: "italic", text: i[8] });
2742
2754
  else {
2743
- const l = i[9].split(",").map((c) => Number(c.trim())).filter((c) => c >= 1 && c <= e);
2744
- e ? l.forEach((c) => t.push({ type: "cite", n: c })) : a(i[0]);
2755
+ const c = i[9].split(",").map((l) => Number(l.trim())).filter((l) => l >= 1 && l <= e);
2756
+ e ? c.forEach((l) => t.push({ type: "cite", n: l })) : a(i[0]);
2745
2757
  }
2746
2758
  s = i.index + i[0].length;
2747
2759
  }
2748
2760
  return a(n.slice(s)), t;
2749
2761
  }
2750
- function ls(n) {
2762
+ function ps(n) {
2751
2763
  if (((n ?? "").match(/```/g) ?? []).length % 2 === 1) return n;
2752
2764
  const e = n.lastIndexOf(`
2753
2765
 
@@ -2759,18 +2771,18 @@ function ls(n) {
2759
2771
  `), s = s.replace(/!?\[[^\]\n]*(\]\([^)\n]*)?$/, "");
2760
2772
  for (const r of ["**", "~~", "`"])
2761
2773
  if ((s.split(r).length - 1) % 2 === 1) {
2762
- const c = s.lastIndexOf(r);
2763
- s = s.slice(0, c) + s.slice(c + r.length);
2774
+ const l = s.lastIndexOf(r);
2775
+ s = s.slice(0, l) + s.slice(l + r.length);
2764
2776
  }
2765
2777
  return t + s;
2766
2778
  }
2767
- function Tt(n) {
2779
+ function Ot(n) {
2768
2780
  const e = /* @__PURE__ */ new Set();
2769
2781
  for (const t of (n ?? "").match(/\[(\d+(?:\s*,\s*\d+)*)\]/g) ?? [])
2770
2782
  t.replace(/[[\]]/g, "").split(",").forEach((s) => e.add(Number(s.trim())));
2771
2783
  return e;
2772
2784
  }
2773
- function cs(n) {
2785
+ function hs(n) {
2774
2786
  return [
2775
2787
  ["", ...n.series.map((e) => e.name)],
2776
2788
  ...n.labels.map((e, t) => [
@@ -2779,24 +2791,24 @@ function cs(n) {
2779
2791
  ])
2780
2792
  ];
2781
2793
  }
2782
- const St = (n) => n.map((e) => e.join(" · ")).join(`
2783
- `), ds = {
2794
+ const Mt = (n) => n.map((e) => e.join(" · ")).join(`
2795
+ `), us = {
2784
2796
  note: "Note",
2785
2797
  tip: "Tip",
2786
2798
  important: "Important",
2787
2799
  warning: "Warning",
2788
2800
  caution: "Caution"
2789
2801
  };
2790
- function ps(n, e) {
2802
+ function gs(n, e) {
2791
2803
  if (e === "rich") return n;
2792
2804
  const t = e === "plain";
2793
2805
  return n.map((s) => {
2794
2806
  switch (s.type) {
2795
2807
  case "chart": {
2796
- const [i, ...a] = cs(s.spec);
2808
+ const [i, ...a] = hs(s.spec);
2797
2809
  return t ? {
2798
2810
  type: "raw",
2799
- text: [s.spec.title, St([i, ...a])].filter(Boolean).join(`
2811
+ text: [s.spec.title, Mt([i, ...a])].filter(Boolean).join(`
2800
2812
  `)
2801
2813
  } : {
2802
2814
  type: "table",
@@ -2810,7 +2822,7 @@ function ps(n, e) {
2810
2822
  case "callout":
2811
2823
  return {
2812
2824
  type: "quote",
2813
- text: `**${s.title || ds[s.kind]}** ${s.text}`.trim()
2825
+ text: `**${s.title || us[s.kind]}** ${s.text}`.trim()
2814
2826
  };
2815
2827
  case "img":
2816
2828
  return {
@@ -2818,7 +2830,7 @@ function ps(n, e) {
2818
2830
  text: s.images.map((i) => `Image: ${i.alt || "untitled"}`).join(" · ")
2819
2831
  };
2820
2832
  case "table":
2821
- return t ? { type: "raw", text: St([s.head, ...s.rows]) } : s;
2833
+ return t ? { type: "raw", text: Mt([s.head, ...s.rows]) } : s;
2822
2834
  case "json":
2823
2835
  return t ? { type: "code", lang: "json", text: s.source } : s;
2824
2836
  case "svg":
@@ -2828,32 +2840,32 @@ function ps(n, e) {
2828
2840
  }
2829
2841
  });
2830
2842
  }
2831
- function Ot(n) {
2843
+ function zt(n) {
2832
2844
  const e = n ?? "", t = e.search(/FOLLOWUPS:/i);
2833
2845
  if (t < 0) return { text: e.trim(), followups: [] };
2834
2846
  const i = e.slice(t).replace(/^FOLLOWUPS:/i, "").split(/\||\n/).map((a) => a.replace(/^\s*(?:[-*↳→]|\d+[.)])\s*/, "").trim()).filter(Boolean).slice(0, 3);
2835
2847
  return { text: e.slice(0, t).trim(), followups: i };
2836
2848
  }
2837
- function hs(n) {
2849
+ function ms(n) {
2838
2850
  return (n ?? "").replace(
2839
2851
  /```(\w*)[\s\S]*?(```|$)/g,
2840
2852
  (e, t) => t === "chart" ? "[Chart] " : t === "svg" ? "[Drawing] " : "[Code] "
2841
2853
  ).replace(/!\[([^\]]*)\]\([^)]*\)/g, "[Image: $1]").replace(/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g, "$1").replace(/\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]/gi, "").replace(/[*#>`~]/g, "").replace(/\|/g, " ").replace(/\s?\[\d+(?:\s*,\s*\d+)*\]/g, "").replace(/\s+/g, " ").trim();
2842
2854
  }
2843
- function us(n, e = 48) {
2844
- const t = hs(n);
2855
+ function fs(n, e = 48) {
2856
+ const t = ms(n);
2845
2857
  if (t.length <= e) return t;
2846
2858
  const s = t.slice(0, e), i = s.lastIndexOf(" ");
2847
2859
  return (i > e / 2 ? s.slice(0, i) : s).trim();
2848
2860
  }
2849
- function gs(n) {
2861
+ function bs(n) {
2850
2862
  return String(n ?? "").split(`
2851
2863
  `)[0].trim().replace(/^["'“”‘’]+|["'“”‘’]+$/g, "").replace(/^title:\s*/i, "").replace(/[.!?:;,]+$/, "").trim().slice(0, 80);
2852
2864
  }
2853
- function It(n, e = !1) {
2865
+ function _t(n, e = !1) {
2854
2866
  return /^https?:\/\//i.test(n) ? !0 : e && /^(blob:|data:image\/)/i.test(n);
2855
2867
  }
2856
- const ms = 2e5, fs = /* @__PURE__ */ new Set([
2868
+ const xs = 2e5, vs = /* @__PURE__ */ new Set([
2857
2869
  "script",
2858
2870
  "foreignobject",
2859
2871
  "iframe",
@@ -2869,23 +2881,23 @@ const ms = 2e5, fs = /* @__PURE__ */ new Set([
2869
2881
  "handler",
2870
2882
  "listener"
2871
2883
  ]);
2872
- function bs(n) {
2873
- if (!n || n.length > ms || typeof DOMParser > "u") return null;
2884
+ function ws(n) {
2885
+ if (!n || n.length > xs || typeof DOMParser > "u") return null;
2874
2886
  const e = new DOMParser().parseFromString(n, "image/svg+xml"), t = e.documentElement;
2875
2887
  if (!t || t.nodeName.toLowerCase() !== "svg" || e.querySelector("parsererror"))
2876
2888
  return null;
2877
2889
  const s = (a) => {
2878
2890
  for (const r of Array.from(a.children)) {
2879
- const l = r.nodeName.toLowerCase();
2880
- if (fs.has(l)) r.remove();
2881
- else if (l === "a") {
2882
- const c = Array.from(r.childNodes);
2883
- r.replaceWith(...c), c.forEach((m) => m instanceof Element && s(m));
2891
+ const c = r.nodeName.toLowerCase();
2892
+ if (vs.has(c)) r.remove();
2893
+ else if (c === "a") {
2894
+ const l = Array.from(r.childNodes);
2895
+ r.replaceWith(...l), l.forEach((f) => f instanceof Element && s(f));
2884
2896
  } else s(r);
2885
2897
  }
2886
2898
  for (const r of Array.from(a.attributes)) {
2887
- const l = r.name.toLowerCase(), c = r.value.trim().toLowerCase(), m = (l === "href" || l.endsWith(":href")) && !c.startsWith("#"), b = c.includes("javascript:") || /url\(\s*['"]?(?!#)/.test(c);
2888
- (l.startsWith("on") || m || b) && a.removeAttribute(r.name);
2899
+ const c = r.name.toLowerCase(), l = r.value.trim().toLowerCase(), f = (c === "href" || c.endsWith(":href")) && !l.startsWith("#"), b = l.includes("javascript:") || /url\(\s*['"]?(?!#)/.test(l);
2900
+ (c.startsWith("on") || f || b) && a.removeAttribute(r.name);
2889
2901
  }
2890
2902
  };
2891
2903
  s(t);
@@ -2895,12 +2907,12 @@ function bs(n) {
2895
2907
  const i = new XMLSerializer().serializeToString(t);
2896
2908
  return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`;
2897
2909
  }
2898
- var Dt = Object.defineProperty, xs = Object.getOwnPropertyDescriptor, vs = (n, e, t) => e in n ? Dt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, g = (n, e, t, s) => {
2899
- for (var i = s > 1 ? void 0 : s ? xs(e, t) : e, a = n.length - 1, r; a >= 0; a--)
2910
+ var Pt = Object.defineProperty, ys = Object.getOwnPropertyDescriptor, ks = (n, e, t) => e in n ? Pt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, g = (n, e, t, s) => {
2911
+ for (var i = s > 1 ? void 0 : s ? ys(e, t) : e, a = n.length - 1, r; a >= 0; a--)
2900
2912
  (r = n[a]) && (i = (s ? r(e, t, i) : r(i)) || i);
2901
- return s && i && Dt(e, t, i), i;
2902
- }, ws = (n, e, t) => vs(n, e + "", t);
2903
- const Mt = [
2913
+ return s && i && Pt(e, t, i), i;
2914
+ }, $s = (n, e, t) => ks(n, e + "", t);
2915
+ const Lt = [
2904
2916
  "embed",
2905
2917
  "mode",
2906
2918
  "format",
@@ -2932,10 +2944,11 @@ const Mt = [
2932
2944
  "showTime",
2933
2945
  "showComposer",
2934
2946
  "footnote",
2935
- "brandingText",
2936
- "brandingUrl",
2937
2947
  "branding",
2938
2948
  "followups",
2949
+ "docsets",
2950
+ "attachmentsMode",
2951
+ "saveAttachments",
2939
2952
  "showFollowups",
2940
2953
  "showSources",
2941
2954
  "showNewChat",
@@ -2950,7 +2963,7 @@ const Mt = [
2950
2963
  "messages",
2951
2964
  "theme",
2952
2965
  "radius"
2953
- ], ft = {
2966
+ ], vt = {
2954
2967
  fromAttribute: (n) => {
2955
2968
  if (n)
2956
2969
  try {
@@ -2961,32 +2974,33 @@ const Mt = [
2961
2974
  }
2962
2975
  },
2963
2976
  toAttribute: (n) => JSON.stringify(n ?? null)
2964
- }, O = {
2977
+ }, I = {
2965
2978
  fromAttribute: (n) => n === null ? !0 : n !== "false",
2966
2979
  toAttribute: (n) => n ? null : "false"
2967
- }, ys = {
2980
+ }, Cs = {
2968
2981
  fromAttribute: (n) => n === null ? "auto" : n === "" || n === "true" ? "open" : n === "false" ? "closed" : ["auto", "open", "closed", "none"].includes(n) ? n : "auto",
2969
2982
  toAttribute: (n) => n === "auto" ? null : n
2970
- }, ks = 272, $s = 820, Cs = 940, zt = 5, _t = 512 * 1024, Ts = /\.(md|markdown|txt|csv|tsv|json|html?|ya?ml|xml|log)$/i, Ss = 5e3, Os = 200, Lt = 2e3, Is = {
2983
+ }, Ts = 272, Ss = 820, Is = 940, At = 5, jt = 512 * 1024, Os = /\.(md|markdown|txt|csv|tsv|json|html?|ya?ml|xml|log)$/i, Ms = 5e3, zs = 200, Nt = 2e3, _s = {
2971
2984
  note: "calloutNote",
2972
2985
  tip: "calloutTip",
2973
2986
  important: "calloutImportant",
2974
2987
  warning: "calloutWarning",
2975
2988
  caution: "calloutCaution"
2976
- }, Ms = 2600, N = [
2989
+ }, Ls = 2600, j = [
2977
2990
  "var(--c-ink)",
2978
2991
  "oklch(0.58 0.13 255)",
2979
2992
  "oklch(0.63 0.1 175)",
2980
2993
  "oklch(0.74 0.12 70)"
2981
- ], jt = {
2994
+ ], Rt = {
2982
2995
  chat: "Be helpful and concise. Use Markdown when it helps: headings, lists, **bold**, code blocks and tables.",
2983
- rag: "Answer ONLY from the sources provided with each message, numbered in the order given. Put a citation like [1] right after each claim it supports. If the sources don't cover the question, say so plainly."
2984
- }, zs = {
2996
+ rag: "Prefer the sources provided with each message, numbered in the order given, and put a citation like [1] right after each claim they support. If they don't cover the question, you may answer from general knowledge, but say clearly that it isn't from the sources.",
2997
+ kb: "Answer ONLY from the sources provided with each message, numbered in the order given. Put a citation like [1] right after each claim. Do not use outside knowledge. If the sources don't contain the answer, say that you can't find it in the available sources."
2998
+ }, As = {
2985
2999
  raw: "Reply in plain text. Don't use Markdown or any other markup.",
2986
3000
  plain: "Format with light Markdown only: short paragraphs, lists, **bold**, *italics*, `inline code`, code blocks and links. Don't use tables, charts, callouts, images or other special blocks.",
2987
3001
  advanced: `You can use Markdown: headings, lists, task lists, **bold**, *italics*, links, code blocks and pipe tables. For data, use a fenced "csv" block or a fenced "json" block. For a diagram or illustration, write a self-contained fenced "svg" block with a viewBox, and no scripts, links or external images. Don't use charts, callouts or images.`,
2988
3002
  rich: 'When the answer is about data, lead with one sentence stating the key finding, with key numbers in **bold**, then show the data visually. You can use Markdown: headings, lists, task lists, **bold**, *italics*, links, code blocks and pipe tables. For data, use a fenced "csv" block or a fenced "json" block. For a diagram or illustration, write a self-contained fenced "svg" block with a viewBox, and no scripts, links or external images. For trends and comparisons, use a fenced "chart" block containing only JSON: {"type":"bar"|"line","title":string,"unit":string,"labels":[string],"series":[{"name":string,"values":[number]}]}. For notes and warnings, use callouts: a quote starting with [!NOTE], [!TIP], [!IMPORTANT], [!WARNING] or [!CAUTION]. Images use ![alt](https://…).'
2989
- }, _s = "After the answer, on a final line write FOLLOWUPS: followed by three short follow-up questions the user might ask next, separated by |.", Nt = {
3003
+ }, js = "After the answer, on a final line write FOLLOWUPS: followed by three short follow-up questions the user might ask next, separated by |.", Et = {
2990
3004
  chat: [
2991
3005
  ["Write", "Draft a short welcome email for new users"],
2992
3006
  ["Explain", "Explain how refresh tokens work, simply"],
@@ -2998,21 +3012,27 @@ const Mt = [
2998
3012
  ["Summarize", "Summarize the most important points"],
2999
3013
  ["Find", "Where is the refund policy described?"],
3000
3014
  ["Explain", "Explain the setup steps in plain language"]
3015
+ ],
3016
+ kb: [
3017
+ ["Find", "Where is the refund policy described?"],
3018
+ ["How to", "How do I reset my password?"],
3019
+ ["Limits", "What are the plan limits?"],
3020
+ ["Policy", "What happens when my account is deleted?"]
3001
3021
  ]
3002
3022
  }, z = (n, e = "") => o`<svg class="i ${e}" viewBox="0 0 16 16" aria-hidden="true">${n}</svg>`, k = {
3003
3023
  sidebar: () => z(
3004
- I`<rect x="2" y="2.5" width="12" height="11" rx="1.5"></rect><path d="M6 2.5v11"></path>`
3024
+ O`<rect x="2" y="2.5" width="12" height="11" rx="1.5"></rect><path d="M6 2.5v11"></path>`
3005
3025
  ),
3006
- plus: () => z(I`<path d="M8 3v10M3 8h10"></path>`),
3007
- bookmark: (n = !1) => z(I`<path d="M4.5 2.5h7v11L8 11l-3.5 2.5z"></path>`, n ? "filled" : ""),
3008
- download: () => z(I`<path d="M8 2.5v8M4.5 7.5L8 11l3.5-3.5M2.5 13.5h11"></path>`),
3009
- trash: () => z(I`<path d="M2.5 4.5h11M6.5 4.5v-2h3v2M4 4.5l.7 9h6.6l.7-9"></path>`),
3010
- pencil: () => z(I`<path d="M10.5 2.5l3 3L6 13H3v-3z"></path>`),
3026
+ plus: () => z(O`<path d="M8 3v10M3 8h10"></path>`),
3027
+ bookmark: (n = !1) => z(O`<path d="M4.5 2.5h7v11L8 11l-3.5 2.5z"></path>`, n ? "filled" : ""),
3028
+ download: () => z(O`<path d="M8 2.5v8M4.5 7.5L8 11l3.5-3.5M2.5 13.5h11"></path>`),
3029
+ trash: () => z(O`<path d="M2.5 4.5h11M6.5 4.5v-2h3v2M4 4.5l.7 9h6.6l.7-9"></path>`),
3030
+ pencil: () => z(O`<path d="M10.5 2.5l3 3L6 13H3v-3z"></path>`),
3011
3031
  copy: () => z(
3012
- I`<rect x="5.5" y="5.5" width="8" height="8" rx="1.5"></rect><path d="M10.5 5.5v-2a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2"></path>`
3032
+ O`<rect x="5.5" y="5.5" width="8" height="8" rx="1.5"></rect><path d="M10.5 5.5v-2a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2"></path>`
3013
3033
  ),
3014
- raw: () => z(I`<path d="M5.5 4.5L2 8l3.5 3.5M10.5 4.5L14 8l-3.5 3.5"></path>`),
3015
- refresh: () => z(I`<path d="M13.5 8A5.5 5.5 0 1 1 11.9 4.1M13.5 2v3.5H10"></path>`),
3034
+ raw: () => z(O`<path d="M5.5 4.5L2 8l3.5 3.5M10.5 4.5L14 8l-3.5 3.5"></path>`),
3035
+ refresh: () => z(O`<path d="M13.5 8A5.5 5.5 0 1 1 11.9 4.1M13.5 2v3.5H10"></path>`),
3016
3036
  thumb: (n = !1) => o`<svg
3017
3037
  class="i"
3018
3038
  viewBox="0 0 16 16"
@@ -3023,15 +3043,15 @@ const Mt = [
3023
3043
  d="M5 7v6.5H2.5V7zM5 7l2.5-4.5a1.3 1.3 0 0 1 1.9 1.4L9 6.5h3.6a1 1 0 0 1 1 1.2l-1 4.8a1 1 0 0 1-1 .8H5"
3024
3044
  ></path>
3025
3045
  </svg>`,
3026
- expand: () => z(I`<path d="M9.5 2.5h4v4M13.5 2.5L9 7M6.5 13.5h-4v-4M2.5 13.5L7 9"></path>`),
3027
- restore: () => z(I`<path d="M13.5 6.5h-4v-4M9.5 6.5l4-4M2.5 9.5h4v4M6.5 9.5l-4 4"></path>`),
3028
- minimize: () => z(I`<path d="M4 8h8"></path>`),
3029
- close: () => z(I`<path d="M4 4l8 8M12 4l-8 8"></path>`),
3046
+ expand: () => z(O`<path d="M9.5 2.5h4v4M13.5 2.5L9 7M6.5 13.5h-4v-4M2.5 13.5L7 9"></path>`),
3047
+ restore: () => z(O`<path d="M13.5 6.5h-4v-4M9.5 6.5l4-4M2.5 9.5h4v4M6.5 9.5l-4 4"></path>`),
3048
+ minimize: () => z(O`<path d="M4 8h8"></path>`),
3049
+ close: () => z(O`<path d="M4 4l8 8M12 4l-8 8"></path>`),
3030
3050
  clip: () => z(
3031
- I`<path d="M13 7.5l-5.3 5.3a3 3 0 0 1-4.3-4.3L9 2.9a2 2 0 0 1 2.9 2.9L6.4 11.3a1 1 0 0 1-1.4-1.4L10 5"></path>`
3051
+ O`<path d="M13 7.5l-5.3 5.3a3 3 0 0 1-4.3-4.3L9 2.9a2 2 0 0 1 2.9 2.9L6.4 11.3a1 1 0 0 1-1.4-1.4L10 5"></path>`
3032
3052
  ),
3033
- up: () => z(I`<path d="M8 13V3M3.5 7.5L8 3l4.5 4.5"></path>`),
3034
- stop: () => z(I`<rect x="4.5" y="4.5" width="7" height="7" rx="1"></rect>`),
3053
+ up: () => z(O`<path d="M8 13V3M3.5 7.5L8 3l4.5 4.5"></path>`),
3054
+ stop: () => z(O`<rect x="4.5" y="4.5" width="7" height="7" rx="1"></rect>`),
3035
3055
  chat: () => o`<svg
3036
3056
  width="22"
3037
3057
  height="22"
@@ -3053,47 +3073,58 @@ const Mt = [
3053
3073
  <path d="M5 8l5 5 5-5"></path>
3054
3074
  </svg>`
3055
3075
  };
3056
- let Ls = 0;
3057
- const mt = () => `m${Date.now().toString(36)}${(Ls++).toString(36)}`;
3058
- function At(n) {
3076
+ let Ns = 0;
3077
+ const bt = () => `m${Date.now().toString(36)}${(Ns++).toString(36)}`;
3078
+ function Bt(n) {
3059
3079
  var t;
3060
3080
  const e = n;
3061
3081
  return (e == null ? void 0 : e.message) === "NOT_FOUND" || (e == null ? void 0 : e.code) === "NOT_FOUND" || ((t = e == null ? void 0 : e.details) == null ? void 0 : t.status) === 404;
3062
3082
  }
3063
- function js(n) {
3083
+ function Rs(n) {
3064
3084
  const e = n;
3065
3085
  return (e == null ? void 0 : e.code) || (e == null ? void 0 : e.message) || "UNKNOWN";
3066
3086
  }
3067
- const Ns = () => typeof matchMedia < "u" && matchMedia("(prefers-reduced-motion: reduce)").matches, ut = (n, e) => (Number.isInteger(n) ? n.toLocaleString("en-US") : n.toFixed(1)) + e, Rt = (n) => {
3087
+ const Es = () => typeof matchMedia < "u" && matchMedia("(prefers-reduced-motion: reduce)").matches, mt = (n, e) => (Number.isInteger(n) ? n.toLocaleString("en-US") : n.toFixed(1)) + e, xt = (n) => {
3068
3088
  const e = n.lastIndexOf(".");
3069
3089
  return e > 0 ? n.slice(e + 1, e + 5).toUpperCase() : "FILE";
3070
3090
  };
3071
- function gt(n, e) {
3072
- const t = n ?? {}, s = t.metadata && typeof t.metadata == "object" ? t.metadata : {}, i = (...l) => l.find((c) => typeof c == "string" && c.trim()), a = i(t.content, t.text, t.page_content, t.body, t.snippet, t.chunk, s.content) ?? JSON.stringify(t, null, 2), r = [t.score, t.relevance, t._score, s.score].find((l) => typeof l == "number");
3091
+ function ft(n, e) {
3092
+ const t = n ?? {}, s = t.metadata && typeof t.metadata == "object" ? t.metadata : {}, i = (...l) => l.find((f) => typeof f == "string" && f.trim()), a = i(t.content, t.text, t.page_content, t.body, t.snippet, t.chunk, s.content) ?? JSON.stringify(t, null, 2), r = [t.score, t.relevance, t._score, s.score].find((l) => typeof l == "number"), c = typeof t.n == "number" && t.n > 0 ? t.n : e;
3073
3093
  return {
3074
- n: e,
3075
- title: i(t.title, t.name, t.filename, s.title, s.name) ?? `Source ${e}`,
3076
- path: i(t.path, t.url, t.key, t.source, s.path, s.url) ?? "",
3094
+ n: c,
3095
+ title: i(t.title, t.name, t.filename, s.title, s.name) ?? `Source ${c}`,
3096
+ section: i(t.section, t.heading, s.section) ?? "",
3097
+ path: i(t.path, t.url, t.key, s.path, s.url) ?? "",
3077
3098
  collection: i(t.collection, t.namespace, t.dbname, s.collection) ?? "",
3078
3099
  updated: i(t.updated, t._modified_at, s.updated) ?? "",
3079
3100
  text: a,
3080
3101
  score: r === void 0 ? null : Math.max(0, Math.min(1, r))
3081
3102
  };
3082
3103
  }
3083
- function As(n) {
3104
+ function Dt(n) {
3105
+ return Array.isArray(n) ? n.filter((e) => e && typeof e == "object" && (e._id || e.id)).filter((e) => e.saved !== !1 && e.status !== "failed").map((e) => ({
3106
+ id: String(e._id ?? e.id),
3107
+ name: String(e.name ?? "file"),
3108
+ type: e.type,
3109
+ mime: e.mime,
3110
+ size: typeof e.size == "number" ? e.size : void 0,
3111
+ status: e.status
3112
+ })) : [];
3113
+ }
3114
+ function Bs(n) {
3084
3115
  const e = [], t = [];
3085
3116
  for (const s of n)
3086
- if (/\.csv$/i.test(s.name)) e.push({ type: "csv", data: s.content });
3117
+ if (/\.csv$/i.test(s.name)) e.push({ source: "csv", data: s.content });
3087
3118
  else if (/\.json$/i.test(s.name))
3088
3119
  try {
3089
- e.push({ type: "json", data: JSON.parse(s.content) });
3120
+ e.push({ source: "json", data: JSON.parse(s.content) });
3090
3121
  } catch {
3091
3122
  t.push({ title: s.name, content: s.content });
3092
3123
  }
3093
3124
  else t.push({ title: s.name, content: s.content });
3094
- return t.length && e.push({ type: "docs", payload: { documents: t } }), e;
3125
+ return t.length && e.push({ source: "docs", payload: { documents: t } }), e;
3095
3126
  }
3096
- function Rs(n) {
3127
+ function Ds(n) {
3097
3128
  const e = n ? Date.parse(n) : NaN;
3098
3129
  if (Number.isNaN(e)) return "older";
3099
3130
  const t = /* @__PURE__ */ new Date();
@@ -3101,49 +3132,49 @@ function Rs(n) {
3101
3132
  const s = 864e5;
3102
3133
  return e >= t.getTime() ? "today" : e >= t.getTime() - s ? "yesterday" : e >= t.getTime() - 7 * s ? "week" : "older";
3103
3134
  }
3104
- var A, R, E, B, D, F, U, P, K, W, J, H, G, q, V, X, Y, Q, Z, ee, te, se, ie, ae, re, oe, ne, le, ce, de, pe, he, ue, ge, me, fe, be, xe, ve, we, ye, ke, $e, Ce, Te, Se, Oe, Ie, Me, ze, _e, Le, je, Ne, Ae, Re, Ee, Be, De, Fe, Ue, Pe, Ke, We, Je, He, Ge, qe, Ve, Xe, Ye, Qe, Ze, et, tt, st, it, at, rt, ot, nt, lt, ct, dt, pt, ht, Et;
3105
- let d = (Et = class extends Kt {
3135
+ var N, R, E, B, D, F, K, P, U, W, H, J, G, q, V, X, Y, Q, Z, ee, te, se, ie, ae, re, oe, ne, le, ce, de, pe, he, ue, ge, me, fe, be, xe, ve, we, ye, ke, $e, Ce, Te, Se, Ie, Oe, Me, ze, _e, Le, Ae, je, Ne, Re, Ee, Be, De, Fe, Ke, Pe, Ue, We, He, Je, Ge, qe, Ve, Xe, Ye, Qe, Ze, et, tt, st, it, at, rt, ot, nt, lt, ct, dt, pt, ht, ut, gt, Ft;
3136
+ let d = (Ft = class extends Jt {
3106
3137
  constructor() {
3107
3138
  super(...arguments);
3108
- h(this, A, null);
3139
+ h(this, N, null);
3109
3140
  h(this, R, {});
3110
3141
  h(this, E);
3111
3142
  h(this, B);
3112
3143
  h(this, D, "chat");
3113
3144
  h(this, F, "advanced");
3114
- h(this, U, {});
3145
+ h(this, K, {});
3115
3146
  h(this, P, null);
3116
- h(this, K, null);
3147
+ h(this, U, null);
3117
3148
  h(this, W, "subtle");
3118
- h(this, J, !0);
3119
- h(this, H, !0);
3149
+ h(this, H, "");
3150
+ h(this, J, "payload");
3120
3151
  h(this, G, !0);
3121
3152
  h(this, q, !0);
3122
3153
  h(this, V, !0);
3123
3154
  h(this, X, !0);
3124
3155
  h(this, Y, !0);
3125
- h(this, Q, "");
3126
- h(this, Z, {});
3127
- h(this, ee, "");
3128
- h(this, te, []);
3156
+ h(this, Q, !0);
3157
+ h(this, Z, !0);
3158
+ h(this, ee, !0);
3159
+ h(this, te, "");
3129
3160
  h(this, se, {});
3130
- h(this, ie, "page");
3131
- h(this, ae, "right");
3132
- h(this, re, "auto");
3133
- h(this, oe, !0);
3134
- h(this, ne, "");
3135
- h(this, le, "Assistant");
3136
- h(this, ce, "");
3161
+ h(this, ie, "");
3162
+ h(this, ae, []);
3163
+ h(this, re, {});
3164
+ h(this, oe, "page");
3165
+ h(this, ne, "right");
3166
+ h(this, le, "auto");
3167
+ h(this, ce, !0);
3137
3168
  h(this, de, "");
3138
- h(this, pe, "");
3139
- h(this, he);
3169
+ h(this, pe, "Assistant");
3170
+ h(this, he, "");
3140
3171
  h(this, ue, "");
3141
3172
  h(this, ge, "");
3142
- h(this, me, !1);
3143
- h(this, fe, !1);
3144
- h(this, be, !0);
3145
- h(this, xe, !0);
3146
- h(this, ve, !0);
3173
+ h(this, me);
3174
+ h(this, fe, "");
3175
+ h(this, be, "");
3176
+ h(this, xe, !1);
3177
+ h(this, ve, !1);
3147
3178
  h(this, we, !0);
3148
3179
  h(this, ye, !0);
3149
3180
  h(this, ke, !0);
@@ -3151,46 +3182,48 @@ let d = (Et = class extends Kt {
3151
3182
  h(this, Ce, !0);
3152
3183
  h(this, Te, !0);
3153
3184
  h(this, Se, !0);
3154
- h(this, Oe);
3155
- h(this, Ie, !1);
3185
+ h(this, Ie, !0);
3186
+ h(this, Oe, !0);
3156
3187
  h(this, Me, !0);
3157
- h(this, ze, "");
3158
- h(this, _e, "");
3159
- h(this, Le, []);
3188
+ h(this, ze);
3189
+ h(this, _e, !1);
3190
+ h(this, Le, !0);
3191
+ h(this, Ae, []);
3160
3192
  h(this, je, "idle");
3161
3193
  h(this, Ne, null);
3162
- h(this, Ae, "");
3163
- h(this, Re, !1);
3164
- h(this, Ee, []);
3165
- h(this, Be, !1);
3166
- h(this, De, "");
3167
- h(this, Fe, !1);
3168
- h(this, Ue, "");
3169
- h(this, Pe, []);
3170
- h(this, Ke, "");
3171
- h(this, We, null);
3172
- h(this, Je, 0);
3194
+ h(this, Re, "");
3195
+ h(this, Ee, !1);
3196
+ h(this, Be, []);
3197
+ h(this, De, !1);
3198
+ h(this, Fe, "");
3199
+ h(this, Ke, !1);
3200
+ h(this, Pe, "");
3201
+ h(this, Ue, []);
3202
+ h(this, We, "");
3173
3203
  h(this, He, null);
3174
- h(this, Ge, !1);
3175
- h(this, qe, "");
3204
+ h(this, Je, 0);
3205
+ h(this, Ge, null);
3206
+ h(this, qe, !1);
3176
3207
  h(this, Ve, "");
3177
- h(this, Xe, !1);
3178
- h(this, Ye, "");
3179
- h(this, Qe, null);
3180
- h(this, Ze, "");
3181
- h(this, et, /* @__PURE__ */ new Set());
3208
+ h(this, Xe, "");
3209
+ h(this, Ye, !1);
3210
+ h(this, Qe, "");
3211
+ h(this, Ze, null);
3212
+ h(this, et, "");
3182
3213
  h(this, tt, /* @__PURE__ */ new Set());
3183
- h(this, st, !1);
3184
- h(this, it, /* @__PURE__ */ new Map());
3185
- h(this, at, "");
3186
- h(this, rt, !1);
3187
- h(this, ot, !1);
3214
+ h(this, st, /* @__PURE__ */ new Set());
3215
+ h(this, it, []);
3216
+ h(this, at, !1);
3217
+ h(this, rt, /* @__PURE__ */ new Map());
3218
+ h(this, ot, "");
3188
3219
  h(this, nt, !1);
3189
3220
  h(this, lt, !1);
3190
3221
  h(this, ct, !1);
3191
3222
  h(this, dt, !1);
3192
3223
  h(this, pt, !1);
3193
3224
  h(this, ht, !1);
3225
+ h(this, ut, !1);
3226
+ h(this, gt, !1);
3194
3227
  M(this, "run", 0);
3195
3228
  M(this, "abort", null);
3196
3229
  M(this, "revealTimer");
@@ -3213,10 +3246,10 @@ let d = (Et = class extends Kt {
3213
3246
  });
3214
3247
  }
3215
3248
  get client() {
3216
- return p(this, A);
3249
+ return p(this, N);
3217
3250
  }
3218
3251
  set client(e) {
3219
- u(this, A, e);
3252
+ u(this, N, e);
3220
3253
  }
3221
3254
  get messages() {
3222
3255
  return p(this, R);
@@ -3249,10 +3282,10 @@ let d = (Et = class extends Kt {
3249
3282
  u(this, F, e);
3250
3283
  }
3251
3284
  get renderers() {
3252
- return p(this, U);
3285
+ return p(this, K);
3253
3286
  }
3254
3287
  set renderers(e) {
3255
- u(this, U, e);
3288
+ u(this, K, e);
3256
3289
  }
3257
3290
  get beforeSend() {
3258
3291
  return p(this, P);
@@ -3261,10 +3294,10 @@ let d = (Et = class extends Kt {
3261
3294
  u(this, P, e);
3262
3295
  }
3263
3296
  get afterParse() {
3264
- return p(this, K);
3297
+ return p(this, U);
3265
3298
  }
3266
3299
  set afterParse(e) {
3267
- u(this, K, e);
3300
+ u(this, U, e);
3268
3301
  }
3269
3302
  get glow() {
3270
3303
  return p(this, W);
@@ -3272,258 +3305,264 @@ let d = (Et = class extends Kt {
3272
3305
  set glow(e) {
3273
3306
  u(this, W, e);
3274
3307
  }
3275
- get followups() {
3276
- return p(this, J);
3277
- }
3278
- set followups(e) {
3279
- u(this, J, e);
3280
- }
3281
- get showSources() {
3308
+ get docsets() {
3282
3309
  return p(this, H);
3283
3310
  }
3284
- set showSources(e) {
3311
+ set docsets(e) {
3285
3312
  u(this, H, e);
3286
3313
  }
3287
- get showNewChat() {
3314
+ get attachmentsMode() {
3315
+ return p(this, J);
3316
+ }
3317
+ set attachmentsMode(e) {
3318
+ u(this, J, e);
3319
+ }
3320
+ get saveAttachments() {
3288
3321
  return p(this, G);
3289
3322
  }
3290
- set showNewChat(e) {
3323
+ set saveAttachments(e) {
3291
3324
  u(this, G, e);
3292
3325
  }
3293
- get showBookmarked() {
3326
+ get followups() {
3294
3327
  return p(this, q);
3295
3328
  }
3296
- set showBookmarked(e) {
3329
+ set followups(e) {
3297
3330
  u(this, q, e);
3298
3331
  }
3299
- get showFollowups() {
3332
+ get showSources() {
3300
3333
  return p(this, V);
3301
3334
  }
3302
- set showFollowups(e) {
3335
+ set showSources(e) {
3303
3336
  u(this, V, e);
3304
3337
  }
3305
- get allowSearch() {
3338
+ get showNewChat() {
3306
3339
  return p(this, X);
3307
3340
  }
3308
- set allowSearch(e) {
3341
+ set showNewChat(e) {
3309
3342
  u(this, X, e);
3310
3343
  }
3311
- get autoTitle() {
3344
+ get showBookmarked() {
3312
3345
  return p(this, Y);
3313
3346
  }
3314
- set autoTitle(e) {
3347
+ set showBookmarked(e) {
3315
3348
  u(this, Y, e);
3316
3349
  }
3317
- get model() {
3350
+ get showFollowups() {
3318
3351
  return p(this, Q);
3319
3352
  }
3320
- set model(e) {
3353
+ set showFollowups(e) {
3321
3354
  u(this, Q, e);
3322
3355
  }
3323
- get params() {
3356
+ get allowSearch() {
3324
3357
  return p(this, Z);
3325
3358
  }
3326
- set params(e) {
3359
+ set allowSearch(e) {
3327
3360
  u(this, Z, e);
3328
3361
  }
3329
- get systemMessage() {
3362
+ get autoTitle() {
3330
3363
  return p(this, ee);
3331
3364
  }
3332
- set systemMessage(e) {
3365
+ set autoTitle(e) {
3333
3366
  u(this, ee, e);
3334
3367
  }
3335
- get retrieval() {
3368
+ get model() {
3336
3369
  return p(this, te);
3337
3370
  }
3338
- set retrieval(e) {
3371
+ set model(e) {
3339
3372
  u(this, te, e);
3340
3373
  }
3341
- get metadata() {
3374
+ get params() {
3342
3375
  return p(this, se);
3343
3376
  }
3344
- set metadata(e) {
3377
+ set params(e) {
3345
3378
  u(this, se, e);
3346
3379
  }
3347
- get embed() {
3380
+ get systemMessage() {
3348
3381
  return p(this, ie);
3349
3382
  }
3350
- set embed(e) {
3383
+ set systemMessage(e) {
3351
3384
  u(this, ie, e);
3352
3385
  }
3353
- get position() {
3386
+ get retrieval() {
3354
3387
  return p(this, ae);
3355
3388
  }
3356
- set position(e) {
3389
+ set retrieval(e) {
3357
3390
  u(this, ae, e);
3358
3391
  }
3359
- get sidebar() {
3392
+ get metadata() {
3360
3393
  return p(this, re);
3361
3394
  }
3362
- set sidebar(e) {
3395
+ set metadata(e) {
3363
3396
  u(this, re, e);
3364
3397
  }
3365
- get showTitle() {
3398
+ get embed() {
3366
3399
  return p(this, oe);
3367
3400
  }
3368
- set showTitle(e) {
3401
+ set embed(e) {
3369
3402
  u(this, oe, e);
3370
3403
  }
3371
- get chatIdAttr() {
3404
+ get position() {
3372
3405
  return p(this, ne);
3373
3406
  }
3374
- set chatIdAttr(e) {
3407
+ set position(e) {
3375
3408
  u(this, ne, e);
3376
3409
  }
3377
- get assistantName() {
3410
+ get sidebar() {
3378
3411
  return p(this, le);
3379
3412
  }
3380
- set assistantName(e) {
3413
+ set sidebar(e) {
3381
3414
  u(this, le, e);
3382
3415
  }
3383
- get logoUrl() {
3416
+ get showTitle() {
3384
3417
  return p(this, ce);
3385
3418
  }
3386
- set logoUrl(e) {
3419
+ set showTitle(e) {
3387
3420
  u(this, ce, e);
3388
3421
  }
3389
- get heading() {
3422
+ get chatIdAttr() {
3390
3423
  return p(this, de);
3391
3424
  }
3392
- set heading(e) {
3425
+ set chatIdAttr(e) {
3393
3426
  u(this, de, e);
3394
3427
  }
3395
- get description() {
3428
+ get assistantName() {
3396
3429
  return p(this, pe);
3397
3430
  }
3398
- set description(e) {
3431
+ set assistantName(e) {
3399
3432
  u(this, pe, e);
3400
3433
  }
3401
- get eyebrow() {
3434
+ get logoUrl() {
3402
3435
  return p(this, he);
3403
3436
  }
3404
- set eyebrow(e) {
3437
+ set logoUrl(e) {
3405
3438
  u(this, he, e);
3406
3439
  }
3407
- get prompts() {
3440
+ get heading() {
3408
3441
  return p(this, ue);
3409
3442
  }
3410
- set prompts(e) {
3443
+ set heading(e) {
3411
3444
  u(this, ue, e);
3412
3445
  }
3413
- get bubbleText() {
3446
+ get description() {
3414
3447
  return p(this, ge);
3415
3448
  }
3416
- set bubbleText(e) {
3449
+ set description(e) {
3417
3450
  u(this, ge, e);
3418
3451
  }
3419
- get greetingBubble() {
3452
+ get eyebrow() {
3420
3453
  return p(this, me);
3421
3454
  }
3422
- set greetingBubble(e) {
3455
+ set eyebrow(e) {
3423
3456
  u(this, me, e);
3424
3457
  }
3425
- get unreadBadge() {
3458
+ get prompts() {
3426
3459
  return p(this, fe);
3427
3460
  }
3428
- set unreadBadge(e) {
3461
+ set prompts(e) {
3429
3462
  u(this, fe, e);
3430
3463
  }
3431
- get allowUpload() {
3464
+ get bubbleText() {
3432
3465
  return p(this, be);
3433
3466
  }
3434
- set allowUpload(e) {
3467
+ set bubbleText(e) {
3435
3468
  u(this, be, e);
3436
3469
  }
3437
- get allowExport() {
3470
+ get greetingBubble() {
3438
3471
  return p(this, xe);
3439
3472
  }
3440
- set allowExport(e) {
3473
+ set greetingBubble(e) {
3441
3474
  u(this, xe, e);
3442
3475
  }
3443
- get allowCopy() {
3476
+ get unreadBadge() {
3444
3477
  return p(this, ve);
3445
3478
  }
3446
- set allowCopy(e) {
3479
+ set unreadBadge(e) {
3447
3480
  u(this, ve, e);
3448
3481
  }
3449
- get allowRegenerate() {
3482
+ get allowUpload() {
3450
3483
  return p(this, we);
3451
3484
  }
3452
- set allowRegenerate(e) {
3485
+ set allowUpload(e) {
3453
3486
  u(this, we, e);
3454
3487
  }
3455
- get allowBookmark() {
3488
+ get allowExport() {
3456
3489
  return p(this, ye);
3457
3490
  }
3458
- set allowBookmark(e) {
3491
+ set allowExport(e) {
3459
3492
  u(this, ye, e);
3460
3493
  }
3461
- get allowDelete() {
3494
+ get allowCopy() {
3462
3495
  return p(this, ke);
3463
3496
  }
3464
- set allowDelete(e) {
3497
+ set allowCopy(e) {
3465
3498
  u(this, ke, e);
3466
3499
  }
3467
- get allowRename() {
3500
+ get allowRegenerate() {
3468
3501
  return p(this, $e);
3469
3502
  }
3470
- set allowRename(e) {
3503
+ set allowRegenerate(e) {
3471
3504
  u(this, $e, e);
3472
3505
  }
3473
- get allowFeedback() {
3506
+ get allowBookmark() {
3474
3507
  return p(this, Ce);
3475
3508
  }
3476
- set allowFeedback(e) {
3509
+ set allowBookmark(e) {
3477
3510
  u(this, Ce, e);
3478
3511
  }
3479
- get showComposer() {
3512
+ get allowDelete() {
3480
3513
  return p(this, Te);
3481
3514
  }
3482
- set showComposer(e) {
3515
+ set allowDelete(e) {
3483
3516
  u(this, Te, e);
3484
3517
  }
3485
- get showTime() {
3518
+ get allowRename() {
3486
3519
  return p(this, Se);
3487
3520
  }
3488
- set showTime(e) {
3521
+ set allowRename(e) {
3489
3522
  u(this, Se, e);
3490
3523
  }
3491
- get footnote() {
3492
- return p(this, Oe);
3493
- }
3494
- set footnote(e) {
3495
- u(this, Oe, e);
3496
- }
3497
- get allowRaw() {
3524
+ get allowFeedback() {
3498
3525
  return p(this, Ie);
3499
3526
  }
3500
- set allowRaw(e) {
3527
+ set allowFeedback(e) {
3501
3528
  u(this, Ie, e);
3502
3529
  }
3503
- get branding() {
3530
+ get showComposer() {
3531
+ return p(this, Oe);
3532
+ }
3533
+ set showComposer(e) {
3534
+ u(this, Oe, e);
3535
+ }
3536
+ get showTime() {
3504
3537
  return p(this, Me);
3505
3538
  }
3506
- set branding(e) {
3539
+ set showTime(e) {
3507
3540
  u(this, Me, e);
3508
3541
  }
3509
- get brandingText() {
3542
+ get footnote() {
3510
3543
  return p(this, ze);
3511
3544
  }
3512
- set brandingText(e) {
3545
+ set footnote(e) {
3513
3546
  u(this, ze, e);
3514
3547
  }
3515
- get brandingUrl() {
3548
+ get allowRaw() {
3516
3549
  return p(this, _e);
3517
3550
  }
3518
- set brandingUrl(e) {
3551
+ set allowRaw(e) {
3519
3552
  u(this, _e, e);
3520
3553
  }
3521
- get chatList() {
3554
+ get branding() {
3522
3555
  return p(this, Le);
3523
3556
  }
3524
- set chatList(e) {
3557
+ set branding(e) {
3525
3558
  u(this, Le, e);
3526
3559
  }
3560
+ get chatList() {
3561
+ return p(this, Ae);
3562
+ }
3563
+ set chatList(e) {
3564
+ u(this, Ae, e);
3565
+ }
3527
3566
  get listState() {
3528
3567
  return p(this, je);
3529
3568
  }
@@ -3537,64 +3576,64 @@ let d = (Et = class extends Kt {
3537
3576
  u(this, Ne, e);
3538
3577
  }
3539
3578
  get chatTitle() {
3540
- return p(this, Ae);
3579
+ return p(this, Re);
3541
3580
  }
3542
3581
  set chatTitle(e) {
3543
- u(this, Ae, e);
3582
+ u(this, Re, e);
3544
3583
  }
3545
3584
  get bookmarked() {
3546
- return p(this, Re);
3585
+ return p(this, Ee);
3547
3586
  }
3548
3587
  set bookmarked(e) {
3549
- u(this, Re, e);
3588
+ u(this, Ee, e);
3550
3589
  }
3551
3590
  get msgs() {
3552
- return p(this, Ee);
3591
+ return p(this, Be);
3553
3592
  }
3554
3593
  set msgs(e) {
3555
- u(this, Ee, e);
3594
+ u(this, Be, e);
3556
3595
  }
3557
3596
  get loadingThread() {
3558
- return p(this, Be);
3597
+ return p(this, De);
3559
3598
  }
3560
3599
  set loadingThread(e) {
3561
- u(this, Be, e);
3600
+ u(this, De, e);
3562
3601
  }
3563
3602
  get threadError() {
3564
- return p(this, De);
3603
+ return p(this, Fe);
3565
3604
  }
3566
3605
  set threadError(e) {
3567
- u(this, De, e);
3606
+ u(this, Fe, e);
3568
3607
  }
3569
3608
  get busy() {
3570
- return p(this, Fe);
3609
+ return p(this, Ke);
3571
3610
  }
3572
3611
  set busy(e) {
3573
- u(this, Fe, e);
3612
+ u(this, Ke, e);
3574
3613
  }
3575
3614
  get draft() {
3576
- return p(this, Ue);
3615
+ return p(this, Pe);
3577
3616
  }
3578
3617
  set draft(e) {
3579
- u(this, Ue, e);
3618
+ u(this, Pe, e);
3580
3619
  }
3581
3620
  get files() {
3582
- return p(this, Pe);
3621
+ return p(this, Ue);
3583
3622
  }
3584
3623
  set files(e) {
3585
- u(this, Pe, e);
3624
+ u(this, Ue, e);
3586
3625
  }
3587
3626
  get search() {
3588
- return p(this, Ke);
3627
+ return p(this, We);
3589
3628
  }
3590
3629
  set search(e) {
3591
- u(this, Ke, e);
3630
+ u(this, We, e);
3592
3631
  }
3593
3632
  get sidebarOpen() {
3594
- return p(this, We);
3633
+ return p(this, He);
3595
3634
  }
3596
3635
  set sidebarOpen(e) {
3597
- u(this, We, e);
3636
+ u(this, He, e);
3598
3637
  }
3599
3638
  get width() {
3600
3639
  return p(this, Je);
@@ -3603,137 +3642,143 @@ let d = (Et = class extends Kt {
3603
3642
  u(this, Je, e);
3604
3643
  }
3605
3644
  get panel() {
3606
- return p(this, He);
3645
+ return p(this, Ge);
3607
3646
  }
3608
3647
  set panel(e) {
3609
- u(this, He, e);
3648
+ u(this, Ge, e);
3610
3649
  }
3611
3650
  get menuOpen() {
3612
- return p(this, Ge);
3651
+ return p(this, qe);
3613
3652
  }
3614
3653
  set menuOpen(e) {
3615
- u(this, Ge, e);
3654
+ u(this, qe, e);
3616
3655
  }
3617
3656
  get editingKey() {
3618
- return p(this, qe);
3657
+ return p(this, Ve);
3619
3658
  }
3620
3659
  set editingKey(e) {
3621
- u(this, qe, e);
3660
+ u(this, Ve, e);
3622
3661
  }
3623
3662
  get editDraft() {
3624
- return p(this, Ve);
3663
+ return p(this, Xe);
3625
3664
  }
3626
3665
  set editDraft(e) {
3627
- u(this, Ve, e);
3666
+ u(this, Xe, e);
3628
3667
  }
3629
3668
  get editingTitle() {
3630
- return p(this, Xe);
3669
+ return p(this, Ye);
3631
3670
  }
3632
3671
  set editingTitle(e) {
3633
- u(this, Xe, e);
3672
+ u(this, Ye, e);
3634
3673
  }
3635
3674
  get renamingId() {
3636
- return p(this, Ye);
3675
+ return p(this, Qe);
3637
3676
  }
3638
3677
  set renamingId(e) {
3639
- u(this, Ye, e);
3678
+ u(this, Qe, e);
3640
3679
  }
3641
3680
  get toast() {
3642
- return p(this, Qe);
3681
+ return p(this, Ze);
3643
3682
  }
3644
3683
  set toast(e) {
3645
- u(this, Qe, e);
3684
+ u(this, Ze, e);
3646
3685
  }
3647
3686
  get copiedKey() {
3648
- return p(this, Ze);
3687
+ return p(this, et);
3649
3688
  }
3650
3689
  set copiedKey(e) {
3651
- u(this, Ze, e);
3690
+ u(this, et, e);
3652
3691
  }
3653
3692
  get retrievalOpen() {
3654
- return p(this, et);
3693
+ return p(this, tt);
3655
3694
  }
3656
3695
  set retrievalOpen(e) {
3657
- u(this, et, e);
3696
+ u(this, tt, e);
3658
3697
  }
3659
3698
  get rawKeys() {
3660
- return p(this, tt);
3699
+ return p(this, st);
3661
3700
  }
3662
3701
  set rawKeys(e) {
3663
- u(this, tt, e);
3702
+ u(this, st, e);
3703
+ }
3704
+ get savedFiles() {
3705
+ return p(this, it);
3706
+ }
3707
+ set savedFiles(e) {
3708
+ u(this, it, e);
3664
3709
  }
3665
3710
  get hasSidebarContent() {
3666
- return p(this, st);
3711
+ return p(this, at);
3667
3712
  }
3668
3713
  set hasSidebarContent(e) {
3669
- u(this, st, e);
3714
+ u(this, at, e);
3670
3715
  }
3671
3716
  get sorts() {
3672
- return p(this, it);
3717
+ return p(this, rt);
3673
3718
  }
3674
3719
  set sorts(e) {
3675
- u(this, it, e);
3720
+ u(this, rt, e);
3676
3721
  }
3677
3722
  get arrivedKey() {
3678
- return p(this, at);
3723
+ return p(this, ot);
3679
3724
  }
3680
3725
  set arrivedKey(e) {
3681
- u(this, at, e);
3726
+ u(this, ot, e);
3682
3727
  }
3683
3728
  get dragging() {
3684
- return p(this, rt);
3729
+ return p(this, nt);
3685
3730
  }
3686
3731
  set dragging(e) {
3687
- u(this, rt, e);
3732
+ u(this, nt, e);
3688
3733
  }
3689
3734
  get showJump() {
3690
- return p(this, ot);
3735
+ return p(this, lt);
3691
3736
  }
3692
3737
  set showJump(e) {
3693
- u(this, ot, e);
3738
+ u(this, lt, e);
3694
3739
  }
3695
3740
  get offline() {
3696
- return p(this, nt);
3741
+ return p(this, ct);
3697
3742
  }
3698
3743
  set offline(e) {
3699
- u(this, nt, e);
3744
+ u(this, ct, e);
3700
3745
  }
3701
3746
  get isOpen() {
3702
- return p(this, lt);
3747
+ return p(this, dt);
3703
3748
  }
3704
3749
  set isOpen(e) {
3705
- u(this, lt, e);
3750
+ u(this, dt, e);
3706
3751
  }
3707
3752
  get expanded() {
3708
- return p(this, ct);
3753
+ return p(this, pt);
3709
3754
  }
3710
3755
  set expanded(e) {
3711
- u(this, ct, e);
3756
+ u(this, pt, e);
3712
3757
  }
3713
3758
  get bubble() {
3714
- return p(this, dt);
3759
+ return p(this, ht);
3715
3760
  }
3716
3761
  set bubble(e) {
3717
- u(this, dt, e);
3762
+ u(this, ht, e);
3718
3763
  }
3719
3764
  get seen() {
3720
- return p(this, pt);
3765
+ return p(this, ut);
3721
3766
  }
3722
3767
  set seen(e) {
3723
- u(this, pt, e);
3768
+ u(this, ut, e);
3724
3769
  }
3725
3770
  get mobile() {
3726
- return p(this, ht);
3771
+ return p(this, gt);
3727
3772
  }
3728
3773
  set mobile(e) {
3729
- u(this, ht, e);
3774
+ u(this, gt, e);
3730
3775
  }
3731
3776
  get msg() {
3732
- return Qt(this.messages);
3777
+ return ts(this.messages);
3733
3778
  }
3734
3779
  /** An explicit `.client`, else the page default. */
3735
3780
  get resolvedClient() {
3736
- return this.client ?? Ht() ?? null;
3781
+ return this.client ?? Vt() ?? null;
3737
3782
  }
3738
3783
  /** The open conversation's id, or null for a new chat. */
3739
3784
  get chatId() {
@@ -3744,6 +3789,15 @@ let d = (Et = class extends Kt {
3744
3789
  return this.msgs;
3745
3790
  }
3746
3791
  /** `format`, falling back to the default for anything unknown. */
3792
+ /** `docsets` as a clean list of ids. */
3793
+ get docsetIds() {
3794
+ const e = this.docsets, t = Array.isArray(e) ? e : String(e ?? "").split(/[\s,]+/);
3795
+ return [...new Set(t.map((s) => String(s).trim()).filter(Boolean))];
3796
+ }
3797
+ /** The files this chat keeps on the service. */
3798
+ get attachments() {
3799
+ return this.savedFiles;
3800
+ }
3747
3801
  get formatLevel() {
3748
3802
  return ["raw", "plain", "advanced", "rich"].includes(this.format) ? this.format : "advanced";
3749
3803
  }
@@ -3763,7 +3817,7 @@ let d = (Et = class extends Kt {
3763
3817
  if (!e) return;
3764
3818
  const t = this;
3765
3819
  "client" in e && (this.client = e.client ?? null);
3766
- for (const s of Mt)
3820
+ for (const s of Lt)
3767
3821
  s in e && (t[s] = e[s]);
3768
3822
  e.chatId && e.chatId !== this.activeId && (this.hasUpdated ? this.openChat(e.chatId) : this.chatIdAttr = e.chatId);
3769
3823
  }
@@ -3781,7 +3835,7 @@ let d = (Et = class extends Kt {
3781
3835
  return {
3782
3836
  client: this.client,
3783
3837
  chatId: this.activeId ?? "",
3784
- ...Object.fromEntries(Mt.map((t) => [t, e[t]]))
3838
+ ...Object.fromEntries(Lt.map((t) => [t, e[t]]))
3785
3839
  };
3786
3840
  }
3787
3841
  // ── lifecycle ─────────────────────────────────────────────
@@ -3828,22 +3882,22 @@ let d = (Et = class extends Kt {
3828
3882
  this.dispatchEvent(new CustomEvent(e, { detail: t, bubbles: !0, composed: !0 }));
3829
3883
  }
3830
3884
  get docked() {
3831
- return this.embed === "page" && this.width >= $s;
3885
+ return this.embed === "page" && this.width >= Ss;
3832
3886
  }
3833
3887
  get panelDocked() {
3834
- const e = this.docked && this.sidebarOpen ? ks : 0;
3835
- return this.width - e >= Cs;
3888
+ const e = this.docked && this.sidebarOpen ? Ts : 0;
3889
+ return this.width - e >= Is;
3836
3890
  }
3837
3891
  // ── public API ────────────────────────────────────────────
3838
3892
  /** Starts a new, empty conversation. */
3839
3893
  newChat() {
3840
- this.halt(), this.pendingChatId = "", this.loadingThread = !1, this.activeId = null, this.chatTitle = "", this.bookmarked = !1, this.msgs = [], this.threadError = "", this.resetViewState(), this.focusNext = "textarea.input";
3894
+ this.halt(), this.pendingChatId = "", this.savedFiles = [], this.loadingThread = !1, this.activeId = null, this.chatTitle = "", this.bookmarked = !1, this.msgs = [], this.threadError = "", this.resetViewState(), this.focusNext = "textarea.input";
3841
3895
  }
3842
3896
  /** Opens a saved conversation. */
3843
3897
  async openChat(e) {
3844
3898
  const t = this.resolvedClient;
3845
3899
  if (!e) return;
3846
- this.halt();
3900
+ this.halt(), this.savedFiles = [];
3847
3901
  const s = this.chatList.find((a) => a._id === e);
3848
3902
  if (this.activeId = e, this.chatTitle = (s == null ? void 0 : s.title) ?? "", this.bookmarked = !!(s != null && s.bookmarked), this.msgs = [], this.threadError = "", this.resetViewState(), !t) {
3849
3903
  this.pendingChatId = e, this.loadingThread = !0;
@@ -3856,10 +3910,10 @@ let d = (Et = class extends Kt {
3856
3910
  _id: e
3857
3911
  });
3858
3912
  if (i !== this.run) return;
3859
- this.chatTitle = (a == null ? void 0 : a.title) ?? "", this.bookmarked = !!(a != null && a.bookmarked), this.msgs = ((a == null ? void 0 : a.messages) ?? []).filter((r) => r && (r.role === "user" || r.role === "assistant")).map((r) => this.fromServer(r)), this.upsertChat({ ...s, ...a, _id: e }), this.stick = !0, this.scrollToBottom();
3913
+ this.chatTitle = (a == null ? void 0 : a.title) ?? "", this.bookmarked = !!(a != null && a.bookmarked), this.msgs = ((a == null ? void 0 : a.messages) ?? []).filter((r) => r && (r.role === "user" || r.role === "assistant")).map((r) => this.fromServer(r)), this.savedFiles = Dt(a == null ? void 0 : a.attachments), this.upsertChat({ ...s, ...a, _id: e }), this.stick = !0, this.scrollToBottom();
3860
3914
  } catch (a) {
3861
3915
  if (i !== this.run) return;
3862
- At(a) ? (this.chatList = this.chatList.filter((r) => r._id !== e), this.newChat(), this.showToast(this.msg.errNotFound)) : this.threadError = this.msg.errLoad;
3916
+ Bt(a) ? (this.chatList = this.chatList.filter((r) => r._id !== e), this.newChat(), this.showToast(this.msg.errNotFound)) : this.threadError = this.msg.errLoad;
3863
3917
  } finally {
3864
3918
  i === this.run && (this.loadingThread = !1);
3865
3919
  }
@@ -3881,15 +3935,15 @@ let d = (Et = class extends Kt {
3881
3935
  }
3882
3936
  /** Downloads the open conversation, or copies it as Markdown. */
3883
3937
  exportChat(e = "md") {
3884
- var _;
3938
+ var L;
3885
3939
  if (!this.msgs.length) return;
3886
3940
  this.menuOpen = !1;
3887
- const t = this.chatTitle || this.msg.untitled, s = (x) => x.role === "user" ? this.msg.you : this.assistantName, i = (x) => new Date(x || Date.now()).toLocaleString(), a = (x) => x.sources.map((T, $) => {
3888
- const j = gt(T, $ + 1);
3889
- return `[${j.n}] ${j.title}${j.path ? ` — ${j.path}` : ""}`;
3890
- }), r = (x) => (x.attachments ?? []).map((T) => T.name);
3891
- let l, c = "text/markdown", m = "md";
3892
- if (e === "json" ? (l = JSON.stringify(
3941
+ const t = this.chatTitle || this.msg.untitled, s = (x) => x.role === "user" ? this.msg.you : this.assistantName, i = (x) => new Date(x || Date.now()).toLocaleString(), a = (x) => x.sources.map((S, $) => {
3942
+ const A = ft(S, $ + 1);
3943
+ return `[${A.n}] ${A.title}${A.path ? ` — ${A.path}` : ""}`;
3944
+ }), r = (x) => (x.attachments ?? []).map((S) => S.name);
3945
+ let c, l = "text/markdown", f = "md";
3946
+ if (e === "json" ? (c = JSON.stringify(
3893
3947
  {
3894
3948
  exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
3895
3949
  id: this.activeId,
@@ -3907,7 +3961,7 @@ let d = (Et = class extends Kt {
3907
3961
  },
3908
3962
  null,
3909
3963
  2
3910
- ), c = "application/json", m = "json") : e === "txt" ? (l = `${t}
3964
+ ), l = "application/json", f = "json") : e === "txt" ? (c = `${t}
3911
3965
  ${"=".repeat(t.length)}
3912
3966
 
3913
3967
  ` + this.msgs.map(
@@ -3922,7 +3976,7 @@ ${a(x).join(`
3922
3976
  `)
3923
3977
  ).join(`
3924
3978
 
3925
- `), c = "text/plain", m = "txt") : l = `# ${t}
3979
+ `), l = "text/plain", f = "txt") : c = `# ${t}
3926
3980
 
3927
3981
  ` + this.msgs.map(
3928
3982
  (x) => [
@@ -3931,7 +3985,7 @@ ${a(x).join(`
3931
3985
  x.content,
3932
3986
  a(x).length ? `**Sources**
3933
3987
 
3934
- ${a(x).map((T) => `- ${T}`).join(`
3988
+ ${a(x).map((S) => `- ${S}`).join(`
3935
3989
  `)}` : ""
3936
3990
  ].filter(Boolean).join(`
3937
3991
 
@@ -3942,12 +3996,12 @@ ${a(x).map((T) => `- ${T}`).join(`
3942
3996
 
3943
3997
  `) + `
3944
3998
  `, this.emit("singlebase-chat-export", { chatId: this.activeId, format: e }), e === "copy") {
3945
- (_ = navigator.clipboard) == null || _.writeText(l).catch(() => {
3999
+ (L = navigator.clipboard) == null || L.writeText(c).catch(() => {
3946
4000
  }), this.showToast(this.msg.copiedMarkdown);
3947
4001
  return;
3948
4002
  }
3949
- const C = `${t.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "chat"}-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.${m}`, S = URL.createObjectURL(new Blob([l], { type: c })), w = document.createElement("a");
3950
- w.href = S, w.download = C, document.body.appendChild(w), w.click(), w.remove(), setTimeout(() => URL.revokeObjectURL(S), 2e3), this.showToast(L(this.msg.exported, { name: C }));
4003
+ const C = `${t.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "chat"}-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.${f}`, T = URL.createObjectURL(new Blob([c], { type: l })), w = document.createElement("a");
4004
+ w.href = T, w.download = C, document.body.appendChild(w), w.click(), w.remove(), setTimeout(() => URL.revokeObjectURL(T), 2e3), this.showToast(_(this.msg.exported, { name: C }));
3951
4005
  }
3952
4006
  /** Inline and launcher: fill the window. */
3953
4007
  expand() {
@@ -3967,7 +4021,7 @@ ${a(x).map((T) => `- ${T}`).join(`
3967
4021
  // ── turns ─────────────────────────────────────────────────
3968
4022
  userMessage(e, t = []) {
3969
4023
  return {
3970
- key: mt(),
4024
+ key: bt(),
3971
4025
  id: null,
3972
4026
  role: "user",
3973
4027
  content: e,
@@ -3982,24 +4036,37 @@ ${a(x).map((T) => `- ${T}`).join(`
3982
4036
  systemPrompt() {
3983
4037
  return [
3984
4038
  this.systemMessage,
3985
- jt[this.mode] ?? jt.chat,
3986
- zs[this.formatLevel],
3987
- this.followups ? _s : ""
4039
+ Rt[this.mode] ?? Rt.chat,
4040
+ As[this.formatLevel],
4041
+ this.followups ? js : ""
3988
4042
  ].filter(Boolean).join(`
3989
4043
 
3990
4044
  `);
3991
4045
  }
3992
4046
  payloadFor(e) {
3993
4047
  const t = { message: e.content, format: "markdown" };
3994
- this.activeId ? t._id = this.activeId : (t.title = us(e.content), t.system_message = this.systemPrompt()), this.model && (t.model = this.model), Object.keys(this.params ?? {}).length && (t.params = this.params);
3995
- const s = (e.attachments ?? []).map((a) => a.name);
3996
- (Object.keys(this.metadata ?? {}).length || s.length) && (t.metadata = { ...this.metadata, ...s.length ? { attachments: s } : {} });
3997
- const i = [...this.retrieval ?? [], ...As(e.attachments ?? [])];
3998
- return i.length && (t.retrieval = i), t;
4048
+ this.activeId ? t._id = this.activeId : (t.title = fs(e.content), t.system_message = this.systemPrompt()), t.mode = this.mode, this.model && (t.model = this.model), Object.keys(this.params ?? {}).length && (t.params = this.params);
4049
+ const s = e.attachments ?? [], i = this.attachmentsMode === "payload";
4050
+ i && s.length && (t.attachments = s.map((l) => ({
4051
+ type: "content",
4052
+ content: l.content,
4053
+ name: l.name,
4054
+ ...l.mime ? { mime: l.mime } : {},
4055
+ size: l.size,
4056
+ save_attachment: this.saveAttachments
4057
+ })));
4058
+ const a = i ? [] : s.map((l) => l.name);
4059
+ (Object.keys(this.metadata ?? {}).length || a.length) && (t.metadata = { ...this.metadata, ...a.length ? { attachments: a } : {} });
4060
+ const r = this.docsetIds, c = [
4061
+ ...r.length ? [{ source: "docset", ids: r }] : [],
4062
+ ...this.retrieval ?? [],
4063
+ ...i ? [] : Bs(s)
4064
+ ];
4065
+ return c.length && (t.retrieval = c), t;
3999
4066
  }
4000
4067
  async runTurn(e) {
4001
4068
  const t = {
4002
- key: mt(),
4069
+ key: bt(),
4003
4070
  id: null,
4004
4071
  role: "assistant",
4005
4072
  content: "",
@@ -4018,51 +4085,53 @@ ${a(x).map((T) => `- ${T}`).join(`
4018
4085
  const i = ++this.run, a = new AbortController();
4019
4086
  this.abort = a;
4020
4087
  const r = !this.activeId;
4021
- let l = this.payloadFor(e);
4088
+ let c = this.payloadFor(e);
4022
4089
  if (this.beforeSend) {
4023
- let c;
4090
+ let l;
4024
4091
  try {
4025
- c = await this.beforeSend(l, { chatId: this.activeId, isNew: r, message: e });
4092
+ l = await this.beforeSend(c, { chatId: this.activeId, isNew: r, message: e });
4026
4093
  } catch (b) {
4027
- c = b;
4094
+ l = b;
4028
4095
  }
4029
4096
  if (i !== this.run) return;
4030
- if (c === !1) {
4097
+ if (l === !1) {
4031
4098
  this.msgs = this.msgs.filter((b) => b !== e && b !== t), this.draft = e.content, this.busy = !1, this.abort = null;
4032
4099
  return;
4033
4100
  }
4034
- if (!(!!c && typeof c == "object" && typeof c.message == "string") || !c.message.trim()) {
4101
+ if (!(!!l && typeof l == "object" && typeof l.message == "string") || !l.message.trim()) {
4035
4102
  console.error(
4036
4103
  "[singlebase-chat] beforeSend must return the request object (with a message) or false to cancel; the message was not sent.",
4037
- c
4104
+ l
4038
4105
  ), this.failTurn(t, this.msg.errGeneric, "BEFORE_SEND_INVALID"), this.busy = !1, this.abort = null;
4039
4106
  return;
4040
4107
  }
4041
- l = c;
4108
+ c = l;
4042
4109
  }
4043
4110
  try {
4044
- const c = await s.llm.call("chat", l, { signal: a.signal }), m = (c == null ? void 0 : c._id) || (c == null ? void 0 : c.chat_id) || this.activeId;
4045
- if (r && m && this.upsertChat({
4046
- _id: m,
4047
- title: (c == null ? void 0 : c.title) || l.title,
4048
- bookmarked: !!(c != null && c.bookmarked),
4111
+ const l = await s.llm.call("chat", c, { signal: a.signal }), f = (l == null ? void 0 : l._id) || (l == null ? void 0 : l.chat_id) || this.activeId;
4112
+ if (r && f && this.upsertChat({
4113
+ _id: f,
4114
+ title: (l == null ? void 0 : l.title) || c.title,
4115
+ bookmarked: !!(l != null && l.bookmarked),
4049
4116
  _modified_at: (/* @__PURE__ */ new Date()).toISOString()
4050
4117
  }), i !== this.run) return;
4051
- m && (this.activeId = m), r ? (this.chatTitle = (c == null ? void 0 : c.title) || l.title, this.bookmarked = !!(c != null && c.bookmarked)) : m && this.touchChat(m);
4052
- const b = (c == null ? void 0 : c.message) ?? {}, C = typeof b.content == "string" ? b.content : (c == null ? void 0 : c.json) !== void 0 ? JSON.stringify(c.json, null, 2) : "", { text: S, followups: w } = Ot(C);
4053
- e.id = b.reply_to ?? null, Object.assign(t, {
4118
+ f && (this.activeId = f), r && (this.chatTitle = (l == null ? void 0 : l.title) || c.title, this.bookmarked = !!(l != null && l.bookmarked));
4119
+ const b = (l == null ? void 0 : l.message) ?? {}, C = typeof b.content == "string" ? b.content : (l == null ? void 0 : l.json) !== void 0 ? JSON.stringify(l.json, null, 2) : "", { text: T, followups: w } = zt(C);
4120
+ e.id = b.reply_to ?? null, this.applyAttachmentResults(l == null ? void 0 : l.attachments), Object.assign(t, {
4054
4121
  id: b._id ?? null,
4055
- content: S,
4122
+ content: T,
4056
4123
  sources: Array.isArray(b.sources) ? b.sources : [],
4057
4124
  followups: w,
4058
4125
  execTime: typeof b.exec_time == "number" ? b.exec_time : void 0,
4059
4126
  model: b.model,
4060
4127
  at: Date.now()
4061
- }), this.emit("singlebase-chat-response", { chatId: m, message: t }), await this.reveal(t, i), r && m && this.autoTitle && this.retitle(m, e.content, t.content);
4062
- } catch (c) {
4128
+ }), this.emit("singlebase-chat-response", { chatId: f, message: t }), await this.reveal(t, i), r && f && this.autoTitle && this.retitle(f, e.content, t.content);
4129
+ } catch (l) {
4063
4130
  if (i !== this.run) return;
4064
- const m = At(c);
4065
- m && (this.chatList = this.chatList.filter((b) => b._id !== this.activeId), this.activeId = null), this.failTurn(t, m ? this.msg.errNotFound : this.msg.errGeneric, js(c));
4131
+ const f = Bt(l);
4132
+ f && (this.chatList = this.chatList.filter((T) => T._id !== this.activeId), this.activeId = null);
4133
+ const b = Rs(l), C = f ? this.msg.errNotFound : b === "KB_SOURCE_REQUIRED" ? this.msg.errKbSource : this.msg.errGeneric;
4134
+ this.failTurn(t, C, b);
4066
4135
  } finally {
4067
4136
  i === this.run && (this.busy = !1, this.abort = null, this.stick && this.scrollToBottom());
4068
4137
  }
@@ -4078,20 +4147,20 @@ ${a(x).map((T) => `- ${T}`).join(`
4078
4147
  const s = e.content.length, i = () => {
4079
4148
  e.phase = "done", this.msgs = [...this.msgs], this.arrivedKey = e.key, this.later(() => {
4080
4149
  this.arrivedKey === e.key && (this.arrivedKey = "");
4081
- }, Ms), this.stick ? this.scrollToBottom() : this.showJump = !0;
4150
+ }, Ls), this.stick ? this.scrollToBottom() : this.showJump = !0;
4082
4151
  };
4083
- if (!s || Ns())
4152
+ if (!s || Es())
4084
4153
  return i(), Promise.resolve();
4085
4154
  const a = e.content, r = Math.max(4, Math.ceil(s / 90));
4086
- let l = 0;
4087
- return e.phase = "streaming", e.content = "", new Promise((c) => {
4155
+ let c = 0;
4156
+ return e.phase = "streaming", e.content = "", new Promise((l) => {
4088
4157
  this.revealTimer = setInterval(() => {
4089
4158
  if (t !== this.run) {
4090
- clearInterval(this.revealTimer), c();
4159
+ clearInterval(this.revealTimer), l();
4091
4160
  return;
4092
4161
  }
4093
- if (l = Math.min(s, l + r), e.content = a.slice(0, l), l >= s) {
4094
- clearInterval(this.revealTimer), i(), c();
4162
+ if (c = Math.min(s, c + r), e.content = a.slice(0, c), c >= s) {
4163
+ clearInterval(this.revealTimer), i(), l();
4095
4164
  return;
4096
4165
  }
4097
4166
  this.msgs = [...this.msgs], this.stick && this.scrollToBottom();
@@ -4112,7 +4181,7 @@ ${a(x).map((T) => `- ${T}`).join(`
4112
4181
  assistant: ${s.slice(0, 1500)}`,
4113
4182
  custom_instructions: "Write a concise title (3–6 words, sentence case, no quotes, no trailing punctuation) for this conversation.",
4114
4183
  format: "text"
4115
- }), r = gs(a == null ? void 0 : a.result);
4184
+ }), r = bs(a == null ? void 0 : a.result);
4116
4185
  if (!r || this.renamed.has(e)) return;
4117
4186
  await i.llm.call("update_chat", { _id: e, title: r }), this.applyTitle(e, r, !0);
4118
4187
  } catch {
@@ -4133,7 +4202,7 @@ assistant: ${s.slice(0, 1500)}`,
4133
4202
  }
4134
4203
  async renameChat(e, t) {
4135
4204
  var a, r;
4136
- const s = t.trim().slice(0, 80), i = ((a = this.chatList.find((l) => l._id === e)) == null ? void 0 : a.title) ?? this.chatTitle;
4205
+ const s = t.trim().slice(0, 80), i = ((a = this.chatList.find((c) => c._id === e)) == null ? void 0 : a.title) ?? this.chatTitle;
4137
4206
  if (!(!s || s === i)) {
4138
4207
  this.renamed.add(e), this.applyTitle(e, s, !1);
4139
4208
  try {
@@ -4144,9 +4213,9 @@ assistant: ${s.slice(0, 1500)}`,
4144
4213
  }
4145
4214
  }
4146
4215
  fromServer(e) {
4147
- const t = e.role === "assistant", { text: s, followups: i } = t ? Ot(String(e.content ?? "")) : { text: String(e.content ?? ""), followups: [] };
4216
+ const t = e.role === "assistant", { text: s, followups: i } = t ? zt(String(e.content ?? "")) : { text: String(e.content ?? ""), followups: [] };
4148
4217
  return {
4149
- key: mt(),
4218
+ key: bt(),
4150
4219
  id: e._id ?? null,
4151
4220
  role: t ? "assistant" : "user",
4152
4221
  content: s,
@@ -4172,13 +4241,24 @@ assistant: ${s.slice(0, 1500)}`,
4172
4241
  }
4173
4242
  }
4174
4243
  }
4244
+ /**
4245
+ * A new chat goes on top. A chat already in the list is updated where it is,
4246
+ * keeping its dates, so opening or using a chat never reorders the list; the
4247
+ * next load from the server brings the fresh order.
4248
+ */
4175
4249
  upsertChat(e) {
4176
- const t = this.chatList.filter((i) => i._id !== e._id), s = this.chatList.find((i) => i._id === e._id);
4177
- this.chatList = [{ ...s, ...e }, ...t];
4178
- }
4179
- touchChat(e) {
4180
- const t = this.chatList.find((s) => s._id === e);
4181
- t && this.upsertChat({ ...t, _modified_at: (/* @__PURE__ */ new Date()).toISOString() });
4250
+ const t = this.chatList.findIndex((a) => a._id === e._id);
4251
+ if (t < 0) {
4252
+ this.chatList = [e, ...this.chatList];
4253
+ return;
4254
+ }
4255
+ const s = this.chatList[t], i = [...this.chatList];
4256
+ i[t] = {
4257
+ ...s,
4258
+ ...e,
4259
+ _created_at: s._created_at ?? e._created_at,
4260
+ _modified_at: s._modified_at ?? e._modified_at
4261
+ }, this.chatList = i;
4182
4262
  }
4183
4263
  // ── actions ───────────────────────────────────────────────
4184
4264
  resetViewState() {
@@ -4213,6 +4293,30 @@ assistant: ${s.slice(0, 1500)}`,
4213
4293
  const t = new Set(this.rawKeys);
4214
4294
  t.has(e) ? t.delete(e) : t.add(e), this.rawKeys = t;
4215
4295
  }
4296
+ /** Adds newly saved files, and says which ones the service couldn't read. */
4297
+ applyAttachmentResults(e) {
4298
+ if (!Array.isArray(e)) return;
4299
+ const t = Dt(e).filter((i) => !this.savedFiles.some((a) => a.id === i.id));
4300
+ t.length && (this.savedFiles = [...this.savedFiles, ...t]);
4301
+ const s = e.filter((i) => (i == null ? void 0 : i.status) === "failed").map((i) => String(i.name ?? "file"));
4302
+ s.length && this.showToast(_(this.msg.attachmentFailed, { name: s.join(", ") }));
4303
+ }
4304
+ /** Removes a file the service keeps on this chat. */
4305
+ async removeSavedFile(e) {
4306
+ var i;
4307
+ const t = this.activeId;
4308
+ if (!t) return;
4309
+ const s = this.savedFiles;
4310
+ this.savedFiles = s.filter((a) => a !== e);
4311
+ try {
4312
+ await ((i = this.resolvedClient) == null ? void 0 : i.llm.call("remove_chat_attachment", {
4313
+ _id: t,
4314
+ attachment_id: e.id
4315
+ }));
4316
+ } catch {
4317
+ this.activeId === t && (this.savedFiles = s), this.showToast(this.msg.errGeneric);
4318
+ }
4319
+ }
4216
4320
  copy(e, t) {
4217
4321
  var s;
4218
4322
  (s = navigator.clipboard) == null || s.writeText(t).catch(() => {
@@ -4238,10 +4342,10 @@ assistant: ${s.slice(0, 1500)}`,
4238
4342
  }
4239
4343
  async toggleChatBookmark(e) {
4240
4344
  var a, r;
4241
- const t = ((a = this.chatList.find((l) => l._id === e)) == null ? void 0 : a.bookmarked) ?? (e === this.activeId ? this.bookmarked : !1), s = !t, i = (l) => {
4345
+ const t = ((a = this.chatList.find((c) => c._id === e)) == null ? void 0 : a.bookmarked) ?? (e === this.activeId ? this.bookmarked : !1), s = !t, i = (c) => {
4242
4346
  this.chatList = this.chatList.map(
4243
- (c) => c._id === e ? { ...c, bookmarked: l } : c
4244
- ), e === this.activeId && (this.bookmarked = l);
4347
+ (l) => l._id === e ? { ...l, bookmarked: c } : l
4348
+ ), e === this.activeId && (this.bookmarked = c);
4245
4349
  };
4246
4350
  i(s), this.showToast(s ? this.msg.chatBookmarked : this.msg.chatUnbookmarked), this.emit("singlebase-chat-bookmark", { chatId: e, bookmarked: s });
4247
4351
  try {
@@ -4299,7 +4403,7 @@ assistant: ${s.slice(0, 1500)}`,
4299
4403
  const s = { key: Date.now(), text: e, ...t };
4300
4404
  this.toast = s, this.toastTimer = setTimeout(() => {
4301
4405
  this.toast === s && this.flushToast();
4302
- }, Ss);
4406
+ }, Ms);
4303
4407
  }
4304
4408
  /** Ends the current toast, committing whatever it was holding back. */
4305
4409
  flushToast() {
@@ -4318,21 +4422,26 @@ assistant: ${s.slice(0, 1500)}`,
4318
4422
  if (!t.length) return;
4319
4423
  const s = [];
4320
4424
  for (const i of t) {
4321
- if (this.files.length + s.length >= zt) {
4322
- this.showToast(L(this.msg.tooManyFiles, { n: zt }));
4425
+ if (this.files.length + s.length >= At) {
4426
+ this.showToast(_(this.msg.tooManyFiles, { n: At }));
4323
4427
  break;
4324
4428
  }
4325
- if (!Ts.test(i.name) && !i.type.startsWith("text/")) {
4326
- this.showToast(L(this.msg.fileType, { name: i.name }));
4429
+ if (!Os.test(i.name) && !i.type.startsWith("text/")) {
4430
+ this.showToast(_(this.msg.fileType, { name: i.name }));
4327
4431
  continue;
4328
4432
  }
4329
- if (i.size > _t) {
4433
+ if (i.size > jt) {
4330
4434
  this.showToast(
4331
- L(this.msg.fileTooLarge, { name: i.name, size: vt(_t) })
4435
+ _(this.msg.fileTooLarge, { name: i.name, size: kt(jt) })
4332
4436
  );
4333
4437
  continue;
4334
4438
  }
4335
- s.push({ name: i.name, size: i.size, content: await i.text() });
4439
+ s.push({
4440
+ name: i.name,
4441
+ size: i.size,
4442
+ content: await i.text(),
4443
+ ...i.type ? { mime: i.type } : {}
4444
+ });
4336
4445
  }
4337
4446
  s.length && (this.files = [...this.files, ...s], this.emit("singlebase-chat-files", {
4338
4447
  files: s.map(({ name: i, size: a }) => ({ name: i, size: a }))
@@ -4399,7 +4508,7 @@ assistant: ${s.slice(0, 1500)}`,
4399
4508
  this.mobile ? "full" : ""
4400
4509
  ].join(" "), s = this.isOpen ? o`<div class=${t} role="dialog" aria-label=${this.assistantName} part="frame">
4401
4510
  ${this.renderWorkspace()}
4402
- </div>` : f, i = this.bubble && !this.isOpen ? o`<div class="bubble" part="bubble">
4511
+ </div>` : m, i = this.bubble && !this.isOpen ? o`<div class="bubble" part="bubble">
4403
4512
  <button type="button" class="bubble-text" @click=${() => this.open()}>
4404
4513
  ${this.bubbleText || e.bubbleText}
4405
4514
  </button>
@@ -4412,7 +4521,7 @@ assistant: ${s.slice(0, 1500)}`,
4412
4521
  >
4413
4522
  ${k.close()}
4414
4523
  </button>
4415
- </div>` : f, r = this.isOpen && (this.expanded || this.mobile) ? f : o`<button
4524
+ </div>` : m, r = this.isOpen && (this.expanded || this.mobile) ? m : o`<button
4416
4525
  type="button"
4417
4526
  class="launcher-btn"
4418
4527
  part="launcher"
@@ -4421,22 +4530,22 @@ assistant: ${s.slice(0, 1500)}`,
4421
4530
  @click=${() => this.isOpen ? this.close() : this.open()}
4422
4531
  >
4423
4532
  ${this.isOpen ? k.chevronDown() : k.chat()}
4424
- ${this.unreadBadge && !this.seen && !this.isOpen ? o`<span class="badge"></span>` : f}
4533
+ ${this.unreadBadge && !this.seen && !this.isOpen ? o`<span class="badge"></span>` : m}
4425
4534
  </button>`;
4426
4535
  return o`${s}${i}${r}`;
4427
4536
  }
4428
4537
  renderWorkspace() {
4429
4538
  const e = !this.docked;
4430
4539
  return o`<div class="root" @keydown=${this.onKeydown}>
4431
- ${this.sidebarOpen && e ? o`<div class="scrim" @click=${() => this.sidebarOpen = !1}></div>` : f}
4432
- ${this.sidebarOpen && this.sidebar !== "none" ? this.renderSidebar(e) : f}
4540
+ ${this.sidebarOpen && e ? o`<div class="scrim" @click=${() => this.sidebarOpen = !1}></div>` : m}
4541
+ ${this.sidebarOpen && this.sidebar !== "none" ? this.renderSidebar(e) : m}
4433
4542
  <main
4434
4543
  class="main"
4435
4544
  @dragenter=${this.onDragEnter}
4436
4545
  @dragover=${(t) => t.preventDefault()}
4437
4546
  >
4438
4547
  ${this.renderHeader()}
4439
- ${this.offline ? o`<div class="banner" role="status">${this.msg.offline}</div>` : f}
4548
+ ${this.offline ? o`<div class="banner" role="status">${this.msg.offline}</div>` : m}
4440
4549
  <div
4441
4550
  class="scroller"
4442
4551
  role="log"
@@ -4449,13 +4558,12 @@ assistant: ${s.slice(0, 1500)}`,
4449
4558
  </div>
4450
4559
  ${this.showJump ? o`<button type="button" class="jump" @click=${this.jumpToLatest}>
4451
4560
  ↓ ${this.msg.newReply}
4452
- </button>` : f}
4453
- ${this.renderComposer()}
4454
- ${Gt(this.branding, this.brandingText, this.msg.brandingLabel, this.brandingUrl)}
4561
+ </button>` : m}
4562
+ ${this.renderComposer()} ${Xt(this.branding, "Chat")}
4455
4563
  ${this.toast ? o`<div class="toast" role="status">
4456
4564
  <span>${this.toast.text}</span>
4457
- ${this.toast.undo ? o`<button type="button" @click=${this.undo}>${this.msg.undo}</button>` : f}
4458
- </div>` : f}
4565
+ ${this.toast.undo ? o`<button type="button" @click=${this.undo}>${this.msg.undo}</button>` : m}
4566
+ </div>` : m}
4459
4567
  ${this.dragging ? o`<div
4460
4568
  class="drop"
4461
4569
  @dragover=${(t) => t.preventDefault()}
@@ -4463,29 +4571,29 @@ assistant: ${s.slice(0, 1500)}`,
4463
4571
  @drop=${this.onDrop}
4464
4572
  >
4465
4573
  <strong>${this.msg.dropTitle}</strong><span>${this.msg.dropSub}</span>
4466
- </div>` : f}
4574
+ </div>` : m}
4467
4575
  </main>
4468
4576
  ${this.renderPanel()}
4469
4577
  </div>`;
4470
4578
  }
4471
4579
  renderSidebar(e) {
4472
4580
  const t = this.msg, s = this.allowSearch ? this.search.trim().toLowerCase() : "", i = this.chatList.filter(
4473
- (m) => !s || (m.title ?? "").toLowerCase().includes(s)
4474
- ), a = (m) => this.showBookmarked && !!m.bookmarked, r = (m) => i.filter((b) => !a(b) && Rs(b._modified_at ?? b._created_at) === m), l = [
4581
+ (f) => !s || (f.title ?? "").toLowerCase().includes(s)
4582
+ ), a = (f) => this.showBookmarked && !!f.bookmarked, r = (f) => i.filter((b) => !a(b) && Ds(b._modified_at ?? b._created_at) === f), c = [
4475
4583
  [t.groupBookmarked, i.filter(a)],
4476
4584
  [t.groupToday, r("today")],
4477
4585
  [t.groupYesterday, r("yesterday")],
4478
4586
  [t.groupWeek, r("week")],
4479
4587
  [t.groupOlder, r("older")]
4480
4588
  ];
4481
- let c;
4482
- return this.listState === "loading" && !this.chatList.length ? c = o`<div aria-label=${t.loadingChats}>
4589
+ let l;
4590
+ return this.listState === "loading" && !this.chatList.length ? l = o`<div aria-label=${t.loadingChats}>
4483
4591
  ${[1, 2, 3, 4].map(() => o`<div class="skeleton"></div>`)}
4484
- </div>` : i.length ? c = l.filter(([, m]) => m.length).map(
4485
- ([m, b]) => o`<div class="group">${m}</div>
4592
+ </div>` : i.length ? l = c.filter(([, f]) => f.length).map(
4593
+ ([f, b]) => o`<div class="group">${f}</div>
4486
4594
  ${b.map((C) => this.renderThreadRow(C))}`
4487
- ) : c = o`<span class="side-note"
4488
- >${s ? L(t.noMatch, { query: this.search.trim() }) : t.noChats}</span
4595
+ ) : l = o`<span class="side-note"
4596
+ >${s ? _(t.noMatch, { query: this.search.trim() }) : t.noChats}</span
4489
4597
  >`, o`<aside
4490
4598
  class="sidebar ${e ? "overlay" : "docked"}"
4491
4599
  part="sidebar"
@@ -4506,21 +4614,21 @@ assistant: ${s.slice(0, 1500)}`,
4506
4614
  <div class="side-tools">
4507
4615
  ${this.showNewChat ? o`<button type="button" class="new-chat" @click=${() => this.newChat()}>
4508
4616
  ${k.plus()}<span>${t.newChat}</span>
4509
- </button>` : f}
4617
+ </button>` : m}
4510
4618
  ${this.allowSearch ? o`<input
4511
4619
  class="search"
4512
4620
  type="search"
4513
4621
  placeholder=${t.searchChats}
4514
4622
  aria-label=${t.searchChats}
4515
4623
  .value=${this.search}
4516
- @input=${(m) => this.search = m.target.value}
4517
- />` : f}
4624
+ @input=${(f) => this.search = f.target.value}
4625
+ />` : m}
4518
4626
  </div>
4519
- <div class="threads">${c}</div>
4627
+ <div class="threads">${l}</div>
4520
4628
  <div class="side-extra ${this.hasSidebarContent ? "filled" : ""}" part="sidebar-extra">
4521
4629
  <slot
4522
4630
  name="sidebar"
4523
- @slotchange=${(m) => this.hasSidebarContent = m.target.assignedNodes().length > 0}
4631
+ @slotchange=${(f) => this.hasSidebarContent = f.target.assignedNodes().length > 0}
4524
4632
  ></slot>
4525
4633
  </div>
4526
4634
  </aside>`;
@@ -4540,8 +4648,8 @@ assistant: ${s.slice(0, 1500)}`,
4540
4648
  @blur=${(r) => this.commitRename(e._id, r.target.value)}
4541
4649
  />
4542
4650
  </div>`;
4543
- const a = (r) => (l) => {
4544
- l.stopPropagation(), r();
4651
+ const a = (r) => (c) => {
4652
+ c.stopPropagation(), r();
4545
4653
  };
4546
4654
  return o`<div
4547
4655
  class="thread ${s ? "active" : ""}"
@@ -4561,7 +4669,7 @@ assistant: ${s.slice(0, 1500)}`,
4561
4669
  @click=${a(() => this.toggleChatBookmark(e._id))}
4562
4670
  >
4563
4671
  ${k.bookmark(!!e.bookmarked)}
4564
- </button>` : f}
4672
+ </button>` : m}
4565
4673
  ${this.allowRename ? o`<button
4566
4674
  type="button"
4567
4675
  class="icon sm"
@@ -4572,7 +4680,7 @@ assistant: ${s.slice(0, 1500)}`,
4572
4680
  })}
4573
4681
  >
4574
4682
  ${k.pencil()}
4575
- </button>` : f}
4683
+ </button>` : m}
4576
4684
  ${this.allowDelete ? o`<button
4577
4685
  type="button"
4578
4686
  class="icon sm danger"
@@ -4581,13 +4689,13 @@ assistant: ${s.slice(0, 1500)}`,
4581
4689
  @click=${a(() => this.deleteChat(e._id))}
4582
4690
  >
4583
4691
  ${k.trash()}
4584
- </button>` : f}
4692
+ </button>` : m}
4585
4693
  </span>
4586
4694
  </div>`;
4587
4695
  }
4588
4696
  renderHeader() {
4589
4697
  const e = this.msg, t = !!this.activeId, s = (this.embed === "inline" || this.embed === "launcher") && !this.mobile, i = this.embed === "launcher" ? () => this.close() : this.expanded ? () => this.collapse() : null;
4590
- let a = f;
4698
+ let a = m;
4591
4699
  return this.showTitle && (a = this.editingTitle ? o`<input
4592
4700
  class="title-input"
4593
4701
  maxlength="80"
@@ -4610,7 +4718,7 @@ assistant: ${s.slice(0, 1500)}`,
4610
4718
  ${this.chatTitle || e.untitled}
4611
4719
  </button>`), o`<header class="header" part="header">
4612
4720
  <div class="header-left">
4613
- ${this.sidebar === "none" || this.sidebarOpen && this.docked ? f : o`<button
4721
+ ${this.sidebar === "none" || this.sidebarOpen && this.docked ? m : o`<button
4614
4722
  type="button"
4615
4723
  class="icon"
4616
4724
  title=${e.showChats}
@@ -4631,7 +4739,7 @@ assistant: ${s.slice(0, 1500)}`,
4631
4739
  @click=${() => this.newChat()}
4632
4740
  >
4633
4741
  ${k.plus()}
4634
- </button>` : f}
4742
+ </button>` : m}
4635
4743
  ${this.allowBookmark ? o`<button
4636
4744
  type="button"
4637
4745
  class="icon ${this.bookmarked ? "on" : ""}"
@@ -4641,7 +4749,7 @@ assistant: ${s.slice(0, 1500)}`,
4641
4749
  @click=${() => this.activeId && this.toggleChatBookmark(this.activeId)}
4642
4750
  >
4643
4751
  ${k.bookmark(this.bookmarked)}
4644
- </button>` : f}
4752
+ </button>` : m}
4645
4753
  ${this.allowExport ? o`<div class="menu-wrap">
4646
4754
  <button
4647
4755
  type="button"
@@ -4655,8 +4763,8 @@ assistant: ${s.slice(0, 1500)}`,
4655
4763
  >
4656
4764
  ${k.download()}
4657
4765
  </button>
4658
- ${this.menuOpen ? this.renderExportMenu() : f}
4659
- </div>` : f}
4766
+ ${this.menuOpen ? this.renderExportMenu() : m}
4767
+ </div>` : m}
4660
4768
  ${this.allowDelete ? o`<button
4661
4769
  type="button"
4662
4770
  class="icon danger"
@@ -4666,7 +4774,7 @@ assistant: ${s.slice(0, 1500)}`,
4666
4774
  @click=${() => this.activeId && this.deleteChat(this.activeId)}
4667
4775
  >
4668
4776
  ${k.trash()}
4669
- </button>` : f}
4777
+ </button>` : m}
4670
4778
  ${s || i ? o`<span class="divider"></span> ${s ? o`<button
4671
4779
  type="button"
4672
4780
  class="icon"
@@ -4675,7 +4783,7 @@ assistant: ${s.slice(0, 1500)}`,
4675
4783
  @click=${() => this.expanded ? this.collapse() : this.expand()}
4676
4784
  >
4677
4785
  ${this.expanded ? k.restore() : k.expand()}
4678
- </button>` : f}
4786
+ </button>` : m}
4679
4787
  ${i ? o`<button
4680
4788
  type="button"
4681
4789
  class="icon"
@@ -4684,7 +4792,7 @@ assistant: ${s.slice(0, 1500)}`,
4684
4792
  @click=${i}
4685
4793
  >
4686
4794
  ${k.minimize()}
4687
- </button>` : f}` : f}
4795
+ </button>` : m}` : m}
4688
4796
  </div>
4689
4797
  </header>`;
4690
4798
  }
@@ -4713,19 +4821,19 @@ assistant: ${s.slice(0, 1500)}`,
4713
4821
  /** The suggestion cards. `[]` or `"none"` shows none; unset uses the mode's. */
4714
4822
  promptList() {
4715
4823
  const e = this.prompts;
4716
- return Array.isArray(e) ? e.map((t) => typeof t == "string" ? { text: t } : t).filter((t) => t == null ? void 0 : t.text).slice(0, 4) : typeof e == "string" && e.trim().toLowerCase() === "none" ? [] : typeof e == "string" && e.trim() ? e.split("|").map((t) => t.trim()).filter(Boolean).slice(0, 4).map((t) => ({ text: t })) : (Nt[this.mode] ?? Nt.chat).map(([t, s]) => ({
4824
+ return Array.isArray(e) ? e.map((t) => typeof t == "string" ? { text: t } : t).filter((t) => t == null ? void 0 : t.text).slice(0, 4) : typeof e == "string" && e.trim().toLowerCase() === "none" ? [] : typeof e == "string" && e.trim() ? e.split("|").map((t) => t.trim()).filter(Boolean).slice(0, 4).map((t) => ({ text: t })) : (Et[this.mode] ?? Et.chat).map(([t, s]) => ({
4717
4825
  label: t,
4718
4826
  text: s
4719
4827
  }));
4720
4828
  }
4721
4829
  renderWelcome() {
4722
- const e = this.msg, t = this.mode === "rag" ? "Rag" : "Chat", s = (r) => e[`${r}${t}`], i = this.eyebrow ?? s("eyebrow"), a = this.promptList();
4830
+ const e = this.msg, t = this.mode === "rag" ? "Rag" : this.mode === "kb" ? "Kb" : "Chat", s = (r) => e[`${r}${t}`], i = this.eyebrow ?? s("eyebrow"), a = this.promptList();
4723
4831
  return o`<div class="welcome-slot">
4724
4832
  <slot name="welcome"
4725
4833
  ><div class="welcome" part="welcome">
4726
4834
  <div class="welcome-head">
4727
- ${this.logoUrl && It(this.logoUrl, !0) ? o`<img class="welcome-logo" src=${this.logoUrl} alt="" />` : f}
4728
- ${i ? o`<span class="label">${i}</span>` : f}
4835
+ ${this.logoUrl && _t(this.logoUrl, !0) ? o`<img class="welcome-logo" src=${this.logoUrl} alt="" />` : m}
4836
+ ${i ? o`<span class="label">${i}</span>` : m}
4729
4837
  <h2>${this.heading || s("heading")}</h2>
4730
4838
  <p>${this.description || s("description")}</p>
4731
4839
  </div>
@@ -4741,7 +4849,7 @@ assistant: ${s.slice(0, 1500)}`,
4741
4849
  <span class="prompt-text">${r.text}</span>
4742
4850
  </button>`
4743
4851
  )}
4744
- </div>` : f}
4852
+ </div>` : m}
4745
4853
  </div></slot
4746
4854
  >
4747
4855
  </div>`;
@@ -4757,10 +4865,10 @@ assistant: ${s.slice(0, 1500)}`,
4757
4865
  @click=${() => this.openChat(this.activeId)}
4758
4866
  >
4759
4867
  ${this.msg.retry}
4760
- </button>` : f}
4761
- </div>` : f}
4762
- ${this.loadingThread ? o`${[1, 2].map(() => o`<div class="skeleton" style="height:48px"></div>`)}` : f}
4763
- ${Jt(
4868
+ </button>` : m}
4869
+ </div>` : m}
4870
+ ${this.loadingThread ? o`${[1, 2].map(() => o`<div class="skeleton" style="height:48px"></div>`)}` : m}
4871
+ ${qt(
4764
4872
  this.msgs,
4765
4873
  (t) => t.key,
4766
4874
  (t, s) => t.role === "user" ? this.renderUser(t) : this.renderBot(t, s === e)
@@ -4771,8 +4879,8 @@ assistant: ${s.slice(0, 1500)}`,
4771
4879
  const t = this.msg, s = e.at ? new Date(e.at).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" }) : "", i = e.attachments ?? [];
4772
4880
  return o`<div class="msg user" part="message user">
4773
4881
  ${i.length ? o`<div class="attachments">
4774
- ${i.map((a) => o`<span class="doc-chip"><span class="ext">${Rt(a.name)}</span><span class="name">${a.name}</span></span>`)}
4775
- </div>` : f}
4882
+ ${i.map((a) => o`<span class="doc-chip"><span class="ext">${xt(a.name)}</span><span class="name">${a.name}</span></span>`)}
4883
+ </div>` : m}
4776
4884
  ${this.editingKey === e.key ? o`<div class="edit-box">
4777
4885
  <textarea
4778
4886
  rows="3"
@@ -4793,9 +4901,9 @@ assistant: ${s.slice(0, 1500)}`,
4793
4901
  </div>
4794
4902
  </div>` : o`<div class="bubble-user">${e.content}</div>
4795
4903
  <div class="toolbar">
4796
- ${this.allowBookmark && e.bookmarked ? o`<span class="saved">${k.bookmark(!0)}${t.saved}</span>` : f}
4797
- ${this.showTime ? o`<span class="time">${s}</span>` : f}
4798
- ${this.busy ? f : o`<button
4904
+ ${this.allowBookmark && e.bookmarked ? o`<span class="saved">${k.bookmark(!0)}${t.saved}</span>` : m}
4905
+ ${this.showTime ? o`<span class="time">${s}</span>` : m}
4906
+ ${this.busy ? m : o`<button
4799
4907
  type="button"
4800
4908
  class="icon"
4801
4909
  title=${t.edit}
@@ -4814,7 +4922,7 @@ assistant: ${s.slice(0, 1500)}`,
4814
4922
  @click=${() => this.copy(e.key, e.content)}
4815
4923
  >
4816
4924
  ${k.copy()}
4817
- </button>` : f}
4925
+ </button>` : m}
4818
4926
  ${this.allowBookmark && e.id ? o`<button
4819
4927
  type="button"
4820
4928
  class="icon ${e.bookmarked ? "on" : ""}"
@@ -4823,7 +4931,7 @@ assistant: ${s.slice(0, 1500)}`,
4823
4931
  @click=${() => this.toggleMessageBookmark(e)}
4824
4932
  >
4825
4933
  ${k.bookmark(e.bookmarked)}
4826
- </button>` : f}
4934
+ </button>` : m}
4827
4935
  ${this.allowDelete ? o`<button
4828
4936
  type="button"
4829
4937
  class="icon danger"
@@ -4832,48 +4940,48 @@ assistant: ${s.slice(0, 1500)}`,
4832
4940
  @click=${() => this.deleteMessage(e)}
4833
4941
  >
4834
4942
  ${k.trash()}
4835
- </button>` : f}
4943
+ </button>` : m}
4836
4944
  </div>`}
4837
4945
  </div>`;
4838
4946
  }
4839
4947
  pillLabel() {
4840
- return this.mode === "rag" ? this.msg.searching : this.msg.thinking;
4948
+ return this.mode === "rag" || this.mode === "kb" ? this.msg.searching : this.msg.thinking;
4841
4949
  }
4842
4950
  renderBot(e, t) {
4843
- const s = this.msg, i = e.phase === "pending", a = e.phase === "done", r = e.sources.length, l = Tt(e.content), c = e.sources.map((w, _) => gt(w, _ + 1)), m = l.size ? c.filter((w) => l.has(w.n)) : c, b = e.at ? new Date(e.at).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" }) : "", C = e.content + (m.length ? `
4951
+ const s = this.msg, i = e.phase === "pending", a = e.phase === "done", r = e.sources.length, c = Ot(e.content), l = e.sources.map((w, L) => ft(w, L + 1)), f = c.size ? l.filter((w) => c.has(w.n)) : l, b = e.at ? new Date(e.at).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" }) : "", C = e.content + (f.length ? `
4844
4952
 
4845
4953
  Sources:
4846
- ${m.map((w) => `[${w.n}] ${w.title}`).join(`
4847
- `)}` : ""), S = this.retrievalOpen.has(e.key);
4954
+ ${f.map((w) => `[${w.n}] ${w.title}`).join(`
4955
+ `)}` : ""), T = this.retrievalOpen.has(e.key);
4848
4956
  return o`<div class="msg bot" part="message assistant">
4849
- ${i ? o`<div class="halo"></div>` : f}
4957
+ ${i ? o`<div class="halo"></div>` : m}
4850
4958
  ${this.arrivedKey === e.key ? o`<div class="arrived">
4851
4959
  <div class="wash"></div>
4852
4960
  <div class="ring"></div>
4853
4961
  <div class="sweep"></div>
4854
- </div>` : f}
4962
+ </div>` : m}
4855
4963
  <div class="bot-body">
4856
- ${this.allowBookmark && e.bookmarked ? o`<span class="saved">${k.bookmark(!0)}${s.saved}</span>` : f}
4964
+ ${this.allowBookmark && e.bookmarked ? o`<span class="saved">${k.bookmark(!0)}${s.saved}</span>` : m}
4857
4965
  ${i ? o`<div class="pill" role="status">
4858
4966
  <span class="ring"></span><span class="dot"></span>
4859
4967
  <span class="shimmer">${this.pillLabel()}</span>
4860
- </div>` : f}
4968
+ </div>` : m}
4861
4969
  ${this.showSources && r && !i ? o`<div class="retrieval">
4862
4970
  <button
4863
4971
  type="button"
4864
4972
  class="retrieval-toggle"
4865
- aria-expanded=${S ? "true" : "false"}
4973
+ aria-expanded=${T ? "true" : "false"}
4866
4974
  @click=${() => {
4867
4975
  const w = new Set(this.retrievalOpen);
4868
4976
  w.has(e.key) ? w.delete(e.key) : w.add(e.key), this.retrievalOpen = w;
4869
4977
  }}
4870
4978
  >
4871
- <span class="chev">${S ? "▾" : "▸"}</span>
4872
- <span style="flex:1">${L(s.searchedSources, { n: r })}</span>
4873
- ${e.execTime !== void 0 ? o`<span class="ms">${e.execTime.toFixed(1)}s</span>` : f}
4979
+ <span class="chev">${T ? "▾" : "▸"}</span>
4980
+ <span style="flex:1">${_(s.searchedSources, { n: r })}</span>
4981
+ ${e.execTime !== void 0 ? o`<span class="ms">${e.execTime.toFixed(1)}s</span>` : m}
4874
4982
  </button>
4875
- ${S ? o`<div class="retrieval-list">
4876
- ${c.map(
4983
+ ${T ? o`<div class="retrieval-list">
4984
+ ${l.map(
4877
4985
  (w) => o`<button
4878
4986
  type="button"
4879
4987
  class="passage"
@@ -4881,7 +4989,8 @@ ${m.map((w) => `[${w.n}] ${w.title}`).join(`
4881
4989
  >
4882
4990
  <span class="n">${w.n}</span>
4883
4991
  <span class="what"
4884
- ><span>${w.title}</span><span>${w.collection || w.path}</span></span
4992
+ ><span>${w.title}${w.section ? ` · ${w.section}` : ""}</span
4993
+ ><span>${w.collection || w.path}</span></span
4885
4994
  >
4886
4995
  ${w.score !== null ? o`<span class="relevance"
4887
4996
  ><span class="score">${w.score.toFixed(2)}</span>
@@ -4893,38 +5002,38 @@ ${m.map((w) => `[${w.n}] ${w.title}`).join(`
4893
5002
  ></span>` : o`<span></span>`}
4894
5003
  </button>`
4895
5004
  )}
4896
- </div>` : f}
4897
- </div>` : f}
4898
- ${i ? f : this.renderAnswer(e)}
4899
- ${e.phase === "streaming" ? o`<span class="caret"></span>` : f}
5005
+ </div>` : m}
5006
+ </div>` : m}
5007
+ ${i ? m : this.renderAnswer(e)}
5008
+ ${e.phase === "streaming" ? o`<span class="caret"></span>` : m}
4900
5009
  ${e.phase === "error" ? o`<div class="error-card" role="alert">
4901
5010
  <span>${e.error}</span>
4902
5011
  <button type="button" class="btn" @click=${() => this.retry(e)}>
4903
5012
  ${s.retry}
4904
5013
  </button>
4905
- </div>` : f}
4906
- ${this.showSources && a && m.length ? o`<div class="cards">
4907
- <span class="label">${l.size ? s.sourcesCited : s.sourcesRetrieved}</span>
5014
+ </div>` : m}
5015
+ ${this.showSources && a && f.length ? o`<div class="cards">
5016
+ <span class="label">${c.size ? s.sourcesCited : s.sourcesRetrieved}</span>
4908
5017
  <div class="card-grid">
4909
- ${m.map(
5018
+ ${f.map(
4910
5019
  (w) => {
4911
- var _;
5020
+ var L;
4912
5021
  return o`<button
4913
5022
  type="button"
4914
- class="source-card ${((_ = this.panel) == null ? void 0 : _.key) === e.key && this.panel.n === w.n ? "active" : ""}"
5023
+ class="source-card ${((L = this.panel) == null ? void 0 : L.key) === e.key && this.panel.n === w.n ? "active" : ""}"
4915
5024
  @click=${() => this.panel = { key: e.key, n: w.n }}
4916
5025
  >
4917
5026
  <span class="top"
4918
5027
  ><span class="num">${w.n}</span
4919
- >${w.collection ? o`<span class="label">${w.collection}</span>` : f}</span
5028
+ >${w.collection ? o`<span class="label">${w.collection}</span>` : m}</span
4920
5029
  >
4921
- <span class="t">${w.title}</span>
5030
+ <span class="t">${w.title}${w.section ? ` · ${w.section}` : ""}</span>
4922
5031
  <span class="s">${w.text}</span>
4923
5032
  </button>`;
4924
5033
  }
4925
5034
  )}
4926
5035
  </div>
4927
- </div>` : f}
5036
+ </div>` : m}
4928
5037
  ${a ? o`<div class="toolbar ${t ? "pinned" : ""}">
4929
5038
  ${this.allowCopy ? o`<button
4930
5039
  type="button"
@@ -4934,7 +5043,7 @@ ${m.map((w) => `[${w.n}] ${w.title}`).join(`
4934
5043
  @click=${() => this.copy(e.key, C)}
4935
5044
  >
4936
5045
  ${k.copy()}
4937
- </button>` : f}
5046
+ </button>` : m}
4938
5047
  ${this.allowRaw && this.formatLevel !== "raw" && e.content ? o`<button
4939
5048
  type="button"
4940
5049
  class="icon ${this.rawKeys.has(e.key) ? "on" : ""}"
@@ -4944,7 +5053,7 @@ ${m.map((w) => `[${w.n}] ${w.title}`).join(`
4944
5053
  @click=${() => this.toggleRaw(e.key)}
4945
5054
  >
4946
5055
  ${k.raw()}
4947
- </button>` : f}
5056
+ </button>` : m}
4948
5057
  ${this.allowRegenerate && t && !this.busy ? o`<button
4949
5058
  type="button"
4950
5059
  class="icon"
@@ -4953,7 +5062,7 @@ ${m.map((w) => `[${w.n}] ${w.title}`).join(`
4953
5062
  @click=${() => this.regenerate()}
4954
5063
  >
4955
5064
  ${k.refresh()}
4956
- </button>` : f}
5065
+ </button>` : m}
4957
5066
  ${this.allowBookmark && e.id ? o`<button
4958
5067
  type="button"
4959
5068
  class="icon ${e.bookmarked ? "on" : ""}"
@@ -4962,7 +5071,7 @@ ${m.map((w) => `[${w.n}] ${w.title}`).join(`
4962
5071
  @click=${() => this.toggleMessageBookmark(e)}
4963
5072
  >
4964
5073
  ${k.bookmark(e.bookmarked)}
4965
- </button>` : f}
5074
+ </button>` : m}
4966
5075
  ${this.allowDelete ? o`<button
4967
5076
  type="button"
4968
5077
  class="icon danger"
@@ -4971,9 +5080,9 @@ ${m.map((w) => `[${w.n}] ${w.title}`).join(`
4971
5080
  @click=${() => this.deleteMessage(e)}
4972
5081
  >
4973
5082
  ${k.trash()}
4974
- </button>` : f}
4975
- ${this.showTime ? o`<span class="time">${b}</span>` : f}
4976
- ${e.stopped ? o`<span class="note">${s.stopped}</span>` : f}
5083
+ </button>` : m}
5084
+ ${this.showTime ? o`<span class="time">${b}</span>` : m}
5085
+ ${e.stopped ? o`<span class="note">${s.stopped}</span>` : m}
4977
5086
  <span class="spacer"></span>
4978
5087
  ${this.allowFeedback ? e.feedback ? o`<span class="note"
4979
5088
  >${e.feedback === "up" ? s.markedHelpful : s.thanksFeedback}</span
@@ -4994,27 +5103,27 @@ ${m.map((w) => `[${w.n}] ${w.title}`).join(`
4994
5103
  @click=${() => this.feedback(e, "down")}
4995
5104
  >
4996
5105
  ${k.thumb(!0)}
4997
- </button>` : f}
4998
- </div>` : f}
5106
+ </button>` : m}
5107
+ </div>` : m}
4999
5108
  ${this.showFollowups && a && t && !this.busy && e.followups.length ? o`<div class="followups">
5000
5109
  ${e.followups.map(
5001
5110
  (w) => o`<button type="button" class="followup" @click=${() => this.send(w)}>
5002
5111
  <span class="arrow">↳</span><span>${w}</span>
5003
5112
  </button>`
5004
5113
  )}
5005
- </div>` : f}
5114
+ </div>` : m}
5006
5115
  </div>
5007
5116
  </div>`;
5008
5117
  }
5009
5118
  renderAnswer(e) {
5010
- if (e.phase === "error" && !e.content) return f;
5119
+ if (e.phase === "error" && !e.content) return m;
5011
5120
  if (e.phase === "done" && !e.content)
5012
- return e.stopped ? f : o`<div class="answer"><p class="note">${this.msg.emptyReply}</p></div>`;
5121
+ return e.stopped ? m : o`<div class="answer"><p class="note">${this.msg.emptyReply}</p></div>`;
5013
5122
  const t = this.formatLevel;
5014
5123
  if (t === "raw" || this.allowRaw && this.rawKeys.has(e.key))
5015
5124
  return o`<div class="answer" part="answer"><p class="raw">${e.content}</p></div>`;
5016
- const s = e.phase === "streaming" ? ls(e.content) : e.content;
5017
- let i = ps(is(s), t);
5125
+ const s = e.phase === "streaming" ? ps(e.content) : e.content;
5126
+ let i = gs(os(s), t);
5018
5127
  if (this.afterParse)
5019
5128
  try {
5020
5129
  const r = this.afterParse(i, { message: e, format: t });
@@ -5024,13 +5133,16 @@ ${m.map((w) => `[${w.n}] ${w.title}`).join(`
5024
5133
  } catch (r) {
5025
5134
  console.warn("[singlebase-chat] afterParse failed; showing the original.", r);
5026
5135
  }
5027
- const a = e.sources.length;
5136
+ const a = e.sources.reduce(
5137
+ (r, c, l) => Math.max(r, ft(c, l + 1).n),
5138
+ 0
5139
+ );
5028
5140
  return o`<div class="answer" part="answer">
5029
- ${i.map((r, l) => this.renderBlock(r, e, a, l))}
5141
+ ${i.map((r, c) => this.renderBlock(r, e, a, c))}
5030
5142
  </div>`;
5031
5143
  }
5032
5144
  renderInline(e, t, s) {
5033
- return ns(e, s).map((i) => {
5145
+ return ds(e, s).map((i) => {
5034
5146
  var a;
5035
5147
  switch (i.type) {
5036
5148
  case "bold":
@@ -5046,8 +5158,8 @@ ${m.map((w) => `[${w.n}] ${w.title}`).join(`
5046
5158
  >${i.text}</a
5047
5159
  >`;
5048
5160
  case "cite": {
5049
- const r = ((a = this.panel) == null ? void 0 : a.key) === t.key && this.panel.n === i.n ? "cite active" : "cite", l = L(this.msg.openSource, { n: i.n });
5050
- return o`<button type="button" class=${r} aria-label=${l} @click=${() => this.panel = { key: t.key, n: i.n }}>${i.n}</button>`;
5161
+ const r = ((a = this.panel) == null ? void 0 : a.key) === t.key && this.panel.n === i.n ? "cite active" : "cite", c = _(this.msg.openSource, { n: i.n });
5162
+ return o`<button type="button" class=${r} aria-label=${c} @click=${() => this.panel = { key: t.key, n: i.n }}>${i.n}</button>`;
5051
5163
  }
5052
5164
  default:
5053
5165
  return i.text;
@@ -5071,7 +5183,7 @@ ${m.map((w) => `[${w.n}] ${w.title}`).join(`
5071
5183
  case "callout":
5072
5184
  return o`<div class="callout ${e.kind}" role="note" part="callout">
5073
5185
  <strong class="callout-title"
5074
- >${e.title || this.msg[Is[e.kind]]}</strong
5186
+ >${e.title || this.msg[_s[e.kind]]}</strong
5075
5187
  >
5076
5188
  ${e.text.split(`
5077
5189
  `).filter((a) => a.trim()).map((a) => o`<p>${this.renderInline(a, t, s)}</p>`)}
@@ -5090,7 +5202,7 @@ ${m.map((w) => `[${w.n}] ${w.title}`).join(`
5090
5202
  case "json":
5091
5203
  return this.renderJsonBlock(e.value, e.source, `${t.key}:${i}`);
5092
5204
  case "svg": {
5093
- const a = bs(e.source);
5205
+ const a = ws(e.source);
5094
5206
  if (!a) return this.renderCode("svg", e.source, `${t.key}:${i}`);
5095
5207
  const r = `${t.key}:${i}`;
5096
5208
  return o`<figure class="svg" part="svg">
@@ -5114,18 +5226,18 @@ ${m.map((w) => `[${w.n}] ${w.title}`).join(`
5114
5226
  return o`<div class="gallery ${e.images.length > 1 ? "many" : ""}">
5115
5227
  ${e.images.map(
5116
5228
  (a) => o`<figure>
5117
- ${a.src && It(a.src, !0) ? o`<img
5229
+ ${a.src && _t(a.src, !0) ? o`<img
5118
5230
  src=${a.src}
5119
5231
  alt=${a.alt}
5120
5232
  loading="lazy"
5121
5233
  referrerpolicy="no-referrer"
5122
5234
  />` : o`<div class="img-missing"><span class="label">Image</span></div>`}
5123
- ${a.alt ? o`<figcaption>${a.alt}</figcaption>` : f}
5235
+ ${a.alt ? o`<figcaption>${a.alt}</figcaption>` : m}
5124
5236
  </figure>`
5125
5237
  )}
5126
5238
  </div>`;
5127
5239
  default:
5128
- return f;
5240
+ return m;
5129
5241
  }
5130
5242
  }
5131
5243
  renderList(e, t, s, i) {
@@ -5134,7 +5246,7 @@ ${m.map((w) => `[${w.n}] ${w.title}`).join(`
5134
5246
  class=${r.checked === null ? "" : "task"}
5135
5247
  style=${r.depth ? `margin-left:${r.depth * 20}px` : ""}
5136
5248
  >
5137
- ${r.checked === null ? f : o`<input type="checkbox" disabled .checked=${r.checked} aria-hidden="true" />`}
5249
+ ${r.checked === null ? m : o`<input type="checkbox" disabled .checked=${r.checked} aria-hidden="true" />`}
5138
5250
  ${this.renderInline(r.text, s, i)}
5139
5251
  </li>`
5140
5252
  );
@@ -5168,30 +5280,30 @@ ${m.map((w) => `[${w.n}] ${w.title}`).join(`
5168
5280
  }
5169
5281
  }
5170
5282
  renderTable(e, t, s, i, a, r) {
5171
- const l = (x) => /^[-+]?[$€£¥]?\s?[\d,.]+\s?%?$/.test(x.trim()) && /\d/.test(x), c = (x) => Number(x.replace(/[^\d.+-]/g, "")), m = e.map((x, T) => {
5172
- if (s[T]) return s[T];
5173
- const $ = t.map((j) => j[T] ?? "").filter(Boolean);
5174
- return $.length && $.filter(l).length / $.length >= 0.8 ? "right" : null;
5283
+ const c = (x) => /^[-+]?[$€£¥]?\s?[\d,.]+\s?%?$/.test(x.trim()) && /\d/.test(x), l = (x) => Number(x.replace(/[^\d.+-]/g, "")), f = e.map((x, S) => {
5284
+ if (s[S]) return s[S];
5285
+ const $ = t.map((A) => A[S] ?? "").filter(Boolean);
5286
+ return $.length && $.filter(c).length / $.length >= 0.8 ? "right" : null;
5175
5287
  }), b = this.sorts.get(r);
5176
5288
  let C = t;
5177
- b && (C = [...t].sort((x, T) => {
5178
- const $ = x[b.col] ?? "", j = T[b.col] ?? "";
5179
- return (l($) && l(j) ? c($) - c(j) : $.localeCompare(j, void 0, { numeric: !0 })) * b.dir;
5289
+ b && (C = [...t].sort((x, S) => {
5290
+ const $ = x[b.col] ?? "", A = S[b.col] ?? "";
5291
+ return (c($) && c(A) ? l($) - l(A) : $.localeCompare(A, void 0, { numeric: !0 })) * b.dir;
5180
5292
  }));
5181
- const S = C.length;
5182
- C = C.slice(0, Os);
5293
+ const T = C.length;
5294
+ C = C.slice(0, zs);
5183
5295
  const w = (x) => {
5184
- const T = new Map(this.sorts), $ = T.get(r);
5185
- ($ == null ? void 0 : $.col) === x && $.dir === -1 ? T.delete(r) : T.set(r, { col: x, dir: ($ == null ? void 0 : $.col) === x ? -1 : 1 }), this.sorts = T;
5186
- }, _ = (x) => m[x] ? `text-align:${m[x]}` : "";
5296
+ const S = new Map(this.sorts), $ = S.get(r);
5297
+ ($ == null ? void 0 : $.col) === x && $.dir === -1 ? S.delete(r) : S.set(r, { col: x, dir: ($ == null ? void 0 : $.col) === x ? -1 : 1 }), this.sorts = S;
5298
+ }, L = (x) => f[x] ? `text-align:${f[x]}` : "";
5187
5299
  return o`<div class="table" part="table">
5188
5300
  <table>
5189
5301
  <thead>
5190
5302
  <tr>
5191
- ${e.map((x, T) => {
5192
- const $ = (b == null ? void 0 : b.col) === T ? b.dir === 1 ? "ascending" : "descending" : "none";
5193
- return o`<th style=${_(T)} aria-sort=${$}>
5194
- ${t.length > 1 ? o`<button type="button" class="sort" @click=${() => w(T)}>
5303
+ ${e.map((x, S) => {
5304
+ const $ = (b == null ? void 0 : b.col) === S ? b.dir === 1 ? "ascending" : "descending" : "none";
5305
+ return o`<th style=${L(S)} aria-sort=${$}>
5306
+ ${t.length > 1 ? o`<button type="button" class="sort" @click=${() => w(S)}>
5195
5307
  ${this.renderInline(x, i, a)}<span class="arrow"
5196
5308
  >${$ === "ascending" ? "↑" : $ === "descending" ? "↓" : "↕"}</span
5197
5309
  >
@@ -5204,7 +5316,7 @@ ${m.map((w) => `[${w.n}] ${w.title}`).join(`
5204
5316
  ${C.map(
5205
5317
  (x) => o`<tr>
5206
5318
  ${e.map(
5207
- (T, $) => o`<td style=${_($)}>
5319
+ (S, $) => o`<td style=${L($)}>
5208
5320
  ${this.renderInline(x[$] ?? "", i, a)}
5209
5321
  </td>`
5210
5322
  )}
@@ -5212,28 +5324,28 @@ ${m.map((w) => `[${w.n}] ${w.title}`).join(`
5212
5324
  )}
5213
5325
  </tbody>
5214
5326
  </table>
5215
- ${S > C.length ? o`<div class="table-note">
5216
- ${L(this.msg.showingRows, { n: C.length, total: S })}
5217
- </div>` : f}
5327
+ ${T > C.length ? o`<div class="table-note">
5328
+ ${_(this.msg.showingRows, { n: C.length, total: T })}
5329
+ </div>` : m}
5218
5330
  </div>`;
5219
5331
  }
5220
5332
  renderJsonBlock(e, t, s) {
5221
5333
  let i = 0;
5222
- const a = (l) => {
5223
- i++, i <= Lt && l && typeof l == "object" && Object.values(l).forEach(a);
5334
+ const a = (c) => {
5335
+ i++, i <= Nt && c && typeof c == "object" && Object.values(c).forEach(a);
5224
5336
  };
5225
- if (a(e), i > Lt) return this.renderCode("json", t, s);
5226
- const r = (l, c, m) => {
5227
- const b = m === void 0 ? f : o`<span class="jkey">${m}</span>: `;
5228
- if (l && typeof l == "object") {
5229
- const S = Object.entries(l), w = Array.isArray(l) ? `[${S.length}]` : `{${S.length}}`;
5230
- return o`<details class="jnode" ?open=${c < 2}>
5337
+ if (a(e), i > Nt) return this.renderCode("json", t, s);
5338
+ const r = (c, l, f) => {
5339
+ const b = f === void 0 ? m : o`<span class="jkey">${f}</span>: `;
5340
+ if (c && typeof c == "object") {
5341
+ const T = Object.entries(c), w = Array.isArray(c) ? `[${T.length}]` : `{${T.length}}`;
5342
+ return o`<details class="jnode" ?open=${l < 2}>
5231
5343
  <summary>${b}<span class="jmeta">${w}</span></summary>
5232
- <div class="jkids">${S.map(([_, x]) => r(x, c + 1, _))}</div>
5344
+ <div class="jkids">${T.map(([L, x]) => r(x, l + 1, L))}</div>
5233
5345
  </details>`;
5234
5346
  }
5235
5347
  return o`<div class="jleaf">
5236
- ${b}<span class="jv ${l === null ? "null" : typeof l}">${JSON.stringify(l)}</span>
5348
+ ${b}<span class="jv ${c === null ? "null" : typeof c}">${JSON.stringify(c)}</span>
5237
5349
  </div>`;
5238
5350
  };
5239
5351
  return o`<div class="code json" part="json">
@@ -5249,26 +5361,26 @@ ${m.map((w) => `[${w.n}] ${w.title}`).join(`
5249
5361
  renderChart(e) {
5250
5362
  const t = e.series.length > 1 ? o`<span class="legend">
5251
5363
  ${e.series.map(
5252
- (r, l) => o`<span
5364
+ (r, c) => o`<span
5253
5365
  ><span
5254
5366
  class="swatch"
5255
- style="background:${N[l % N.length]}"
5367
+ style="background:${j[c % j.length]}"
5256
5368
  ></span
5257
5369
  >${r.name}</span
5258
5370
  >`
5259
5371
  )}
5260
- </span>` : f, s = o`<div class="chart-head">
5372
+ </span>` : m, s = o`<div class="chart-head">
5261
5373
  <span class="chart-title">${e.title}</span>${t}
5262
5374
  </div>`;
5263
5375
  if (e.type === "line") {
5264
- const r = Math.max(0, ...e.series.flatMap((b) => b.values)), l = Math.pow(10, Math.floor(Math.log10(r || 1))), c = Math.ceil(r / l * 2) / 2 * l || 1, m = Math.max(e.labels.length, ...e.series.map((b) => b.values.length));
5376
+ const r = Math.max(0, ...e.series.flatMap((b) => b.values)), c = Math.pow(10, Math.floor(Math.log10(r || 1))), l = Math.ceil(r / c * 2) / 2 * c || 1, f = Math.max(e.labels.length, ...e.series.map((b) => b.values.length));
5265
5377
  return o`<figure class="chart" part="chart" aria-label=${e.title}>
5266
5378
  ${s}
5267
5379
  <div class="line-chart">
5268
5380
  <div class="plot">
5269
5381
  ${[1, 0.5, 0].map(
5270
5382
  (b) => o`<div class="tick ${b === 0 ? "base" : ""}" style="top:${(1 - b) * 100}%">
5271
- <span>${ut(Math.round(c * b), e.unit)}</span>
5383
+ <span>${mt(Math.round(l * b), e.unit)}</span>
5272
5384
  </div>`
5273
5385
  )}
5274
5386
  <svg
@@ -5278,12 +5390,12 @@ ${m.map((w) => `[${w.n}] ${w.title}`).join(`
5278
5390
  aria-label=${e.title}
5279
5391
  >
5280
5392
  ${e.series.map(
5281
- (b, C) => I`<polyline pathLength="1" stroke=${N[C % N.length]}
5393
+ (b, C) => O`<polyline pathLength="1" stroke=${j[C % j.length]}
5282
5394
  points=${b.values.map(
5283
- (S, w) => `${(m > 1 ? w / (m - 1) * 600 : 300).toFixed(1)},${(170 - S / c * 170).toFixed(1)}`
5395
+ (T, w) => `${(f > 1 ? w / (f - 1) * 600 : 300).toFixed(1)},${(170 - T / l * 170).toFixed(1)}`
5284
5396
  ).join(
5285
5397
  " "
5286
- )}><title>${b.name}: ${b.values.map((S) => ut(S, e.unit)).join(", ")}</title></polyline>`
5398
+ )}><title>${b.name}: ${b.values.map((T) => mt(T, e.unit)).join(", ")}</title></polyline>`
5287
5399
  )}
5288
5400
  </svg>
5289
5401
  </div>
@@ -5292,77 +5404,80 @@ ${m.map((w) => `[${w.n}] ${w.title}`).join(`
5292
5404
  </figure>`;
5293
5405
  }
5294
5406
  const i = e.labels.map(
5295
- (r, l) => e.series.reduce((c, m) => c + (m.values[l] || 0), 0)
5407
+ (r, c) => e.series.reduce((l, f) => l + (f.values[c] || 0), 0)
5296
5408
  ), a = Math.max(0, ...i) || 1;
5297
5409
  return o`<figure class="chart" part="chart" aria-label=${e.title}>
5298
5410
  ${s}
5299
5411
  <div class="bars">
5300
5412
  ${e.labels.map(
5301
- (r, l) => o`<div class="bar-row" title="${r}: ${ut(i[l], e.unit)}">
5413
+ (r, c) => o`<div class="bar-row" title="${r}: ${mt(i[c], e.unit)}">
5302
5414
  <span class="bar-label">${r}</span>
5303
5415
  <span class="bar-track"
5304
- ><span class="bar-fill" style="width:${Math.max(0, i[l]) / a * 100}%">
5416
+ ><span class="bar-fill" style="width:${Math.max(0, i[c]) / a * 100}%">
5305
5417
  ${e.series.map(
5306
- (c, m) => o`<span
5307
- style="flex:${Math.max(0, c.values[l] || 0)};background:${e.series.length > 1 ? N[m % N.length] : "var(--c-ink)"}"
5418
+ (l, f) => o`<span
5419
+ style="flex:${Math.max(0, l.values[c] || 0)};background:${e.series.length > 1 ? j[f % j.length] : "var(--c-ink)"}"
5308
5420
  ></span>`
5309
5421
  )}
5310
5422
  </span></span
5311
5423
  >
5312
- <span class="bar-value">${ut(i[l], e.unit)}</span>
5424
+ <span class="bar-value">${mt(i[c], e.unit)}</span>
5313
5425
  </div>`
5314
5426
  )}
5315
5427
  </div>
5316
5428
  </figure>`;
5317
5429
  }
5318
5430
  renderPanel() {
5319
- if (!this.panel) return f;
5320
- const e = this.msgs.find((b) => b.key === this.panel.key), t = e == null ? void 0 : e.sources[this.panel.n - 1];
5321
- if (!e || !t) return f;
5322
- const s = this.msg, i = gt(t, this.panel.n), a = Tt(e.content), r = e.sources.map((b, C) => gt(b, C + 1)).filter((b) => b.n !== i.n && (!a.size || a.has(b.n))), l = `ref:${e.key}:${i.n}`, c = `"${i.text}"
5323
- — ${i.title} [${i.n}]${i.path ? `
5324
- ${i.path}` : ""}${i.updated ? ` · Updated ${i.updated}` : ""}`, m = [
5325
- i.updated ? `Updated ${i.updated}` : "",
5326
- i.score !== null ? `Relevance ${i.score.toFixed(2)}` : ""
5431
+ if (!this.panel) return m;
5432
+ const e = this.msgs.find((b) => b.key === this.panel.key);
5433
+ if (!e) return m;
5434
+ const t = e.sources.map((b, C) => ft(b, C + 1)), s = t.find((b) => b.n === this.panel.n);
5435
+ if (!s) return m;
5436
+ const i = this.msg, a = Ot(e.content), r = t.filter((b) => b.n !== s.n && (!a.size || a.has(b.n))), c = `ref:${e.key}:${s.n}`, l = `"${s.text}"
5437
+ — ${s.title} [${s.n}]${s.path ? `
5438
+ ${s.path}` : ""}${s.updated ? ` · Updated ${s.updated}` : ""}`, f = [
5439
+ s.updated ? `Updated ${s.updated}` : "",
5440
+ s.score !== null ? `Relevance ${s.score.toFixed(2)}` : ""
5327
5441
  ].filter(Boolean).join(" · ");
5328
5442
  return o`<aside
5329
5443
  class="panel ${this.panelDocked ? "docked" : "overlay"}"
5330
5444
  part="panel"
5331
5445
  role="region"
5332
- aria-label=${L(s.sourceLabel, { n: i.n })}
5446
+ aria-label=${_(i.sourceLabel, { n: s.n })}
5333
5447
  >
5334
5448
  <div class="panel-head">
5335
5449
  <span class="label"
5336
- >${L(s.sourceLabel, { n: i.n })}${i.collection ? ` · ${i.collection}` : ""}</span
5450
+ >${_(i.sourceLabel, { n: s.n })}${s.collection ? ` · ${s.collection}` : ""}</span
5337
5451
  >
5338
5452
  <button type="button" class="text-btn underline" @click=${() => this.panel = null}>
5339
- ${s.close}
5453
+ ${i.close}
5340
5454
  </button>
5341
5455
  </div>
5342
5456
  <div class="panel-body">
5343
5457
  <div class="panel-meta">
5344
- <h3>${i.title}</h3>
5345
- ${i.path ? o`<span class="path">${i.path}</span>` : f}
5346
- ${m ? o`<span class="meta">${m}</span>` : f}
5458
+ <h3>${s.title}</h3>
5459
+ ${s.section ? o`<span class="meta">${s.section}</span>` : m}
5460
+ ${s.path ? o`<span class="path">${s.path}</span>` : m}
5461
+ ${f ? o`<span class="meta">${f}</span>` : m}
5347
5462
  </div>
5348
5463
  <div class="passage-box">
5349
- <span class="text">${i.text}</span>
5464
+ <span class="text">${s.text}</span>
5350
5465
  <div class="passage-foot">
5351
- <span class="label">${s.citedPassage}</span>
5466
+ <span class="label">${i.citedPassage}</span>
5352
5467
  <button
5353
5468
  type="button"
5354
5469
  class="copy-ref"
5355
- title=${s.copyReference}
5356
- aria-label=${s.copyReference}
5357
- @click=${() => this.copy(l, c)}
5470
+ title=${i.copyReference}
5471
+ aria-label=${i.copyReference}
5472
+ @click=${() => this.copy(c, l)}
5358
5473
  >
5359
- ${k.copy()}<span>${this.copiedKey === l ? s.copied : s.copy}</span>
5474
+ ${k.copy()}<span>${this.copiedKey === c ? i.copied : i.copy}</span>
5360
5475
  </button>
5361
5476
  </div>
5362
5477
  </div>
5363
5478
  </div>
5364
5479
  ${r.length ? o`<div class="panel-foot">
5365
- <span class="label">${s.alsoCited}</span>
5480
+ <span class="label">${i.alsoCited}</span>
5366
5481
  <div class="chips">
5367
5482
  ${r.map(
5368
5483
  (b) => o`<button
@@ -5374,12 +5489,12 @@ ${i.path}` : ""}${i.updated ? ` · Updated ${i.updated}` : ""}`, m = [
5374
5489
  </button>`
5375
5490
  )}
5376
5491
  </div>
5377
- </div>` : f}
5492
+ </div>` : m}
5378
5493
  </aside>`;
5379
5494
  }
5380
5495
  renderComposer() {
5381
- const e = this.msg, t = this.mode === "rag" ? e.placeholderRag : L(e.placeholderChat, { name: this.assistantName }), s = !this.draft.trim(), i = this.footnote === "" ? f : o`<span class="footnote" part="footnote"
5382
- >${this.footnote ?? L(e.footnote, { name: this.assistantName })}</span
5496
+ const e = this.msg, t = this.mode === "rag" ? e.placeholderRag : this.mode === "kb" ? e.placeholderKb : _(e.placeholderChat, { name: this.assistantName }), s = !this.draft.trim(), i = this.footnote === "" ? m : o`<span class="footnote" part="footnote"
5497
+ >${this.footnote ?? _(e.footnote, { name: this.assistantName })}</span
5383
5498
  >`;
5384
5499
  return this.showComposer ? o`<div class="composer-wrap">
5385
5500
  <div class="composer-col">
@@ -5394,15 +5509,34 @@ ${i.path}` : ""}${i.updated ? ` · Updated ${i.updated}` : ""}`, m = [
5394
5509
  }}
5395
5510
  />
5396
5511
  <div class="composer-box">
5397
- ${this.busy ? o`<div class="composer-glow"></div>` : f}
5512
+ ${this.busy ? o`<div class="composer-glow"></div>` : m}
5398
5513
  <div class="composer ${this.busy ? "busy" : ""}" part="composer">
5514
+ ${this.savedFiles.length ? o`<div class="pending-files" part="saved-files">
5515
+ ${this.savedFiles.map(
5516
+ (a) => o`<div class="pending-file kept">
5517
+ <span class="ext">${xt(a.name)}</span>
5518
+ <span class="meta"
5519
+ ><span class="name">${a.name}</span
5520
+ ><span class="size">${e.inThisChat}</span></span
5521
+ >
5522
+ <button
5523
+ type="button"
5524
+ aria-label=${e.removeFromChat}
5525
+ title=${e.removeFromChat}
5526
+ @click=${() => this.removeSavedFile(a)}
5527
+ >
5528
+ ×
5529
+ </button>
5530
+ </div>`
5531
+ )}
5532
+ </div>` : m}
5399
5533
  ${this.files.length ? o`<div class="pending-files">
5400
5534
  ${this.files.map(
5401
5535
  (a) => o`<div class="pending-file">
5402
- <span class="ext">${Rt(a.name)}</span>
5536
+ <span class="ext">${xt(a.name)}</span>
5403
5537
  <span class="meta"
5404
5538
  ><span class="name">${a.name}</span
5405
- ><span class="size">${vt(a.size)}</span></span
5539
+ ><span class="size">${kt(a.size)}</span></span
5406
5540
  >
5407
5541
  <button
5408
5542
  type="button"
@@ -5414,7 +5548,7 @@ ${i.path}` : ""}${i.updated ? ` · Updated ${i.updated}` : ""}`, m = [
5414
5548
  </button>
5415
5549
  </div>`
5416
5550
  )}
5417
- </div>` : f}
5551
+ </div>` : m}
5418
5552
  <textarea
5419
5553
  class="input"
5420
5554
  rows="1"
@@ -5437,7 +5571,7 @@ ${i.path}` : ""}${i.updated ? ` · Updated ${i.updated}` : ""}`, m = [
5437
5571
  }}
5438
5572
  >
5439
5573
  ${k.clip()}
5440
- </button>` : f}
5574
+ </button>` : m}
5441
5575
  </div>
5442
5576
  ${this.busy ? o`<button
5443
5577
  type="button"
@@ -5459,7 +5593,7 @@ ${i.path}` : ""}${i.updated ? ` · Updated ${i.updated}` : ""}`, m = [
5459
5593
  </button>`}
5460
5594
  </div>
5461
5595
  </div>
5462
- ${this.busy ? o`<div class="composer-ring"><div class="ring"></div></div>` : f}
5596
+ ${this.busy ? o`<div class="composer-ring"><div class="ring"></div></div>` : m}
5463
5597
  </div>
5464
5598
  ${i}
5465
5599
  </div>
@@ -5467,8 +5601,8 @@ ${i.path}` : ""}${i.updated ? ` · Updated ${i.updated}` : ""}`, m = [
5467
5601
  <div class="composer-col">${i}</div>
5468
5602
  </div>`;
5469
5603
  }
5470
- }, A = new WeakMap(), R = new WeakMap(), E = new WeakMap(), B = new WeakMap(), D = new WeakMap(), F = new WeakMap(), U = new WeakMap(), P = new WeakMap(), K = new WeakMap(), W = new WeakMap(), J = new WeakMap(), H = new WeakMap(), G = new WeakMap(), q = new WeakMap(), V = new WeakMap(), X = new WeakMap(), Y = new WeakMap(), Q = new WeakMap(), Z = new WeakMap(), ee = new WeakMap(), te = new WeakMap(), se = new WeakMap(), ie = new WeakMap(), ae = new WeakMap(), re = new WeakMap(), oe = new WeakMap(), ne = new WeakMap(), le = new WeakMap(), ce = new WeakMap(), de = new WeakMap(), pe = new WeakMap(), he = new WeakMap(), ue = new WeakMap(), ge = new WeakMap(), me = new WeakMap(), fe = new WeakMap(), be = new WeakMap(), xe = new WeakMap(), ve = new WeakMap(), we = new WeakMap(), ye = new WeakMap(), ke = new WeakMap(), $e = new WeakMap(), Ce = new WeakMap(), Te = new WeakMap(), Se = new WeakMap(), Oe = new WeakMap(), Ie = new WeakMap(), Me = new WeakMap(), ze = new WeakMap(), _e = new WeakMap(), Le = new WeakMap(), je = new WeakMap(), Ne = new WeakMap(), Ae = new WeakMap(), Re = new WeakMap(), Ee = new WeakMap(), Be = new WeakMap(), De = new WeakMap(), Fe = new WeakMap(), Ue = new WeakMap(), Pe = new WeakMap(), Ke = new WeakMap(), We = new WeakMap(), Je = new WeakMap(), He = new WeakMap(), Ge = new WeakMap(), qe = new WeakMap(), Ve = new WeakMap(), Xe = new WeakMap(), Ye = new WeakMap(), Qe = new WeakMap(), Ze = new WeakMap(), et = new WeakMap(), tt = new WeakMap(), st = new WeakMap(), it = new WeakMap(), at = new WeakMap(), rt = new WeakMap(), ot = new WeakMap(), nt = new WeakMap(), lt = new WeakMap(), ct = new WeakMap(), dt = new WeakMap(), pt = new WeakMap(), ht = new WeakMap(), Et);
5471
- ws(d, "styles", [qt, Vt, Xt]);
5604
+ }, N = new WeakMap(), R = new WeakMap(), E = new WeakMap(), B = new WeakMap(), D = new WeakMap(), F = new WeakMap(), K = new WeakMap(), P = new WeakMap(), U = new WeakMap(), W = new WeakMap(), H = new WeakMap(), J = new WeakMap(), G = new WeakMap(), q = new WeakMap(), V = new WeakMap(), X = new WeakMap(), Y = new WeakMap(), Q = new WeakMap(), Z = new WeakMap(), ee = new WeakMap(), te = new WeakMap(), se = new WeakMap(), ie = new WeakMap(), ae = new WeakMap(), re = new WeakMap(), oe = new WeakMap(), ne = new WeakMap(), le = new WeakMap(), ce = new WeakMap(), de = new WeakMap(), pe = new WeakMap(), he = new WeakMap(), ue = new WeakMap(), ge = new WeakMap(), me = new WeakMap(), fe = new WeakMap(), be = new WeakMap(), xe = new WeakMap(), ve = new WeakMap(), we = new WeakMap(), ye = new WeakMap(), ke = new WeakMap(), $e = new WeakMap(), Ce = new WeakMap(), Te = new WeakMap(), Se = new WeakMap(), Ie = new WeakMap(), Oe = new WeakMap(), Me = new WeakMap(), ze = new WeakMap(), _e = new WeakMap(), Le = new WeakMap(), Ae = new WeakMap(), je = new WeakMap(), Ne = new WeakMap(), Re = new WeakMap(), Ee = new WeakMap(), Be = new WeakMap(), De = new WeakMap(), Fe = new WeakMap(), Ke = new WeakMap(), Pe = new WeakMap(), Ue = new WeakMap(), We = new WeakMap(), He = new WeakMap(), Je = new WeakMap(), Ge = new WeakMap(), qe = new WeakMap(), Ve = new WeakMap(), Xe = new WeakMap(), Ye = new WeakMap(), Qe = new WeakMap(), Ze = new WeakMap(), et = new WeakMap(), tt = new WeakMap(), st = new WeakMap(), it = new WeakMap(), at = new WeakMap(), rt = new WeakMap(), ot = new WeakMap(), nt = new WeakMap(), lt = new WeakMap(), ct = new WeakMap(), dt = new WeakMap(), pt = new WeakMap(), ht = new WeakMap(), ut = new WeakMap(), gt = new WeakMap(), Ft);
5605
+ $s(d, "styles", [Yt, Qt, Zt]);
5472
5606
  g([
5473
5607
  v({ attribute: !1 })
5474
5608
  ], d.prototype, "client", 1);
@@ -5500,40 +5634,49 @@ g([
5500
5634
  v({ reflect: !0 })
5501
5635
  ], d.prototype, "glow", 1);
5502
5636
  g([
5503
- v({ converter: O })
5637
+ v()
5638
+ ], d.prototype, "docsets", 1);
5639
+ g([
5640
+ v({ attribute: "attachments-mode" })
5641
+ ], d.prototype, "attachmentsMode", 1);
5642
+ g([
5643
+ v({ converter: I, attribute: "save-attachments" })
5644
+ ], d.prototype, "saveAttachments", 1);
5645
+ g([
5646
+ v({ converter: I })
5504
5647
  ], d.prototype, "followups", 1);
5505
5648
  g([
5506
- v({ converter: O, attribute: "show-sources" })
5649
+ v({ converter: I, attribute: "show-sources" })
5507
5650
  ], d.prototype, "showSources", 1);
5508
5651
  g([
5509
- v({ converter: O, attribute: "show-new-chat" })
5652
+ v({ converter: I, attribute: "show-new-chat" })
5510
5653
  ], d.prototype, "showNewChat", 1);
5511
5654
  g([
5512
- v({ converter: O, attribute: "show-bookmarked" })
5655
+ v({ converter: I, attribute: "show-bookmarked" })
5513
5656
  ], d.prototype, "showBookmarked", 1);
5514
5657
  g([
5515
- v({ converter: O, attribute: "show-followups" })
5658
+ v({ converter: I, attribute: "show-followups" })
5516
5659
  ], d.prototype, "showFollowups", 1);
5517
5660
  g([
5518
- v({ converter: O, attribute: "allow-search" })
5661
+ v({ converter: I, attribute: "allow-search" })
5519
5662
  ], d.prototype, "allowSearch", 1);
5520
5663
  g([
5521
- v({ converter: O, attribute: "auto-title" })
5664
+ v({ converter: I, attribute: "auto-title" })
5522
5665
  ], d.prototype, "autoTitle", 1);
5523
5666
  g([
5524
5667
  v()
5525
5668
  ], d.prototype, "model", 1);
5526
5669
  g([
5527
- v({ converter: ft })
5670
+ v({ converter: vt })
5528
5671
  ], d.prototype, "params", 1);
5529
5672
  g([
5530
5673
  v({ attribute: "system-message" })
5531
5674
  ], d.prototype, "systemMessage", 1);
5532
5675
  g([
5533
- v({ converter: ft })
5676
+ v({ converter: vt })
5534
5677
  ], d.prototype, "retrieval", 1);
5535
5678
  g([
5536
- v({ converter: ft })
5679
+ v({ converter: vt })
5537
5680
  ], d.prototype, "metadata", 1);
5538
5681
  g([
5539
5682
  v({ reflect: !0 })
@@ -5542,10 +5685,10 @@ g([
5542
5685
  v({ reflect: !0 })
5543
5686
  ], d.prototype, "position", 1);
5544
5687
  g([
5545
- v({ converter: ys })
5688
+ v({ converter: Cs })
5546
5689
  ], d.prototype, "sidebar", 1);
5547
5690
  g([
5548
- v({ converter: O, attribute: "show-title" })
5691
+ v({ converter: I, attribute: "show-title" })
5549
5692
  ], d.prototype, "showTitle", 1);
5550
5693
  g([
5551
5694
  v({ attribute: "chat-id" })
@@ -5578,34 +5721,34 @@ g([
5578
5721
  v({ type: Boolean, attribute: "unread-badge" })
5579
5722
  ], d.prototype, "unreadBadge", 1);
5580
5723
  g([
5581
- v({ converter: O, attribute: "allow-upload" })
5724
+ v({ converter: I, attribute: "allow-upload" })
5582
5725
  ], d.prototype, "allowUpload", 1);
5583
5726
  g([
5584
- v({ converter: O, attribute: "allow-export" })
5727
+ v({ converter: I, attribute: "allow-export" })
5585
5728
  ], d.prototype, "allowExport", 1);
5586
5729
  g([
5587
- v({ converter: O, attribute: "allow-copy" })
5730
+ v({ converter: I, attribute: "allow-copy" })
5588
5731
  ], d.prototype, "allowCopy", 1);
5589
5732
  g([
5590
- v({ converter: O, attribute: "allow-regenerate" })
5733
+ v({ converter: I, attribute: "allow-regenerate" })
5591
5734
  ], d.prototype, "allowRegenerate", 1);
5592
5735
  g([
5593
- v({ converter: O, attribute: "allow-bookmark" })
5736
+ v({ converter: I, attribute: "allow-bookmark" })
5594
5737
  ], d.prototype, "allowBookmark", 1);
5595
5738
  g([
5596
- v({ converter: O, attribute: "allow-delete" })
5739
+ v({ converter: I, attribute: "allow-delete" })
5597
5740
  ], d.prototype, "allowDelete", 1);
5598
5741
  g([
5599
- v({ converter: O, attribute: "allow-rename" })
5742
+ v({ converter: I, attribute: "allow-rename" })
5600
5743
  ], d.prototype, "allowRename", 1);
5601
5744
  g([
5602
- v({ converter: O, attribute: "allow-feedback" })
5745
+ v({ converter: I, attribute: "allow-feedback" })
5603
5746
  ], d.prototype, "allowFeedback", 1);
5604
5747
  g([
5605
- v({ converter: O, attribute: "show-composer" })
5748
+ v({ converter: I, attribute: "show-composer" })
5606
5749
  ], d.prototype, "showComposer", 1);
5607
5750
  g([
5608
- v({ converter: O, attribute: "show-time" })
5751
+ v({ converter: I, attribute: "show-time" })
5609
5752
  ], d.prototype, "showTime", 1);
5610
5753
  g([
5611
5754
  v()
@@ -5614,14 +5757,8 @@ g([
5614
5757
  v({ type: Boolean, attribute: "allow-raw" })
5615
5758
  ], d.prototype, "allowRaw", 1);
5616
5759
  g([
5617
- v({ converter: O })
5760
+ v({ converter: I })
5618
5761
  ], d.prototype, "branding", 1);
5619
- g([
5620
- v({ attribute: "branding-text" })
5621
- ], d.prototype, "brandingText", 1);
5622
- g([
5623
- v({ attribute: "branding-url" })
5624
- ], d.prototype, "brandingUrl", 1);
5625
5762
  g([
5626
5763
  y()
5627
5764
  ], d.prototype, "chatList", 1);
@@ -5694,6 +5831,9 @@ g([
5694
5831
  g([
5695
5832
  y()
5696
5833
  ], d.prototype, "rawKeys", 1);
5834
+ g([
5835
+ y()
5836
+ ], d.prototype, "savedFiles", 1);
5697
5837
  g([
5698
5838
  y()
5699
5839
  ], d.prototype, "hasSidebarContent", 1);
@@ -5728,19 +5868,19 @@ g([
5728
5868
  y()
5729
5869
  ], d.prototype, "mobile", 1);
5730
5870
  d = g([
5731
- Wt("singlebase-chat")
5871
+ Gt("singlebase-chat")
5732
5872
  ], d);
5733
5873
  export {
5734
5874
  d as S,
5735
- ps as a,
5736
- gt as b,
5737
- Tt as c,
5738
- Yt as d,
5739
- is as e,
5740
- Ot as f,
5741
- bs as g,
5742
- ns as p,
5743
- Qt as r,
5744
- ls as s
5875
+ gs as a,
5876
+ ft as b,
5877
+ Ot as c,
5878
+ es as d,
5879
+ os as e,
5880
+ zt as f,
5881
+ ws as g,
5882
+ ds as p,
5883
+ ts as r,
5884
+ ps as s
5745
5885
  };
5746
- //# sourceMappingURL=chat-CEh6RygY.js.map
5886
+ //# sourceMappingURL=chat-t4o5FsxM.js.map