@cuadra-ai/uikit 0.4.4 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,19 +1,19 @@
1
- var zr = Object.defineProperty;
2
- var jr = (e, r, t) => r in e ? zr(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
3
- var oe = (e, r, t) => jr(e, typeof r != "symbol" ? r + "" : r, t);
4
- import { jsx as d, jsxs as C, Fragment as ae } from "react/jsx-runtime";
5
- import vt, { forwardRef as be, createElement as rt, useMemo as G, useState as R, useEffect as $, useCallback as X, memo as Ur, useImperativeHandle as ct, useRef as ue, useSyncExternalStore as $r, createContext as Ot, Component as Or, useContext as ut } from "react";
6
- import { createPortal as at } from "react-dom";
7
- import { useThreadListItem as Bt, RuntimeAdapterProvider as Br, useLocalRuntime as Wt, AssistantRuntimeProvider as qt, unstable_useRemoteThreadListRuntime as Wr, useThreadRuntime as qr, useAssistantApi as Hr, ThreadPrimitive as De, ComposerPrimitive as Ce, useAssistantState as Me, AttachmentPrimitive as Vr, MessagePrimitive as ve, ThreadListPrimitive as Ke, useThread as Xr, ThreadListItemPrimitive as Qe } from "@assistant-ui/react";
1
+ var jr = Object.defineProperty;
2
+ var Ur = (e, r, t) => r in e ? jr(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
3
+ var se = (e, r, t) => Ur(e, typeof r != "symbol" ? r + "" : r, t);
4
+ import { jsx as d, jsxs as C, Fragment as ne } from "react/jsx-runtime";
5
+ import vt, { forwardRef as ge, createElement as tt, useMemo as K, useState as _, useEffect as B, useCallback as Q, memo as $r, useImperativeHandle as ct, useRef as le, useSyncExternalStore as Or, createContext as Ot, Component as Br, useContext as ut } from "react";
6
+ import { createPortal as rt } from "react-dom";
7
+ import { useThreadListItem as Bt, RuntimeAdapterProvider as Wr, useLocalRuntime as Wt, AssistantRuntimeProvider as qt, unstable_useRemoteThreadListRuntime as qr, useThreadRuntime as Hr, useAssistantApi as Vr, ThreadPrimitive as De, ComposerPrimitive as Ce, useAssistantState as Ae, AttachmentPrimitive as Xr, MessagePrimitive as Te, ThreadListPrimitive as Xe, useThread as Kr, ThreadListItemPrimitive as Ke } from "@assistant-ui/react";
8
8
  import "@assistant-ui/react-markdown/styles/dot.css";
9
- import { unstable_memoizeMarkdownComponents as Kr, useIsMarkdownCodeBlock as Qr, MarkdownTextPrimitive as Gr } from "@assistant-ui/react-markdown";
10
- let Te = !1, Tt = !1;
9
+ import { unstable_memoizeMarkdownComponents as Qr, useIsMarkdownCodeBlock as Gr, MarkdownTextPrimitive as Yr } from "@assistant-ui/react-markdown";
10
+ let Me = !1, Tt = !1;
11
11
  function Mt() {
12
12
  if (Tt || (Tt = !0, typeof document > "u" || typeof window > "u"))
13
13
  return;
14
14
  const e = document.querySelector("link[data-cuadra-uikit-styles]"), r = document.querySelector("style[data-cuadra-uikit-styles]");
15
15
  if (e || r) {
16
- Te = !0;
16
+ Me = !0;
17
17
  return;
18
18
  }
19
19
  try {
@@ -21,15 +21,15 @@ function Mt() {
21
21
  t.className = "cuadra-flex", t.style.visibility = "hidden", t.style.position = "absolute", t.style.pointerEvents = "none", document.body.appendChild(t);
22
22
  const a = window.getComputedStyle(t).display === "flex";
23
23
  if (document.body.removeChild(t), a) {
24
- Te = !0;
24
+ Me = !0;
25
25
  return;
26
26
  }
27
27
  } catch {
28
28
  }
29
- Yr();
29
+ Zr();
30
30
  }
31
- function Yr() {
32
- if (Te)
31
+ function Zr() {
32
+ if (Me)
33
33
  return;
34
34
  const e = document.createElement("link");
35
35
  e.setAttribute("data-cuadra-uikit-styles", "true"), e.rel = "stylesheet", e.type = "text/css";
@@ -40,7 +40,7 @@ function Yr() {
40
40
  e.href = "/node_modules/@cuadra-ai/uikit/dist/uikit.css";
41
41
  }
42
42
  e.onload = () => {
43
- Te = !0;
43
+ Me = !0;
44
44
  }, e.onerror = () => {
45
45
  const r = [
46
46
  "/node_modules/@cuadra-ai/uikit/dist/uikit.css",
@@ -49,25 +49,25 @@ function Yr() {
49
49
  let t = 0;
50
50
  const a = () => {
51
51
  t < r.length && (e.href = r[t++], e.onerror = a, e.onload = () => {
52
- Te = !0;
52
+ Me = !0;
53
53
  });
54
54
  };
55
55
  a();
56
56
  }, document.head.appendChild(e);
57
57
  }
58
58
  typeof document < "u" && typeof window < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", Mt) : Mt());
59
- const Zr = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), Jr = (e) => e.replace(
59
+ const Jr = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), ea = (e) => e.replace(
60
60
  /^([A-Z])|[\s-_]+(\w)/g,
61
61
  (r, t, a) => a ? a.toUpperCase() : t.toLowerCase()
62
62
  ), At = (e) => {
63
- const r = Jr(e);
63
+ const r = ea(e);
64
64
  return r.charAt(0).toUpperCase() + r.slice(1);
65
- }, Ht = (...e) => e.filter((r, t, a) => !!r && r.trim() !== "" && a.indexOf(r) === t).join(" ").trim(), ea = (e) => {
65
+ }, Ht = (...e) => e.filter((r, t, a) => !!r && r.trim() !== "" && a.indexOf(r) === t).join(" ").trim(), ta = (e) => {
66
66
  for (const r in e)
67
67
  if (r.startsWith("aria-") || r === "role" || r === "title")
68
68
  return !0;
69
69
  };
70
- var ta = {
70
+ var ra = {
71
71
  xmlns: "http://www.w3.org/2000/svg",
72
72
  width: 24,
73
73
  height: 24,
@@ -78,7 +78,7 @@ var ta = {
78
78
  strokeLinecap: "round",
79
79
  strokeLinejoin: "round"
80
80
  };
81
- const ra = be(
81
+ const aa = ge(
82
82
  ({
83
83
  color: e = "currentColor",
84
84
  size: r = 24,
@@ -88,32 +88,32 @@ const ra = be(
88
88
  children: o,
89
89
  iconNode: n,
90
90
  ...c
91
- }, s) => rt(
91
+ }, s) => tt(
92
92
  "svg",
93
93
  {
94
94
  ref: s,
95
- ...ta,
95
+ ...ra,
96
96
  width: r,
97
97
  height: r,
98
98
  stroke: e,
99
99
  strokeWidth: a ? Number(t) * 24 / Number(r) : t,
100
100
  className: Ht("lucide", i),
101
- ...!o && !ea(c) && { "aria-hidden": "true" },
101
+ ...!o && !ta(c) && { "aria-hidden": "true" },
102
102
  ...c
103
103
  },
104
104
  [
105
- ...n.map(([l, f]) => rt(l, f)),
105
+ ...n.map(([l, f]) => tt(l, f)),
106
106
  ...Array.isArray(o) ? o : [o]
107
107
  ]
108
108
  )
109
109
  );
110
- const q = (e, r) => {
111
- const t = be(
112
- ({ className: a, ...i }, o) => rt(ra, {
110
+ const W = (e, r) => {
111
+ const t = ge(
112
+ ({ className: a, ...i }, o) => tt(aa, {
113
113
  ref: o,
114
114
  iconNode: r,
115
115
  className: Ht(
116
- `lucide-${Zr(At(e))}`,
116
+ `lucide-${Jr(At(e))}`,
117
117
  `lucide-${e}`,
118
118
  a
119
119
  ),
@@ -122,26 +122,26 @@ const q = (e, r) => {
122
122
  );
123
123
  return t.displayName = At(e), t;
124
124
  };
125
- const aa = [
125
+ const na = [
126
126
  ["path", { d: "m5 12 7-7 7 7", key: "hav0vg" }],
127
127
  ["path", { d: "M12 19V5", key: "x0mq9r" }]
128
- ], na = q("arrow-up", aa);
129
- const ia = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]], oa = q("check", ia);
130
- const sa = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]], nt = q("chevron-down", sa);
131
- const ca = [
128
+ ], ia = W("arrow-up", na);
129
+ const oa = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]], sa = W("check", oa);
130
+ const ca = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]], at = W("chevron-down", ca);
131
+ const ua = [
132
132
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
133
133
  ["path", { d: "M12 18a6 6 0 0 0 0-12v12z", key: "j4l70d" }]
134
- ], ua = q("contrast", ca);
135
- const la = [
134
+ ], la = W("contrast", ua);
135
+ const da = [
136
136
  ["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
137
137
  ["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2", key: "zix9uf" }]
138
- ], da = q("copy", la);
139
- const fa = [
138
+ ], fa = W("copy", da);
139
+ const ha = [
140
140
  ["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
141
141
  ["circle", { cx: "12", cy: "5", r: "1", key: "gxeob9" }],
142
142
  ["circle", { cx: "12", cy: "19", r: "1", key: "lyex9k" }]
143
- ], ha = q("ellipsis-vertical", fa);
144
- const ma = [
143
+ ], ma = W("ellipsis-vertical", ha);
144
+ const pa = [
145
145
  [
146
146
  "path",
147
147
  {
@@ -154,8 +154,8 @@ const ma = [
154
154
  ["path", { d: "M14 13h2", key: "un5t4a" }],
155
155
  ["path", { d: "M8 17h2", key: "2yhykz" }],
156
156
  ["path", { d: "M14 17h2", key: "10kma7" }]
157
- ], pa = q("file-spreadsheet", ma);
158
- const ga = [
157
+ ], ga = W("file-spreadsheet", pa);
158
+ const ba = [
159
159
  [
160
160
  "path",
161
161
  {
@@ -167,8 +167,8 @@ const ga = [
167
167
  ["path", { d: "M10 9H8", key: "b1mrlr" }],
168
168
  ["path", { d: "M16 13H8", key: "t4e002" }],
169
169
  ["path", { d: "M16 17H8", key: "z1uh3a" }]
170
- ], Vt = q("file-text", ga);
171
- const ba = [
170
+ ], Vt = W("file-text", ba);
171
+ const ya = [
172
172
  [
173
173
  "path",
174
174
  {
@@ -180,19 +180,19 @@ const ba = [
180
180
  ["path", { d: "M11 18h2", key: "12mj7e" }],
181
181
  ["path", { d: "M12 12v6", key: "3ahymv" }],
182
182
  ["path", { d: "M9 13v-.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 .5.5v.5", key: "qbrxap" }]
183
- ], ya = q("file-type", ba);
184
- const xa = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]], Xt = q("loader-circle", xa);
185
- const wa = [
183
+ ], xa = W("file-type", ya);
184
+ const wa = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]], Xt = W("loader-circle", wa);
185
+ const ka = [
186
186
  ["path", { d: "m16 17 5-5-5-5", key: "1bji2h" }],
187
187
  ["path", { d: "M21 12H9", key: "dn1m92" }],
188
188
  ["path", { d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4", key: "1uf3rs" }]
189
- ], ka = q("log-out", wa);
190
- const Ca = [
189
+ ], Ca = W("log-out", ka);
190
+ const va = [
191
191
  ["path", { d: "M4 5h16", key: "1tepv9" }],
192
192
  ["path", { d: "M4 12h16", key: "1lakjw" }],
193
193
  ["path", { d: "M4 19h16", key: "1djgab" }]
194
- ], va = q("menu", Ca);
195
- const Ta = [
194
+ ], Ta = W("menu", va);
195
+ const Ma = [
196
196
  [
197
197
  "path",
198
198
  {
@@ -200,15 +200,15 @@ const Ta = [
200
200
  key: "1miecu"
201
201
  }
202
202
  ]
203
- ], Kt = q("paperclip", Ta);
204
- const Ma = [
203
+ ], Kt = W("paperclip", Ma);
204
+ const Aa = [
205
205
  ["path", { d: "M5 12h14", key: "1ays0h" }],
206
206
  ["path", { d: "M12 5v14", key: "s699le" }]
207
- ], Aa = q("plus", Ma);
208
- const Ia = [
207
+ ], Ia = W("plus", Aa);
208
+ const Na = [
209
209
  ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
210
210
  ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
211
- ], lt = q("x", Ia), Na = [
211
+ ], lt = W("x", Na), Sa = [
212
212
  // Llama/Mistral instruction format
213
213
  /\[INST\]/gi,
214
214
  /\[\/INST\]/gi,
@@ -226,17 +226,17 @@ const Ia = [
226
226
  // Generic role injection attempts
227
227
  /^(system|user|assistant):\s*/gim
228
228
  ];
229
- function rs(e) {
229
+ function as(e) {
230
230
  if (!e || typeof e != "string")
231
231
  return "";
232
232
  let r = e;
233
- for (const t of Na)
233
+ for (const t of Sa)
234
234
  r = r.replace(t, "");
235
235
  return r = r.replace(/\n{3,}/g, `
236
236
 
237
237
  `).replace(/ {2,}/g, " ").trim(), r;
238
238
  }
239
- function as(e) {
239
+ function ns(e) {
240
240
  if (!e || typeof e != "string")
241
241
  return !1;
242
242
  try {
@@ -246,7 +246,7 @@ function as(e) {
246
246
  return !1;
247
247
  }
248
248
  }
249
- function ns(e) {
249
+ function is(e) {
250
250
  if (!e)
251
251
  return { valid: !1, error: "URL is required" };
252
252
  if (typeof e != "string")
@@ -255,7 +255,7 @@ function ns(e) {
255
255
  return { valid: !0 };
256
256
  try {
257
257
  const r = new URL(e);
258
- return ["http:", "https:"].includes(r.protocol) ? r.protocol === "http:" && !Sa(e) ? {
258
+ return ["http:", "https:"].includes(r.protocol) ? r.protocol === "http:" && !La(e) ? {
259
259
  valid: !0,
260
260
  parsed: r,
261
261
  error: "Warning: Using HTTP for non-localhost URL. Consider using HTTPS."
@@ -267,7 +267,7 @@ function ns(e) {
267
267
  return { valid: !1, error: "Invalid URL format" };
268
268
  }
269
269
  }
270
- function Sa(e) {
270
+ function La(e) {
271
271
  try {
272
272
  const r = new URL(e);
273
273
  return ["localhost", "127.0.0.1", "[::1]"].includes(r.hostname);
@@ -275,7 +275,7 @@ function Sa(e) {
275
275
  return !1;
276
276
  }
277
277
  }
278
- function is(e) {
278
+ function os(e) {
279
279
  if (!e || typeof e != "string")
280
280
  return "";
281
281
  const r = {
@@ -288,7 +288,7 @@ function is(e) {
288
288
  };
289
289
  return e.replace(/[&<>"'/]/g, (t) => r[t] || t);
290
290
  }
291
- function La() {
291
+ function Ea() {
292
292
  if (typeof crypto < "u" && crypto.randomUUID)
293
293
  return crypto.randomUUID();
294
294
  if (typeof crypto < "u" && crypto.getRandomValues) {
@@ -301,9 +301,9 @@ function La() {
301
301
  }
302
302
  class Qt {
303
303
  constructor(r, t, a = !1) {
304
- oe(this, "baseUrl");
305
- oe(this, "sessionToken", null);
306
- oe(this, "isProxyMode", !1);
304
+ se(this, "baseUrl");
305
+ se(this, "sessionToken", null);
306
+ se(this, "isProxyMode", !1);
307
307
  this.baseUrl = r.replace(/\/$/, ""), this.isProxyMode = a, t && (this.sessionToken = t);
308
308
  }
309
309
  /**
@@ -406,7 +406,7 @@ class Qt {
406
406
  * Uses the shared secure UUID generator from sanitize utils
407
407
  */
408
408
  generateIdempotencyKey() {
409
- return La();
409
+ return Ea();
410
410
  }
411
411
  /**
412
412
  * Update a chat
@@ -537,7 +537,7 @@ class Qt {
537
537
  return s.json();
538
538
  }
539
539
  }
540
- async function* Ea(e, r) {
540
+ async function* Pa(e, r) {
541
541
  const t = e.getReader(), a = new TextDecoder();
542
542
  let i = "";
543
543
  try {
@@ -570,7 +570,7 @@ async function* Ea(e, r) {
570
570
  t.releaseLock();
571
571
  }
572
572
  }
573
- function Pa(e) {
573
+ function Ra(e) {
574
574
  return e.map((r) => {
575
575
  let t = "";
576
576
  if (typeof r.content == "string")
@@ -586,7 +586,7 @@ function Pa(e) {
586
586
  };
587
587
  });
588
588
  }
589
- function Ra(e) {
589
+ function Da(e) {
590
590
  return {
591
591
  id: e.id,
592
592
  role: e.role,
@@ -618,8 +618,8 @@ function Ra(e) {
618
618
  }
619
619
  };
620
620
  }
621
- const Ue = /* @__PURE__ */ new Map();
622
- function Da(e, r) {
621
+ const ve = /* @__PURE__ */ new Map(), nt = /* @__PURE__ */ new Map();
622
+ function _a(e, r) {
623
623
  return {
624
624
  async list() {
625
625
  const t = [];
@@ -640,17 +640,19 @@ function Da(e, r) {
640
640
  }).filter((c) => c !== null) };
641
641
  },
642
642
  async initialize(t) {
643
- return { remoteId: Ue.get(t) || t, externalId: void 0 };
643
+ return { remoteId: ve.get(t) || t, externalId: void 0 };
644
644
  },
645
645
  async rename(t, a) {
646
- await e.updateChat(t, { title: a });
646
+ const i = ve.get(t) || t;
647
+ await e.updateChat(i, { title: a });
647
648
  },
648
649
  async archive(t) {
649
650
  },
650
651
  async unarchive(t) {
651
652
  },
652
653
  async delete(t) {
653
- await e.deleteChat(t);
654
+ const a = ve.get(t) || t;
655
+ await e.deleteChat(a);
654
656
  },
655
657
  async generateTitle(t, a) {
656
658
  return new ReadableStream();
@@ -676,7 +678,7 @@ function Da(e, r) {
676
678
  },
677
679
  // Add a method to update the remoteId mapping when chat ID is received
678
680
  updateRemoteId(t, a) {
679
- Ue.set(t, a), r?.(t, a);
681
+ ve.set(t, a), r?.(t, a);
680
682
  },
681
683
  // Provider component that adds thread-specific history adapter
682
684
  unstable_Provider: ({ children: t }) => {
@@ -686,7 +688,15 @@ function Da(e, r) {
686
688
  if (!i) return { messages: [] };
687
689
  try {
688
690
  const c = await e.getChat(i);
689
- return !c.messages || c.messages.length === 0 ? { messages: [] } : { messages: c.messages.map((l) => Ra(l)) };
691
+ if (!c.messages || c.messages.length === 0)
692
+ return { messages: [] };
693
+ const s = c.messages.map((f) => Da(f)), l = s.map((f, u) => ({
694
+ message: f,
695
+ parentId: u > 0 ? s[u - 1].id : null
696
+ }));
697
+ for (const f of s)
698
+ nt.set(f.id, i);
699
+ return { messages: l };
690
700
  } catch {
691
701
  return { messages: [] };
692
702
  }
@@ -696,17 +706,17 @@ function Da(e, r) {
696
706
  }),
697
707
  [i, e]
698
708
  ), n = vt.useMemo(() => ({ history: o }), [o]);
699
- return /* @__PURE__ */ d(Br, { adapters: n, children: t });
709
+ return /* @__PURE__ */ d(Wr, { adapters: n, children: t });
700
710
  }
701
711
  };
702
712
  }
703
- class _a {
713
+ class Fa {
704
714
  constructor() {
705
715
  /** Per-message metadata, keyed by message ID */
706
- oe(this, "messageMetadata", /* @__PURE__ */ new Map());
716
+ se(this, "messageMetadata", /* @__PURE__ */ new Map());
707
717
  /** Current streaming message ID */
708
- oe(this, "currentMessageId", null);
709
- oe(this, "listeners", /* @__PURE__ */ new Set());
718
+ se(this, "currentMessageId", null);
719
+ se(this, "listeners", /* @__PURE__ */ new Set());
710
720
  }
711
721
  /**
712
722
  * Set the current streaming message ID
@@ -760,7 +770,7 @@ class _a {
760
770
  this.listeners.forEach((r) => r());
761
771
  }
762
772
  }
763
- const se = new _a(), It = /* @__PURE__ */ new Map(), it = [];
773
+ const ce = new Fa(), It = /* @__PURE__ */ new Map(), it = [];
764
774
  let _e = [];
765
775
  function Gt(e, r, t = 50, a = 800) {
766
776
  it.push({ question: e, response: r, streamingSpeed: t, initialDelay: a });
@@ -770,148 +780,193 @@ function Yt(e, r) {
770
780
  let u;
771
781
  return {
772
782
  async *run(p) {
773
- const { messages: g, abortSignal: h, context: y } = p, b = it.shift();
774
- if (b) {
783
+ const { messages: g, abortSignal: h } = p, y = it.shift();
784
+ if (y) {
775
785
  c?.();
776
- const v = b.initialDelay ?? 800;
777
- if (v > 0 && await new Promise((S) => setTimeout(S, v)), h?.aborted)
786
+ const k = y.initialDelay ?? 800;
787
+ if (k > 0 && await new Promise((M) => setTimeout(M, k)), h?.aborted)
778
788
  throw new Error("Request aborted");
779
- const N = b.response.split(" ");
780
- let F = "";
781
- const P = b.streamingSpeed || 50, W = `premade-${Date.now()}`;
782
- i && n?.(W);
783
- for (let S = 0; S < N.length; S++) {
789
+ const R = y.response.split(" ");
790
+ let P = "";
791
+ const j = y.streamingSpeed || 50, F = `premade-${Date.now()}`;
792
+ i && n?.(F);
793
+ for (let M = 0; M < R.length; M++) {
784
794
  if (h?.aborted)
785
795
  throw new Error("Request aborted");
786
- F += (S === 0 ? "" : " ") + N[S], yield {
787
- content: [{ type: "text", text: F }]
788
- }, await new Promise((B) => setTimeout(B, P + Math.random() * (P * 0.5)));
796
+ P += (M === 0 ? "" : " ") + R[M], yield {
797
+ content: [{ type: "text", text: P }]
798
+ }, await new Promise((U) => setTimeout(U, j + Math.random() * (j * 0.5)));
789
799
  }
790
800
  yield {
791
- content: [{ type: "text", text: F }]
801
+ content: [{ type: "text", text: P }]
792
802
  }, _e.push(
793
- { role: "user", content: b.question },
794
- { role: "assistant", content: b.response }
803
+ { role: "user", content: y.question },
804
+ { role: "assistant", content: y.response }
795
805
  );
796
806
  return;
797
807
  }
798
- const x = y?.threadId;
799
- let w = x;
800
- if (!w && g.length > 0) {
801
- const v = g.find((N) => N.role === "user");
802
- v && (w = (typeof v.content == "string" ? v.content : Array.isArray(v.content) && v.content.find((F) => F.type === "text")?.text || "").substring(0, 50));
808
+ let b;
809
+ for (const k of g) {
810
+ const R = nt.get(k.id);
811
+ if (R) {
812
+ b = R;
813
+ break;
814
+ }
815
+ }
816
+ if (!b && g.length > 0) {
817
+ const k = g.find((R) => R.role === "user");
818
+ if (k) {
819
+ const P = (typeof k.content == "string" ? k.content : Array.isArray(k.content) && k.content.find((j) => j.type === "text")?.text || "").substring(0, 50);
820
+ b = It.get(P);
821
+ }
803
822
  }
804
- let k;
805
- x && (k = Ue.get(x)), !k && w && (k = It.get(w)), !k && u && (k = u), c?.();
806
- let L = g, E = -1;
807
- for (let v = g.length - 1; v >= 0; v--)
808
- if (g[v].role === "assistant") {
809
- E = v;
823
+ !b && u && (b = u), c?.();
824
+ let x = g, w = -1;
825
+ for (let k = g.length - 1; k >= 0; k--)
826
+ if (g[k].role === "assistant") {
827
+ w = k;
810
828
  break;
811
829
  }
812
- (k || E >= 0) && E >= 0 && (L = g.slice(E + 1));
813
- const I = Pa(L);
814
- if (_e.length > 0 && !k) {
815
- const v = _e.map((N) => ({
816
- role: N.role,
817
- content: N.content
830
+ (b || w >= 0) && w >= 0 && (x = g.slice(w + 1));
831
+ const v = Ra(x);
832
+ if (_e.length > 0 && !b) {
833
+ const k = _e.map((R) => ({
834
+ role: R.role,
835
+ content: R.content
818
836
  }));
819
- I.unshift(...v), _e = [];
837
+ v.unshift(...k), _e = [];
838
+ }
839
+ const L = [];
840
+ let E;
841
+ for (let k = x.length - 1; k >= 0; k--)
842
+ if (x[k].role === "user") {
843
+ E = x[k];
844
+ break;
845
+ }
846
+ if (E && "attachments" in E) {
847
+ const k = E.attachments;
848
+ if (k && k.length > 0) {
849
+ for (const R of k)
850
+ if (R.file)
851
+ try {
852
+ const P = await e.uploadFile(R.file);
853
+ L.push(P.id);
854
+ } catch {
855
+ }
856
+ }
820
857
  }
821
- const M = {
822
- messages: I,
823
- chatId: k || null,
858
+ const N = {
859
+ messages: v,
860
+ chatId: b || null,
824
861
  // Use server chatId if available
825
862
  systemPrompt: a,
826
863
  ephemeral: i,
827
864
  enableReasoning: o,
828
865
  stream: !0
829
866
  };
830
- if (t && t.trim() !== "" && (M.modelId = t), l && !await l()) {
867
+ if (t && t.trim() !== "" && (N.modelId = t), L.length > 0 && (N.fileIds = L), l && !await l()) {
831
868
  if (f) {
832
- const N = typeof f == "function" ? f() : f, F = g.filter((B) => B.role === "user"), P = F.length > 0 ? F[F.length - 1] : void 0;
833
- let W = "Message";
834
- P && (typeof P.content == "string" ? W = P.content : Array.isArray(P.content) && (W = P.content.find(
835
- (Q) => Q.type === "text"
836
- )?.text || "Message")), Gt(W, N, 40, 400);
837
- const S = it.shift();
838
- if (S) {
869
+ const R = typeof f == "function" ? f() : f, P = g.filter((U) => U.role === "user"), j = P.length > 0 ? P[P.length - 1] : void 0;
870
+ let F = "Message";
871
+ j && (typeof j.content == "string" ? F = j.content : Array.isArray(j.content) && (F = j.content.find(
872
+ (V) => V.type === "text"
873
+ )?.text || "Message")), Gt(F, R, 40, 400);
874
+ const M = it.shift();
875
+ if (M) {
839
876
  c?.();
840
- const B = S.initialDelay ?? 400;
841
- if (B > 0 && await new Promise((ie) => setTimeout(ie, B)), h?.aborted)
877
+ const U = M.initialDelay ?? 400;
878
+ if (U > 0 && await new Promise((Y) => setTimeout(Y, U)), h?.aborted)
842
879
  throw new Error("Request aborted");
843
- const Q = S.response.split(" ");
844
- let J = "";
845
- const de = S.streamingSpeed || 40, fe = `mock-${Date.now()}`;
846
- i && n?.(fe);
847
- for (let ie = 0; ie < Q.length; ie++) {
880
+ const V = M.response.split(" ");
881
+ let X = "";
882
+ const oe = M.streamingSpeed || 40, ye = `mock-${Date.now()}`;
883
+ i && n?.(ye);
884
+ for (let Y = 0; Y < V.length; Y++) {
848
885
  if (h?.aborted)
849
886
  throw new Error("Request aborted");
850
- J += (ie === 0 ? "" : " ") + Q[ie], yield {
851
- content: [{ type: "text", text: J }]
852
- }, await new Promise((Ve) => setTimeout(Ve, de + Math.random() * (de * 0.3)));
887
+ X += (Y === 0 ? "" : " ") + V[Y], yield {
888
+ content: [{ type: "text", text: X }]
889
+ }, await new Promise((He) => setTimeout(He, oe + Math.random() * (oe * 0.3)));
853
890
  }
854
891
  yield {
855
- content: [{ type: "text", text: J }]
892
+ content: [{ type: "text", text: X }]
856
893
  };
857
894
  return;
858
895
  }
859
896
  }
860
897
  throw new Error("Request blocked");
861
898
  }
862
- const _ = await e.createOrContinueChat(M, h);
863
- let A = "", m = "", O;
864
- const j = [];
865
- let K = 0, V = !1;
866
- const ye = `msg_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
867
- se.clear(), se.setCurrentMessage(ye);
868
- const Le = () => {
869
- j.length !== K && (K = j.length, se.update({
870
- sources: j.length > 0 ? [...j] : void 0
899
+ const A = await e.createOrContinueChat(N, h);
900
+ let I = "", S = "", m;
901
+ const D = [];
902
+ let G = 0, H = !1;
903
+ const ee = `msg_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
904
+ ce.clear(), ce.setCurrentMessage(ee);
905
+ const be = () => {
906
+ D.length !== G && (G = D.length, ce.update({
907
+ sources: D.length > 0 ? [...D] : void 0
871
908
  }));
872
909
  }, Z = () => {
873
- Le();
874
- const v = [];
875
- return m && v.push({ type: "reasoning", text: m }), A && v.push({ type: "text", text: A }), v.length === 0 && v.push({ type: "text", text: "" }), { content: v };
910
+ be();
911
+ const k = [];
912
+ return S && k.push({ type: "reasoning", text: S }), I && k.push({ type: "text", text: I }), k.length === 0 && k.push({ type: "text", text: "" }), { content: k };
876
913
  };
877
- for await (const v of Ea(_, h)) {
914
+ for await (const k of Pa(A, h)) {
878
915
  if (h?.aborted)
879
916
  throw new Error("Request aborted");
880
- const N = v.id || v.chatId || v.messageId;
881
- N && !O && (O = N, u = N, n?.(N), x && s && (s(x, N), Ue.set(x, N)), w && It.set(w, N));
882
- const F = v.sources;
883
- if (F && Array.isArray(F) && F.length > 0)
884
- for (const S of F)
885
- j.some((B) => B.sourceId === S.sourceId) || j.push({
886
- sourceId: S.sourceId,
887
- filename: S.filename || "Unknown",
888
- score: S.score ?? 1,
889
- chunkId: S.chunkId,
890
- datasetId: S.datasetId
917
+ const R = k.id || k.chatId || k.messageId;
918
+ if (R && !m) {
919
+ m = R, u = R, n?.(R);
920
+ for (const M of g)
921
+ nt.set(M.id, R);
922
+ if (g.length > 0) {
923
+ const M = g.find((U) => U.role === "user");
924
+ if (M) {
925
+ const V = (typeof M.content == "string" ? M.content : Array.isArray(M.content) && M.content.find((X) => X.type === "text")?.text || "").substring(0, 50);
926
+ It.set(V, R);
927
+ }
928
+ }
929
+ if (s) {
930
+ for (const [M, U] of ve.entries())
931
+ if (U === R) {
932
+ s(M, R);
933
+ break;
934
+ }
935
+ }
936
+ }
937
+ const P = k.sources;
938
+ if (P && Array.isArray(P) && P.length > 0)
939
+ for (const M of P)
940
+ D.some((U) => U.sourceId === M.sourceId) || D.push({
941
+ sourceId: M.sourceId,
942
+ filename: M.filename || "Unknown",
943
+ score: M.score ?? 1,
944
+ chunkId: M.chunkId,
945
+ datasetId: M.datasetId
891
946
  });
892
- const P = v.reasoning;
893
- if (P && P.length > 0 && (m += P, yield Z()), v.type)
894
- switch (v.type) {
947
+ const j = k.reasoning;
948
+ if (j && j.length > 0 && (S += j, yield Z()), k.type)
949
+ switch (k.type) {
895
950
  case "source-document":
896
- v.sourceId && j.push({
897
- sourceId: v.sourceId,
898
- filename: v.title || "Unknown",
951
+ k.sourceId && D.push({
952
+ sourceId: k.sourceId,
953
+ filename: k.title || "Unknown",
899
954
  score: 1
900
955
  });
901
956
  continue;
902
957
  case "reasoning-start":
903
958
  continue;
904
959
  case "reasoning-delta":
905
- v.delta && (m += v.delta), (A || m) && (yield Z());
960
+ k.delta && (S += k.delta), (I || S) && (yield Z());
906
961
  continue;
907
962
  case "reasoning-end":
908
- (A || m) && (yield Z());
963
+ (I || S) && (yield Z());
909
964
  continue;
910
965
  case "text-delta":
911
- v.delta && (m && !V && !A && (V = !0, await new Promise((S) => setTimeout(S, 400))), A += v.delta), A && (yield Z());
966
+ k.delta && (S && !H && !I && (H = !0, await new Promise((M) => setTimeout(M, 400))), I += k.delta), I && (yield Z());
912
967
  continue;
913
968
  case "error":
914
- throw new Error(v.errorText || "Stream error");
969
+ throw new Error(k.errorText || "Stream error");
915
970
  case "text-start":
916
971
  case "text-end":
917
972
  case "start":
@@ -920,14 +975,14 @@ function Yt(e, r) {
920
975
  case "finish":
921
976
  continue;
922
977
  }
923
- const W = v.delta;
924
- if (W != null && (m && !V && !A && (V = !0, await new Promise((S) => setTimeout(S, 400))), A += W), v.content && (A += v.content), v.message && (A += v.message.content || ""), v.finished) {
925
- (A || m || j.length > 0) && (yield Z());
978
+ const F = k.delta;
979
+ if (F != null && (S && !H && !I && (H = !0, await new Promise((M) => setTimeout(M, 400))), I += F), k.content && (I += k.content), k.message && (I += k.message.content || ""), k.finished) {
980
+ (I || S || D.length > 0) && (yield Z());
926
981
  break;
927
982
  }
928
- (A || m || j.length > 0) && (yield Z());
983
+ (I || S || D.length > 0) && (yield Z());
929
984
  }
930
- (A || m || j.length > 0) && (yield Z());
985
+ (I || S || D.length > 0) && (yield Z());
931
986
  }
932
987
  };
933
988
  }
@@ -936,7 +991,7 @@ class Fe extends Error {
936
991
  super(r), this.code = t, this.file = a, this.name = "AttachmentValidationError";
937
992
  }
938
993
  }
939
- const Fa = [
994
+ const za = [
940
995
  // Images
941
996
  "image/jpeg",
942
997
  "image/png",
@@ -954,7 +1009,7 @@ const Fa = [
954
1009
  "text/markdown",
955
1010
  "text/csv",
956
1011
  "application/json"
957
- ], za = [
1012
+ ], ja = [
958
1013
  ".pdf",
959
1014
  ".doc",
960
1015
  ".docx",
@@ -970,16 +1025,16 @@ const Fa = [
970
1025
  ".gif",
971
1026
  ".webp",
972
1027
  ".svg"
973
- ], ja = 10 * 1024 * 1024;
1028
+ ], Ua = 10 * 1024 * 1024;
974
1029
  function Nt(e) {
975
1030
  if (e === 0) return "0 Bytes";
976
1031
  const r = 1024, t = ["Bytes", "KB", "MB", "GB"], a = Math.floor(Math.log(e) / Math.log(r));
977
1032
  return parseFloat((e / Math.pow(r, a)).toFixed(2)) + " " + t[a];
978
1033
  }
979
- function Ua(e) {
1034
+ function $a(e) {
980
1035
  return e.lastIndexOf(".") >= 0 ? e.slice(e.lastIndexOf(".")).toLowerCase() : "";
981
1036
  }
982
- function $a(e, r) {
1037
+ function Oa(e, r) {
983
1038
  const a = {
984
1039
  "image/jpeg": [".jpg", ".jpeg"],
985
1040
  "image/png": [".png"],
@@ -994,7 +1049,7 @@ function $a(e, r) {
994
1049
  }[e];
995
1050
  return a ? a.includes(r.toLowerCase()) : !0;
996
1051
  }
997
- function Oa() {
1052
+ function Ba() {
998
1053
  return typeof crypto < "u" && crypto.randomUUID ? "attachment-" + crypto.randomUUID() : "attachment-" + Date.now() + "-" + Math.random().toString(36).slice(2, 11);
999
1054
  }
1000
1055
  function Zt(e = {}) {
@@ -1004,9 +1059,9 @@ function Zt(e = {}) {
1004
1059
  onAttachmentAdded: a,
1005
1060
  onAttachmentRemoved: i
1006
1061
  } = e, {
1007
- maxFileSizeBytes: o = ja,
1008
- allowedMimeTypes: n = Fa,
1009
- allowedExtensions: c = za,
1062
+ maxFileSizeBytes: o = Ua,
1063
+ allowedMimeTypes: n = za,
1064
+ allowedExtensions: c = ja,
1010
1065
  validateContentType: s = !0
1011
1066
  } = r, l = c.join(",");
1012
1067
  function f(u) {
@@ -1018,7 +1073,7 @@ function Zt(e = {}) {
1018
1073
  );
1019
1074
  throw t?.(g), g;
1020
1075
  }
1021
- const p = Ua(u.name);
1076
+ const p = $a(u.name);
1022
1077
  if (p && !c.some((g) => g.toLowerCase() === p)) {
1023
1078
  const g = new Fe(
1024
1079
  'File type "' + p + '" is not allowed. Allowed types: ' + c.join(", "),
@@ -1041,7 +1096,7 @@ function Zt(e = {}) {
1041
1096
  );
1042
1097
  throw t?.(g), g;
1043
1098
  }
1044
- if (s && u.type && p && !$a(u.type, p)) {
1099
+ if (s && u.type && p && !Oa(u.type, p)) {
1045
1100
  const g = new Fe(
1046
1101
  'File extension "' + p + '" does not match content type "' + u.type + '".',
1047
1102
  "VALIDATION_FAILED",
@@ -1057,7 +1112,7 @@ function Zt(e = {}) {
1057
1112
  let p = "file";
1058
1113
  u.type.startsWith("image/") ? p = "image" : (u.type.includes("pdf") || u.type.includes("document") || u.type.includes("text") || u.name.endsWith(".pdf") || u.name.endsWith(".docx") || u.name.endsWith(".txt") || u.name.endsWith(".md") || u.name.endsWith(".csv") || u.name.endsWith(".json")) && (p = "document");
1059
1114
  const g = {
1060
- id: Oa(),
1115
+ id: Ba(),
1061
1116
  type: p,
1062
1117
  name: u.name,
1063
1118
  contentType: u.type,
@@ -1094,7 +1149,7 @@ function Zt(e = {}) {
1094
1149
  }
1095
1150
  };
1096
1151
  }
1097
- function Ba({
1152
+ function Wa({
1098
1153
  children: e,
1099
1154
  baseUrl: r,
1100
1155
  sessionToken: t,
@@ -1115,70 +1170,70 @@ function Ba({
1115
1170
  onBeforeRequest: x,
1116
1171
  mockResponseOnBlocked: w
1117
1172
  }) {
1118
- const k = G(
1173
+ const v = K(
1119
1174
  () => new Qt(r, t || void 0, a),
1120
1175
  [r, t, a]
1121
- ), [L, E] = R(o || null);
1122
- $(() => {
1176
+ ), [L, E] = _(o || null);
1177
+ B(() => {
1123
1178
  o && E(o);
1124
1179
  }, [o]);
1125
- const I = X(
1126
- (A) => {
1127
- p?.(A);
1180
+ const N = Q(
1181
+ (S) => {
1182
+ p?.(S);
1128
1183
  },
1129
1184
  [p]
1130
- ), M = X(
1131
- (A, m) => {
1132
- h?.(A, m);
1185
+ ), A = Q(
1186
+ (S, m) => {
1187
+ h?.(S, m);
1133
1188
  },
1134
1189
  [h]
1135
- ), _ = G(() => Yt(k, {
1190
+ ), I = K(() => Yt(v, {
1136
1191
  modelId: L || void 0,
1137
1192
  // Pass undefined if not set (backend resolves it)
1138
1193
  systemPrompt: s,
1139
1194
  ephemeral: c,
1140
1195
  enableReasoning: l,
1141
- onChatCreated: I,
1196
+ onChatCreated: N,
1142
1197
  onUserMessage: g,
1143
1198
  onBeforeRequest: x,
1144
1199
  mockResponseOnBlocked: w
1145
- }), [k, L, s, c, l, I, g, x, w]);
1146
- return i === "singleChat" ? /* @__PURE__ */ d(Wa, { modelAdapter: _, enableAttachments: b, children: e }) : /* @__PURE__ */ d(
1147
- qa,
1200
+ }), [v, L, s, c, l, N, g, x, w]);
1201
+ return i === "singleChat" ? /* @__PURE__ */ d(qa, { modelAdapter: I, enableAttachments: b, children: e }) : /* @__PURE__ */ d(
1202
+ Ha,
1148
1203
  {
1149
- client: k,
1204
+ client: v,
1150
1205
  modelAdapterOptions: {
1151
1206
  modelId: L || void 0,
1152
1207
  systemPrompt: s,
1153
1208
  ephemeral: c,
1154
1209
  enableReasoning: l,
1155
- onChatCreated: I,
1210
+ onChatCreated: N,
1156
1211
  onUserMessage: g,
1157
1212
  onBeforeRequest: x,
1158
1213
  mockResponseOnBlocked: w
1159
1214
  },
1160
1215
  initialThreadId: f,
1161
1216
  onChatsLoaded: y,
1162
- onThreadIdUpdate: M,
1217
+ onThreadIdUpdate: A,
1163
1218
  onError: u,
1164
1219
  enableAttachments: b,
1165
1220
  children: e
1166
1221
  }
1167
1222
  );
1168
1223
  }
1169
- function Wa({
1224
+ function qa({
1170
1225
  modelAdapter: e,
1171
1226
  enableAttachments: r,
1172
1227
  children: t
1173
1228
  }) {
1174
- const a = G(() => r ? Zt() : void 0, [r]), i = Wt(e, {
1229
+ const a = K(() => r ? Zt() : void 0, [r]), i = Wt(e, {
1175
1230
  adapters: {
1176
1231
  ...a && { attachments: a }
1177
1232
  }
1178
1233
  });
1179
1234
  return /* @__PURE__ */ d(qt, { runtime: i, children: t });
1180
1235
  }
1181
- function qa({
1236
+ function Ha({
1182
1237
  client: e,
1183
1238
  modelAdapterOptions: r,
1184
1239
  initialThreadId: t,
@@ -1188,35 +1243,35 @@ function qa({
1188
1243
  enableAttachments: n,
1189
1244
  children: c
1190
1245
  }) {
1191
- const s = G(() => Da(e, (y, b) => {
1246
+ const s = K(() => _a(e, (y, b) => {
1192
1247
  i?.(y, b);
1193
- }), [e, i]), l = X(
1248
+ }), [e, i]), l = Q(
1194
1249
  (y, b) => {
1195
1250
  s.updateRemoteId && s.updateRemoteId(y, b), i?.(y, b);
1196
1251
  },
1197
1252
  [s, i]
1198
- ), f = G(() => ({
1253
+ ), f = K(() => ({
1199
1254
  ...s,
1200
1255
  async list() {
1201
1256
  const y = await s.list();
1202
1257
  return a?.(), y;
1203
1258
  }
1204
1259
  }), [s, a]);
1205
- $(() => {
1260
+ B(() => {
1206
1261
  window.__cuadraThreadListAdapter = f, window.__cuadraThreadListRuntime = null;
1207
1262
  }, [f]);
1208
- const u = G(() => Yt(e, {
1263
+ const u = K(() => Yt(e, {
1209
1264
  ...r,
1210
1265
  onThreadIdUpdate: l
1211
- }), [e, r, l]), p = G(() => n ? Zt() : void 0, [n]), g = X(() => Wt(u, {
1266
+ }), [e, r, l]), p = K(() => n ? Zt() : void 0, [n]), g = Q(() => Wt(u, {
1212
1267
  adapters: {
1213
1268
  ...p && { attachments: p }
1214
1269
  }
1215
- }), [u, p]), h = Wr({
1270
+ }), [u, p]), h = qr({
1216
1271
  adapter: f,
1217
1272
  runtimeHook: g
1218
1273
  });
1219
- return $(() => {
1274
+ return B(() => {
1220
1275
  window.__cuadraThreadListRuntime = h;
1221
1276
  }, [h]), /* @__PURE__ */ d(qt, { runtime: h, children: c });
1222
1277
  }
@@ -1229,36 +1284,36 @@ function St(e, r) {
1229
1284
  a++, i = t.indexOf(r, i + r.length);
1230
1285
  return a;
1231
1286
  }
1232
- const Ae = We(/[A-Za-z]/), dt = We(/[\dA-Za-z]/);
1233
- function Ha(e) {
1287
+ const Ie = Be(/[A-Za-z]/), dt = Be(/[\dA-Za-z]/);
1288
+ function Va(e) {
1234
1289
  return (
1235
1290
  // Special whitespace codes (which have negative values), C0 and Control
1236
1291
  // character DEL
1237
1292
  e !== null && (e < 32 || e === 127)
1238
1293
  );
1239
1294
  }
1240
- function ge(e) {
1295
+ function pe(e) {
1241
1296
  return e !== null && e < -2;
1242
1297
  }
1243
- function H(e) {
1298
+ function q(e) {
1244
1299
  return e !== null && (e < 0 || e === 32);
1245
1300
  }
1246
- function te(e) {
1301
+ function re(e) {
1247
1302
  return e === -2 || e === -1 || e === 32;
1248
1303
  }
1249
- const Be = We(/\p{P}|\p{S}/u), le = We(/\s/);
1250
- function We(e) {
1304
+ const Oe = Be(/\p{P}|\p{S}/u), de = Be(/\s/);
1305
+ function Be(e) {
1251
1306
  return r;
1252
1307
  function r(t) {
1253
1308
  return t !== null && t > -1 && e.test(String.fromCharCode(t));
1254
1309
  }
1255
1310
  }
1256
- function Va(e) {
1311
+ function Xa(e) {
1257
1312
  if (typeof e != "string")
1258
1313
  throw new TypeError("Expected a string");
1259
1314
  return e.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
1260
1315
  }
1261
- const qe = (
1316
+ const We = (
1262
1317
  // Note: overloads in JSDoc can’t yet use different `@template`s.
1263
1318
  /**
1264
1319
  * @type {(
@@ -1275,29 +1330,29 @@ const qe = (
1275
1330
  */
1276
1331
  (function(e) {
1277
1332
  if (e == null)
1278
- return Ga;
1333
+ return Ya;
1279
1334
  if (typeof e == "function")
1280
- return He(e);
1335
+ return qe(e);
1281
1336
  if (typeof e == "object")
1282
- return Array.isArray(e) ? Xa(e) : (
1337
+ return Array.isArray(e) ? Ka(e) : (
1283
1338
  // Cast because `ReadonlyArray` goes into the above but `isArray`
1284
1339
  // narrows to `Array`.
1285
- Ka(
1340
+ Qa(
1286
1341
  /** @type {Props} */
1287
1342
  e
1288
1343
  )
1289
1344
  );
1290
1345
  if (typeof e == "string")
1291
- return Qa(e);
1346
+ return Ga(e);
1292
1347
  throw new Error("Expected function, string, or object as test");
1293
1348
  })
1294
1349
  );
1295
- function Xa(e) {
1350
+ function Ka(e) {
1296
1351
  const r = [];
1297
1352
  let t = -1;
1298
1353
  for (; ++t < e.length; )
1299
- r[t] = qe(e[t]);
1300
- return He(a);
1354
+ r[t] = We(e[t]);
1355
+ return qe(a);
1301
1356
  function a(...i) {
1302
1357
  let o = -1;
1303
1358
  for (; ++o < r.length; )
@@ -1305,12 +1360,12 @@ function Xa(e) {
1305
1360
  return !1;
1306
1361
  }
1307
1362
  }
1308
- function Ka(e) {
1363
+ function Qa(e) {
1309
1364
  const r = (
1310
1365
  /** @type {Record<string, unknown>} */
1311
1366
  e
1312
1367
  );
1313
- return He(t);
1368
+ return qe(t);
1314
1369
  function t(a) {
1315
1370
  const i = (
1316
1371
  /** @type {Record<string, unknown>} */
@@ -1323,16 +1378,16 @@ function Ka(e) {
1323
1378
  return !0;
1324
1379
  }
1325
1380
  }
1326
- function Qa(e) {
1327
- return He(r);
1381
+ function Ga(e) {
1382
+ return qe(r);
1328
1383
  function r(t) {
1329
1384
  return t && t.type === e;
1330
1385
  }
1331
1386
  }
1332
- function He(e) {
1387
+ function qe(e) {
1333
1388
  return r;
1334
1389
  function r(t, a, i) {
1335
- return !!(Ya(t) && e.call(
1390
+ return !!(Za(t) && e.call(
1336
1391
  this,
1337
1392
  t,
1338
1393
  typeof a == "number" ? a : void 0,
@@ -1340,17 +1395,17 @@ function He(e) {
1340
1395
  ));
1341
1396
  }
1342
1397
  }
1343
- function Ga() {
1398
+ function Ya() {
1344
1399
  return !0;
1345
1400
  }
1346
- function Ya(e) {
1401
+ function Za(e) {
1347
1402
  return e !== null && typeof e == "object" && "type" in e;
1348
1403
  }
1349
- const Jt = [], Za = !0, ot = !1, Ja = "skip";
1404
+ const Jt = [], Ja = !0, ot = !1, en = "skip";
1350
1405
  function er(e, r, t, a) {
1351
1406
  let i;
1352
1407
  typeof r == "function" && typeof t != "function" ? (a = t, t = r) : i = r;
1353
- const o = qe(i), n = a ? -1 : 1;
1408
+ const o = We(i), n = a ? -1 : 1;
1354
1409
  c(e, void 0, [])();
1355
1410
  function c(s, l, f) {
1356
1411
  const u = (
@@ -1372,14 +1427,14 @@ function er(e, r, t, a) {
1372
1427
  return p;
1373
1428
  function p() {
1374
1429
  let g = Jt, h, y, b;
1375
- if ((!r || o(s, l, f[f.length - 1] || void 0)) && (g = en(t(s, f)), g[0] === ot))
1430
+ if ((!r || o(s, l, f[f.length - 1] || void 0)) && (g = tn(t(s, f)), g[0] === ot))
1376
1431
  return g;
1377
1432
  if ("children" in s && s.children) {
1378
1433
  const x = (
1379
1434
  /** @type {UnistParent} */
1380
1435
  s
1381
1436
  );
1382
- if (x.children && g[0] !== Ja)
1437
+ if (x.children && g[0] !== en)
1383
1438
  for (y = (a ? x.children.length : -1) + n, b = f.concat(x); y > -1 && y < x.children.length; ) {
1384
1439
  const w = x.children[y];
1385
1440
  if (h = c(w, y, b)(), h[0] === ot)
@@ -1391,11 +1446,11 @@ function er(e, r, t, a) {
1391
1446
  }
1392
1447
  }
1393
1448
  }
1394
- function en(e) {
1395
- return Array.isArray(e) ? e : typeof e == "number" ? [Za, e] : e == null ? Jt : [e];
1449
+ function tn(e) {
1450
+ return Array.isArray(e) ? e : typeof e == "number" ? [Ja, e] : e == null ? Jt : [e];
1396
1451
  }
1397
- function tn(e, r, t) {
1398
- const i = qe((t || {}).ignore || []), o = rn(r);
1452
+ function rn(e, r, t) {
1453
+ const i = We((t || {}).ignore || []), o = an(r);
1399
1454
  let n = -1;
1400
1455
  for (; ++n < o.length; )
1401
1456
  er(e, "text", c);
@@ -1420,25 +1475,25 @@ function tn(e, r, t) {
1420
1475
  const b = u.children.indexOf(l);
1421
1476
  let x = !1, w = [];
1422
1477
  p.lastIndex = 0;
1423
- let k = p.exec(l.value);
1424
- for (; k; ) {
1425
- const L = k.index, E = {
1426
- index: k.index,
1427
- input: k.input,
1478
+ let v = p.exec(l.value);
1479
+ for (; v; ) {
1480
+ const L = v.index, E = {
1481
+ index: v.index,
1482
+ input: v.input,
1428
1483
  stack: [...f, l]
1429
1484
  };
1430
- let I = g(...k, E);
1431
- if (typeof I == "string" && (I = I.length > 0 ? { type: "text", value: I } : void 0), I === !1 ? p.lastIndex = L + 1 : (h !== L && w.push({
1485
+ let N = g(...v, E);
1486
+ if (typeof N == "string" && (N = N.length > 0 ? { type: "text", value: N } : void 0), N === !1 ? p.lastIndex = L + 1 : (h !== L && w.push({
1432
1487
  type: "text",
1433
1488
  value: l.value.slice(h, L)
1434
- }), Array.isArray(I) ? w.push(...I) : I && w.push(I), h = L + k[0].length, x = !0), !p.global)
1489
+ }), Array.isArray(N) ? w.push(...N) : N && w.push(N), h = L + v[0].length, x = !0), !p.global)
1435
1490
  break;
1436
- k = p.exec(l.value);
1491
+ v = p.exec(l.value);
1437
1492
  }
1438
1493
  return x ? (h < l.value.length && w.push({ type: "text", value: l.value.slice(h) }), u.children.splice(b, 1, ...w)) : w = [l], b + w.length;
1439
1494
  }
1440
1495
  }
1441
- function rn(e) {
1496
+ function an(e) {
1442
1497
  const r = [];
1443
1498
  if (!Array.isArray(e))
1444
1499
  throw new TypeError("Expected find and replace tuple or list of tuples");
@@ -1446,98 +1501,98 @@ function rn(e) {
1446
1501
  let a = -1;
1447
1502
  for (; ++a < t.length; ) {
1448
1503
  const i = t[a];
1449
- r.push([an(i[0]), nn(i[1])]);
1504
+ r.push([nn(i[0]), on(i[1])]);
1450
1505
  }
1451
1506
  return r;
1452
1507
  }
1453
- function an(e) {
1454
- return typeof e == "string" ? new RegExp(Va(e), "g") : e;
1455
- }
1456
1508
  function nn(e) {
1509
+ return typeof e == "string" ? new RegExp(Xa(e), "g") : e;
1510
+ }
1511
+ function on(e) {
1457
1512
  return typeof e == "function" ? e : function() {
1458
1513
  return e;
1459
1514
  };
1460
1515
  }
1461
- const Ge = "phrasing", Ye = ["autolink", "link", "image", "label"];
1462
- function on() {
1516
+ const Qe = "phrasing", Ge = ["autolink", "link", "image", "label"];
1517
+ function sn() {
1463
1518
  return {
1464
- transforms: [hn],
1519
+ transforms: [mn],
1465
1520
  enter: {
1466
- literalAutolink: cn,
1467
- literalAutolinkEmail: Ze,
1468
- literalAutolinkHttp: Ze,
1469
- literalAutolinkWww: Ze
1521
+ literalAutolink: un,
1522
+ literalAutolinkEmail: Ye,
1523
+ literalAutolinkHttp: Ye,
1524
+ literalAutolinkWww: Ye
1470
1525
  },
1471
1526
  exit: {
1472
- literalAutolink: fn,
1473
- literalAutolinkEmail: dn,
1474
- literalAutolinkHttp: un,
1475
- literalAutolinkWww: ln
1527
+ literalAutolink: hn,
1528
+ literalAutolinkEmail: fn,
1529
+ literalAutolinkHttp: ln,
1530
+ literalAutolinkWww: dn
1476
1531
  }
1477
1532
  };
1478
1533
  }
1479
- function sn() {
1534
+ function cn() {
1480
1535
  return {
1481
1536
  unsafe: [
1482
1537
  {
1483
1538
  character: "@",
1484
1539
  before: "[+\\-.\\w]",
1485
1540
  after: "[\\-.\\w]",
1486
- inConstruct: Ge,
1487
- notInConstruct: Ye
1541
+ inConstruct: Qe,
1542
+ notInConstruct: Ge
1488
1543
  },
1489
1544
  {
1490
1545
  character: ".",
1491
1546
  before: "[Ww]",
1492
1547
  after: "[\\-.\\w]",
1493
- inConstruct: Ge,
1494
- notInConstruct: Ye
1548
+ inConstruct: Qe,
1549
+ notInConstruct: Ge
1495
1550
  },
1496
1551
  {
1497
1552
  character: ":",
1498
1553
  before: "[ps]",
1499
1554
  after: "\\/",
1500
- inConstruct: Ge,
1501
- notInConstruct: Ye
1555
+ inConstruct: Qe,
1556
+ notInConstruct: Ge
1502
1557
  }
1503
1558
  ]
1504
1559
  };
1505
1560
  }
1506
- function cn(e) {
1561
+ function un(e) {
1507
1562
  this.enter({ type: "link", title: null, url: "", children: [] }, e);
1508
1563
  }
1509
- function Ze(e) {
1564
+ function Ye(e) {
1510
1565
  this.config.enter.autolinkProtocol.call(this, e);
1511
1566
  }
1512
- function un(e) {
1567
+ function ln(e) {
1513
1568
  this.config.exit.autolinkProtocol.call(this, e);
1514
1569
  }
1515
- function ln(e) {
1570
+ function dn(e) {
1516
1571
  this.config.exit.data.call(this, e);
1517
1572
  const r = this.stack[this.stack.length - 1];
1518
1573
  r.type, r.url = "http://" + this.sliceSerialize(e);
1519
1574
  }
1520
- function dn(e) {
1575
+ function fn(e) {
1521
1576
  this.config.exit.autolinkEmail.call(this, e);
1522
1577
  }
1523
- function fn(e) {
1578
+ function hn(e) {
1524
1579
  this.exit(e);
1525
1580
  }
1526
- function hn(e) {
1527
- tn(
1581
+ function mn(e) {
1582
+ rn(
1528
1583
  e,
1529
1584
  [
1530
- [/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi, mn],
1531
- [/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu, pn]
1585
+ [/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi, pn],
1586
+ [/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu, gn]
1532
1587
  ],
1533
1588
  { ignore: ["link", "linkReference"] }
1534
1589
  );
1535
1590
  }
1536
- function mn(e, r, t, a, i) {
1591
+ function pn(e, r, t, a, i) {
1537
1592
  let o = "";
1538
- if (!tr(i) || (/^w/i.test(r) && (t = r + t, r = "", o = "http://"), !gn(t)))
1593
+ if (!tr(i) || (/^w/i.test(r) && (t = r + t, r = "", o = "http://"), !bn(t)))
1539
1594
  return !1;
1540
- const n = bn(t + a);
1595
+ const n = yn(t + a);
1541
1596
  if (!n[0]) return !1;
1542
1597
  const c = {
1543
1598
  type: "link",
@@ -1547,7 +1602,7 @@ function mn(e, r, t, a, i) {
1547
1602
  };
1548
1603
  return n[1] ? [c, { type: "text", value: n[1] }] : c;
1549
1604
  }
1550
- function pn(e, r, t, a) {
1605
+ function gn(e, r, t, a) {
1551
1606
  return (
1552
1607
  // Not an expected previous character.
1553
1608
  !tr(a, !0) || // Label ends in not allowed character.
@@ -1559,11 +1614,11 @@ function pn(e, r, t, a) {
1559
1614
  }
1560
1615
  );
1561
1616
  }
1562
- function gn(e) {
1617
+ function bn(e) {
1563
1618
  const r = e.split(".");
1564
1619
  return !(r.length < 2 || r[r.length - 1] && (/_/.test(r[r.length - 1]) || !/[a-zA-Z\d]/.test(r[r.length - 1])) || r[r.length - 2] && (/_/.test(r[r.length - 2]) || !/[a-zA-Z\d]/.test(r[r.length - 2])));
1565
1620
  }
1566
- function bn(e) {
1621
+ function yn(e) {
1567
1622
  const r = /[!"&'),.:;<>?\]}]+$/.exec(e);
1568
1623
  if (!r)
1569
1624
  return [e, void 0];
@@ -1577,47 +1632,47 @@ function bn(e) {
1577
1632
  }
1578
1633
  function tr(e, r) {
1579
1634
  const t = e.input.charCodeAt(e.index - 1);
1580
- return (e.index === 0 || le(t) || Be(t)) && // If it’s an email, the previous character should not be a slash.
1635
+ return (e.index === 0 || de(t) || Oe(t)) && // If it’s an email, the previous character should not be a slash.
1581
1636
  (!r || t !== 47);
1582
1637
  }
1583
- function Ne(e) {
1638
+ function Se(e) {
1584
1639
  return e.replace(/[\t\n\r ]+/g, " ").replace(/^ | $/g, "").toLowerCase().toUpperCase();
1585
1640
  }
1586
- rr.peek = An;
1587
- function yn() {
1641
+ rr.peek = In;
1642
+ function xn() {
1588
1643
  this.buffer();
1589
1644
  }
1590
- function xn(e) {
1645
+ function wn(e) {
1591
1646
  this.enter({ type: "footnoteReference", identifier: "", label: "" }, e);
1592
1647
  }
1593
- function wn() {
1648
+ function kn() {
1594
1649
  this.buffer();
1595
1650
  }
1596
- function kn(e) {
1651
+ function Cn(e) {
1597
1652
  this.enter(
1598
1653
  { type: "footnoteDefinition", identifier: "", label: "", children: [] },
1599
1654
  e
1600
1655
  );
1601
1656
  }
1602
- function Cn(e) {
1657
+ function vn(e) {
1603
1658
  const r = this.resume(), t = this.stack[this.stack.length - 1];
1604
- t.type, t.identifier = Ne(
1659
+ t.type, t.identifier = Se(
1605
1660
  this.sliceSerialize(e)
1606
1661
  ).toLowerCase(), t.label = r;
1607
1662
  }
1608
- function vn(e) {
1663
+ function Tn(e) {
1609
1664
  this.exit(e);
1610
1665
  }
1611
- function Tn(e) {
1666
+ function Mn(e) {
1612
1667
  const r = this.resume(), t = this.stack[this.stack.length - 1];
1613
- t.type, t.identifier = Ne(
1668
+ t.type, t.identifier = Se(
1614
1669
  this.sliceSerialize(e)
1615
1670
  ).toLowerCase(), t.label = r;
1616
1671
  }
1617
- function Mn(e) {
1672
+ function An(e) {
1618
1673
  this.exit(e);
1619
1674
  }
1620
- function An() {
1675
+ function In() {
1621
1676
  return "[";
1622
1677
  }
1623
1678
  function rr(e, r, t, a) {
@@ -1628,23 +1683,23 @@ function rr(e, r, t, a) {
1628
1683
  t.safe(t.associationId(e), { after: "]", before: o })
1629
1684
  ), c(), n(), o += i.move("]"), o;
1630
1685
  }
1631
- function In() {
1686
+ function Nn() {
1632
1687
  return {
1633
1688
  enter: {
1634
- gfmFootnoteCallString: yn,
1635
- gfmFootnoteCall: xn,
1636
- gfmFootnoteDefinitionLabelString: wn,
1637
- gfmFootnoteDefinition: kn
1689
+ gfmFootnoteCallString: xn,
1690
+ gfmFootnoteCall: wn,
1691
+ gfmFootnoteDefinitionLabelString: kn,
1692
+ gfmFootnoteDefinition: Cn
1638
1693
  },
1639
1694
  exit: {
1640
- gfmFootnoteCallString: Cn,
1641
- gfmFootnoteCall: vn,
1642
- gfmFootnoteDefinitionLabelString: Tn,
1643
- gfmFootnoteDefinition: Mn
1695
+ gfmFootnoteCallString: vn,
1696
+ gfmFootnoteCall: Tn,
1697
+ gfmFootnoteDefinitionLabelString: Mn,
1698
+ gfmFootnoteDefinition: An
1644
1699
  }
1645
1700
  };
1646
1701
  }
1647
- function Nn(e) {
1702
+ function Sn(e) {
1648
1703
  let r = !1;
1649
1704
  return e && e.firstLineBlank && (r = !0), {
1650
1705
  handlers: { footnoteDefinition: t, footnoteReference: rr },
@@ -1661,18 +1716,18 @@ function Nn(e) {
1661
1716
  (r ? `
1662
1717
  ` : " ") + o.indentLines(
1663
1718
  o.containerFlow(a, c.current()),
1664
- r ? ar : Sn
1719
+ r ? ar : Ln
1665
1720
  )
1666
1721
  )), l(), s;
1667
1722
  }
1668
1723
  }
1669
- function Sn(e, r, t) {
1724
+ function Ln(e, r, t) {
1670
1725
  return r === 0 ? e : ar(e, r, t);
1671
1726
  }
1672
1727
  function ar(e, r, t) {
1673
1728
  return (t ? "" : " ") + e;
1674
1729
  }
1675
- const Ln = [
1730
+ const En = [
1676
1731
  "autolink",
1677
1732
  "destinationLiteral",
1678
1733
  "destinationRaw",
@@ -1680,30 +1735,30 @@ const Ln = [
1680
1735
  "titleQuote",
1681
1736
  "titleApostrophe"
1682
1737
  ];
1683
- nr.peek = _n;
1684
- function En() {
1738
+ nr.peek = Fn;
1739
+ function Pn() {
1685
1740
  return {
1686
1741
  canContainEols: ["delete"],
1687
- enter: { strikethrough: Rn },
1688
- exit: { strikethrough: Dn }
1742
+ enter: { strikethrough: Dn },
1743
+ exit: { strikethrough: _n }
1689
1744
  };
1690
1745
  }
1691
- function Pn() {
1746
+ function Rn() {
1692
1747
  return {
1693
1748
  unsafe: [
1694
1749
  {
1695
1750
  character: "~",
1696
1751
  inConstruct: "phrasing",
1697
- notInConstruct: Ln
1752
+ notInConstruct: En
1698
1753
  }
1699
1754
  ],
1700
1755
  handlers: { delete: nr }
1701
1756
  };
1702
1757
  }
1703
- function Rn(e) {
1758
+ function Dn(e) {
1704
1759
  this.enter({ type: "delete", children: [] }, e);
1705
1760
  }
1706
- function Dn(e) {
1761
+ function _n(e) {
1707
1762
  this.exit(e);
1708
1763
  }
1709
1764
  function nr(e, r, t, a) {
@@ -1715,23 +1770,23 @@ function nr(e, r, t, a) {
1715
1770
  after: "~"
1716
1771
  }), n += i.move("~~"), o(), n;
1717
1772
  }
1718
- function _n() {
1773
+ function Fn() {
1719
1774
  return "~";
1720
1775
  }
1721
- function Fn(e) {
1776
+ function zn(e) {
1722
1777
  return e.length;
1723
1778
  }
1724
- function zn(e, r) {
1725
- const t = r || {}, a = (t.align || []).concat(), i = t.stringLength || Fn, o = [], n = [], c = [], s = [];
1779
+ function jn(e, r) {
1780
+ const t = r || {}, a = (t.align || []).concat(), i = t.stringLength || zn, o = [], n = [], c = [], s = [];
1726
1781
  let l = 0, f = -1;
1727
1782
  for (; ++f < e.length; ) {
1728
1783
  const y = [], b = [];
1729
1784
  let x = -1;
1730
1785
  for (e[f].length > l && (l = e[f].length); ++x < e[f].length; ) {
1731
- const w = jn(e[f][x]);
1786
+ const w = Un(e[f][x]);
1732
1787
  if (t.alignDelimiters !== !1) {
1733
- const k = i(w);
1734
- b[x] = k, (s[x] === void 0 || k > s[x]) && (s[x] = k);
1788
+ const v = i(w);
1789
+ b[x] = v, (s[x] === void 0 || v > s[x]) && (s[x] = v);
1735
1790
  }
1736
1791
  y.push(w);
1737
1792
  }
@@ -1756,8 +1811,8 @@ function zn(e, r) {
1756
1811
  1,
1757
1812
  s[u] - b.length - x.length
1758
1813
  );
1759
- const k = b + "-".repeat(w) + x;
1760
- t.alignDelimiters !== !1 && (w = b.length + w + x.length, w > s[u] && (s[u] = w), g[u] = w), p[u] = k;
1814
+ const v = b + "-".repeat(w) + x;
1815
+ t.alignDelimiters !== !1 && (w = b.length + w + x.length, w > s[u] && (s[u] = w), g[u] = w), p[u] = v;
1761
1816
  }
1762
1817
  n.splice(1, 0, p), c.splice(1, 0, g), f = -1;
1763
1818
  const h = [];
@@ -1767,14 +1822,14 @@ function zn(e, r) {
1767
1822
  const x = [];
1768
1823
  for (; ++u < l; ) {
1769
1824
  const w = y[u] || "";
1770
- let k = "", L = "";
1825
+ let v = "", L = "";
1771
1826
  if (t.alignDelimiters !== !1) {
1772
- const E = s[u] - (b[u] || 0), I = o[u];
1773
- I === 114 ? k = " ".repeat(E) : I === 99 ? E % 2 ? (k = " ".repeat(E / 2 + 0.5), L = " ".repeat(E / 2 - 0.5)) : (k = " ".repeat(E / 2), L = k) : L = " ".repeat(E);
1827
+ const E = s[u] - (b[u] || 0), N = o[u];
1828
+ N === 114 ? v = " ".repeat(E) : N === 99 ? E % 2 ? (v = " ".repeat(E / 2 + 0.5), L = " ".repeat(E / 2 - 0.5)) : (v = " ".repeat(E / 2), L = v) : L = " ".repeat(E);
1774
1829
  }
1775
1830
  t.delimiterStart !== !1 && !u && x.push("|"), t.padding !== !1 && // Don’t add the opening space if we’re not aligning and the cell is
1776
1831
  // empty: there will be a closing space.
1777
- !(t.alignDelimiters === !1 && w === "") && (t.delimiterStart !== !1 || u) && x.push(" "), t.alignDelimiters !== !1 && x.push(k), x.push(w), t.alignDelimiters !== !1 && x.push(L), t.padding !== !1 && x.push(" "), (t.delimiterEnd !== !1 || u !== l - 1) && x.push("|");
1832
+ !(t.alignDelimiters === !1 && w === "") && (t.delimiterStart !== !1 || u) && x.push(" "), t.alignDelimiters !== !1 && x.push(v), x.push(w), t.alignDelimiters !== !1 && x.push(L), t.padding !== !1 && x.push(" "), (t.delimiterEnd !== !1 || u !== l - 1) && x.push("|");
1778
1833
  }
1779
1834
  h.push(
1780
1835
  t.delimiterEnd === !1 ? x.join("").replace(/ +$/, "") : x.join("")
@@ -1783,26 +1838,26 @@ function zn(e, r) {
1783
1838
  return h.join(`
1784
1839
  `);
1785
1840
  }
1786
- function jn(e) {
1841
+ function Un(e) {
1787
1842
  return e == null ? "" : String(e);
1788
1843
  }
1789
1844
  function Lt(e) {
1790
1845
  const r = typeof e == "string" ? e.codePointAt(0) : 0;
1791
1846
  return r === 67 || r === 99 ? 99 : r === 76 || r === 108 ? 108 : r === 82 || r === 114 ? 114 : 0;
1792
1847
  }
1793
- function Un(e, r, t, a) {
1848
+ function $n(e, r, t, a) {
1794
1849
  const i = t.enter("blockquote"), o = t.createTracker(a);
1795
1850
  o.move("> "), o.shift(2);
1796
1851
  const n = t.indentLines(
1797
1852
  t.containerFlow(e, o.current()),
1798
- $n
1853
+ On
1799
1854
  );
1800
1855
  return i(), n;
1801
1856
  }
1802
- function $n(e, r, t) {
1857
+ function On(e, r, t) {
1803
1858
  return ">" + (t ? "" : " ") + e;
1804
1859
  }
1805
- function On(e, r) {
1860
+ function Bn(e, r) {
1806
1861
  return Et(e, r.inConstruct, !0) && !Et(e, r.notInConstruct, !1);
1807
1862
  }
1808
1863
  function Et(e, r, t) {
@@ -1818,12 +1873,12 @@ function Pt(e, r, t, a) {
1818
1873
  let i = -1;
1819
1874
  for (; ++i < t.unsafe.length; )
1820
1875
  if (t.unsafe[i].character === `
1821
- ` && On(t.stack, t.unsafe[i]))
1876
+ ` && Bn(t.stack, t.unsafe[i]))
1822
1877
  return /[ \t]/.test(a.before) ? "" : " ";
1823
1878
  return `\\
1824
1879
  `;
1825
1880
  }
1826
- function Bn(e, r) {
1881
+ function Wn(e, r) {
1827
1882
  const t = String(e);
1828
1883
  let a = t.indexOf(r), i = a, o = 0, n = 0;
1829
1884
  if (typeof r != "string")
@@ -1832,13 +1887,13 @@ function Bn(e, r) {
1832
1887
  a === i ? ++o > n && (n = o) : o = 1, i = a + r.length, a = t.indexOf(r, i);
1833
1888
  return n;
1834
1889
  }
1835
- function Wn(e, r) {
1890
+ function qn(e, r) {
1836
1891
  return !!(r.options.fences === !1 && e.value && // If there’s no info…
1837
1892
  !e.lang && // And there’s a non-whitespace character…
1838
1893
  /[^ \r\n]/.test(e.value) && // And the value doesn’t start or end in a blank…
1839
1894
  !/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value));
1840
1895
  }
1841
- function qn(e) {
1896
+ function Hn(e) {
1842
1897
  const r = e.options.fence || "`";
1843
1898
  if (r !== "`" && r !== "~")
1844
1899
  throw new Error(
@@ -1846,13 +1901,13 @@ function qn(e) {
1846
1901
  );
1847
1902
  return r;
1848
1903
  }
1849
- function Hn(e, r, t, a) {
1850
- const i = qn(t), o = e.value || "", n = i === "`" ? "GraveAccent" : "Tilde";
1851
- if (Wn(e, t)) {
1852
- const u = t.enter("codeIndented"), p = t.indentLines(o, Vn);
1904
+ function Vn(e, r, t, a) {
1905
+ const i = Hn(t), o = e.value || "", n = i === "`" ? "GraveAccent" : "Tilde";
1906
+ if (qn(e, t)) {
1907
+ const u = t.enter("codeIndented"), p = t.indentLines(o, Xn);
1853
1908
  return u(), p;
1854
1909
  }
1855
- const c = t.createTracker(a), s = i.repeat(Math.max(Bn(o, i) + 1, 3)), l = t.enter("codeFenced");
1910
+ const c = t.createTracker(a), s = i.repeat(Math.max(Wn(o, i) + 1, 3)), l = t.enter("codeFenced");
1856
1911
  let f = c.move(s);
1857
1912
  if (e.lang) {
1858
1913
  const u = t.enter(`codeFencedLang${n}`);
@@ -1881,7 +1936,7 @@ function Hn(e, r, t, a) {
1881
1936
  `), o && (f += c.move(o + `
1882
1937
  `)), f += c.move(s), l(), f;
1883
1938
  }
1884
- function Vn(e, r, t) {
1939
+ function Xn(e, r, t) {
1885
1940
  return (t ? "" : " ") + e;
1886
1941
  }
1887
1942
  function ft(e) {
@@ -1892,7 +1947,7 @@ function ft(e) {
1892
1947
  );
1893
1948
  return r;
1894
1949
  }
1895
- function Xn(e, r, t, a) {
1950
+ function Kn(e, r, t, a) {
1896
1951
  const i = ft(t), o = i === '"' ? "Quote" : "Apostrophe", n = t.enter("definition");
1897
1952
  let c = t.enter("label");
1898
1953
  const s = t.createTracker(a);
@@ -1922,7 +1977,7 @@ function Xn(e, r, t, a) {
1922
1977
  })
1923
1978
  ), l += s.move(i), c()), n(), l;
1924
1979
  }
1925
- function Kn(e) {
1980
+ function Qn(e) {
1926
1981
  const r = e.options.emphasis || "*";
1927
1982
  if (r !== "*" && r !== "_")
1928
1983
  throw new Error(
@@ -1930,17 +1985,17 @@ function Kn(e) {
1930
1985
  );
1931
1986
  return r;
1932
1987
  }
1933
- function Ie(e) {
1988
+ function Ne(e) {
1934
1989
  return "&#x" + e.toString(16).toUpperCase() + ";";
1935
1990
  }
1936
- function $e(e) {
1937
- if (e === null || H(e) || le(e))
1991
+ function Ue(e) {
1992
+ if (e === null || q(e) || de(e))
1938
1993
  return 1;
1939
- if (Be(e))
1994
+ if (Oe(e))
1940
1995
  return 2;
1941
1996
  }
1942
- function Oe(e, r, t) {
1943
- const a = $e(e), i = $e(r);
1997
+ function $e(e, r, t) {
1998
+ const a = Ue(e), i = Ue(r);
1944
1999
  return a === void 0 ? i === void 0 ? (
1945
2000
  // Letter inside:
1946
2001
  // we have to encode *both* letters for `_` as it is looser.
@@ -1972,9 +2027,9 @@ function Oe(e, r, t) {
1972
2027
  { inside: !1, outside: !1 }
1973
2028
  );
1974
2029
  }
1975
- ir.peek = Qn;
2030
+ ir.peek = Gn;
1976
2031
  function ir(e, r, t, a) {
1977
- const i = Kn(t), o = t.enter("emphasis"), n = t.createTracker(a), c = n.move(i);
2032
+ const i = Qn(t), o = t.enter("emphasis"), n = t.createTracker(a), c = n.move(i);
1978
2033
  let s = n.move(
1979
2034
  t.containerPhrasing(e, {
1980
2035
  after: i,
@@ -1982,24 +2037,24 @@ function ir(e, r, t, a) {
1982
2037
  ...n.current()
1983
2038
  })
1984
2039
  );
1985
- const l = s.charCodeAt(0), f = Oe(
2040
+ const l = s.charCodeAt(0), f = $e(
1986
2041
  a.before.charCodeAt(a.before.length - 1),
1987
2042
  l,
1988
2043
  i
1989
2044
  );
1990
- f.inside && (s = Ie(l) + s.slice(1));
1991
- const u = s.charCodeAt(s.length - 1), p = Oe(a.after.charCodeAt(0), u, i);
1992
- p.inside && (s = s.slice(0, -1) + Ie(u));
2045
+ f.inside && (s = Ne(l) + s.slice(1));
2046
+ const u = s.charCodeAt(s.length - 1), p = $e(a.after.charCodeAt(0), u, i);
2047
+ p.inside && (s = s.slice(0, -1) + Ne(u));
1993
2048
  const g = n.move(i);
1994
2049
  return o(), t.attentionEncodeSurroundingInfo = {
1995
2050
  after: p.outside,
1996
2051
  before: f.outside
1997
2052
  }, c + s + g;
1998
2053
  }
1999
- function Qn(e, r, t) {
2054
+ function Gn(e, r, t) {
2000
2055
  return t.options.emphasis || "*";
2001
2056
  }
2002
- function Gn(e, r, t, a) {
2057
+ function Yn(e, r, t, a) {
2003
2058
  let i, o, n;
2004
2059
  typeof r == "function" && typeof t != "function" ? (o = void 0, n = r, i = t) : (o = r, n = t, i = a), er(e, o, c, i);
2005
2060
  function c(s, l) {
@@ -2007,13 +2062,13 @@ function Gn(e, r, t, a) {
2007
2062
  return n(s, u, f);
2008
2063
  }
2009
2064
  }
2010
- const Yn = {};
2065
+ const Zn = {};
2011
2066
  function or(e, r) {
2012
- const t = Yn, a = typeof t.includeImageAlt == "boolean" ? t.includeImageAlt : !0, i = typeof t.includeHtml == "boolean" ? t.includeHtml : !0;
2067
+ const t = Zn, a = typeof t.includeImageAlt == "boolean" ? t.includeImageAlt : !0, i = typeof t.includeHtml == "boolean" ? t.includeHtml : !0;
2013
2068
  return sr(e, a, i);
2014
2069
  }
2015
2070
  function sr(e, r, t) {
2016
- if (Zn(e)) {
2071
+ if (Jn(e)) {
2017
2072
  if ("value" in e)
2018
2073
  return e.type === "html" && !t ? "" : e.value;
2019
2074
  if (r && "alt" in e && e.alt)
@@ -2030,19 +2085,19 @@ function Rt(e, r, t) {
2030
2085
  a[i] = sr(e[i], r, t);
2031
2086
  return a.join("");
2032
2087
  }
2033
- function Zn(e) {
2088
+ function Jn(e) {
2034
2089
  return !!(e && typeof e == "object");
2035
2090
  }
2036
- function Jn(e, r) {
2091
+ function ei(e, r) {
2037
2092
  let t = !1;
2038
- return Gn(e, function(a) {
2093
+ return Yn(e, function(a) {
2039
2094
  if ("value" in a && /\r?\n|\r/.test(a.value) || a.type === "break")
2040
2095
  return t = !0, ot;
2041
2096
  }), !!((!e.depth || e.depth < 3) && or(e) && (r.options.setext || t));
2042
2097
  }
2043
- function ei(e, r, t, a) {
2098
+ function ti(e, r, t, a) {
2044
2099
  const i = Math.max(Math.min(6, e.depth || 1), 1), o = t.createTracker(a);
2045
- if (Jn(e, t)) {
2100
+ if (ei(e, t)) {
2046
2101
  const f = t.enter("headingSetext"), u = t.enter("phrasing"), p = t.containerPhrasing(e, {
2047
2102
  ...o.current(),
2048
2103
  before: `
@@ -2067,16 +2122,16 @@ function ei(e, r, t, a) {
2067
2122
  `,
2068
2123
  ...o.current()
2069
2124
  });
2070
- return /^[\t ]/.test(l) && (l = Ie(l.charCodeAt(0)) + l.slice(1)), l = l ? n + " " + l : n, t.options.closeAtx && (l += " " + n), s(), c(), l;
2125
+ return /^[\t ]/.test(l) && (l = Ne(l.charCodeAt(0)) + l.slice(1)), l = l ? n + " " + l : n, t.options.closeAtx && (l += " " + n), s(), c(), l;
2071
2126
  }
2072
- cr.peek = ti;
2127
+ cr.peek = ri;
2073
2128
  function cr(e) {
2074
2129
  return e.value || "";
2075
2130
  }
2076
- function ti() {
2131
+ function ri() {
2077
2132
  return "<";
2078
2133
  }
2079
- ur.peek = ri;
2134
+ ur.peek = ai;
2080
2135
  function ur(e, r, t, a) {
2081
2136
  const i = ft(t), o = i === '"' ? "Quote" : "Apostrophe", n = t.enter("image");
2082
2137
  let c = t.enter("label");
@@ -2102,10 +2157,10 @@ function ur(e, r, t, a) {
2102
2157
  })
2103
2158
  ), l += s.move(i), c()), l += s.move(")"), n(), l;
2104
2159
  }
2105
- function ri() {
2160
+ function ai() {
2106
2161
  return "!";
2107
2162
  }
2108
- lr.peek = ai;
2163
+ lr.peek = ni;
2109
2164
  function lr(e, r, t, a) {
2110
2165
  const i = e.referenceType, o = t.enter("imageReference");
2111
2166
  let n = t.enter("label");
@@ -2126,10 +2181,10 @@ function lr(e, r, t, a) {
2126
2181
  });
2127
2182
  return n(), t.stack = f, o(), i === "full" || !l || l !== u ? s += c.move(u + "]") : i === "shortcut" ? s = s.slice(0, -1) : s += c.move("]"), s;
2128
2183
  }
2129
- function ai() {
2184
+ function ni() {
2130
2185
  return "!";
2131
2186
  }
2132
- dr.peek = ni;
2187
+ dr.peek = ii;
2133
2188
  function dr(e, r, t) {
2134
2189
  let a = e.value || "", i = "`", o = -1;
2135
2190
  for (; new RegExp("(^|[^`])" + i + "([^`]|$)").test(a); )
@@ -2145,7 +2200,7 @@ function dr(e, r, t) {
2145
2200
  }
2146
2201
  return i + a + i;
2147
2202
  }
2148
- function ni() {
2203
+ function ii() {
2149
2204
  return "`";
2150
2205
  }
2151
2206
  function fr(e, r) {
@@ -2159,7 +2214,7 @@ function fr(e, r) {
2159
2214
  // references don’t work), space, or angle brackets…
2160
2215
  !/[\0- <>\u007F]/.test(e.url));
2161
2216
  }
2162
- hr.peek = ii;
2217
+ hr.peek = oi;
2163
2218
  function hr(e, r, t, a) {
2164
2219
  const i = ft(t), o = i === '"' ? "Quote" : "Apostrophe", n = t.createTracker(a);
2165
2220
  let c, s;
@@ -2201,10 +2256,10 @@ function hr(e, r, t, a) {
2201
2256
  })
2202
2257
  ), l += n.move(i), s()), l += n.move(")"), c(), l;
2203
2258
  }
2204
- function ii(e, r, t) {
2259
+ function oi(e, r, t) {
2205
2260
  return fr(e, t) ? "<" : "[";
2206
2261
  }
2207
- mr.peek = oi;
2262
+ mr.peek = si;
2208
2263
  function mr(e, r, t, a) {
2209
2264
  const i = e.referenceType, o = t.enter("linkReference");
2210
2265
  let n = t.enter("label");
@@ -2225,7 +2280,7 @@ function mr(e, r, t, a) {
2225
2280
  });
2226
2281
  return n(), t.stack = f, o(), i === "full" || !l || l !== u ? s += c.move(u + "]") : i === "shortcut" ? s = s.slice(0, -1) : s += c.move("]"), s;
2227
2282
  }
2228
- function oi() {
2283
+ function si() {
2229
2284
  return "[";
2230
2285
  }
2231
2286
  function ht(e) {
@@ -2236,7 +2291,7 @@ function ht(e) {
2236
2291
  );
2237
2292
  return r;
2238
2293
  }
2239
- function si(e) {
2294
+ function ci(e) {
2240
2295
  const r = ht(e), t = e.options.bulletOther;
2241
2296
  if (!t)
2242
2297
  return r === "*" ? "-" : "*";
@@ -2250,7 +2305,7 @@ function si(e) {
2250
2305
  );
2251
2306
  return t;
2252
2307
  }
2253
- function ci(e) {
2308
+ function ui(e) {
2254
2309
  const r = e.options.bulletOrdered || ".";
2255
2310
  if (r !== "." && r !== ")")
2256
2311
  throw new Error(
@@ -2266,10 +2321,10 @@ function pr(e) {
2266
2321
  );
2267
2322
  return r;
2268
2323
  }
2269
- function ui(e, r, t, a) {
2324
+ function li(e, r, t, a) {
2270
2325
  const i = t.enter("list"), o = t.bulletCurrent;
2271
- let n = e.ordered ? ci(t) : ht(t);
2272
- const c = e.ordered ? n === "." ? ")" : "." : si(t);
2326
+ let n = e.ordered ? ui(t) : ht(t);
2327
+ const c = e.ordered ? n === "." ? ")" : "." : ci(t);
2273
2328
  let s = r && t.bulletLastUsed ? n === t.bulletLastUsed : !1;
2274
2329
  if (!e.ordered) {
2275
2330
  const f = e.children ? e.children[0] : void 0;
@@ -2294,7 +2349,7 @@ function ui(e, r, t, a) {
2294
2349
  const l = t.containerFlow(e, a);
2295
2350
  return t.bulletLastUsed = n, t.bulletCurrent = o, i(), l;
2296
2351
  }
2297
- function li(e) {
2352
+ function di(e) {
2298
2353
  const r = e.options.listItemIndent || "one";
2299
2354
  if (r !== "tab" && r !== "one" && r !== "mixed")
2300
2355
  throw new Error(
@@ -2302,8 +2357,8 @@ function li(e) {
2302
2357
  );
2303
2358
  return r;
2304
2359
  }
2305
- function di(e, r, t, a) {
2306
- const i = li(t);
2360
+ function fi(e, r, t, a) {
2361
+ const i = di(t);
2307
2362
  let o = t.bulletCurrent || ht(t);
2308
2363
  r && r.type === "list" && r.ordered && (o = (typeof r.start == "number" && r.start > -1 ? r.start : 1) + (t.options.incrementListMarker === !1 ? 0 : r.children.indexOf(e)) + o);
2309
2364
  let n = o.length + 1;
@@ -2319,13 +2374,13 @@ function di(e, r, t, a) {
2319
2374
  return p ? (g ? "" : " ".repeat(n)) + u : (g ? o : o + " ".repeat(n - o.length)) + u;
2320
2375
  }
2321
2376
  }
2322
- function fi(e, r, t, a) {
2377
+ function hi(e, r, t, a) {
2323
2378
  const i = t.enter("paragraph"), o = t.enter("phrasing"), n = t.containerPhrasing(e, a);
2324
2379
  return o(), i(), n;
2325
2380
  }
2326
- const hi = (
2381
+ const mi = (
2327
2382
  /** @type {(node?: unknown) => node is Exclude<PhrasingContent, Html>} */
2328
- qe([
2383
+ We([
2329
2384
  "break",
2330
2385
  "delete",
2331
2386
  "emphasis",
@@ -2349,12 +2404,12 @@ const hi = (
2349
2404
  "textDirective"
2350
2405
  ])
2351
2406
  );
2352
- function mi(e, r, t, a) {
2407
+ function pi(e, r, t, a) {
2353
2408
  return (e.children.some(function(n) {
2354
- return hi(n);
2409
+ return mi(n);
2355
2410
  }) ? t.containerPhrasing : t.containerFlow).call(t, e, a);
2356
2411
  }
2357
- function pi(e) {
2412
+ function gi(e) {
2358
2413
  const r = e.options.strong || "*";
2359
2414
  if (r !== "*" && r !== "_")
2360
2415
  throw new Error(
@@ -2362,9 +2417,9 @@ function pi(e) {
2362
2417
  );
2363
2418
  return r;
2364
2419
  }
2365
- gr.peek = gi;
2420
+ gr.peek = bi;
2366
2421
  function gr(e, r, t, a) {
2367
- const i = pi(t), o = t.enter("strong"), n = t.createTracker(a), c = n.move(i + i);
2422
+ const i = gi(t), o = t.enter("strong"), n = t.createTracker(a), c = n.move(i + i);
2368
2423
  let s = n.move(
2369
2424
  t.containerPhrasing(e, {
2370
2425
  after: i,
@@ -2372,27 +2427,27 @@ function gr(e, r, t, a) {
2372
2427
  ...n.current()
2373
2428
  })
2374
2429
  );
2375
- const l = s.charCodeAt(0), f = Oe(
2430
+ const l = s.charCodeAt(0), f = $e(
2376
2431
  a.before.charCodeAt(a.before.length - 1),
2377
2432
  l,
2378
2433
  i
2379
2434
  );
2380
- f.inside && (s = Ie(l) + s.slice(1));
2381
- const u = s.charCodeAt(s.length - 1), p = Oe(a.after.charCodeAt(0), u, i);
2382
- p.inside && (s = s.slice(0, -1) + Ie(u));
2435
+ f.inside && (s = Ne(l) + s.slice(1));
2436
+ const u = s.charCodeAt(s.length - 1), p = $e(a.after.charCodeAt(0), u, i);
2437
+ p.inside && (s = s.slice(0, -1) + Ne(u));
2383
2438
  const g = n.move(i + i);
2384
2439
  return o(), t.attentionEncodeSurroundingInfo = {
2385
2440
  after: p.outside,
2386
2441
  before: f.outside
2387
2442
  }, c + s + g;
2388
2443
  }
2389
- function gi(e, r, t) {
2444
+ function bi(e, r, t) {
2390
2445
  return t.options.strong || "*";
2391
2446
  }
2392
- function bi(e, r, t, a) {
2447
+ function yi(e, r, t, a) {
2393
2448
  return t.safe(e.value, a);
2394
2449
  }
2395
- function yi(e) {
2450
+ function xi(e) {
2396
2451
  const r = e.options.ruleRepetition || 3;
2397
2452
  if (r < 3)
2398
2453
  throw new Error(
@@ -2400,50 +2455,50 @@ function yi(e) {
2400
2455
  );
2401
2456
  return r;
2402
2457
  }
2403
- function xi(e, r, t) {
2404
- const a = (pr(t) + (t.options.ruleSpaces ? " " : "")).repeat(yi(t));
2458
+ function wi(e, r, t) {
2459
+ const a = (pr(t) + (t.options.ruleSpaces ? " " : "")).repeat(xi(t));
2405
2460
  return t.options.ruleSpaces ? a.slice(0, -1) : a;
2406
2461
  }
2407
2462
  const br = {
2408
- blockquote: Un,
2463
+ blockquote: $n,
2409
2464
  break: Pt,
2410
- code: Hn,
2411
- definition: Xn,
2465
+ code: Vn,
2466
+ definition: Kn,
2412
2467
  emphasis: ir,
2413
2468
  hardBreak: Pt,
2414
- heading: ei,
2469
+ heading: ti,
2415
2470
  html: cr,
2416
2471
  image: ur,
2417
2472
  imageReference: lr,
2418
2473
  inlineCode: dr,
2419
2474
  link: hr,
2420
2475
  linkReference: mr,
2421
- list: ui,
2422
- listItem: di,
2423
- paragraph: fi,
2424
- root: mi,
2476
+ list: li,
2477
+ listItem: fi,
2478
+ paragraph: hi,
2479
+ root: pi,
2425
2480
  strong: gr,
2426
- text: bi,
2427
- thematicBreak: xi
2481
+ text: yi,
2482
+ thematicBreak: wi
2428
2483
  };
2429
- function wi() {
2484
+ function ki() {
2430
2485
  return {
2431
2486
  enter: {
2432
- table: ki,
2487
+ table: Ci,
2433
2488
  tableData: Dt,
2434
2489
  tableHeader: Dt,
2435
- tableRow: vi
2490
+ tableRow: Ti
2436
2491
  },
2437
2492
  exit: {
2438
- codeText: Ti,
2439
- table: Ci,
2440
- tableData: Je,
2441
- tableHeader: Je,
2442
- tableRow: Je
2493
+ codeText: Mi,
2494
+ table: vi,
2495
+ tableData: Ze,
2496
+ tableHeader: Ze,
2497
+ tableRow: Ze
2443
2498
  }
2444
2499
  };
2445
2500
  }
2446
- function ki(e) {
2501
+ function Ci(e) {
2447
2502
  const r = e._align;
2448
2503
  this.enter(
2449
2504
  {
@@ -2456,28 +2511,28 @@ function ki(e) {
2456
2511
  e
2457
2512
  ), this.data.inTable = !0;
2458
2513
  }
2459
- function Ci(e) {
2514
+ function vi(e) {
2460
2515
  this.exit(e), this.data.inTable = void 0;
2461
2516
  }
2462
- function vi(e) {
2517
+ function Ti(e) {
2463
2518
  this.enter({ type: "tableRow", children: [] }, e);
2464
2519
  }
2465
- function Je(e) {
2520
+ function Ze(e) {
2466
2521
  this.exit(e);
2467
2522
  }
2468
2523
  function Dt(e) {
2469
2524
  this.enter({ type: "tableCell", children: [] }, e);
2470
2525
  }
2471
- function Ti(e) {
2526
+ function Mi(e) {
2472
2527
  let r = this.resume();
2473
- this.data.inTable && (r = r.replace(/\\([\\|])/g, Mi));
2528
+ this.data.inTable && (r = r.replace(/\\([\\|])/g, Ai));
2474
2529
  const t = this.stack[this.stack.length - 1];
2475
2530
  t.type, t.value = r, this.exit(e);
2476
2531
  }
2477
- function Mi(e, r) {
2532
+ function Ai(e, r) {
2478
2533
  return r === "|" ? r : e;
2479
2534
  }
2480
- function Ai(e) {
2535
+ function Ii(e) {
2481
2536
  const r = e || {}, t = r.tableCellPadding, a = r.tablePipeAlign, i = r.stringLength, o = t ? " " : "|";
2482
2537
  return {
2483
2538
  unsafe: [
@@ -2515,15 +2570,15 @@ function Ai(e) {
2515
2570
  `));
2516
2571
  }
2517
2572
  function s(g, h, y, b) {
2518
- const x = y.enter("tableCell"), w = y.enter("phrasing"), k = y.containerPhrasing(g, {
2573
+ const x = y.enter("tableCell"), w = y.enter("phrasing"), v = y.containerPhrasing(g, {
2519
2574
  ...b,
2520
2575
  before: o,
2521
2576
  after: o
2522
2577
  });
2523
- return w(), x(), k;
2578
+ return w(), x(), v;
2524
2579
  }
2525
2580
  function l(g, h) {
2526
- return zn(g, {
2581
+ return jn(g, {
2527
2582
  align: h,
2528
2583
  // @ts-expect-error: `markdown-table` types should support `null`.
2529
2584
  alignDelimiters: a,
@@ -2536,44 +2591,44 @@ function Ai(e) {
2536
2591
  function f(g, h, y) {
2537
2592
  const b = g.children;
2538
2593
  let x = -1;
2539
- const w = [], k = h.enter("table");
2594
+ const w = [], v = h.enter("table");
2540
2595
  for (; ++x < b.length; )
2541
2596
  w[x] = u(b[x], h, y);
2542
- return k(), w;
2597
+ return v(), w;
2543
2598
  }
2544
2599
  function u(g, h, y) {
2545
2600
  const b = g.children;
2546
2601
  let x = -1;
2547
- const w = [], k = h.enter("tableRow");
2602
+ const w = [], v = h.enter("tableRow");
2548
2603
  for (; ++x < b.length; )
2549
2604
  w[x] = s(b[x], g, h, y);
2550
- return k(), w;
2605
+ return v(), w;
2551
2606
  }
2552
2607
  function p(g, h, y) {
2553
2608
  let b = br.inlineCode(g, h, y);
2554
2609
  return y.stack.includes("tableCell") && (b = b.replace(/\|/g, "\\$&")), b;
2555
2610
  }
2556
2611
  }
2557
- function Ii() {
2612
+ function Ni() {
2558
2613
  return {
2559
2614
  exit: {
2560
2615
  taskListCheckValueChecked: _t,
2561
2616
  taskListCheckValueUnchecked: _t,
2562
- paragraph: Si
2617
+ paragraph: Li
2563
2618
  }
2564
2619
  };
2565
2620
  }
2566
- function Ni() {
2621
+ function Si() {
2567
2622
  return {
2568
2623
  unsafe: [{ atBreak: !0, character: "-", after: "[:|-]" }],
2569
- handlers: { listItem: Li }
2624
+ handlers: { listItem: Ei }
2570
2625
  };
2571
2626
  }
2572
2627
  function _t(e) {
2573
2628
  const r = this.stack[this.stack.length - 2];
2574
2629
  r.type, r.checked = e.type === "taskListCheckValueChecked";
2575
2630
  }
2576
- function Si(e) {
2631
+ function Li(e) {
2577
2632
  const r = this.stack[this.stack.length - 2];
2578
2633
  if (r && r.type === "listItem" && typeof r.checked == "boolean") {
2579
2634
  const t = this.stack[this.stack.length - 1];
@@ -2594,7 +2649,7 @@ function Si(e) {
2594
2649
  }
2595
2650
  this.exit(e);
2596
2651
  }
2597
- function Li(e, r, t, a) {
2652
+ function Ei(e, r, t, a) {
2598
2653
  const i = e.children[0], o = typeof e.checked == "boolean" && i && i.type === "paragraph", n = "[" + (e.checked ? "x" : " ") + "] ", c = t.createTracker(a);
2599
2654
  o && c.move(n);
2600
2655
  let s = br.listItem(e, r, t, {
@@ -2606,23 +2661,23 @@ function Li(e, r, t, a) {
2606
2661
  return f + n;
2607
2662
  }
2608
2663
  }
2609
- function Ei() {
2664
+ function Pi() {
2610
2665
  return [
2611
- on(),
2612
- In(),
2613
- En(),
2614
- wi(),
2615
- Ii()
2666
+ sn(),
2667
+ Nn(),
2668
+ Pn(),
2669
+ ki(),
2670
+ Ni()
2616
2671
  ];
2617
2672
  }
2618
- function Pi(e) {
2673
+ function Ri(e) {
2619
2674
  return {
2620
2675
  extensions: [
2621
- sn(),
2622
- Nn(e),
2623
- Pn(),
2624
- Ai(e),
2625
- Ni()
2676
+ cn(),
2677
+ Sn(e),
2678
+ Rn(),
2679
+ Ii(e),
2680
+ Si()
2626
2681
  ]
2627
2682
  };
2628
2683
  }
@@ -2636,14 +2691,14 @@ function je(e, r, t, a) {
2636
2691
  n = a.slice(o, o + 1e4), n.unshift(r, 0), e.splice(...n), o += 1e4, r += 1e4;
2637
2692
  }
2638
2693
  const Ft = {}.hasOwnProperty;
2639
- function Ri(e) {
2694
+ function Di(e) {
2640
2695
  const r = {};
2641
2696
  let t = -1;
2642
2697
  for (; ++t < e.length; )
2643
- Di(r, e[t]);
2698
+ _i(r, e[t]);
2644
2699
  return r;
2645
2700
  }
2646
- function Di(e, r) {
2701
+ function _i(e, r) {
2647
2702
  let t;
2648
2703
  for (t in r) {
2649
2704
  const i = (Ft.call(e, t) ? e[t] : void 0) || (e[t] = {}), o = r[t];
@@ -2652,7 +2707,7 @@ function Di(e, r) {
2652
2707
  for (n in o) {
2653
2708
  Ft.call(i, n) || (i[n] = []);
2654
2709
  const c = o[n];
2655
- _i(
2710
+ Fi(
2656
2711
  // @ts-expect-error Looks like a list.
2657
2712
  i[n],
2658
2713
  Array.isArray(c) ? c : c ? [c] : []
@@ -2660,58 +2715,58 @@ function Di(e, r) {
2660
2715
  }
2661
2716
  }
2662
2717
  }
2663
- function _i(e, r) {
2718
+ function Fi(e, r) {
2664
2719
  let t = -1;
2665
2720
  const a = [];
2666
2721
  for (; ++t < r.length; )
2667
2722
  (r[t].add === "after" ? e : a).push(r[t]);
2668
2723
  je(e, 0, 0, a);
2669
2724
  }
2670
- const Fi = {
2671
- tokenize: Bi,
2672
- partial: !0
2673
- }, yr = {
2725
+ const zi = {
2674
2726
  tokenize: Wi,
2675
2727
  partial: !0
2676
- }, xr = {
2728
+ }, yr = {
2677
2729
  tokenize: qi,
2678
2730
  partial: !0
2679
- }, wr = {
2731
+ }, xr = {
2680
2732
  tokenize: Hi,
2681
2733
  partial: !0
2682
- }, zi = {
2734
+ }, wr = {
2683
2735
  tokenize: Vi,
2684
2736
  partial: !0
2737
+ }, ji = {
2738
+ tokenize: Xi,
2739
+ partial: !0
2685
2740
  }, kr = {
2686
2741
  name: "wwwAutolink",
2687
- tokenize: $i,
2742
+ tokenize: Oi,
2688
2743
  previous: vr
2689
2744
  }, Cr = {
2690
2745
  name: "protocolAutolink",
2691
- tokenize: Oi,
2746
+ tokenize: Bi,
2692
2747
  previous: Tr
2693
- }, ne = {
2748
+ }, ie = {
2694
2749
  name: "emailAutolink",
2695
- tokenize: Ui,
2750
+ tokenize: $i,
2696
2751
  previous: Mr
2697
- }, Y = {};
2698
- function ji() {
2752
+ }, J = {};
2753
+ function Ui() {
2699
2754
  return {
2700
- text: Y
2755
+ text: J
2701
2756
  };
2702
2757
  }
2703
- let ce = 48;
2704
- for (; ce < 123; )
2705
- Y[ce] = ne, ce++, ce === 58 ? ce = 65 : ce === 91 && (ce = 97);
2706
- Y[43] = ne;
2707
- Y[45] = ne;
2708
- Y[46] = ne;
2709
- Y[95] = ne;
2710
- Y[72] = [ne, Cr];
2711
- Y[104] = [ne, Cr];
2712
- Y[87] = [ne, kr];
2713
- Y[119] = [ne, kr];
2714
- function Ui(e, r, t) {
2758
+ let ue = 48;
2759
+ for (; ue < 123; )
2760
+ J[ue] = ie, ue++, ue === 58 ? ue = 65 : ue === 91 && (ue = 97);
2761
+ J[43] = ie;
2762
+ J[45] = ie;
2763
+ J[46] = ie;
2764
+ J[95] = ie;
2765
+ J[72] = [ie, Cr];
2766
+ J[104] = [ie, Cr];
2767
+ J[87] = [ie, kr];
2768
+ J[119] = [ie, kr];
2769
+ function $i(e, r, t) {
2715
2770
  const a = this;
2716
2771
  let i, o;
2717
2772
  return n;
@@ -2722,26 +2777,26 @@ function Ui(e, r, t) {
2722
2777
  return st(u) ? (e.consume(u), c) : u === 64 ? (e.consume(u), s) : t(u);
2723
2778
  }
2724
2779
  function s(u) {
2725
- return u === 46 ? e.check(zi, f, l)(u) : u === 45 || u === 95 || dt(u) ? (o = !0, e.consume(u), s) : f(u);
2780
+ return u === 46 ? e.check(ji, f, l)(u) : u === 45 || u === 95 || dt(u) ? (o = !0, e.consume(u), s) : f(u);
2726
2781
  }
2727
2782
  function l(u) {
2728
2783
  return e.consume(u), i = !0, s;
2729
2784
  }
2730
2785
  function f(u) {
2731
- return o && i && Ae(a.previous) ? (e.exit("literalAutolinkEmail"), e.exit("literalAutolink"), r(u)) : t(u);
2786
+ return o && i && Ie(a.previous) ? (e.exit("literalAutolinkEmail"), e.exit("literalAutolink"), r(u)) : t(u);
2732
2787
  }
2733
2788
  }
2734
- function $i(e, r, t) {
2789
+ function Oi(e, r, t) {
2735
2790
  const a = this;
2736
2791
  return i;
2737
2792
  function i(n) {
2738
- return n !== 87 && n !== 119 || !vr.call(a, a.previous) || mt(a.events) ? t(n) : (e.enter("literalAutolink"), e.enter("literalAutolinkWww"), e.check(Fi, e.attempt(yr, e.attempt(xr, o), t), t)(n));
2793
+ return n !== 87 && n !== 119 || !vr.call(a, a.previous) || mt(a.events) ? t(n) : (e.enter("literalAutolink"), e.enter("literalAutolinkWww"), e.check(zi, e.attempt(yr, e.attempt(xr, o), t), t)(n));
2739
2794
  }
2740
2795
  function o(n) {
2741
2796
  return e.exit("literalAutolinkWww"), e.exit("literalAutolink"), r(n);
2742
2797
  }
2743
2798
  }
2744
- function Oi(e, r, t) {
2799
+ function Bi(e, r, t) {
2745
2800
  const a = this;
2746
2801
  let i = "", o = !1;
2747
2802
  return n;
@@ -2749,7 +2804,7 @@ function Oi(e, r, t) {
2749
2804
  return (u === 72 || u === 104) && Tr.call(a, a.previous) && !mt(a.events) ? (e.enter("literalAutolink"), e.enter("literalAutolinkHttp"), i += String.fromCodePoint(u), e.consume(u), c) : t(u);
2750
2805
  }
2751
2806
  function c(u) {
2752
- if (Ae(u) && i.length < 5)
2807
+ if (Ie(u) && i.length < 5)
2753
2808
  return i += String.fromCodePoint(u), e.consume(u), c;
2754
2809
  if (u === 58) {
2755
2810
  const p = i.toLowerCase();
@@ -2762,13 +2817,13 @@ function Oi(e, r, t) {
2762
2817
  return u === 47 ? (e.consume(u), o ? l : (o = !0, s)) : t(u);
2763
2818
  }
2764
2819
  function l(u) {
2765
- return u === null || Ha(u) || H(u) || le(u) || Be(u) ? t(u) : e.attempt(yr, e.attempt(xr, f), t)(u);
2820
+ return u === null || Va(u) || q(u) || de(u) || Oe(u) ? t(u) : e.attempt(yr, e.attempt(xr, f), t)(u);
2766
2821
  }
2767
2822
  function f(u) {
2768
2823
  return e.exit("literalAutolinkHttp"), e.exit("literalAutolink"), r(u);
2769
2824
  }
2770
2825
  }
2771
- function Bi(e, r, t) {
2826
+ function Wi(e, r, t) {
2772
2827
  let a = 0;
2773
2828
  return i;
2774
2829
  function i(n) {
@@ -2778,11 +2833,11 @@ function Bi(e, r, t) {
2778
2833
  return n === null ? t(n) : r(n);
2779
2834
  }
2780
2835
  }
2781
- function Wi(e, r, t) {
2836
+ function qi(e, r, t) {
2782
2837
  let a, i, o;
2783
2838
  return n;
2784
2839
  function n(l) {
2785
- return l === 46 || l === 95 ? e.check(wr, s, c)(l) : l === null || H(l) || le(l) || l !== 45 && Be(l) ? s(l) : (o = !0, e.consume(l), n);
2840
+ return l === 46 || l === 95 ? e.check(wr, s, c)(l) : l === null || q(l) || de(l) || l !== 45 && Oe(l) ? s(l) : (o = !0, e.consume(l), n);
2786
2841
  }
2787
2842
  function c(l) {
2788
2843
  return l === 95 ? a = !0 : (i = a, a = void 0), e.consume(l), n;
@@ -2791,36 +2846,36 @@ function Wi(e, r, t) {
2791
2846
  return i || a || !o ? t(l) : r(l);
2792
2847
  }
2793
2848
  }
2794
- function qi(e, r) {
2849
+ function Hi(e, r) {
2795
2850
  let t = 0, a = 0;
2796
2851
  return i;
2797
2852
  function i(n) {
2798
- return n === 40 ? (t++, e.consume(n), i) : n === 41 && a < t ? o(n) : n === 33 || n === 34 || n === 38 || n === 39 || n === 41 || n === 42 || n === 44 || n === 46 || n === 58 || n === 59 || n === 60 || n === 63 || n === 93 || n === 95 || n === 126 ? e.check(wr, r, o)(n) : n === null || H(n) || le(n) ? r(n) : (e.consume(n), i);
2853
+ return n === 40 ? (t++, e.consume(n), i) : n === 41 && a < t ? o(n) : n === 33 || n === 34 || n === 38 || n === 39 || n === 41 || n === 42 || n === 44 || n === 46 || n === 58 || n === 59 || n === 60 || n === 63 || n === 93 || n === 95 || n === 126 ? e.check(wr, r, o)(n) : n === null || q(n) || de(n) ? r(n) : (e.consume(n), i);
2799
2854
  }
2800
2855
  function o(n) {
2801
2856
  return n === 41 && a++, e.consume(n), i;
2802
2857
  }
2803
2858
  }
2804
- function Hi(e, r, t) {
2859
+ function Vi(e, r, t) {
2805
2860
  return a;
2806
2861
  function a(c) {
2807
2862
  return c === 33 || c === 34 || c === 39 || c === 41 || c === 42 || c === 44 || c === 46 || c === 58 || c === 59 || c === 63 || c === 95 || c === 126 ? (e.consume(c), a) : c === 38 ? (e.consume(c), o) : c === 93 ? (e.consume(c), i) : (
2808
2863
  // `<` is an end.
2809
2864
  c === 60 || // So is whitespace.
2810
- c === null || H(c) || le(c) ? r(c) : t(c)
2865
+ c === null || q(c) || de(c) ? r(c) : t(c)
2811
2866
  );
2812
2867
  }
2813
2868
  function i(c) {
2814
- return c === null || c === 40 || c === 91 || H(c) || le(c) ? r(c) : a(c);
2869
+ return c === null || c === 40 || c === 91 || q(c) || de(c) ? r(c) : a(c);
2815
2870
  }
2816
2871
  function o(c) {
2817
- return Ae(c) ? n(c) : t(c);
2872
+ return Ie(c) ? n(c) : t(c);
2818
2873
  }
2819
2874
  function n(c) {
2820
- return c === 59 ? (e.consume(c), a) : Ae(c) ? (e.consume(c), n) : t(c);
2875
+ return c === 59 ? (e.consume(c), a) : Ie(c) ? (e.consume(c), n) : t(c);
2821
2876
  }
2822
2877
  }
2823
- function Vi(e, r, t) {
2878
+ function Xi(e, r, t) {
2824
2879
  return a;
2825
2880
  function a(o) {
2826
2881
  return e.consume(o), i;
@@ -2830,10 +2885,10 @@ function Vi(e, r, t) {
2830
2885
  }
2831
2886
  }
2832
2887
  function vr(e) {
2833
- return e === null || e === 40 || e === 42 || e === 95 || e === 91 || e === 93 || e === 126 || H(e);
2888
+ return e === null || e === 40 || e === 42 || e === 95 || e === 91 || e === 93 || e === 126 || q(e);
2834
2889
  }
2835
2890
  function Tr(e) {
2836
- return !Ae(e);
2891
+ return !Ie(e);
2837
2892
  }
2838
2893
  function Mr(e) {
2839
2894
  return !(e === 47 || st(e));
@@ -2856,7 +2911,7 @@ function mt(e) {
2856
2911
  }
2857
2912
  return e.length > 0 && !t && (e[e.length - 1][1]._gfmAutolinkLiteralWalkedInto = !0), t;
2858
2913
  }
2859
- function Xi(e, r, t) {
2914
+ function Ki(e, r, t) {
2860
2915
  const a = [];
2861
2916
  let i = -1;
2862
2917
  for (; ++i < e.length; ) {
@@ -2865,61 +2920,61 @@ function Xi(e, r, t) {
2865
2920
  }
2866
2921
  return r;
2867
2922
  }
2868
- function re(e, r, t, a) {
2923
+ function ae(e, r, t, a) {
2869
2924
  const i = a ? a - 1 : Number.POSITIVE_INFINITY;
2870
2925
  let o = 0;
2871
2926
  return n;
2872
2927
  function n(s) {
2873
- return te(s) ? (e.enter(t), c(s)) : r(s);
2928
+ return re(s) ? (e.enter(t), c(s)) : r(s);
2874
2929
  }
2875
2930
  function c(s) {
2876
- return te(s) && o++ < i ? (e.consume(s), c) : (e.exit(t), r(s));
2931
+ return re(s) && o++ < i ? (e.consume(s), c) : (e.exit(t), r(s));
2877
2932
  }
2878
2933
  }
2879
- const Ki = {
2934
+ const Qi = {
2880
2935
  partial: !0,
2881
- tokenize: Qi
2936
+ tokenize: Gi
2882
2937
  };
2883
- function Qi(e, r, t) {
2938
+ function Gi(e, r, t) {
2884
2939
  return a;
2885
2940
  function a(o) {
2886
- return te(o) ? re(e, i, "linePrefix")(o) : i(o);
2941
+ return re(o) ? ae(e, i, "linePrefix")(o) : i(o);
2887
2942
  }
2888
2943
  function i(o) {
2889
- return o === null || ge(o) ? r(o) : t(o);
2944
+ return o === null || pe(o) ? r(o) : t(o);
2890
2945
  }
2891
2946
  }
2892
- const Gi = {
2893
- tokenize: no,
2947
+ const Yi = {
2948
+ tokenize: io,
2894
2949
  partial: !0
2895
2950
  };
2896
- function Yi() {
2951
+ function Zi() {
2897
2952
  return {
2898
2953
  document: {
2899
2954
  91: {
2900
2955
  name: "gfmFootnoteDefinition",
2901
- tokenize: to,
2956
+ tokenize: ro,
2902
2957
  continuation: {
2903
- tokenize: ro
2958
+ tokenize: ao
2904
2959
  },
2905
- exit: ao
2960
+ exit: no
2906
2961
  }
2907
2962
  },
2908
2963
  text: {
2909
2964
  91: {
2910
2965
  name: "gfmFootnoteCall",
2911
- tokenize: eo
2966
+ tokenize: to
2912
2967
  },
2913
2968
  93: {
2914
2969
  name: "gfmPotentialFootnoteCall",
2915
2970
  add: "after",
2916
- tokenize: Zi,
2917
- resolveTo: Ji
2971
+ tokenize: Ji,
2972
+ resolveTo: eo
2918
2973
  }
2919
2974
  }
2920
2975
  };
2921
2976
  }
2922
- function Zi(e, r, t) {
2977
+ function Ji(e, r, t) {
2923
2978
  const a = this;
2924
2979
  let i = a.events.length;
2925
2980
  const o = a.parser.gfmFootnotes || (a.parser.gfmFootnotes = []);
@@ -2937,14 +2992,14 @@ function Zi(e, r, t) {
2937
2992
  function c(s) {
2938
2993
  if (!n || !n._balanced)
2939
2994
  return t(s);
2940
- const l = Ne(a.sliceSerialize({
2995
+ const l = Se(a.sliceSerialize({
2941
2996
  start: n.end,
2942
2997
  end: a.now()
2943
2998
  }));
2944
2999
  return l.codePointAt(0) !== 94 || !o.includes(l.slice(1)) ? t(s) : (e.enter("gfmFootnoteCallLabelMarker"), e.consume(s), e.exit("gfmFootnoteCallLabelMarker"), r(s));
2945
3000
  }
2946
3001
  }
2947
- function Ji(e, r) {
3002
+ function eo(e, r) {
2948
3003
  let t = e.length;
2949
3004
  for (; t--; )
2950
3005
  if (e[t][1].type === "labelImage" && e[t][0] === "enter") {
@@ -2994,7 +3049,7 @@ function Ji(e, r) {
2994
3049
  ];
2995
3050
  return e.splice(t, e.length - t + 1, ...c), e;
2996
3051
  }
2997
- function eo(e, r, t) {
3052
+ function to(e, r, t) {
2998
3053
  const a = this, i = a.parser.gfmFootnotes || (a.parser.gfmFootnotes = []);
2999
3054
  let o = 0, n;
3000
3055
  return c;
@@ -3010,21 +3065,21 @@ function eo(e, r, t) {
3010
3065
  o > 999 || // Closing brace with nothing.
3011
3066
  u === 93 && !n || // Space or tab is not supported by GFM for some reason.
3012
3067
  // `\n` and `[` not being supported makes sense.
3013
- u === null || u === 91 || H(u)
3068
+ u === null || u === 91 || q(u)
3014
3069
  )
3015
3070
  return t(u);
3016
3071
  if (u === 93) {
3017
3072
  e.exit("chunkString");
3018
3073
  const p = e.exit("gfmFootnoteCallString");
3019
- return i.includes(Ne(a.sliceSerialize(p))) ? (e.enter("gfmFootnoteCallLabelMarker"), e.consume(u), e.exit("gfmFootnoteCallLabelMarker"), e.exit("gfmFootnoteCall"), r) : t(u);
3074
+ return i.includes(Se(a.sliceSerialize(p))) ? (e.enter("gfmFootnoteCallLabelMarker"), e.consume(u), e.exit("gfmFootnoteCallLabelMarker"), e.exit("gfmFootnoteCall"), r) : t(u);
3020
3075
  }
3021
- return H(u) || (n = !0), o++, e.consume(u), u === 92 ? f : l;
3076
+ return q(u) || (n = !0), o++, e.consume(u), u === 92 ? f : l;
3022
3077
  }
3023
3078
  function f(u) {
3024
3079
  return u === 91 || u === 92 || u === 93 ? (e.consume(u), o++, l) : l(u);
3025
3080
  }
3026
3081
  }
3027
- function to(e, r, t) {
3082
+ function ro(e, r, t) {
3028
3083
  const a = this, i = a.parser.gfmFootnotes || (a.parser.gfmFootnotes = []);
3029
3084
  let o, n = 0, c;
3030
3085
  return s;
@@ -3040,41 +3095,41 @@ function to(e, r, t) {
3040
3095
  n > 999 || // Closing brace with nothing.
3041
3096
  h === 93 && !c || // Space or tab is not supported by GFM for some reason.
3042
3097
  // `\n` and `[` not being supported makes sense.
3043
- h === null || h === 91 || H(h)
3098
+ h === null || h === 91 || q(h)
3044
3099
  )
3045
3100
  return t(h);
3046
3101
  if (h === 93) {
3047
3102
  e.exit("chunkString");
3048
3103
  const y = e.exit("gfmFootnoteDefinitionLabelString");
3049
- return o = Ne(a.sliceSerialize(y)), e.enter("gfmFootnoteDefinitionLabelMarker"), e.consume(h), e.exit("gfmFootnoteDefinitionLabelMarker"), e.exit("gfmFootnoteDefinitionLabel"), p;
3104
+ return o = Se(a.sliceSerialize(y)), e.enter("gfmFootnoteDefinitionLabelMarker"), e.consume(h), e.exit("gfmFootnoteDefinitionLabelMarker"), e.exit("gfmFootnoteDefinitionLabel"), p;
3050
3105
  }
3051
- return H(h) || (c = !0), n++, e.consume(h), h === 92 ? u : f;
3106
+ return q(h) || (c = !0), n++, e.consume(h), h === 92 ? u : f;
3052
3107
  }
3053
3108
  function u(h) {
3054
3109
  return h === 91 || h === 92 || h === 93 ? (e.consume(h), n++, f) : f(h);
3055
3110
  }
3056
3111
  function p(h) {
3057
- return h === 58 ? (e.enter("definitionMarker"), e.consume(h), e.exit("definitionMarker"), i.includes(o) || i.push(o), re(e, g, "gfmFootnoteDefinitionWhitespace")) : t(h);
3112
+ return h === 58 ? (e.enter("definitionMarker"), e.consume(h), e.exit("definitionMarker"), i.includes(o) || i.push(o), ae(e, g, "gfmFootnoteDefinitionWhitespace")) : t(h);
3058
3113
  }
3059
3114
  function g(h) {
3060
3115
  return r(h);
3061
3116
  }
3062
3117
  }
3063
- function ro(e, r, t) {
3064
- return e.check(Ki, r, e.attempt(Gi, r, t));
3118
+ function ao(e, r, t) {
3119
+ return e.check(Qi, r, e.attempt(Yi, r, t));
3065
3120
  }
3066
- function ao(e) {
3121
+ function no(e) {
3067
3122
  e.exit("gfmFootnoteDefinition");
3068
3123
  }
3069
- function no(e, r, t) {
3124
+ function io(e, r, t) {
3070
3125
  const a = this;
3071
- return re(e, i, "gfmFootnoteDefinitionIndent", 5);
3126
+ return ae(e, i, "gfmFootnoteDefinitionIndent", 5);
3072
3127
  function i(o) {
3073
3128
  const n = a.events[a.events.length - 1];
3074
3129
  return n && n[1].type === "gfmFootnoteDefinitionIndent" && n[2].sliceSerialize(n[1], !0).length === 4 ? r(o) : t(o);
3075
3130
  }
3076
3131
  }
3077
- function io(e) {
3132
+ function oo(e) {
3078
3133
  let t = (e || {}).singleTilde;
3079
3134
  const a = {
3080
3135
  name: "strikethrough",
@@ -3110,7 +3165,7 @@ function io(e) {
3110
3165
  start: Object.assign({}, n[l][1].end),
3111
3166
  end: Object.assign({}, n[s][1].start)
3112
3167
  }, p = [["enter", f, c], ["enter", n[l][1], c], ["exit", n[l][1], c], ["enter", u, c]], g = c.parser.constructs.insideSpan.null;
3113
- g && je(p, p.length, 0, Xi(g, n.slice(l + 1, s), c)), je(p, p.length, 0, [["exit", u, c], ["enter", n[s][1], c], ["exit", n[s][1], c], ["exit", f, c]]), je(n, l - 1, s - l + 3, p), s = l + p.length - 2;
3168
+ g && je(p, p.length, 0, Ki(g, n.slice(l + 1, s), c)), je(p, p.length, 0, [["exit", u, c], ["enter", n[s][1], c], ["exit", n[s][1], c], ["exit", f, c]]), je(n, l - 1, s - l + 3, p), s = l + p.length - 2;
3114
3169
  break;
3115
3170
  }
3116
3171
  }
@@ -3126,16 +3181,16 @@ function io(e) {
3126
3181
  return l === 126 && f[f.length - 1][1].type !== "characterEscape" ? s(h) : (n.enter("strikethroughSequenceTemporary"), g(h));
3127
3182
  }
3128
3183
  function g(h) {
3129
- const y = $e(l);
3184
+ const y = Ue(l);
3130
3185
  if (h === 126)
3131
3186
  return u > 1 ? s(h) : (n.consume(h), u++, g);
3132
3187
  if (u < 2 && !t) return s(h);
3133
- const b = n.exit("strikethroughSequenceTemporary"), x = $e(h);
3188
+ const b = n.exit("strikethroughSequenceTemporary"), x = Ue(h);
3134
3189
  return b._open = !x || x === 2 && !!y, b._close = !y || y === 2 && !!x, c(h);
3135
3190
  }
3136
3191
  }
3137
3192
  }
3138
- class oo {
3193
+ class so {
3139
3194
  /**
3140
3195
  * Create a new edit map.
3141
3196
  */
@@ -3151,7 +3206,7 @@ class oo {
3151
3206
  * @returns {undefined}
3152
3207
  */
3153
3208
  add(r, t, a) {
3154
- so(this, r, t, a);
3209
+ co(this, r, t, a);
3155
3210
  }
3156
3211
  // To do: add this when moving to `micromark`.
3157
3212
  // /**
@@ -3190,7 +3245,7 @@ class oo {
3190
3245
  this.map.length = 0;
3191
3246
  }
3192
3247
  }
3193
- function so(e, r, t, a) {
3248
+ function co(e, r, t, a) {
3194
3249
  let i = 0;
3195
3250
  if (!(t === 0 && a.length === 0)) {
3196
3251
  for (; i < e.map.length; ) {
@@ -3203,7 +3258,7 @@ function so(e, r, t, a) {
3203
3258
  e.map.push([r, t, a]);
3204
3259
  }
3205
3260
  }
3206
- function co(e, r) {
3261
+ function uo(e, r) {
3207
3262
  let t = !1;
3208
3263
  const a = [];
3209
3264
  for (; r < e.length; ) {
@@ -3223,31 +3278,31 @@ function co(e, r) {
3223
3278
  }
3224
3279
  return a;
3225
3280
  }
3226
- function uo() {
3281
+ function lo() {
3227
3282
  return {
3228
3283
  flow: {
3229
3284
  null: {
3230
3285
  name: "table",
3231
- tokenize: lo,
3232
- resolveAll: fo
3286
+ tokenize: fo,
3287
+ resolveAll: ho
3233
3288
  }
3234
3289
  }
3235
3290
  };
3236
3291
  }
3237
- function lo(e, r, t) {
3292
+ function fo(e, r, t) {
3238
3293
  const a = this;
3239
3294
  let i = 0, o = 0, n;
3240
3295
  return c;
3241
3296
  function c(m) {
3242
- let O = a.events.length - 1;
3243
- for (; O > -1; ) {
3244
- const V = a.events[O][1].type;
3245
- if (V === "lineEnding" || // Note: markdown-rs uses `whitespace` instead of `linePrefix`
3246
- V === "linePrefix") O--;
3297
+ let D = a.events.length - 1;
3298
+ for (; D > -1; ) {
3299
+ const ee = a.events[D][1].type;
3300
+ if (ee === "lineEnding" || // Note: markdown-rs uses `whitespace` instead of `linePrefix`
3301
+ ee === "linePrefix") D--;
3247
3302
  else break;
3248
3303
  }
3249
- const j = O > -1 ? a.events[O][1].type : null, K = j === "tableHead" || j === "tableRow" ? I : s;
3250
- return K === I && a.parser.lazy[a.now().line] ? t(m) : K(m);
3304
+ const G = D > -1 ? a.events[D][1].type : null, H = G === "tableHead" || G === "tableRow" ? N : s;
3305
+ return H === N && a.parser.lazy[a.now().line] ? t(m) : H(m);
3251
3306
  }
3252
3307
  function s(m) {
3253
3308
  return e.enter("tableHead"), e.enter("tableRow"), l(m);
@@ -3256,57 +3311,57 @@ function lo(e, r, t) {
3256
3311
  return m === 124 || (n = !0, o += 1), f(m);
3257
3312
  }
3258
3313
  function f(m) {
3259
- return m === null ? t(m) : ge(m) ? o > 1 ? (o = 0, a.interrupt = !0, e.exit("tableRow"), e.enter("lineEnding"), e.consume(m), e.exit("lineEnding"), g) : t(m) : te(m) ? re(e, f, "whitespace")(m) : (o += 1, n && (n = !1, i += 1), m === 124 ? (e.enter("tableCellDivider"), e.consume(m), e.exit("tableCellDivider"), n = !0, f) : (e.enter("data"), u(m)));
3314
+ return m === null ? t(m) : pe(m) ? o > 1 ? (o = 0, a.interrupt = !0, e.exit("tableRow"), e.enter("lineEnding"), e.consume(m), e.exit("lineEnding"), g) : t(m) : re(m) ? ae(e, f, "whitespace")(m) : (o += 1, n && (n = !1, i += 1), m === 124 ? (e.enter("tableCellDivider"), e.consume(m), e.exit("tableCellDivider"), n = !0, f) : (e.enter("data"), u(m)));
3260
3315
  }
3261
3316
  function u(m) {
3262
- return m === null || m === 124 || H(m) ? (e.exit("data"), f(m)) : (e.consume(m), m === 92 ? p : u);
3317
+ return m === null || m === 124 || q(m) ? (e.exit("data"), f(m)) : (e.consume(m), m === 92 ? p : u);
3263
3318
  }
3264
3319
  function p(m) {
3265
3320
  return m === 92 || m === 124 ? (e.consume(m), u) : u(m);
3266
3321
  }
3267
3322
  function g(m) {
3268
- return a.interrupt = !1, a.parser.lazy[a.now().line] ? t(m) : (e.enter("tableDelimiterRow"), n = !1, te(m) ? re(e, h, "linePrefix", a.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(m) : h(m));
3323
+ return a.interrupt = !1, a.parser.lazy[a.now().line] ? t(m) : (e.enter("tableDelimiterRow"), n = !1, re(m) ? ae(e, h, "linePrefix", a.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(m) : h(m));
3269
3324
  }
3270
3325
  function h(m) {
3271
3326
  return m === 45 || m === 58 ? b(m) : m === 124 ? (n = !0, e.enter("tableCellDivider"), e.consume(m), e.exit("tableCellDivider"), y) : E(m);
3272
3327
  }
3273
3328
  function y(m) {
3274
- return te(m) ? re(e, b, "whitespace")(m) : b(m);
3329
+ return re(m) ? ae(e, b, "whitespace")(m) : b(m);
3275
3330
  }
3276
3331
  function b(m) {
3277
- return m === 58 ? (o += 1, n = !0, e.enter("tableDelimiterMarker"), e.consume(m), e.exit("tableDelimiterMarker"), x) : m === 45 ? (o += 1, x(m)) : m === null || ge(m) ? L(m) : E(m);
3332
+ return m === 58 ? (o += 1, n = !0, e.enter("tableDelimiterMarker"), e.consume(m), e.exit("tableDelimiterMarker"), x) : m === 45 ? (o += 1, x(m)) : m === null || pe(m) ? L(m) : E(m);
3278
3333
  }
3279
3334
  function x(m) {
3280
3335
  return m === 45 ? (e.enter("tableDelimiterFiller"), w(m)) : E(m);
3281
3336
  }
3282
3337
  function w(m) {
3283
- return m === 45 ? (e.consume(m), w) : m === 58 ? (n = !0, e.exit("tableDelimiterFiller"), e.enter("tableDelimiterMarker"), e.consume(m), e.exit("tableDelimiterMarker"), k) : (e.exit("tableDelimiterFiller"), k(m));
3338
+ return m === 45 ? (e.consume(m), w) : m === 58 ? (n = !0, e.exit("tableDelimiterFiller"), e.enter("tableDelimiterMarker"), e.consume(m), e.exit("tableDelimiterMarker"), v) : (e.exit("tableDelimiterFiller"), v(m));
3284
3339
  }
3285
- function k(m) {
3286
- return te(m) ? re(e, L, "whitespace")(m) : L(m);
3340
+ function v(m) {
3341
+ return re(m) ? ae(e, L, "whitespace")(m) : L(m);
3287
3342
  }
3288
3343
  function L(m) {
3289
- return m === 124 ? h(m) : m === null || ge(m) ? !n || i !== o ? E(m) : (e.exit("tableDelimiterRow"), e.exit("tableHead"), r(m)) : E(m);
3344
+ return m === 124 ? h(m) : m === null || pe(m) ? !n || i !== o ? E(m) : (e.exit("tableDelimiterRow"), e.exit("tableHead"), r(m)) : E(m);
3290
3345
  }
3291
3346
  function E(m) {
3292
3347
  return t(m);
3293
3348
  }
3294
- function I(m) {
3295
- return e.enter("tableRow"), M(m);
3349
+ function N(m) {
3350
+ return e.enter("tableRow"), A(m);
3296
3351
  }
3297
- function M(m) {
3298
- return m === 124 ? (e.enter("tableCellDivider"), e.consume(m), e.exit("tableCellDivider"), M) : m === null || ge(m) ? (e.exit("tableRow"), r(m)) : te(m) ? re(e, M, "whitespace")(m) : (e.enter("data"), _(m));
3352
+ function A(m) {
3353
+ return m === 124 ? (e.enter("tableCellDivider"), e.consume(m), e.exit("tableCellDivider"), A) : m === null || pe(m) ? (e.exit("tableRow"), r(m)) : re(m) ? ae(e, A, "whitespace")(m) : (e.enter("data"), I(m));
3299
3354
  }
3300
- function _(m) {
3301
- return m === null || m === 124 || H(m) ? (e.exit("data"), M(m)) : (e.consume(m), m === 92 ? A : _);
3355
+ function I(m) {
3356
+ return m === null || m === 124 || q(m) ? (e.exit("data"), A(m)) : (e.consume(m), m === 92 ? S : I);
3302
3357
  }
3303
- function A(m) {
3304
- return m === 92 || m === 124 ? (e.consume(m), _) : _(m);
3358
+ function S(m) {
3359
+ return m === 92 || m === 124 ? (e.consume(m), I) : I(m);
3305
3360
  }
3306
3361
  }
3307
- function fo(e, r) {
3362
+ function ho(e, r) {
3308
3363
  let t = -1, a = !0, i = 0, o = [0, 0, 0, 0], n = [0, 0, 0, 0], c = !1, s = 0, l, f, u;
3309
- const p = new oo();
3364
+ const p = new so();
3310
3365
  for (; ++t < e.length; ) {
3311
3366
  const g = e[t], h = g[1];
3312
3367
  g[0] === "enter" ? h.type === "tableHead" ? (c = !1, s !== 0 && (zt(p, r, s, l, f), f = void 0, s = 0), l = {
@@ -3323,21 +3378,21 @@ function fo(e, r) {
3323
3378
  }
3324
3379
  for (s !== 0 && zt(p, r, s, l, f), p.consume(r.events), t = -1; ++t < r.events.length; ) {
3325
3380
  const g = r.events[t];
3326
- g[0] === "enter" && g[1].type === "table" && (g[1]._align = co(r.events, t));
3381
+ g[0] === "enter" && g[1].type === "table" && (g[1]._align = uo(r.events, t));
3327
3382
  }
3328
3383
  return e;
3329
3384
  }
3330
3385
  function ze(e, r, t, a, i, o) {
3331
3386
  const n = a === 1 ? "tableHeader" : a === 2 ? "tableDelimiter" : "tableData", c = "tableContent";
3332
- t[0] !== 0 && (o.end = Object.assign({}, pe(r.events, t[0])), e.add(t[0], 0, [["exit", o, r]]));
3333
- const s = pe(r.events, t[1]);
3387
+ t[0] !== 0 && (o.end = Object.assign({}, me(r.events, t[0])), e.add(t[0], 0, [["exit", o, r]]));
3388
+ const s = me(r.events, t[1]);
3334
3389
  if (o = {
3335
3390
  type: n,
3336
3391
  start: Object.assign({}, s),
3337
3392
  // Note: correct end is set later.
3338
3393
  end: Object.assign({}, s)
3339
3394
  }, e.add(t[1], 0, [["enter", o, r]]), t[2] !== 0) {
3340
- const l = pe(r.events, t[2]), f = pe(r.events, t[3]), u = {
3395
+ const l = me(r.events, t[2]), f = me(r.events, t[3]), u = {
3341
3396
  type: c,
3342
3397
  start: Object.assign({}, l),
3343
3398
  end: Object.assign({}, f)
@@ -3351,28 +3406,28 @@ function ze(e, r, t, a, i, o) {
3351
3406
  }
3352
3407
  e.add(t[3] + 1, 0, [["exit", u, r]]);
3353
3408
  }
3354
- return i !== void 0 && (o.end = Object.assign({}, pe(r.events, i)), e.add(i, 0, [["exit", o, r]]), o = void 0), o;
3409
+ return i !== void 0 && (o.end = Object.assign({}, me(r.events, i)), e.add(i, 0, [["exit", o, r]]), o = void 0), o;
3355
3410
  }
3356
3411
  function zt(e, r, t, a, i) {
3357
- const o = [], n = pe(r.events, t);
3412
+ const o = [], n = me(r.events, t);
3358
3413
  i && (i.end = Object.assign({}, n), o.push(["exit", i, r])), a.end = Object.assign({}, n), o.push(["exit", a, r]), e.add(t + 1, 0, o);
3359
3414
  }
3360
- function pe(e, r) {
3415
+ function me(e, r) {
3361
3416
  const t = e[r], a = t[0] === "enter" ? "start" : "end";
3362
3417
  return t[1][a];
3363
3418
  }
3364
- const ho = {
3419
+ const mo = {
3365
3420
  name: "tasklistCheck",
3366
- tokenize: po
3421
+ tokenize: go
3367
3422
  };
3368
- function mo() {
3423
+ function po() {
3369
3424
  return {
3370
3425
  text: {
3371
- 91: ho
3426
+ 91: mo
3372
3427
  }
3373
3428
  };
3374
3429
  }
3375
- function po(e, r, t) {
3430
+ function go(e, r, t) {
3376
3431
  const a = this;
3377
3432
  return i;
3378
3433
  function i(s) {
@@ -3384,53 +3439,53 @@ function po(e, r, t) {
3384
3439
  );
3385
3440
  }
3386
3441
  function o(s) {
3387
- return H(s) ? (e.enter("taskListCheckValueUnchecked"), e.consume(s), e.exit("taskListCheckValueUnchecked"), n) : s === 88 || s === 120 ? (e.enter("taskListCheckValueChecked"), e.consume(s), e.exit("taskListCheckValueChecked"), n) : t(s);
3442
+ return q(s) ? (e.enter("taskListCheckValueUnchecked"), e.consume(s), e.exit("taskListCheckValueUnchecked"), n) : s === 88 || s === 120 ? (e.enter("taskListCheckValueChecked"), e.consume(s), e.exit("taskListCheckValueChecked"), n) : t(s);
3388
3443
  }
3389
3444
  function n(s) {
3390
3445
  return s === 93 ? (e.enter("taskListCheckMarker"), e.consume(s), e.exit("taskListCheckMarker"), e.exit("taskListCheck"), c) : t(s);
3391
3446
  }
3392
3447
  function c(s) {
3393
- return ge(s) ? r(s) : te(s) ? e.check({
3394
- tokenize: go
3448
+ return pe(s) ? r(s) : re(s) ? e.check({
3449
+ tokenize: bo
3395
3450
  }, r, t)(s) : t(s);
3396
3451
  }
3397
3452
  }
3398
- function go(e, r, t) {
3399
- return re(e, a, "whitespace");
3453
+ function bo(e, r, t) {
3454
+ return ae(e, a, "whitespace");
3400
3455
  function a(i) {
3401
3456
  return i === null ? t(i) : r(i);
3402
3457
  }
3403
3458
  }
3404
- function bo(e) {
3405
- return Ri([
3406
- ji(),
3407
- Yi(),
3408
- io(e),
3409
- uo(),
3410
- mo()
3459
+ function yo(e) {
3460
+ return Di([
3461
+ Ui(),
3462
+ Zi(),
3463
+ oo(e),
3464
+ lo(),
3465
+ po()
3411
3466
  ]);
3412
3467
  }
3413
- const yo = {};
3414
- function xo(e) {
3468
+ const xo = {};
3469
+ function wo(e) {
3415
3470
  const r = (
3416
3471
  /** @type {Processor<Root>} */
3417
3472
  this
3418
- ), t = e || yo, a = r.data(), i = a.micromarkExtensions || (a.micromarkExtensions = []), o = a.fromMarkdownExtensions || (a.fromMarkdownExtensions = []), n = a.toMarkdownExtensions || (a.toMarkdownExtensions = []);
3419
- i.push(bo(t)), o.push(Ei()), n.push(Pi(t));
3473
+ ), t = e || xo, a = r.data(), i = a.micromarkExtensions || (a.micromarkExtensions = []), o = a.fromMarkdownExtensions || (a.fromMarkdownExtensions = []), n = a.toMarkdownExtensions || (a.toMarkdownExtensions = []);
3474
+ i.push(yo(t)), o.push(Pi()), n.push(Ri(t));
3420
3475
  }
3421
- function U(...e) {
3476
+ function O(...e) {
3422
3477
  return e.filter(Boolean).join(" ");
3423
3478
  }
3424
- const wo = ({ content: e }) => /* @__PURE__ */ d(
3425
- Gr,
3479
+ const ko = ({ content: e }) => /* @__PURE__ */ d(
3480
+ Yr,
3426
3481
  {
3427
- remarkPlugins: [xo],
3482
+ remarkPlugins: [wo],
3428
3483
  className: "cuadra-aui-md",
3429
- components: vo,
3484
+ components: To,
3430
3485
  children: e
3431
3486
  }
3432
- ), pt = Ur(wo), ko = ({ language: e, code: r }) => {
3433
- const { isCopied: t, copyToClipboard: a } = Co();
3487
+ ), pt = $r(ko), Co = ({ language: e, code: r }) => {
3488
+ const { isCopied: t, copyToClipboard: a } = vo();
3434
3489
  return /* @__PURE__ */ C("div", { className: "cuadra-flex cuadra-items-center cuadra-justify-between cuadra-gap-4 cuadra-mt-4 cuadra-rounded-t-lg cuadra-bg-muted/50 cuadra-border-b cuadra-border-border cuadra-px-4 cuadra-py-2 cuadra-text-sm cuadra-font-normal cuadra-text-foreground cuadra-font-brand", children: [
3435
3490
  /* @__PURE__ */ d("span", { className: "cuadra-lowercase [&>span]:cuadra-text-xs cuadra-font-brand", children: e }),
3436
3491
  /* @__PURE__ */ C(
@@ -3442,33 +3497,33 @@ const wo = ({ content: e }) => /* @__PURE__ */ d(
3442
3497
  className: "cuadra-p-1 cuadra-rounded hover:cuadra-bg-muted cuadra-transition-colors",
3443
3498
  "aria-label": "Copy code",
3444
3499
  children: [
3445
- !t && /* @__PURE__ */ d(da, { className: "cuadra-h-4 cuadra-w-4" }),
3446
- t && /* @__PURE__ */ d(oa, { className: "cuadra-h-4 cuadra-w-4" })
3500
+ !t && /* @__PURE__ */ d(fa, { className: "cuadra-h-4 cuadra-w-4" }),
3501
+ t && /* @__PURE__ */ d(sa, { className: "cuadra-h-4 cuadra-w-4" })
3447
3502
  ]
3448
3503
  }
3449
3504
  )
3450
3505
  ] });
3451
- }, Co = ({
3506
+ }, vo = ({
3452
3507
  copiedDuration: e = 3e3
3453
3508
  } = {}) => {
3454
- const [r, t] = R(!1);
3509
+ const [r, t] = _(!1);
3455
3510
  return { isCopied: r, copyToClipboard: (i) => {
3456
3511
  i && navigator.clipboard.writeText(i).then(() => {
3457
3512
  t(!0), setTimeout(() => t(!1), e);
3458
3513
  });
3459
3514
  } };
3460
- }, vo = Kr({
3515
+ }, To = Qr({
3461
3516
  h1: ({ className: e, ...r }) => /* @__PURE__ */ d(
3462
3517
  "h1",
3463
3518
  {
3464
- className: U("cuadra-mb-6 cuadra-scroll-m-20 cuadra-text-2xl cuadra-font-normal cuadra-tracking-tight last:cuadra-mb-0 font-brand", e),
3519
+ className: O("cuadra-mb-6 cuadra-scroll-m-20 cuadra-text-2xl cuadra-font-normal cuadra-tracking-tight last:cuadra-mb-0 font-brand", e),
3465
3520
  ...r
3466
3521
  }
3467
3522
  ),
3468
3523
  h2: ({ className: e, ...r }) => /* @__PURE__ */ d(
3469
3524
  "h2",
3470
3525
  {
3471
- className: U(
3526
+ className: O(
3472
3527
  "cuadra-mb-4 cuadra-mt-6 cuadra-scroll-m-20 cuadra-text-xl cuadra-font-normal cuadra-tracking-tight first:cuadra-mt-0 last:cuadra-mb-0 font-brand",
3473
3528
  e
3474
3529
  ),
@@ -3478,7 +3533,7 @@ const wo = ({ content: e }) => /* @__PURE__ */ d(
3478
3533
  h3: ({ className: e, ...r }) => /* @__PURE__ */ d(
3479
3534
  "h3",
3480
3535
  {
3481
- className: U(
3536
+ className: O(
3482
3537
  "cuadra-mb-3 cuadra-mt-5 cuadra-scroll-m-20 cuadra-text-lg cuadra-font-normal cuadra-tracking-tight first:cuadra-mt-0 last:cuadra-mb-0 font-brand",
3483
3538
  e
3484
3539
  ),
@@ -3488,38 +3543,38 @@ const wo = ({ content: e }) => /* @__PURE__ */ d(
3488
3543
  h4: ({ className: e, ...r }) => /* @__PURE__ */ d(
3489
3544
  "h4",
3490
3545
  {
3491
- className: U(
3546
+ className: O(
3492
3547
  "cuadra-mb-4 cuadra-mt-6 cuadra-scroll-m-20 cuadra-text-xl cuadra-font-normal cuadra-tracking-tight first:cuadra-mt-0 last:cuadra-mb-0 font-brand",
3493
3548
  e
3494
3549
  ),
3495
3550
  ...r
3496
3551
  }
3497
3552
  ),
3498
- h5: ({ className: e, ...r }) => /* @__PURE__ */ d("h5", { className: U("cuadra-my-4 cuadra-text-lg cuadra-font-normal first:cuadra-mt-0 last:cuadra-mb-0 font-brand", e), ...r }),
3499
- h6: ({ className: e, ...r }) => /* @__PURE__ */ d("h6", { className: U("cuadra-my-4 cuadra-font-normal first:cuadra-mb-0 font-brand", e), ...r }),
3500
- p: ({ className: e, ...r }) => /* @__PURE__ */ d("p", { className: U("cuadra-mb-5 cuadra-mt-5 cuadra-leading-7 first:cuadra-mt-0 last:cuadra-mb-0 font-brand", e), ...r }),
3553
+ h5: ({ className: e, ...r }) => /* @__PURE__ */ d("h5", { className: O("cuadra-my-4 cuadra-text-lg cuadra-font-normal first:cuadra-mt-0 last:cuadra-mb-0 font-brand", e), ...r }),
3554
+ h6: ({ className: e, ...r }) => /* @__PURE__ */ d("h6", { className: O("cuadra-my-4 cuadra-font-normal first:cuadra-mb-0 font-brand", e), ...r }),
3555
+ p: ({ className: e, ...r }) => /* @__PURE__ */ d("p", { className: O("cuadra-mb-5 cuadra-mt-5 cuadra-leading-7 first:cuadra-mt-0 last:cuadra-mb-0 font-brand", e), ...r }),
3501
3556
  a: ({ className: e, ...r }) => /* @__PURE__ */ d(
3502
3557
  "a",
3503
3558
  {
3504
- className: U("cuadra-text-primary cuadra-font-medium cuadra-underline cuadra-underline-offset-4 font-brand", e),
3559
+ className: O("cuadra-text-primary cuadra-font-medium cuadra-underline cuadra-underline-offset-4 font-brand", e),
3505
3560
  ...r
3506
3561
  }
3507
3562
  ),
3508
- blockquote: ({ className: e, ...r }) => /* @__PURE__ */ d("blockquote", { className: U("cuadra-border-l-2 cuadra-pl-6 cuadra-italic font-brand", e), ...r }),
3509
- ul: ({ className: e, ...r }) => /* @__PURE__ */ d("ul", { className: U("cuadra-my-5 cuadra-ml-6 cuadra-list-disc [&>li]:cuadra-mt-2 font-brand", e), ...r }),
3510
- ol: ({ className: e, ...r }) => /* @__PURE__ */ d("ol", { className: U("cuadra-my-5 cuadra-ml-6 cuadra-list-decimal [&>li]:cuadra-mt-2 font-brand", e), ...r }),
3511
- hr: ({ className: e, ...r }) => /* @__PURE__ */ d("hr", { className: U("cuadra-my-5 cuadra-border-b", e), ...r }),
3563
+ blockquote: ({ className: e, ...r }) => /* @__PURE__ */ d("blockquote", { className: O("cuadra-border-l-2 cuadra-pl-6 cuadra-italic font-brand", e), ...r }),
3564
+ ul: ({ className: e, ...r }) => /* @__PURE__ */ d("ul", { className: O("cuadra-my-5 cuadra-ml-6 cuadra-list-disc [&>li]:cuadra-mt-2 font-brand", e), ...r }),
3565
+ ol: ({ className: e, ...r }) => /* @__PURE__ */ d("ol", { className: O("cuadra-my-5 cuadra-ml-6 cuadra-list-decimal [&>li]:cuadra-mt-2 font-brand", e), ...r }),
3566
+ hr: ({ className: e, ...r }) => /* @__PURE__ */ d("hr", { className: O("cuadra-my-5 cuadra-border-b", e), ...r }),
3512
3567
  table: ({ className: e, ...r }) => /* @__PURE__ */ d(
3513
3568
  "table",
3514
3569
  {
3515
- className: U("cuadra-my-5 cuadra-w-full cuadra-border-separate cuadra-border-spacing-0 cuadra-overflow-y-auto font-brand", e),
3570
+ className: O("cuadra-my-5 cuadra-w-full cuadra-border-separate cuadra-border-spacing-0 cuadra-overflow-y-auto font-brand", e),
3516
3571
  ...r
3517
3572
  }
3518
3573
  ),
3519
3574
  th: ({ className: e, ...r }) => /* @__PURE__ */ d(
3520
3575
  "th",
3521
3576
  {
3522
- className: U(
3577
+ className: O(
3523
3578
  "cuadra-bg-muted cuadra-px-4 cuadra-py-2 cuadra-text-left cuadra-font-normal first:cuadra-rounded-tl-lg last:cuadra-rounded-tr-lg [&[align=center]]:cuadra-text-center [&[align=right]]:cuadra-text-right font-brand",
3524
3579
  e
3525
3580
  ),
@@ -3529,7 +3584,7 @@ const wo = ({ content: e }) => /* @__PURE__ */ d(
3529
3584
  td: ({ className: e, ...r }) => /* @__PURE__ */ d(
3530
3585
  "td",
3531
3586
  {
3532
- className: U(
3587
+ className: O(
3533
3588
  "cuadra-border-b cuadra-border-l cuadra-px-4 cuadra-py-2 cuadra-text-left last:cuadra-border-r [&[align=center]]:cuadra-text-center [&[align=right]]:cuadra-text-right font-brand",
3534
3589
  e
3535
3590
  ),
@@ -3539,18 +3594,18 @@ const wo = ({ content: e }) => /* @__PURE__ */ d(
3539
3594
  tr: ({ className: e, ...r }) => /* @__PURE__ */ d(
3540
3595
  "tr",
3541
3596
  {
3542
- className: U(
3597
+ className: O(
3543
3598
  "cuadra-m-0 cuadra-border-b cuadra-p-0 first:cuadra-border-t [&:last-child>td:first-child]:cuadra-rounded-bl-lg [&:last-child>td:last-child]:cuadra-rounded-br-lg",
3544
3599
  e
3545
3600
  ),
3546
3601
  ...r
3547
3602
  }
3548
3603
  ),
3549
- sup: ({ className: e, ...r }) => /* @__PURE__ */ d("sup", { className: U("[&>a]:cuadra-text-xs [&>a]:cuadra-no-underline font-brand", e), ...r }),
3604
+ sup: ({ className: e, ...r }) => /* @__PURE__ */ d("sup", { className: O("[&>a]:cuadra-text-xs [&>a]:cuadra-no-underline font-brand", e), ...r }),
3550
3605
  pre: ({ className: e, ...r }) => /* @__PURE__ */ d(
3551
3606
  "pre",
3552
3607
  {
3553
- className: U(
3608
+ className: O(
3554
3609
  "cuadra-overflow-x-auto cuadra-whitespace-pre-wrap cuadra-break-words cuadra-rounded-b-lg !cuadra-rounded-t-none cuadra-bg-muted cuadra-p-4 cuadra-text-foreground font-brand",
3555
3610
  e
3556
3611
  ),
@@ -3558,16 +3613,16 @@ const wo = ({ content: e }) => /* @__PURE__ */ d(
3558
3613
  }
3559
3614
  ),
3560
3615
  code: function({ className: r, ...t }) {
3561
- const a = Qr();
3616
+ const a = Gr();
3562
3617
  return /* @__PURE__ */ d(
3563
3618
  "code",
3564
3619
  {
3565
- className: U(!a && "cuadra-bg-muted cuadra-rounded cuadra-border cuadra-font-normal font-brand", r),
3620
+ className: O(!a && "cuadra-bg-muted cuadra-rounded cuadra-border cuadra-font-normal font-brand", r),
3566
3621
  ...t
3567
3622
  }
3568
3623
  );
3569
3624
  },
3570
- CodeHeader: ko
3625
+ CodeHeader: Co
3571
3626
  });
3572
3627
  function Ar({ className: e = "", variant: r = "default", ...t }) {
3573
3628
  const a = "cuadra-inline-flex cuadra-items-center cuadra-rounded-md cuadra-px-3 cuadra-py-1.5 cuadra-text-xs cuadra-font-medium font-brand", i = {
@@ -3584,7 +3639,7 @@ function Ar({ className: e = "", variant: r = "default", ...t }) {
3584
3639
  }
3585
3640
  );
3586
3641
  }
3587
- function To(e) {
3642
+ function Mo(e) {
3588
3643
  const r = /* @__PURE__ */ new Map();
3589
3644
  for (const t of e) {
3590
3645
  const a = r.get(t.filename);
@@ -3592,19 +3647,19 @@ function To(e) {
3592
3647
  }
3593
3648
  return Array.from(r.values()).sort((t, a) => a.score - t.score);
3594
3649
  }
3595
- function Mo({
3650
+ function Ao({
3596
3651
  sources: e,
3597
3652
  maxVisible: r = 3
3598
3653
  }) {
3599
3654
  if (!e || e.length === 0) return null;
3600
- const t = To(e), a = t.slice(0, r), i = t.length - r;
3655
+ const t = Mo(e), a = t.slice(0, r), i = t.length - r;
3601
3656
  return /* @__PURE__ */ C("div", { className: "cuadra-mt-4 cuadra-pt-3 cuadra-border-t cuadra-border-border", children: [
3602
3657
  /* @__PURE__ */ C("div", { className: "cuadra-flex cuadra-items-center cuadra-gap-1.5 cuadra-mb-2.5", children: [
3603
3658
  /* @__PURE__ */ d(Vt, { className: "cuadra-h-3.5 cuadra-w-3.5 cuadra-text-muted-foreground" }),
3604
3659
  /* @__PURE__ */ d("span", { className: "cuadra-text-xs cuadra-font-medium cuadra-text-muted-foreground font-brand", children: "Sources" })
3605
3660
  ] }),
3606
3661
  /* @__PURE__ */ C("div", { className: "cuadra-flex cuadra-flex-wrap cuadra-gap-2", children: [
3607
- a.map((o, n) => /* @__PURE__ */ d(Io, { source: o }, o.sourceId || n)),
3662
+ a.map((o, n) => /* @__PURE__ */ d(No, { source: o }, o.sourceId || n)),
3608
3663
  i > 0 && /* @__PURE__ */ C(Ar, { variant: "subtle", children: [
3609
3664
  "+",
3610
3665
  i,
@@ -3613,21 +3668,21 @@ function Mo({
3613
3668
  ] })
3614
3669
  ] });
3615
3670
  }
3616
- function Ao(e) {
3671
+ function Io(e) {
3617
3672
  switch (e.split(".").pop()?.toLowerCase()) {
3618
3673
  case "csv":
3619
3674
  case "xlsx":
3620
3675
  case "xls":
3621
- return pa;
3676
+ return ga;
3622
3677
  case "md":
3623
3678
  case "txt":
3624
- return ya;
3679
+ return xa;
3625
3680
  default:
3626
3681
  return Vt;
3627
3682
  }
3628
3683
  }
3629
- function Io({ source: e }) {
3630
- const { filename: r, score: t } = e, a = Ao(r);
3684
+ function No({ source: e }) {
3685
+ const { filename: r, score: t } = e, a = Io(r);
3631
3686
  return /* @__PURE__ */ C(
3632
3687
  Ar,
3633
3688
  {
@@ -3644,7 +3699,7 @@ function Io({ source: e }) {
3644
3699
  }
3645
3700
  );
3646
3701
  }
3647
- const jt = be(
3702
+ const jt = ge(
3648
3703
  function({
3649
3704
  welcomeTitle: r = "Hi, how can I help you today?",
3650
3705
  welcomeSubtitle: t = "Start exploring our platform and discover what you can build.",
@@ -3656,67 +3711,67 @@ const jt = be(
3656
3711
  streamingSpeed: s = 50,
3657
3712
  safeArea: l = !1
3658
3713
  }, f) {
3659
- const u = qr(), p = Hr(), [g, h] = R(!1), [y, b] = R(null), [x, w] = R(!1), k = X((M, _, A) => {
3714
+ const u = Hr(), p = Vr(), [g, h] = _(!1), [y, b] = _(null), [x, w] = _(!1), v = Q((A, I, S) => {
3660
3715
  if (!x)
3661
3716
  try {
3662
- const m = A?.streamingSpeed ?? s, O = A?.delay ?? c;
3663
- Gt(M, _, m, O), p.composer().setText(M), setTimeout(() => {
3717
+ const m = S?.streamingSpeed ?? s, D = S?.delay ?? c;
3718
+ Gt(A, I, m, D), p.composer().setText(A), setTimeout(() => {
3664
3719
  p.composer().send();
3665
3720
  }, 10);
3666
3721
  } catch {
3667
3722
  }
3668
- }, [x, s, c, p]), L = X((M) => {
3723
+ }, [x, s, c, p]), L = Q((A) => {
3669
3724
  try {
3670
- p.composer().setText(M), setTimeout(() => {
3725
+ p.composer().setText(A), setTimeout(() => {
3671
3726
  p.composer().send();
3672
3727
  }, 10);
3673
3728
  } catch {
3674
3729
  }
3675
- }, [p]), E = X(async (M) => {
3730
+ }, [p]), E = Q(async (A) => {
3676
3731
  if (!(x || !u))
3677
3732
  try {
3678
- if (M.response) {
3679
- const _ = M.responseDelay ?? c;
3680
- await k(M.prompt, M.response, {
3681
- delay: _,
3733
+ if (A.response) {
3734
+ const I = A.responseDelay ?? c;
3735
+ await v(A.prompt, A.response, {
3736
+ delay: I,
3682
3737
  streamingSpeed: s
3683
3738
  });
3684
3739
  } else
3685
- L(M.prompt);
3740
+ L(A.prompt);
3686
3741
  } catch {
3687
3742
  }
3688
- }, [u, x, c, s, k, L]), I = X(() => {
3743
+ }, [u, x, c, s, v, L]), N = Q(() => {
3689
3744
  try {
3690
- const M = window.__cuadraThreadListRuntime;
3691
- M?.switchToNewThread && M.switchToNewThread();
3745
+ const A = window.__cuadraThreadListRuntime;
3746
+ A?.switchToNewThread && A.switchToNewThread();
3692
3747
  } catch {
3693
3748
  }
3694
3749
  }, []);
3695
3750
  return ct(f, () => ({
3696
3751
  sendMessage: L,
3697
- sendPreMadeQA: k,
3698
- clearChat: I
3699
- }), [L, k, I]), $(() => {
3752
+ sendPreMadeQA: v,
3753
+ clearChat: N
3754
+ }), [L, v, N]), B(() => {
3700
3755
  if (!u) {
3701
3756
  h(!1);
3702
3757
  return;
3703
3758
  }
3704
3759
  try {
3705
- const M = u?.store;
3706
- if (!M) {
3760
+ const A = u?.store;
3761
+ if (!A) {
3707
3762
  h(!1);
3708
3763
  return;
3709
3764
  }
3710
- const _ = M.subscribe?.((m) => {
3711
- const O = m?.threadId, j = m?.messages || [], K = m?.isLoadingHistory || !1, V = j.length;
3712
- O && O !== y && b(O), h(K && V === 0);
3713
- }), A = M.getState?.();
3714
- if (A) {
3715
- const m = A?.threadId, O = A?.messages || [], j = A?.isLoadingHistory || !1, K = O.length;
3716
- m && m !== y && b(m), h(j && K === 0);
3765
+ const I = A.subscribe?.((m) => {
3766
+ const D = m?.threadId, G = m?.messages || [], H = m?.isLoadingHistory || !1, ee = G.length;
3767
+ D && D !== y && b(D), h(H && ee === 0);
3768
+ }), S = A.getState?.();
3769
+ if (S) {
3770
+ const m = S?.threadId, D = S?.messages || [], G = S?.isLoadingHistory || !1, H = D.length;
3771
+ m && m !== y && b(m), h(G && H === 0);
3717
3772
  }
3718
3773
  return () => {
3719
- _ && _();
3774
+ I && I();
3720
3775
  };
3721
3776
  } catch {
3722
3777
  h(!1);
@@ -3730,9 +3785,9 @@ const jt = be(
3730
3785
  children: g ? /* @__PURE__ */ d("div", { className: "cuadra-absolute cuadra-inset-0 cuadra-flex cuadra-items-center cuadra-justify-center", children: /* @__PURE__ */ C("div", { className: "cuadra-flex cuadra-flex-col cuadra-items-center cuadra-gap-2", children: [
3731
3786
  /* @__PURE__ */ d(Xt, { className: "cuadra-h-6 cuadra-w-6 cuadra-animate-spin cuadra-text-muted-foreground" }),
3732
3787
  /* @__PURE__ */ d("p", { className: "cuadra-text-sm cuadra-text-muted-foreground font-brand", children: "Loading messages..." })
3733
- ] }) }) : /* @__PURE__ */ C(ae, { children: [
3788
+ ] }) }) : /* @__PURE__ */ C(ne, { children: [
3734
3789
  /* @__PURE__ */ d(De.Empty, { children: /* @__PURE__ */ d(
3735
- No,
3790
+ So,
3736
3791
  {
3737
3792
  title: r,
3738
3793
  subtitle: t,
@@ -3745,8 +3800,8 @@ const jt = be(
3745
3800
  De.Messages,
3746
3801
  {
3747
3802
  components: {
3748
- UserMessage: So,
3749
- AssistantMessage: Po
3803
+ UserMessage: Lo,
3804
+ AssistantMessage: Ro
3750
3805
  }
3751
3806
  }
3752
3807
  )
@@ -3764,10 +3819,10 @@ const jt = be(
3764
3819
  {
3765
3820
  components: {
3766
3821
  Attachment: () => {
3767
- const M = Me(({ attachment: _ }) => _);
3768
- return M ? /* @__PURE__ */ C("div", { className: "cuadra-relative cuadra-inline-flex cuadra-items-center cuadra-gap-2 cuadra-mb-2 cuadra-px-2 cuadra-py-1 cuadra-rounded-md cuadra-bg-muted cuadra-border cuadra-border-border", children: [
3769
- /* @__PURE__ */ d("span", { className: "cuadra-text-xs cuadra-text-muted-foreground font-brand", children: M.name || "Attachment" }),
3770
- /* @__PURE__ */ d(Vr.Remove, { asChild: !0, children: /* @__PURE__ */ d(
3822
+ const A = Ae(({ attachment: I }) => I);
3823
+ return A ? /* @__PURE__ */ C("div", { className: "cuadra-relative cuadra-inline-flex cuadra-items-center cuadra-gap-2 cuadra-mb-2 cuadra-px-2 cuadra-py-1 cuadra-rounded-md cuadra-bg-muted cuadra-border cuadra-border-border", children: [
3824
+ /* @__PURE__ */ d("span", { className: "cuadra-text-xs cuadra-text-muted-foreground font-brand", children: A.name || "Attachment" }),
3825
+ /* @__PURE__ */ d(Xr.Remove, { asChild: !0, children: /* @__PURE__ */ d(
3771
3826
  "button",
3772
3827
  {
3773
3828
  type: "button",
@@ -3835,7 +3890,7 @@ const jt = be(
3835
3890
  },
3836
3891
  "aria-label": "Send message",
3837
3892
  type: "button",
3838
- children: /* @__PURE__ */ d(na, { className: "cuadra-h-4 cuadra-w-4" })
3893
+ children: /* @__PURE__ */ d(ia, { className: "cuadra-h-4 cuadra-w-4" })
3839
3894
  }
3840
3895
  ) })
3841
3896
  ] })
@@ -3845,7 +3900,7 @@ const jt = be(
3845
3900
  ] });
3846
3901
  }
3847
3902
  );
3848
- function No({ title: e, subtitle: r, suggestions: t, onSuggestionClick: a, isProcessing: i }) {
3903
+ function So({ title: e, subtitle: r, suggestions: t, onSuggestionClick: a, isProcessing: i }) {
3849
3904
  return /* @__PURE__ */ d("div", { className: "cuadra-flex cuadra-flex-col cuadra-items-center cuadra-h-full cuadra-py-12 cuadra-px-4 cuadra-overflow-y-auto scrollbar-hide", children: /* @__PURE__ */ C("div", { className: "cuadra-text-center cuadra-max-w-3xl cuadra-w-full cuadra-flex cuadra-flex-col cuadra-items-center cuadra-justify-center cuadra-min-h-full", children: [
3850
3905
  /* @__PURE__ */ C("div", { className: "cuadra-flex cuadra-flex-col cuadra-items-center cuadra-justify-center cuadra-mb-8", children: [
3851
3906
  /* @__PURE__ */ d("h2", { className: "cuadra-text-xl cuadra-font-normal cuadra-text-foreground cuadra-mb-2 font-brand", children: e }),
@@ -3865,14 +3920,14 @@ function No({ title: e, subtitle: r, suggestions: t, onSuggestionClick: a, isPro
3865
3920
  )) })
3866
3921
  ] }) });
3867
3922
  }
3868
- function So() {
3869
- return /* @__PURE__ */ C(ve.Root, { className: "cuadra-grid cuadra-w-full cuadra-auto-rows-auto cuadra-grid-cols-[minmax(72px,1fr)_auto] cuadra-gap-y-2 cuadra-py-3 [&:where(>*)]:cuadra-col-start-2", children: [
3923
+ function Lo() {
3924
+ return /* @__PURE__ */ C(Te.Root, { className: "cuadra-grid cuadra-w-full cuadra-auto-rows-auto cuadra-grid-cols-[minmax(72px,1fr)_auto] cuadra-gap-y-2 cuadra-py-3 [&:where(>*)]:cuadra-col-start-2", children: [
3870
3925
  /* @__PURE__ */ d(
3871
- ve.Attachments,
3926
+ Te.Attachments,
3872
3927
  {
3873
3928
  components: {
3874
3929
  Attachment: () => {
3875
- const e = Me(({ attachment: o }) => o);
3930
+ const e = Ae(({ attachment: o }) => o);
3876
3931
  if (!e) return null;
3877
3932
  const r = e.type === "image", t = e.file, a = e.content?.find((o) => o.type === "image"), i = t ? URL.createObjectURL(t) : a?.image;
3878
3933
  return /* @__PURE__ */ d("div", { className: "cuadra-col-start-2 cuadra-row-start-1 cuadra-mb-2 cuadra-max-w-[calc(42rem*0.8)]", children: r && i ? /* @__PURE__ */ d(
@@ -3908,7 +3963,7 @@ function So() {
3908
3963
  borderWidth: "1px"
3909
3964
  },
3910
3965
  children: /* @__PURE__ */ d(
3911
- ve.Parts,
3966
+ Te.Parts,
3912
3967
  {
3913
3968
  components: {
3914
3969
  Text: ({ text: e }) => /* @__PURE__ */ d(pt, { content: e || "" })
@@ -3919,8 +3974,8 @@ function So() {
3919
3974
  )
3920
3975
  ] });
3921
3976
  }
3922
- function Lo({ text: e }) {
3923
- const [r, t] = R(!1), a = Me(({ message: i }) => i?.status?.type === "running");
3977
+ function Eo({ text: e }) {
3978
+ const [r, t] = _(!1), a = Ae(({ message: i }) => i?.status?.type === "running");
3924
3979
  return e ? a ? /* @__PURE__ */ d("div", { className: "cuadra-mb-3 cuadra-py-1", children: /* @__PURE__ */ d("div", { className: "cuadra-text-sm cuadra-text-muted-foreground cuadra-leading-relaxed font-brand cuadra-animate-text-shimmer", children: e }) }) : /* @__PURE__ */ C("div", { className: "cuadra-mb-3", children: [
3925
3980
  /* @__PURE__ */ C(
3926
3981
  "button",
@@ -3930,7 +3985,7 @@ function Lo({ text: e }) {
3930
3985
  className: "cuadra-flex cuadra-items-center cuadra-gap-1.5 cuadra-py-1 cuadra-text-sm cuadra-text-muted-foreground hover:cuadra-text-foreground cuadra-transition-colors font-brand",
3931
3986
  children: [
3932
3987
  /* @__PURE__ */ d(
3933
- nt,
3988
+ at,
3934
3989
  {
3935
3990
  className: `cuadra-h-3.5 cuadra-w-3.5 cuadra-shrink-0 cuadra-transition-transform cuadra-duration-200 ${r ? "" : "cuadra--rotate-90"}`
3936
3991
  }
@@ -3948,7 +4003,7 @@ function Lo({ text: e }) {
3948
4003
  )
3949
4004
  ] }) : null;
3950
4005
  }
3951
- function Eo() {
4006
+ function Po() {
3952
4007
  return /* @__PURE__ */ C("div", { className: "cuadra-flex cuadra-items-center cuadra-gap-2 cuadra-text-muted-foreground cuadra-text-sm font-brand cuadra-py-2", children: [
3953
4008
  /* @__PURE__ */ C("div", { className: "cuadra-flex cuadra-items-center cuadra-gap-1", children: [
3954
4009
  /* @__PURE__ */ d("span", { className: "cuadra-inline-block cuadra-w-1.5 cuadra-h-1.5 cuadra-bg-current cuadra-rounded-full cuadra-animate-bounce", style: { animationDelay: "0ms" } }),
@@ -3958,28 +4013,28 @@ function Eo() {
3958
4013
  /* @__PURE__ */ d("span", { children: "Thinking..." })
3959
4014
  ] });
3960
4015
  }
3961
- function Po() {
3962
- const e = Me(({ message: n }) => n?.status?.type === "running"), r = Me(({ message: n }) => {
4016
+ function Ro() {
4017
+ const e = Ae(({ message: n }) => n?.status?.type === "running"), r = Ae(({ message: n }) => {
3963
4018
  const c = n?.content;
3964
4019
  return !c || !Array.isArray(c) ? !1 : c.some((s) => !!(s.type === "text" && s.text && s.text.length > 0 || s.type === "reasoning" && s.text && s.text.length > 0));
3965
- }), t = ue(!1), [a, i] = R(null);
3966
- $(() => {
4020
+ }), t = le(!1), [a, i] = _(null);
4021
+ B(() => {
3967
4022
  if (e && r && !t.current) {
3968
- const n = se.getCurrentMessageId();
4023
+ const n = ce.getCurrentMessageId();
3969
4024
  n && (t.current = !0, i(n));
3970
4025
  }
3971
4026
  }, [e, r]);
3972
- const o = $r(
3973
- (n) => se.subscribe(n),
4027
+ const o = Or(
4028
+ (n) => ce.subscribe(n),
3974
4029
  () => {
3975
4030
  if (a) {
3976
- const n = se.getForMessage(a);
4031
+ const n = ce.getForMessage(a);
3977
4032
  return n.sources?.length ? n.sources : null;
3978
4033
  }
3979
4034
  if (e && r) {
3980
- const n = se.getCurrentMessageId();
4035
+ const n = ce.getCurrentMessageId();
3981
4036
  if (n) {
3982
- const c = se.getForMessage(n);
4037
+ const c = ce.getForMessage(n);
3983
4038
  return c.sources?.length ? c.sources : null;
3984
4039
  }
3985
4040
  }
@@ -3987,7 +4042,7 @@ function Po() {
3987
4042
  },
3988
4043
  () => null
3989
4044
  );
3990
- return /* @__PURE__ */ d(ve.Root, { className: "cuadra-relative cuadra-grid cuadra-w-full cuadra-grid-cols-[auto_auto_1fr] cuadra-grid-rows-[auto_1fr] cuadra-py-3", children: /* @__PURE__ */ C(
4045
+ return /* @__PURE__ */ d(Te.Root, { className: "cuadra-relative cuadra-grid cuadra-w-full cuadra-grid-cols-[auto_auto_1fr] cuadra-grid-rows-[auto_1fr] cuadra-py-3", children: /* @__PURE__ */ C(
3991
4046
  "div",
3992
4047
  {
3993
4048
  className: "cuadra-text-foreground cuadra-col-span-2 cuadra-col-start-2 cuadra-row-start-1 cuadra-my-1.5 cuadra-max-w-[90%] cuadra-break-words cuadra-leading-7 font-brand",
@@ -3998,16 +4053,16 @@ function Po() {
3998
4053
  },
3999
4054
  children: [
4000
4055
  /* @__PURE__ */ d(
4001
- ve.Parts,
4056
+ Te.Parts,
4002
4057
  {
4003
4058
  components: {
4004
4059
  Text: ({ text: n }) => /* @__PURE__ */ d(pt, { content: n || "" }),
4005
- Reasoning: ({ text: n }) => /* @__PURE__ */ d(Lo, { text: n || "" })
4060
+ Reasoning: ({ text: n }) => /* @__PURE__ */ d(Eo, { text: n || "" })
4006
4061
  }
4007
4062
  }
4008
4063
  ),
4009
- e && !r && /* @__PURE__ */ d(Eo, {}),
4010
- o && o.length > 0 && /* @__PURE__ */ d(Mo, { sources: o })
4064
+ e && !r && /* @__PURE__ */ d(Po, {}),
4065
+ o && o.length > 0 && /* @__PURE__ */ d(Ao, { sources: o })
4011
4066
  ]
4012
4067
  }
4013
4068
  ) });
@@ -4020,10 +4075,10 @@ const Ir = ({ className: e = "", theme: r = "system" }) => {
4020
4075
  return n || (window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light");
4021
4076
  }
4022
4077
  return r;
4023
- }, [a, i] = R(t);
4024
- return $(() => {
4078
+ }, [a, i] = _(t);
4079
+ return B(() => {
4025
4080
  r !== "system" && i(r);
4026
- }, [r]), $(() => {
4081
+ }, [r]), B(() => {
4027
4082
  const n = document.documentElement;
4028
4083
  n.classList.remove("light", "dark"), n.classList.add(a), r === "system" && localStorage.setItem("theme", a);
4029
4084
  }, [a, r]), /* @__PURE__ */ d(
@@ -4037,7 +4092,7 @@ const Ir = ({ className: e = "", theme: r = "system" }) => {
4037
4092
  disabled: r !== "system",
4038
4093
  className: `cuadra-flex cuadra-items-center cuadra-justify-center cuadra-h-8 cuadra-w-8 cuadra-rounded-full cuadra-bg-muted hover:cuadra-bg-muted/80 cuadra-transition-colors disabled:cuadra-opacity-50 disabled:cuadra-cursor-not-allowed ${e}`,
4039
4094
  children: /* @__PURE__ */ d(
4040
- ua,
4095
+ la,
4041
4096
  {
4042
4097
  className: `cuadra-h-4 cuadra-w-4 cuadra-transition-colors ${a === "dark" ? "cuadra-text-primary" : "cuadra-text-gray-400"}`
4043
4098
  }
@@ -4045,8 +4100,8 @@ const Ir = ({ className: e = "", theme: r = "system" }) => {
4045
4100
  }
4046
4101
  );
4047
4102
  };
4048
- function Ro({ onThreadSelect: e }) {
4049
- const r = Bt(), t = Xr((b) => b.threadId), [a, i] = R(null), o = r?.id === t, n = a === r?.id, [c, s] = R(!1), [l, f] = R(r?.title || ""), [u, p] = R(!1), [g, h] = R(!1), y = async () => {
4103
+ function Do({ onThreadSelect: e }) {
4104
+ const r = Bt(), t = Kr((b) => b.threadId), [a, i] = _(null), o = r?.id === t, n = a === r?.id, [c, s] = _(!1), [l, f] = _(r?.title || ""), [u, p] = _(!1), [g, h] = _(!1), y = async () => {
4050
4105
  if (!r?.remoteId || !l || l === r.title) {
4051
4106
  s(!1);
4052
4107
  return;
@@ -4061,10 +4116,10 @@ function Ro({ onThreadSelect: e }) {
4061
4116
  h(!1);
4062
4117
  }
4063
4118
  };
4064
- return $(() => {
4119
+ return B(() => {
4065
4120
  r?.title && !c && f(r.title);
4066
4121
  }, [r?.title, c]), r ? /* @__PURE__ */ C(
4067
- Qe.Root,
4122
+ Ke.Root,
4068
4123
  {
4069
4124
  className: `group cuadra-relative cuadra-flex cuadra-items-center cuadra-rounded-lg cuadra-transition-colors cuadra-cursor-pointer cuadra-border cuadra-mb-2 ${o ? "cuadra-bg-muted cuadra-border-border" : "cuadra-border-transparent hover:cuadra-bg-muted hover:cuadra-border-border"}`,
4070
4125
  style: { marginBottom: "0.5rem" },
@@ -4072,24 +4127,27 @@ function Ro({ onThreadSelect: e }) {
4072
4127
  onMouseLeave: () => i(null),
4073
4128
  children: [
4074
4129
  /* @__PURE__ */ d(
4075
- Qe.Trigger,
4130
+ Ke.Trigger,
4076
4131
  {
4077
4132
  className: "cuadra-p-3 cuadra-flex-1 cuadra-flex cuadra-items-center cuadra-min-w-0 cuadra-cursor-pointer",
4078
4133
  onClick: () => e?.(),
4079
4134
  children: /* @__PURE__ */ d("div", { className: "cuadra-flex cuadra-flex-col cuadra-min-w-0 cuadra-flex-1 cuadra-items-start cuadra-text-left", children: c ? /* @__PURE__ */ d(
4080
4135
  "input",
4081
4136
  {
4082
- className: "cuadra-flex cuadra-w-full cuadra-rounded-md cuadra-border cuadra-border-input cuadra-bg-background cuadra-px-3 cuadra-py-2 cuadra-text-sm placeholder:cuadra-text-muted-foreground focus-visible:cuadra-outline-none disabled:cuadra-cursor-not-allowed disabled:cuadra-opacity-50 font-brand",
4137
+ className: "cuadra-flex cuadra-w-full cuadra-rounded-md cuadra-border cuadra-border-input cuadra-bg-background cuadra-text-foreground cuadra-px-3 cuadra-py-2 cuadra-text-sm placeholder:cuadra-text-muted-foreground focus-visible:cuadra-outline-none disabled:cuadra-cursor-not-allowed disabled:cuadra-opacity-50 font-brand",
4083
4138
  value: l,
4084
4139
  onChange: (b) => f(b.target.value),
4085
4140
  onKeyDown: (b) => {
4086
4141
  b.key === "Enter" && y(), b.key === "Escape" && (s(!1), f(r.title || ""));
4087
4142
  },
4143
+ onBlur: () => {
4144
+ s(!1), f(r.title || "Chat");
4145
+ },
4088
4146
  disabled: g,
4089
4147
  autoFocus: !0,
4090
4148
  onClick: (b) => b.stopPropagation()
4091
4149
  }
4092
- ) : /* @__PURE__ */ C(ae, { children: [
4150
+ ) : /* @__PURE__ */ C(ne, { children: [
4093
4151
  /* @__PURE__ */ d("span", { className: "cuadra-text-sm cuadra-font-normal cuadra-text-foreground cuadra-truncate font-brand", children: (r.title?.length || 0) > 60 ? `${r.title?.slice(0, 60)}…` : r.title || "Chat" }),
4094
4152
  r.updatedAt && /* @__PURE__ */ d("span", { className: "cuadra-text-xs cuadra-text-muted-foreground cuadra-mt-1 font-brand", children: new Date(r.updatedAt).toLocaleDateString() })
4095
4153
  ] }) })
@@ -4105,10 +4163,10 @@ function Ro({ onThreadSelect: e }) {
4105
4163
  b.stopPropagation(), p(!u);
4106
4164
  },
4107
4165
  "aria-label": "Thread options",
4108
- children: /* @__PURE__ */ d(ha, { className: "cuadra-h-4 cuadra-w-4 cuadra-text-muted-foreground" })
4166
+ children: /* @__PURE__ */ d(ma, { className: "cuadra-h-4 cuadra-w-4 cuadra-text-muted-foreground" })
4109
4167
  }
4110
4168
  ),
4111
- u && /* @__PURE__ */ C(ae, { children: [
4169
+ u && /* @__PURE__ */ C(ne, { children: [
4112
4170
  /* @__PURE__ */ d(
4113
4171
  "div",
4114
4172
  {
@@ -4120,27 +4178,27 @@ function Ro({ onThreadSelect: e }) {
4120
4178
  "button",
4121
4179
  {
4122
4180
  type: "button",
4123
- className: "cuadra-w-full cuadra-px-3 cuadra-py-2 cuadra-text-sm cuadra-text-left hover:cuadra-bg-muted cuadra-transition-colors font-brand",
4181
+ className: "cuadra-w-full cuadra-px-3 cuadra-py-2 cuadra-text-sm cuadra-text-left cuadra-text-foreground hover:cuadra-bg-muted cuadra-transition-colors font-brand",
4124
4182
  onClick: (b) => {
4125
4183
  b.stopPropagation(), y();
4126
4184
  },
4127
4185
  disabled: g,
4128
4186
  children: "Save"
4129
4187
  }
4130
- ) : /* @__PURE__ */ C(ae, { children: [
4188
+ ) : /* @__PURE__ */ C(ne, { children: [
4131
4189
  /* @__PURE__ */ d(
4132
4190
  "button",
4133
4191
  {
4134
4192
  type: "button",
4135
- className: "cuadra-w-full cuadra-px-3 cuadra-py-2 cuadra-text-sm cuadra-text-left hover:cuadra-bg-muted cuadra-transition-colors font-brand",
4193
+ className: "cuadra-w-full cuadra-px-3 cuadra-py-2 cuadra-text-sm cuadra-text-left cuadra-text-foreground hover:cuadra-bg-muted cuadra-transition-colors font-brand",
4136
4194
  onClick: (b) => {
4137
- b.stopPropagation(), s(!0), f(r.title || ""), p(!1);
4195
+ b.stopPropagation(), s(!0), f(r.title || "Chat"), p(!1);
4138
4196
  },
4139
4197
  children: "Rename"
4140
4198
  }
4141
4199
  ),
4142
4200
  /* @__PURE__ */ d("div", { className: "cuadra-border-t cuadra-border-border" }),
4143
- /* @__PURE__ */ d(Qe.Delete, { asChild: !0, children: /* @__PURE__ */ d(
4201
+ /* @__PURE__ */ d(Ke.Delete, { asChild: !0, children: /* @__PURE__ */ d(
4144
4202
  "button",
4145
4203
  {
4146
4204
  type: "button",
@@ -4167,7 +4225,7 @@ function Ut({
4167
4225
  orgName: o,
4168
4226
  primaryColor: n
4169
4227
  }) {
4170
- return /* @__PURE__ */ C(Ke.Root, { className: "!cuadra-border-r cuadra-border-border cuadra-flex cuadra-flex-col cuadra-bg-background cuadra-transition-all cuadra-duration-300 cuadra-ease-in-out cuadra-h-full cuadra-w-80", style: { borderRightWidth: "1px" }, children: [
4228
+ return /* @__PURE__ */ C(Xe.Root, { className: "!cuadra-border-r cuadra-border-border cuadra-flex cuadra-flex-col cuadra-bg-background cuadra-transition-all cuadra-duration-300 cuadra-ease-in-out cuadra-h-full cuadra-w-80", style: { borderRightWidth: "1px" }, children: [
4171
4229
  /* @__PURE__ */ C(
4172
4230
  "div",
4173
4231
  {
@@ -4205,22 +4263,22 @@ function Ut({
4205
4263
  style: i ? { paddingLeft: "calc(env(safe-area-inset-left) + 1rem)" } : void 0,
4206
4264
  children: [
4207
4265
  /* @__PURE__ */ d(
4208
- Ke.New,
4266
+ Xe.New,
4209
4267
  {
4210
4268
  className: "group cuadra-relative cuadra-flex cuadra-items-center cuadra-gap-3 cuadra-p-3 cuadra-rounded-lg cuadra-cursor-pointer cuadra-transition-colors cuadra-border cuadra-border-transparent hover:cuadra-bg-muted hover:cuadra-border-border",
4211
4269
  onClick: () => e?.(),
4212
4270
  children: /* @__PURE__ */ d("div", { className: "cuadra-flex-1 cuadra-min-w-0", children: /* @__PURE__ */ C("div", { className: "cuadra-flex cuadra-items-center cuadra-gap-2", children: [
4213
- /* @__PURE__ */ d(Aa, { className: "cuadra-h-4 cuadra-w-4 cuadra-text-muted-foreground" }),
4271
+ /* @__PURE__ */ d(Ia, { className: "cuadra-h-4 cuadra-w-4 cuadra-text-muted-foreground" }),
4214
4272
  /* @__PURE__ */ d("h4", { className: "cuadra-text-sm cuadra-font-normal cuadra-text-foreground font-brand", children: "New Chat" })
4215
4273
  ] }) })
4216
4274
  }
4217
4275
  ),
4218
4276
  /* @__PURE__ */ d("div", { className: "cuadra-my-2 cuadra-border-t cuadra-border-border" }),
4219
4277
  /* @__PURE__ */ d(
4220
- Ke.Items,
4278
+ Xe.Items,
4221
4279
  {
4222
4280
  components: {
4223
- ThreadListItem: (c) => /* @__PURE__ */ d(Ro, { ...c, onThreadSelect: e })
4281
+ ThreadListItem: (c) => /* @__PURE__ */ d(Do, { ...c, onThreadSelect: e })
4224
4282
  }
4225
4283
  }
4226
4284
  )
@@ -4240,7 +4298,7 @@ function Ut({
4240
4298
  onClick: a,
4241
4299
  className: "cuadra-flex cuadra-items-center cuadra-justify-center cuadra-h-8 cuadra-w-8 cuadra-rounded-full cuadra-bg-muted hover:cuadra-bg-muted/80 cuadra-transition-colors",
4242
4300
  "aria-label": "Logout",
4243
- children: /* @__PURE__ */ d(ka, { className: "cuadra-h-4 cuadra-w-4 cuadra-text-foreground" })
4301
+ children: /* @__PURE__ */ d(Ca, { className: "cuadra-h-4 cuadra-w-4 cuadra-text-foreground" })
4244
4302
  }
4245
4303
  ),
4246
4304
  r && /* @__PURE__ */ d(Ir, { theme: t })
@@ -4249,11 +4307,11 @@ function Ut({
4249
4307
  )
4250
4308
  ] });
4251
4309
  }
4252
- const Do = `
4310
+ const _o = `
4253
4311
  @keyframes rotate {
4254
4312
  100% { transform: rotate(1turn); }
4255
4313
  }
4256
- `, et = ({
4314
+ `, Je = ({
4257
4315
  children: e,
4258
4316
  className: r = "",
4259
4317
  paddingX: t = "px-0",
@@ -4262,8 +4320,8 @@ const Do = `
4262
4320
  style: o,
4263
4321
  contentStyle: n,
4264
4322
  rotating: c = !1
4265
- }) => /* @__PURE__ */ C(ae, { children: [
4266
- /* @__PURE__ */ d("style", { children: Do }),
4323
+ }) => /* @__PURE__ */ C(ne, { children: [
4324
+ /* @__PURE__ */ d("style", { children: _o }),
4267
4325
  /* @__PURE__ */ C(
4268
4326
  "div",
4269
4327
  {
@@ -4321,10 +4379,10 @@ const Do = `
4321
4379
  showMobileMenuButton: l = !1,
4322
4380
  safeArea: f = !1
4323
4381
  }) => {
4324
- const [u, p] = R(!1), [g, h] = R(!1), y = ue(null);
4325
- $(() => {
4326
- const w = (k) => {
4327
- y.current && !y.current.contains(k.target) && p(!1);
4382
+ const [u, p] = _(!1), [g, h] = _(!1), y = le(null);
4383
+ B(() => {
4384
+ const w = (v) => {
4385
+ y.current && !y.current.contains(v.target) && p(!1);
4328
4386
  };
4329
4387
  return u && document.addEventListener("mousedown", w), () => {
4330
4388
  document.removeEventListener("mousedown", w);
@@ -4348,14 +4406,14 @@ const Do = `
4348
4406
  className: "cuadra-flex cuadra-items-center cuadra-justify-center cuadra-h-10 cuadra-w-10 cuadra-rounded-full cuadra-bg-muted hover:cuadra-bg-muted/80 cuadra-transition-colors disabled:cuadra-opacity-50 disabled:cuadra-cursor-not-allowed md:cuadra-hidden",
4349
4407
  style: { backgroundColor: "hsl(var(--muted))" },
4350
4408
  "aria-label": "Toggle thread list",
4351
- children: /* @__PURE__ */ d(va, { className: "cuadra-h-5 cuadra-w-5 cuadra-text-foreground", strokeWidth: 1.5 })
4409
+ children: /* @__PURE__ */ d(Ta, { className: "cuadra-h-5 cuadra-w-5 cuadra-text-foreground", strokeWidth: 1.5 })
4352
4410
  }
4353
4411
  ),
4354
4412
  n && /* @__PURE__ */ d("div", { className: "cuadra-hidden md:cuadra-flex cuadra-items-center cuadra-gap-2", children: /* @__PURE__ */ d(Ir, { theme: c }) })
4355
4413
  ] }),
4356
4414
  /* @__PURE__ */ C("div", { className: "cuadra-flex cuadra-items-center cuadra-gap-2 md:cuadra-ml-0 cuadra-ml-auto", children: [
4357
4415
  !o && /* @__PURE__ */ d("label", { className: "cuadra-hidden md:cuadra-inline cuadra-text-sm cuadra-text-muted-foreground cuadra-font-brand", children: "Model" }),
4358
- o ? null : t ? /* @__PURE__ */ d("div", { className: "cuadra-w-48 cuadra-rounded-md cuadra-border cuadra-border-border cuadra-px-3 cuadra-py-2 cuadra-bg-muted", children: /* @__PURE__ */ d("span", { className: "cuadra-text-muted-foreground cuadra-text-sm cuadra-font-brand", children: "Loading..." }) }) : a ? /* @__PURE__ */ d("div", { className: "cuadra-w-48 cuadra-rounded-md cuadra-border cuadra-border-destructive cuadra-px-3 cuadra-py-2 cuadra-bg-destructive/10", children: /* @__PURE__ */ d("span", { className: "cuadra-text-destructive cuadra-text-sm cuadra-font-brand", children: "Failed to load models" }) }) : /* @__PURE__ */ C(ae, { children: [
4416
+ o ? null : t ? /* @__PURE__ */ d("div", { className: "cuadra-w-48 cuadra-rounded-md cuadra-border cuadra-border-border cuadra-px-3 cuadra-py-2 cuadra-bg-muted", children: /* @__PURE__ */ d("span", { className: "cuadra-text-muted-foreground cuadra-text-sm cuadra-font-brand", children: "Loading..." }) }) : a ? /* @__PURE__ */ d("div", { className: "cuadra-w-48 cuadra-rounded-md cuadra-border cuadra-border-destructive cuadra-px-3 cuadra-py-2 cuadra-bg-destructive/10", children: /* @__PURE__ */ d("span", { className: "cuadra-text-destructive cuadra-text-sm cuadra-font-brand", children: "Failed to load models" }) }) : /* @__PURE__ */ C(ne, { children: [
4359
4417
  /* @__PURE__ */ C("div", { ref: y, className: "cuadra-hidden md:cuadra-block cuadra-relative cuadra-w-48", children: [
4360
4418
  /* @__PURE__ */ C(
4361
4419
  "button",
@@ -4366,7 +4424,7 @@ const Do = `
4366
4424
  className: "cuadra-flex cuadra-h-10 cuadra-w-full cuadra-items-center cuadra-justify-between cuadra-rounded-md cuadra-border cuadra-border-input cuadra-bg-background cuadra-px-3 cuadra-py-2 cuadra-text-sm placeholder:cuadra-text-muted-foreground focus:cuadra-outline-none disabled:cuadra-cursor-not-allowed disabled:cuadra-opacity-50 cuadra-font-brand",
4367
4425
  children: [
4368
4426
  /* @__PURE__ */ d("span", { className: b ? "cuadra-text-foreground" : "cuadra-text-muted-foreground", children: b?.name || "Select model" }),
4369
- /* @__PURE__ */ d(nt, { className: "cuadra-ml-2 cuadra-h-4 cuadra-w-4 cuadra-opacity-50" })
4427
+ /* @__PURE__ */ d(at, { className: "cuadra-ml-2 cuadra-h-4 cuadra-w-4 cuadra-opacity-50" })
4370
4428
  ]
4371
4429
  }
4372
4430
  ),
@@ -4412,12 +4470,12 @@ const Do = `
4412
4470
  style: { backgroundColor: "hsl(var(--muted))" },
4413
4471
  children: [
4414
4472
  /* @__PURE__ */ d("span", { className: "cuadra-text-foreground", children: b?.name || "Select model" }),
4415
- /* @__PURE__ */ d(nt, { className: "cuadra-h-4 cuadra-w-4 cuadra-text-muted-foreground" })
4473
+ /* @__PURE__ */ d(at, { className: "cuadra-h-4 cuadra-w-4 cuadra-text-muted-foreground" })
4416
4474
  ]
4417
4475
  }
4418
4476
  ),
4419
- g && typeof document < "u" && at(
4420
- /* @__PURE__ */ C(ae, { children: [
4477
+ g && typeof document < "u" && rt(
4478
+ /* @__PURE__ */ C(ne, { children: [
4421
4479
  /* @__PURE__ */ d(
4422
4480
  "div",
4423
4481
  {
@@ -4487,9 +4545,9 @@ const Do = `
4487
4545
  ]
4488
4546
  }
4489
4547
  );
4490
- }, _o = Ot(void 0), tt = ({ children: e, value: r }) => /* @__PURE__ */ d(_o.Provider, { value: r, children: e });
4491
- function Fo() {
4492
- $(() => {
4548
+ }, Fo = Ot(void 0), et = ({ children: e, value: r }) => /* @__PURE__ */ d(Fo.Provider, { value: r, children: e });
4549
+ function zo() {
4550
+ B(() => {
4493
4551
  if (document.querySelector("style[data-cuadra-uikit]"))
4494
4552
  return;
4495
4553
  const r = document.createElement("div");
@@ -4511,10 +4569,10 @@ function Fo() {
4511
4569
  }, document.head.appendChild(a), o) break;
4512
4570
  }, []);
4513
4571
  }
4514
- const zo = be(
4572
+ const jo = ge(
4515
4573
  function({ config: r }, t) {
4516
- Fo();
4517
- const a = ue(null), i = ue(!1), {
4574
+ zo();
4575
+ const a = le(null), i = le(!1), {
4518
4576
  baseUrl: o,
4519
4577
  proxyUrl: n,
4520
4578
  sessionToken: c,
@@ -4529,103 +4587,103 @@ const zo = be(
4529
4587
  welcomeTitle: b,
4530
4588
  welcomeSubtitle: x,
4531
4589
  extraTopPadding: w,
4532
- suggestions: k,
4590
+ suggestions: v,
4533
4591
  inputPlaceholder: L,
4534
4592
  preMadeResponseDelay: E = 1e3,
4535
- streamingSpeed: I = 50,
4536
- showThemeToggle: M = !0,
4537
- initialMessage: _,
4538
- initialPreMadeQA: A,
4593
+ streamingSpeed: N = 50,
4594
+ showThemeToggle: A = !0,
4595
+ initialMessage: I,
4596
+ initialPreMadeQA: S,
4539
4597
  theme: m = "system",
4540
- onError: O,
4541
- onChatCreated: j,
4542
- onUserMessage: K,
4543
- onThreadIdUpdate: V,
4544
- onLogout: ye,
4545
- enableAttachments: Le = !1,
4546
- onBeforeRequest: Z,
4547
- mockResponseOnBlocked: v
4598
+ onError: D,
4599
+ onChatCreated: G,
4600
+ onUserMessage: H,
4601
+ onThreadIdUpdate: ee,
4602
+ onLogout: be,
4603
+ enableAttachments: Z = !1,
4604
+ onBeforeRequest: k,
4605
+ mockResponseOnBlocked: R
4548
4606
  } = r;
4549
4607
  ct(t, () => ({
4550
4608
  sendMessage: (T) => {
4551
4609
  a.current?.sendMessage(T);
4552
4610
  },
4553
- sendPreMadeQA: (T, z, D) => {
4554
- a.current?.sendPreMadeQA(T, z, D);
4611
+ sendPreMadeQA: (T, $, z) => {
4612
+ a.current?.sendPreMadeQA(T, $, z);
4555
4613
  },
4556
4614
  clearChat: () => {
4557
4615
  a.current?.clearChat();
4558
4616
  }
4559
- }), []), $(() => {
4617
+ }), []), B(() => {
4560
4618
  if (i.current) return;
4561
4619
  const T = setTimeout(() => {
4562
- A ? (i.current = !0, a.current?.sendPreMadeQA(
4563
- A.question,
4564
- A.answer,
4565
- { delay: E, streamingSpeed: I }
4566
- )) : _ && (i.current = !0, a.current?.sendMessage(_));
4620
+ S ? (i.current = !0, a.current?.sendPreMadeQA(
4621
+ S.question,
4622
+ S.answer,
4623
+ { delay: E, streamingSpeed: N }
4624
+ )) : I && (i.current = !0, a.current?.sendMessage(I));
4567
4625
  }, 500);
4568
4626
  return () => clearTimeout(T);
4569
- }, [_, A, E, I]);
4570
- const [N, F] = R(!1), [P, W] = R(null), [S, B] = R(null), [Q, J] = R(!1), de = ue(null), fe = (T) => {
4627
+ }, [I, S, E, N]);
4628
+ const [P, j] = _(!1), [F, M] = _(null), [U, V] = _(null), [X, oe] = _(!1), ye = le(null), Y = (T) => {
4571
4629
  if (T < 30) return !0;
4572
- if (de.current) {
4573
- const z = de.current.getBoundingClientRect();
4574
- if (T - z.left < 30) return !0;
4630
+ if (ye.current) {
4631
+ const $ = ye.current.getBoundingClientRect();
4632
+ if (T - $.left < 30) return !0;
4575
4633
  }
4576
4634
  return !1;
4577
- }, ie = (T) => {
4578
- const z = window.innerWidth;
4579
- return T > z - 80;
4580
- }, Ve = (T) => {
4581
- const D = T.touches[0].clientX;
4582
- if (N) {
4583
- ie(D) && (W(D), B(D), J(!0));
4635
+ }, He = (T) => {
4636
+ const $ = window.innerWidth;
4637
+ return T > $ - 80;
4638
+ }, Lr = (T) => {
4639
+ const z = T.touches[0].clientX;
4640
+ if (P) {
4641
+ He(z) && (M(z), V(z), oe(!0));
4584
4642
  return;
4585
4643
  }
4586
- fe(D) && (W(D), B(D), J(!0));
4587
- }, Lr = (T) => {
4588
- if (P === null || !Q) return;
4589
- const z = T.touches[0];
4590
- B(z.clientX);
4591
- }, Er = () => {
4592
- if (P === null || S === null) {
4593
- J(!1), W(null), B(null);
4644
+ Y(z) && (M(z), V(z), oe(!0));
4645
+ }, Er = (T) => {
4646
+ if (F === null || !X) return;
4647
+ const $ = T.touches[0];
4648
+ V($.clientX);
4649
+ }, Pr = () => {
4650
+ if (F === null || U === null) {
4651
+ oe(!1), M(null), V(null);
4594
4652
  return;
4595
4653
  }
4596
- const T = S - P, z = Math.abs(T), D = 50;
4597
- if (z < 10) {
4598
- W(null), B(null), J(!1);
4654
+ const T = U - F, $ = Math.abs(T), z = 50;
4655
+ if ($ < 10) {
4656
+ M(null), V(null), oe(!1);
4599
4657
  return;
4600
4658
  }
4601
- T > D && !N && P !== null ? fe(P) && F(!0) : T < -D && N && F(!1), W(null), B(null), J(!1);
4602
- }, Pr = () => {
4603
- if (Q && P !== null && S !== null) {
4604
- const T = S - P;
4605
- if (N)
4659
+ T > z && !P && F !== null ? Y(F) && j(!0) : T < -z && P && j(!1), M(null), V(null), oe(!1);
4660
+ }, Rr = () => {
4661
+ if (X && F !== null && U !== null) {
4662
+ const T = U - F;
4663
+ if (P)
4606
4664
  return `translateX(${Math.min(0, T)}px)`;
4607
- if (P !== null && fe(P))
4665
+ if (F !== null && Y(F))
4608
4666
  return `translateX(${Math.min(0, -320 + T)}px)`;
4609
4667
  }
4610
- return N ? "translateX(0)" : "translateX(-100%)";
4611
- }, Rr = () => {
4612
- if (!Q || P === null || S === null)
4613
- return N ? 0.5 : 0;
4614
- const z = S - P;
4615
- return N ? Math.max(0, Math.min(1, (320 + z) / 320)) * 0.5 : P !== null && fe(P) ? Math.max(0, Math.min(1, (z + 320) / 320)) * 0.5 : 0;
4616
- }, Ee = n || o || "", Pe = !!n, gt = G(
4668
+ return P ? "translateX(0)" : "translateX(-100%)";
4669
+ }, Dr = () => {
4670
+ if (!X || F === null || U === null)
4671
+ return P ? 0.5 : 0;
4672
+ const $ = U - F;
4673
+ return P ? Math.max(0, Math.min(1, (320 + $) / 320)) * 0.5 : F !== null && Y(F) ? Math.max(0, Math.min(1, ($ + 320) / 320)) * 0.5 : 0;
4674
+ }, Ee = n || o || "", Pe = !!n, gt = K(
4617
4675
  () => new Qt(Ee, c || void 0, Pe),
4618
4676
  [Ee, c, Pe]
4619
- ), [he, Dr] = R(null), [xe, bt] = R(!1), [we, yt] = R(null), [_r, xt] = R(!1);
4620
- $(() => {
4677
+ ), [fe, _r] = _(null), [xe, bt] = _(!1), [we, yt] = _(null), [Fr, xt] = _(!1);
4678
+ B(() => {
4621
4679
  s === "multiChat" && xt(!0);
4622
4680
  }, [s]);
4623
- const me = X(async () => {
4681
+ const he = Q(async () => {
4624
4682
  if (l === "selector") {
4625
4683
  bt(!0), yt(null);
4626
4684
  try {
4627
4685
  const T = await gt.listModels();
4628
- Dr(T);
4686
+ _r(T);
4629
4687
  } catch (T) {
4630
4688
  yt(T instanceof Error ? T : new Error("Failed to load models"));
4631
4689
  } finally {
@@ -4633,62 +4691,62 @@ const zo = be(
4633
4691
  }
4634
4692
  }
4635
4693
  }, [gt, l]);
4636
- $(() => {
4637
- l === "selector" && me();
4638
- }, [l, me]), $(() => (typeof window < "u" && (window.__cuadraUIKitRefetchModels = me), () => {
4694
+ B(() => {
4695
+ l === "selector" && he();
4696
+ }, [l, he]), B(() => (typeof window < "u" && (window.__cuadraUIKitRefetchModels = he), () => {
4639
4697
  typeof window < "u" && delete window.__cuadraUIKitRefetchModels;
4640
- }), [me]);
4641
- const [ee, wt] = R(
4698
+ }), [he]);
4699
+ const [te, wt] = _(
4642
4700
  l === "fixed" && f || null
4643
- ), kt = ue(ee), ke = X(
4701
+ ), kt = le(te), ke = Q(
4644
4702
  (T) => {
4645
- const z = kt.current;
4646
- wt(T), kt.current = T, u?.(T), z !== null && z !== T && s === "multiChat" && setTimeout(() => {
4647
- const D = window.__cuadraThreadListRuntime;
4648
- if (D?.threads?.switchToNewThread)
4703
+ const $ = kt.current;
4704
+ wt(T), kt.current = T, u?.(T), $ !== null && $ !== T && s === "multiChat" && setTimeout(() => {
4705
+ const z = window.__cuadraThreadListRuntime;
4706
+ if (z?.threads?.switchToNewThread)
4649
4707
  try {
4650
- D.threads.switchToNewThread();
4708
+ z.threads.switchToNewThread();
4651
4709
  } catch {
4652
4710
  }
4653
- else if (D?.threads?.createThread)
4711
+ else if (z?.threads?.createThread)
4654
4712
  try {
4655
- D.threads.createThread();
4713
+ z.threads.createThread();
4656
4714
  } catch {
4657
4715
  }
4658
- else if (D?.switchToNewThread)
4716
+ else if (z?.switchToNewThread)
4659
4717
  try {
4660
- D.switchToNewThread();
4718
+ z.switchToNewThread();
4661
4719
  } catch {
4662
4720
  }
4663
4721
  }, 100);
4664
4722
  },
4665
4723
  [u, s]
4666
4724
  );
4667
- $(() => {
4668
- if (l === "selector" && he?.items && he.items.length > 0 && !ee) {
4669
- const T = he.items[0];
4725
+ B(() => {
4726
+ if (l === "selector" && fe?.items && fe.items.length > 0 && !te) {
4727
+ const T = fe.items[0];
4670
4728
  if (T?.id) {
4671
- const z = T.id;
4672
- wt(z), u?.(z);
4729
+ const $ = T.id;
4730
+ wt($), u?.($);
4673
4731
  }
4674
4732
  }
4675
- }, [l, he?.items, ee, u]);
4676
- const Fr = l === "fixed" ? !!f : !!ee, Re = G(
4677
- () => (he?.items || []).filter((T) => T?.id && T?.displayName).map((T) => ({ id: T.id, name: T.displayName })),
4678
- [he]
4679
- ), Xe = G(
4733
+ }, [l, fe?.items, te, u]);
4734
+ const zr = l === "fixed" ? !!f : !!te, Re = K(
4735
+ () => (fe?.items || []).filter((T) => T?.id && T?.displayName).map((T) => ({ id: T.id, name: T.displayName })),
4736
+ [fe]
4737
+ ), Ve = K(
4680
4738
  () => ({
4681
- currentModelId: ee || "",
4739
+ currentModelId: te || "",
4682
4740
  models: Re,
4683
4741
  modelsLoading: xe,
4684
4742
  modelsError: we,
4685
4743
  onModelChange: ke,
4686
- refetchModels: me
4744
+ refetchModels: he
4687
4745
  }),
4688
- [ee, Re, xe, we, ke, me]
4746
+ [te, Re, xe, we, ke, he]
4689
4747
  );
4690
- return l === "selector" && xe || s === "multiChat" && _r ? /* @__PURE__ */ d(tt, { value: Xe, children: /* @__PURE__ */ d(
4691
- et,
4748
+ return l === "selector" && xe || s === "multiChat" && Fr ? /* @__PURE__ */ d(et, { value: Ve, children: /* @__PURE__ */ d(
4749
+ Je,
4692
4750
  {
4693
4751
  className: "cuadra-h-full",
4694
4752
  paddingX: "cuadra-px-0",
@@ -4696,32 +4754,32 @@ const zo = be(
4696
4754
  borderSizePx: r.borderless ? 0 : 4,
4697
4755
  children: /* @__PURE__ */ d("div", { className: "cuadra-flex cuadra-items-center cuadra-justify-center cuadra-h-full", children: /* @__PURE__ */ d(Xt, { className: "cuadra-h-6 cuadra-w-6 cuadra-animate-spin cuadra-text-muted-foreground" }) })
4698
4756
  }
4699
- ) }) : l === "selector" && !Fr && we ? /* @__PURE__ */ d(tt, { value: Xe, children: /* @__PURE__ */ d(et, { className: "cuadra-h-full", paddingX: "cuadra-px-0", paddingY: "cuadra-py-0", children: /* @__PURE__ */ d("div", { className: "cuadra-flex cuadra-items-center cuadra-justify-center cuadra-h-full", children: /* @__PURE__ */ d("div", { className: "cuadra-flex cuadra-flex-col cuadra-items-center cuadra-gap-2", children: /* @__PURE__ */ d("p", { className: "cuadra-text-sm cuadra-text-destructive font-brand", children: "Failed to load models" }) }) }) }) }) : /* @__PURE__ */ d("div", { className: "cuadra-uikit cuadra-h-full cuadra-w-full", style: { height: "100%", width: "100%" }, children: /* @__PURE__ */ d(tt, { value: Xe, children: /* @__PURE__ */ d(
4700
- Ba,
4757
+ ) }) : l === "selector" && !zr && we ? /* @__PURE__ */ d(et, { value: Ve, children: /* @__PURE__ */ d(Je, { className: "cuadra-h-full", paddingX: "cuadra-px-0", paddingY: "cuadra-py-0", children: /* @__PURE__ */ d("div", { className: "cuadra-flex cuadra-items-center cuadra-justify-center cuadra-h-full", children: /* @__PURE__ */ d("div", { className: "cuadra-flex cuadra-flex-col cuadra-items-center cuadra-gap-2", children: /* @__PURE__ */ d("p", { className: "cuadra-text-sm cuadra-text-destructive font-brand", children: "Failed to load models" }) }) }) }) }) : /* @__PURE__ */ d("div", { className: "cuadra-uikit cuadra-h-full cuadra-w-full", style: { height: "100%", width: "100%" }, children: /* @__PURE__ */ d(et, { value: Ve, children: /* @__PURE__ */ d(
4758
+ Wa,
4701
4759
  {
4702
4760
  baseUrl: Pe ? Ee : o || Ee,
4703
4761
  sessionToken: c,
4704
4762
  isProxyMode: Pe,
4705
4763
  mode: s,
4706
4764
  modelMode: l,
4707
- modelId: ee || f || void 0,
4765
+ modelId: te || f || void 0,
4708
4766
  onModelChange: ke,
4709
4767
  ephemeral: p,
4710
4768
  systemPrompt: g,
4711
4769
  enableReasoning: h,
4712
4770
  initialThreadId: y,
4713
- enableAttachments: Le,
4714
- onError: O,
4715
- onChatCreated: j,
4716
- onUserMessage: K,
4717
- onThreadIdUpdate: V,
4718
- onBeforeRequest: Z,
4719
- mockResponseOnBlocked: v,
4771
+ enableAttachments: Z,
4772
+ onError: D,
4773
+ onChatCreated: G,
4774
+ onUserMessage: H,
4775
+ onThreadIdUpdate: ee,
4776
+ onBeforeRequest: k,
4777
+ mockResponseOnBlocked: R,
4720
4778
  onChatsLoaded: () => {
4721
4779
  s === "multiChat" && xt(!1);
4722
4780
  },
4723
4781
  children: /* @__PURE__ */ d(
4724
- et,
4782
+ Je,
4725
4783
  {
4726
4784
  paddingX: "cuadra-px-0",
4727
4785
  paddingY: "cuadra-py-0",
@@ -4733,22 +4791,22 @@ const zo = be(
4733
4791
  {
4734
4792
  className: "cuadra-h-full cuadra-flex cuadra-relative",
4735
4793
  style: { height: "100%" },
4736
- onTouchStart: Ve,
4737
- onTouchMove: Lr,
4738
- onTouchEnd: Er,
4739
- children: s === "multiChat" ? /* @__PURE__ */ C(ae, { children: [
4740
- typeof document < "u" && at(
4794
+ onTouchStart: Lr,
4795
+ onTouchMove: Er,
4796
+ onTouchEnd: Pr,
4797
+ children: s === "multiChat" ? /* @__PURE__ */ C(ne, { children: [
4798
+ typeof document < "u" && rt(
4741
4799
  /* @__PURE__ */ d(
4742
4800
  "div",
4743
4801
  {
4744
- className: `cuadra-fixed cuadra-inset-0 cuadra-bg-black cuadra-z-40 md:cuadra-hidden cuadra-transition-opacity cuadra-duration-300 ${N || Q ? "" : "cuadra-pointer-events-none"}`,
4745
- style: { opacity: Rr() },
4746
- onClick: () => F(!1)
4802
+ className: `cuadra-fixed cuadra-inset-0 cuadra-bg-black cuadra-z-40 md:cuadra-hidden cuadra-transition-opacity cuadra-duration-300 ${P || X ? "" : "cuadra-pointer-events-none"}`,
4803
+ style: { opacity: Dr() },
4804
+ onClick: () => j(!1)
4747
4805
  }
4748
4806
  ),
4749
4807
  document.body
4750
4808
  ),
4751
- typeof document < "u" && /* @__PURE__ */ C(ae, { children: [
4809
+ typeof document < "u" && /* @__PURE__ */ C(ne, { children: [
4752
4810
  /* @__PURE__ */ d(
4753
4811
  "div",
4754
4812
  {
@@ -4757,10 +4815,10 @@ const zo = be(
4757
4815
  children: /* @__PURE__ */ d(
4758
4816
  Ut,
4759
4817
  {
4760
- onThreadSelect: () => F(!1),
4761
- showThemeToggle: M,
4818
+ onThreadSelect: () => j(!1),
4819
+ showThemeToggle: A,
4762
4820
  theme: m,
4763
- onLogout: ye,
4821
+ onLogout: be,
4764
4822
  safeArea: r.safeArea,
4765
4823
  orgName: r.orgName,
4766
4824
  primaryColor: r.primaryColor
@@ -4768,23 +4826,23 @@ const zo = be(
4768
4826
  )
4769
4827
  }
4770
4828
  ),
4771
- typeof document < "u" && at(
4829
+ typeof document < "u" && rt(
4772
4830
  /* @__PURE__ */ d(
4773
4831
  "div",
4774
4832
  {
4775
- className: `cuadra-block md:cuadra-hidden !cuadra-border-r cuadra-border-border cuadra-flex cuadra-flex-col cuadra-bg-background cuadra-h-screen cuadra-w-80 cuadra-fixed cuadra-z-50 cuadra-top-0 cuadra-left-0 ${N || Q ? "" : "cuadra-pointer-events-none"}`,
4833
+ className: `cuadra-block md:cuadra-hidden !cuadra-border-r cuadra-border-border cuadra-flex cuadra-flex-col cuadra-bg-background cuadra-h-screen cuadra-w-80 cuadra-fixed cuadra-z-50 cuadra-top-0 cuadra-left-0 ${P || X ? "" : "cuadra-pointer-events-none"}`,
4776
4834
  style: {
4777
4835
  borderRightWidth: "1px",
4778
- transform: Pr(),
4779
- transition: Q ? "none" : "transform 0.3s ease-in-out"
4836
+ transform: Rr(),
4837
+ transition: X ? "none" : "transform 0.3s ease-in-out"
4780
4838
  },
4781
4839
  children: /* @__PURE__ */ d(
4782
4840
  Ut,
4783
4841
  {
4784
- onThreadSelect: () => F(!1),
4785
- showThemeToggle: M,
4842
+ onThreadSelect: () => j(!1),
4843
+ showThemeToggle: A,
4786
4844
  theme: m,
4787
- onLogout: ye,
4845
+ onLogout: be,
4788
4846
  safeArea: r.safeArea,
4789
4847
  orgName: r.orgName,
4790
4848
  primaryColor: r.primaryColor
@@ -4795,18 +4853,18 @@ const zo = be(
4795
4853
  document.body
4796
4854
  )
4797
4855
  ] }),
4798
- /* @__PURE__ */ C("div", { ref: de, className: "cuadra-flex-1 cuadra-flex cuadra-flex-col", children: [
4856
+ /* @__PURE__ */ C("div", { ref: ye, className: "cuadra-flex-1 cuadra-flex cuadra-flex-col", children: [
4799
4857
  l === "selector" && /* @__PURE__ */ d(
4800
4858
  $t,
4801
4859
  {
4802
- currentModel: ee || "",
4860
+ currentModel: te || "",
4803
4861
  models: Re,
4804
4862
  modelsLoading: xe,
4805
4863
  modelsError: we,
4806
4864
  onModelChange: ke,
4807
- showThemeToggle: M,
4865
+ showThemeToggle: A,
4808
4866
  theme: m,
4809
- onMobileMenuClick: () => F(!N),
4867
+ onMobileMenuClick: () => j(!P),
4810
4868
  showMobileMenuButton: s === "multiChat",
4811
4869
  safeArea: r.safeArea
4812
4870
  }
@@ -4818,11 +4876,11 @@ const zo = be(
4818
4876
  welcomeTitle: b,
4819
4877
  welcomeSubtitle: x,
4820
4878
  extraTopPadding: w,
4821
- suggestions: k,
4879
+ suggestions: v,
4822
4880
  inputPlaceholder: L,
4823
- enableAttachments: Le,
4881
+ enableAttachments: Z,
4824
4882
  preMadeResponseDelay: E,
4825
- streamingSpeed: I,
4883
+ streamingSpeed: N,
4826
4884
  safeArea: r.safeArea
4827
4885
  }
4828
4886
  ) })
@@ -4831,12 +4889,12 @@ const zo = be(
4831
4889
  l === "selector" && /* @__PURE__ */ d(
4832
4890
  $t,
4833
4891
  {
4834
- currentModel: ee || "",
4892
+ currentModel: te || "",
4835
4893
  models: Re,
4836
4894
  modelsLoading: xe,
4837
4895
  modelsError: we,
4838
4896
  onModelChange: ke,
4839
- showThemeToggle: M,
4897
+ showThemeToggle: A,
4840
4898
  theme: m,
4841
4899
  safeArea: r.safeArea
4842
4900
  }
@@ -4848,10 +4906,10 @@ const zo = be(
4848
4906
  welcomeTitle: b,
4849
4907
  welcomeSubtitle: x,
4850
4908
  extraTopPadding: w,
4851
- suggestions: k,
4909
+ suggestions: v,
4852
4910
  inputPlaceholder: L,
4853
4911
  preMadeResponseDelay: E,
4854
- streamingSpeed: I,
4912
+ streamingSpeed: N,
4855
4913
  safeArea: r.safeArea
4856
4914
  }
4857
4915
  ) })
@@ -4864,18 +4922,18 @@ const zo = be(
4864
4922
  ) }) });
4865
4923
  }
4866
4924
  );
4867
- function jo(e, r = ":root") {
4925
+ function Uo(e, r = ":root") {
4868
4926
  if (typeof document > "u")
4869
4927
  return;
4870
4928
  const t = document.documentElement;
4871
- if (e.light && $o(e.light, t), e.dark) {
4929
+ if (e.light && Oo(e.light, t), e.dark) {
4872
4930
  let a = document.getElementById("cuadra-theme-dark");
4873
4931
  a || (a = document.createElement("style"), a.id = "cuadra-theme-dark", document.head.appendChild(a));
4874
- const i = Oo(e.dark);
4932
+ const i = Bo(e.dark);
4875
4933
  a.textContent = `.dark { ${i} }`;
4876
4934
  }
4877
4935
  }
4878
- const Uo = {
4936
+ const $o = {
4879
4937
  background: "background",
4880
4938
  foreground: "foreground",
4881
4939
  card: "card",
@@ -4905,10 +4963,10 @@ const Uo = {
4905
4963
  warningForeground: "warning-foreground"
4906
4964
  };
4907
4965
  function Nr(e) {
4908
- const r = Uo[e];
4966
+ const r = $o[e];
4909
4967
  return r ? `--cuadra-${r}` : `--cuadra-${e.replace(/([A-Z])/g, "-$1").toLowerCase()}`;
4910
4968
  }
4911
- function $o(e, r) {
4969
+ function Oo(e, r) {
4912
4970
  Object.entries(e).forEach(([t, a]) => {
4913
4971
  if (a) {
4914
4972
  const i = Nr(t);
@@ -4916,10 +4974,10 @@ function $o(e, r) {
4916
4974
  }
4917
4975
  });
4918
4976
  }
4919
- function Oo(e) {
4977
+ function Bo(e) {
4920
4978
  return Object.entries(e).map(([r, t]) => t ? `${Nr(r)}: ${t};` : "").filter(Boolean).join(" ");
4921
4979
  }
4922
- function os() {
4980
+ function ss() {
4923
4981
  if (typeof document > "u")
4924
4982
  return;
4925
4983
  const e = document.documentElement;
@@ -4927,7 +4985,7 @@ function os() {
4927
4985
  const t = document.getElementById("cuadra-theme-dark");
4928
4986
  t && t.remove();
4929
4987
  }
4930
- function Bo({
4988
+ function Wo({
4931
4989
  onReset: e,
4932
4990
  error: r
4933
4991
  }) {
@@ -4966,13 +5024,13 @@ function Bo({
4966
5024
  )
4967
5025
  ] });
4968
5026
  }
4969
- class Sr extends Or {
5027
+ class Sr extends Br {
4970
5028
  constructor(t) {
4971
5029
  super(t);
4972
5030
  /**
4973
5031
  * Reset the error state and attempt to re-render children
4974
5032
  */
4975
- oe(this, "reset", () => {
5033
+ se(this, "reset", () => {
4976
5034
  this.setState({ hasError: !1, error: null });
4977
5035
  });
4978
5036
  this.state = { hasError: !1, error: null };
@@ -4986,19 +5044,19 @@ class Sr extends Or {
4986
5044
  render() {
4987
5045
  if (this.state.hasError) {
4988
5046
  const { fallback: t } = this.props, { error: a } = this.state;
4989
- return typeof t == "function" ? t(a, this.reset) : t || /* @__PURE__ */ d(Bo, { error: a, onReset: this.reset });
5047
+ return typeof t == "function" ? t(a, this.reset) : t || /* @__PURE__ */ d(Wo, { error: a, onReset: this.reset });
4990
5048
  }
4991
5049
  return this.props.children;
4992
5050
  }
4993
5051
  }
4994
- function ss(e, r) {
5052
+ function cs(e, r) {
4995
5053
  const t = (a) => /* @__PURE__ */ d(Sr, { ...r, children: /* @__PURE__ */ d(e, { ...a }) });
4996
5054
  return t.displayName = `withErrorBoundary(${e.displayName || e.name || "Component"})`, t;
4997
5055
  }
4998
- const Se = Ot(null);
4999
- Se.displayName = "CuadraChatContext";
5000
- function cs() {
5001
- const e = ut(Se);
5056
+ const Le = Ot(null);
5057
+ Le.displayName = "CuadraChatContext";
5058
+ function us() {
5059
+ const e = ut(Le);
5002
5060
  if (e === null)
5003
5061
  throw new Error(
5004
5062
  "useCuadraChat must be used within a CuadraChatProvider. Wrap your component tree with <CuadraChatProvider>...</CuadraChatProvider>"
@@ -5008,32 +5066,32 @@ function cs() {
5008
5066
  isReady: e.controls !== null
5009
5067
  };
5010
5068
  }
5011
- function us() {
5012
- const e = ut(Se);
5069
+ function ls() {
5070
+ const e = ut(Le);
5013
5071
  return e === null ? null : {
5014
5072
  controls: e.controls,
5015
5073
  isReady: e.controls !== null
5016
5074
  };
5017
5075
  }
5018
- function ls({ children: e }) {
5019
- const [r, t] = R(null), a = X((n) => {
5076
+ function ds({ children: e }) {
5077
+ const [r, t] = _(null), a = Q((n) => {
5020
5078
  t(n);
5021
- }, []), i = X(() => {
5079
+ }, []), i = Q(() => {
5022
5080
  t(null);
5023
- }, []), o = {
5081
+ }, []), o = K(() => ({
5024
5082
  controls: r,
5025
5083
  registerControls: a,
5026
5084
  unregisterControls: i
5027
- };
5028
- return /* @__PURE__ */ d(Se.Provider, { value: o, children: e });
5029
- }
5030
- function Wo(e) {
5031
- return "connection" in e && typeof e.connection == "object";
5085
+ }), [r, a, i]);
5086
+ return /* @__PURE__ */ d(Le.Provider, { value: o, children: e });
5032
5087
  }
5033
5088
  function qo(e) {
5034
- return Wo(e) ? Ho(e) : Vo(e);
5089
+ return "connection" in e && typeof e.connection == "object";
5035
5090
  }
5036
5091
  function Ho(e) {
5092
+ return qo(e) ? Vo(e) : Xo(e);
5093
+ }
5094
+ function Vo(e) {
5037
5095
  return {
5038
5096
  connection: {
5039
5097
  baseUrl: e.connection.baseUrl || "",
@@ -5089,7 +5147,7 @@ function Ho(e) {
5089
5147
  errorFallback: e.errorFallback
5090
5148
  };
5091
5149
  }
5092
- function Vo(e) {
5150
+ function Xo(e) {
5093
5151
  return typeof process < "u" && process.env?.NODE_ENV === "development" && console.warn(
5094
5152
  `[CuadraUIKit] Using legacy flat props format. Consider migrating to grouped props for better organization.
5095
5153
  See: https://docs.cuadra.ai/guides/uikit-migration`
@@ -5152,28 +5210,28 @@ See: https://docs.cuadra.ai/guides/uikit-migration`
5152
5210
  errorFallback: e.errorFallback
5153
5211
  };
5154
5212
  }
5155
- const Xo = be(
5213
+ const Ko = ge(
5156
5214
  function({ config: r }, t) {
5157
- const a = ue(null), i = ut(Se);
5158
- $(() => {
5159
- r.ui.customTheme && jo(r.ui.customTheme);
5160
- }, [r.ui.customTheme]), $(() => {
5215
+ const a = le(null), i = ut(Le);
5216
+ B(() => {
5217
+ r.ui.customTheme && Uo(r.ui.customTheme);
5218
+ }, [r.ui.customTheme]), B(() => {
5161
5219
  if (r.ui.primaryColor && typeof document < "u") {
5162
5220
  const c = document.documentElement, s = (l) => {
5163
5221
  const f = l.replace("#", ""), u = parseInt(f.slice(0, 2), 16) / 255, p = parseInt(f.slice(2, 4), 16) / 255, g = parseInt(f.slice(4, 6), 16) / 255, h = Math.max(u, p, g), y = Math.min(u, p, g);
5164
5222
  let b = 0, x = 0;
5165
5223
  const w = (h + y) / 2;
5166
5224
  if (h !== y) {
5167
- const k = h - y;
5168
- switch (x = w > 0.5 ? k / (2 - h - y) : k / (h + y), h) {
5225
+ const v = h - y;
5226
+ switch (x = w > 0.5 ? v / (2 - h - y) : v / (h + y), h) {
5169
5227
  case u:
5170
- b = ((p - g) / k + (p < g ? 6 : 0)) / 6;
5228
+ b = ((p - g) / v + (p < g ? 6 : 0)) / 6;
5171
5229
  break;
5172
5230
  case p:
5173
- b = ((g - u) / k + 2) / 6;
5231
+ b = ((g - u) / v + 2) / 6;
5174
5232
  break;
5175
5233
  case g:
5176
- b = ((u - p) / k + 4) / 6;
5234
+ b = ((u - p) / v + 4) / 6;
5177
5235
  break;
5178
5236
  }
5179
5237
  }
@@ -5189,15 +5247,15 @@ const Xo = be(
5189
5247
  };
5190
5248
  }
5191
5249
  }, [r.ui.primaryColor]);
5192
- const o = {
5250
+ const o = K(() => ({
5193
5251
  sendMessage: (c) => a.current?.sendMessage(c),
5194
5252
  sendPreMadeQA: (c, s, l) => a.current?.sendPreMadeQA(c, s, l),
5195
5253
  clearChat: () => a.current?.clearChat()
5196
- };
5197
- ct(t, () => o, []), $(() => {
5254
+ }), []);
5255
+ ct(t, () => o, []), B(() => {
5198
5256
  if (i)
5199
5257
  return i.registerControls(o), () => i.unregisterControls();
5200
- }, [i, o]), $(() => (typeof window < "u" && (process.env.NODE_ENV === "development" && console.warn(
5258
+ }, [i, o]), B(() => (typeof window < "u" && (process.env.NODE_ENV === "development" && console.warn(
5201
5259
  "[CuadraUIKit] window.__cuadraChatControls is deprecated. Use CuadraChatProvider and useCuadraChat() hook instead. See: https://docs.cuadra.ai/guides/uikit-migration"
5202
5260
  ), window.__cuadraChatControls = o), () => {
5203
5261
  typeof window < "u" && delete window.__cuadraChatControls;
@@ -5247,11 +5305,11 @@ const Xo = be(
5247
5305
  onThreadIdUpdate: r.callbacks.onThreadIdUpdate,
5248
5306
  onLogout: r.callbacks.onLogout
5249
5307
  };
5250
- return /* @__PURE__ */ d(zo, { ref: a, config: n });
5308
+ return /* @__PURE__ */ d(jo, { ref: a, config: n });
5251
5309
  }
5252
- ), ds = be(
5310
+ ), fs = ge(
5253
5311
  function(r, t) {
5254
- const a = qo(r), i = a.errorFallback;
5312
+ const a = Ho(r), i = a.errorFallback;
5255
5313
  return /* @__PURE__ */ d(
5256
5314
  Sr,
5257
5315
  {
@@ -5259,7 +5317,7 @@ const Xo = be(
5259
5317
  onError: (o, n) => {
5260
5318
  a.callbacks.onError?.(o), process.env.NODE_ENV === "development" && console.error("[CuadraChat] Error caught by boundary:", o, n);
5261
5319
  },
5262
- children: /* @__PURE__ */ d(Xo, { ref: t, config: a })
5320
+ children: /* @__PURE__ */ d(Ko, { ref: t, config: a })
5263
5321
  }
5264
5322
  );
5265
5323
  }
@@ -5267,24 +5325,24 @@ const Xo = be(
5267
5325
  export {
5268
5326
  Fe as AttachmentValidationError,
5269
5327
  Ar as Badge,
5270
- ds as CuadraChat,
5271
- Se as CuadraChatContext,
5272
- ls as CuadraChatProvider,
5328
+ fs as CuadraChat,
5329
+ Le as CuadraChatContext,
5330
+ ds as CuadraChatProvider,
5273
5331
  Sr as CuadraErrorBoundary,
5274
- Mo as SourceCitations,
5275
- jo as applyTheme,
5332
+ Ao as SourceCitations,
5333
+ Uo as applyTheme,
5276
5334
  Zt as createAttachmentAdapter,
5277
- is as escapeHtml,
5278
- La as generateSecureUUID,
5279
- Wo as isV2Props,
5280
- as as isValidUrl,
5281
- qo as normalizeCuadraChatProps,
5282
- os as removeTheme,
5283
- rs as sanitizeSystemPrompt,
5284
- se as streamingMetadataStore,
5285
- cs as useCuadraChat,
5286
- us as useCuadraChatOptional,
5287
- ns as validateBaseUrl,
5288
- ss as withErrorBoundary
5335
+ os as escapeHtml,
5336
+ Ea as generateSecureUUID,
5337
+ qo as isV2Props,
5338
+ ns as isValidUrl,
5339
+ Ho as normalizeCuadraChatProps,
5340
+ ss as removeTheme,
5341
+ as as sanitizeSystemPrompt,
5342
+ ce as streamingMetadataStore,
5343
+ us as useCuadraChat,
5344
+ ls as useCuadraChatOptional,
5345
+ is as validateBaseUrl,
5346
+ cs as withErrorBoundary
5289
5347
  };
5290
5348
  //# sourceMappingURL=index.mjs.map