@cuadra-ai/uikit 0.1.19 → 0.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,14 +1,14 @@
1
- var fr = Object.defineProperty;
2
- var hr = (e, r, t) => r in e ? fr(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
3
- var pe = (e, r, t) => hr(e, typeof r != "symbol" ? r + "" : r, t);
4
- import { jsx as d, jsxs as C, Fragment as H } from "react/jsx-runtime";
5
- import rt, { forwardRef as wt, createElement as Ee, useMemo as E, useState as N, useEffect as P, useCallback as ee, memo as mr, useRef as ze, createContext as pr } from "react";
6
- import { createPortal as je } from "react-dom";
7
- import { useThreadListItem as Ct, RuntimeAdapterProvider as gr, useLocalRuntime as vt, AssistantRuntimeProvider as Tt, unstable_useRemoteThreadListRuntime as br, useThreadRuntime as xr, ThreadPrimitive as ne, ComposerPrimitive as ie, useAssistantState as At, AttachmentPrimitive as yr, useAssistantApi as kr, MessagePrimitive as oe, ThreadListPrimitive as Se, useThread as wr, ThreadListItemPrimitive as Me } from "@assistant-ui/react";
8
- import { unstable_memoizeMarkdownComponents as Cr, useIsMarkdownCodeBlock as vr, MarkdownTextPrimitive as Tr } from "@assistant-ui/react-markdown";
9
- let ce = !1, at = !1;
10
- function nt() {
11
- if (at || (at = !0, typeof document > "u" || typeof window > "u"))
1
+ var mr = Object.defineProperty;
2
+ var pr = (e, r, t) => r in e ? mr(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
3
+ var pe = (e, r, t) => pr(e, typeof r != "symbol" ? r + "" : r, t);
4
+ import { jsx as d, jsxs as C, Fragment as q } from "react/jsx-runtime";
5
+ import at, { forwardRef as vt, createElement as je, useMemo as z, useState as S, useEffect as E, useCallback as ee, memo as gr, useRef as ze, createContext as br } from "react";
6
+ import { createPortal as $e } from "react-dom";
7
+ import { useThreadListItem as Ct, RuntimeAdapterProvider as yr, useLocalRuntime as Tt, AssistantRuntimeProvider as At, unstable_useRemoteThreadListRuntime as xr, useThreadRuntime as kr, ThreadPrimitive as ne, ComposerPrimitive as ie, useAssistantState as Nt, AttachmentPrimitive as wr, useAssistantApi as vr, MessagePrimitive as oe, ThreadListPrimitive as Me, useThread as Cr, ThreadListItemPrimitive as Le } from "@assistant-ui/react";
8
+ import { unstable_memoizeMarkdownComponents as Tr, useIsMarkdownCodeBlock as Ar, MarkdownTextPrimitive as Nr } from "@assistant-ui/react-markdown";
9
+ let ce = !1, nt = !1;
10
+ function it() {
11
+ if (nt || (nt = !0, typeof document > "u" || typeof window > "u"))
12
12
  return;
13
13
  const e = document.querySelector("link[data-cuadra-uikit-styles]"), r = document.querySelector("style[data-cuadra-uikit-styles]");
14
14
  if (e || r) {
@@ -25,9 +25,9 @@ function nt() {
25
25
  }
26
26
  } catch {
27
27
  }
28
- Ar();
28
+ Ir();
29
29
  }
30
- function Ar() {
30
+ function Ir() {
31
31
  if (ce)
32
32
  return;
33
33
  const e = document.createElement("link");
@@ -54,19 +54,19 @@ function Ar() {
54
54
  a();
55
55
  }, document.head.appendChild(e);
56
56
  }
57
- typeof document < "u" && typeof window < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", nt) : nt());
58
- const Nr = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), Ir = (e) => e.replace(
57
+ typeof document < "u" && typeof window < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", it) : it());
58
+ const Sr = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), Mr = (e) => e.replace(
59
59
  /^([A-Z])|[\s-_]+(\w)/g,
60
60
  (r, t, a) => a ? a.toUpperCase() : t.toLowerCase()
61
- ), it = (e) => {
62
- const r = Ir(e);
61
+ ), ot = (e) => {
62
+ const r = Mr(e);
63
63
  return r.charAt(0).toUpperCase() + r.slice(1);
64
- }, Nt = (...e) => e.filter((r, t, a) => !!r && r.trim() !== "" && a.indexOf(r) === t).join(" ").trim(), Sr = (e) => {
64
+ }, It = (...e) => e.filter((r, t, a) => !!r && r.trim() !== "" && a.indexOf(r) === t).join(" ").trim(), Lr = (e) => {
65
65
  for (const r in e)
66
66
  if (r.startsWith("aria-") || r === "role" || r === "title")
67
67
  return !0;
68
68
  };
69
- var Mr = {
69
+ var Dr = {
70
70
  xmlns: "http://www.w3.org/2000/svg",
71
71
  width: 24,
72
72
  height: 24,
@@ -77,7 +77,7 @@ var Mr = {
77
77
  strokeLinecap: "round",
78
78
  strokeLinejoin: "round"
79
79
  };
80
- const Lr = wt(
80
+ const Rr = vt(
81
81
  ({
82
82
  color: e = "currentColor",
83
83
  size: r = 24,
@@ -87,71 +87,71 @@ const Lr = wt(
87
87
  children: o,
88
88
  iconNode: n,
89
89
  ...u
90
- }, c) => Ee(
90
+ }, c) => je(
91
91
  "svg",
92
92
  {
93
93
  ref: c,
94
- ...Mr,
94
+ ...Dr,
95
95
  width: r,
96
96
  height: r,
97
97
  stroke: e,
98
98
  strokeWidth: a ? Number(t) * 24 / Number(r) : t,
99
- className: Nt("lucide", i),
100
- ...!o && !Sr(u) && { "aria-hidden": "true" },
99
+ className: It("lucide", i),
100
+ ...!o && !Lr(u) && { "aria-hidden": "true" },
101
101
  ...u
102
102
  },
103
103
  [
104
- ...n.map(([l, f]) => Ee(l, f)),
104
+ ...n.map(([s, f]) => je(s, f)),
105
105
  ...Array.isArray(o) ? o : [o]
106
106
  ]
107
107
  )
108
108
  );
109
- const _ = (e, r) => {
110
- const t = wt(
111
- ({ className: a, ...i }, o) => Ee(Lr, {
109
+ const F = (e, r) => {
110
+ const t = vt(
111
+ ({ className: a, ...i }, o) => je(Rr, {
112
112
  ref: o,
113
113
  iconNode: r,
114
- className: Nt(
115
- `lucide-${Nr(it(e))}`,
114
+ className: It(
115
+ `lucide-${Sr(ot(e))}`,
116
116
  `lucide-${e}`,
117
117
  a
118
118
  ),
119
119
  ...i
120
120
  })
121
121
  );
122
- return t.displayName = it(e), t;
122
+ return t.displayName = ot(e), t;
123
123
  };
124
- const Dr = [
124
+ const Pr = [
125
125
  ["path", { d: "m5 12 7-7 7 7", key: "hav0vg" }],
126
126
  ["path", { d: "M12 19V5", key: "x0mq9r" }]
127
- ], Rr = _("arrow-up", Dr);
128
- const Pr = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]], Fr = _("check", Pr);
129
- const _r = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]], ot = _("chevron-down", _r);
130
- const Er = [
127
+ ], Er = F("arrow-up", Pr);
128
+ const _r = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]], Fr = F("check", _r);
129
+ const jr = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]], ct = F("chevron-down", jr);
130
+ const zr = [
131
131
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
132
132
  ["path", { d: "M12 18a6 6 0 0 0 0-12v12z", key: "j4l70d" }]
133
- ], zr = _("contrast", Er);
134
- const jr = [
133
+ ], $r = F("contrast", zr);
134
+ const Or = [
135
135
  ["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
136
136
  ["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" }]
137
- ], $r = _("copy", jr);
138
- const Or = [
137
+ ], Ur = F("copy", Or);
138
+ const Wr = [
139
139
  ["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
140
140
  ["circle", { cx: "12", cy: "5", r: "1", key: "gxeob9" }],
141
141
  ["circle", { cx: "12", cy: "19", r: "1", key: "lyex9k" }]
142
- ], Ur = _("ellipsis-vertical", Or);
143
- const Wr = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]], It = _("loader-circle", Wr);
144
- const Br = [
142
+ ], Br = F("ellipsis-vertical", Wr);
143
+ const Hr = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]], St = F("loader-circle", Hr);
144
+ const qr = [
145
145
  ["path", { d: "m16 17 5-5-5-5", key: "1bji2h" }],
146
146
  ["path", { d: "M21 12H9", key: "dn1m92" }],
147
147
  ["path", { d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4", key: "1uf3rs" }]
148
- ], Hr = _("log-out", Br);
149
- const qr = [
148
+ ], Vr = F("log-out", qr);
149
+ const Xr = [
150
150
  ["path", { d: "M4 5h16", key: "1tepv9" }],
151
151
  ["path", { d: "M4 12h16", key: "1lakjw" }],
152
152
  ["path", { d: "M4 19h16", key: "1djgab" }]
153
- ], Xr = _("menu", qr);
154
- const Kr = [
153
+ ], Kr = F("menu", Xr);
154
+ const Gr = [
155
155
  [
156
156
  "path",
157
157
  {
@@ -159,16 +159,16 @@ const Kr = [
159
159
  key: "1miecu"
160
160
  }
161
161
  ]
162
- ], St = _("paperclip", Kr);
163
- const Vr = [
162
+ ], Mt = F("paperclip", Gr);
163
+ const Zr = [
164
164
  ["path", { d: "M5 12h14", key: "1ays0h" }],
165
165
  ["path", { d: "M12 5v14", key: "s699le" }]
166
- ], Gr = _("plus", Vr);
167
- const Zr = [
166
+ ], Jr = F("plus", Zr);
167
+ const Qr = [
168
168
  ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
169
169
  ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
170
- ], Ue = _("x", Zr);
171
- class Mt {
170
+ ], We = F("x", Qr);
171
+ class Lt {
172
172
  constructor(r, t, a = !1) {
173
173
  pe(this, "baseUrl");
174
174
  pe(this, "sessionToken", null);
@@ -292,23 +292,23 @@ class Mt {
292
292
  });
293
293
  if (!c.ok) {
294
294
  const f = await c.text();
295
- let s = {};
295
+ let l = {};
296
296
  try {
297
- s = JSON.parse(f);
297
+ l = JSON.parse(f);
298
298
  } catch {
299
- s = { detail: f };
299
+ l = { detail: f };
300
300
  }
301
301
  throw new Error(
302
- s.detail || s.message || `API error: ${c.status} ${c.statusText}`
302
+ l.detail || l.message || `API error: ${c.status} ${c.statusText}`
303
303
  );
304
304
  }
305
305
  if (c.status === 204)
306
306
  return {};
307
- const l = await c.text();
308
- if (!l)
307
+ const s = await c.text();
308
+ if (!s)
309
309
  return {};
310
310
  try {
311
- return JSON.parse(l);
311
+ return JSON.parse(s);
312
312
  } catch {
313
313
  return {};
314
314
  }
@@ -397,15 +397,15 @@ class Mt {
397
397
  body: n
398
398
  });
399
399
  if (!c.ok) {
400
- const l = await c.json().catch(() => ({}));
400
+ const s = await c.json().catch(() => ({}));
401
401
  throw new Error(
402
- l.detail || l.message || `API error: ${c.status} ${c.statusText}`
402
+ s.detail || s.message || `API error: ${c.status} ${c.statusText}`
403
403
  );
404
404
  }
405
405
  return c.json();
406
406
  }
407
407
  }
408
- async function* Jr(e, r) {
408
+ async function* Yr(e, r) {
409
409
  const t = e.getReader(), a = new TextDecoder();
410
410
  let i = "";
411
411
  try {
@@ -423,13 +423,13 @@ async function* Jr(e, r) {
423
423
  i = u.pop() || "";
424
424
  for (const c of u)
425
425
  if (c.startsWith("data: ")) {
426
- const l = c.slice(6);
427
- if (l.trim() === "[DONE]") {
426
+ const s = c.slice(6);
427
+ if (s.trim() === "[DONE]") {
428
428
  yield { done: !0 };
429
429
  continue;
430
430
  }
431
431
  try {
432
- yield JSON.parse(l);
432
+ yield JSON.parse(s);
433
433
  } catch {
434
434
  }
435
435
  }
@@ -438,7 +438,7 @@ async function* Jr(e, r) {
438
438
  t.releaseLock();
439
439
  }
440
440
  }
441
- function Qr(e) {
441
+ function ea(e) {
442
442
  return e.map((r) => {
443
443
  let t = "";
444
444
  if (typeof r.content == "string")
@@ -454,7 +454,7 @@ function Qr(e) {
454
454
  };
455
455
  });
456
456
  }
457
- function Yr(e) {
457
+ function ta(e) {
458
458
  return {
459
459
  id: e.id,
460
460
  role: e.role,
@@ -486,51 +486,8 @@ function Yr(e) {
486
486
  }
487
487
  };
488
488
  }
489
- function Lt(e, r) {
490
- const { modelId: t, systemPrompt: a, ephemeral: i, onChatCreated: o, onUserMessage: n, onThreadIdUpdate: u } = r;
491
- return {
492
- async *run(c) {
493
- const { messages: l, abortSignal: f, context: s } = c, p = s?.threadId;
494
- n?.();
495
- const h = {
496
- messages: Qr(l),
497
- chatId: null,
498
- // Thread ID will be set by runtime if needed
499
- systemPrompt: a,
500
- ephemeral: i,
501
- stream: !0
502
- };
503
- t && t.trim() !== "" && (h.modelId = t);
504
- const y = await e.createOrContinueChat(h, f);
505
- let g = "", b;
506
- for await (const k of Jr(y, f)) {
507
- if (f?.aborted)
508
- throw new Error("Request aborted");
509
- const w = k.id;
510
- w && !b && (b = w, o?.(w), p && u && u(p, w));
511
- const A = k.delta;
512
- if (A != null && (g += A), k.type === "message" || k.content) {
513
- const T = k.content || "";
514
- g += T;
515
- }
516
- if (k.message && (g += k.message.content || ""), k.tool_calls, k.finished) {
517
- g && (yield {
518
- content: [{ type: "text", text: g }]
519
- });
520
- break;
521
- }
522
- g && (yield {
523
- content: [{ type: "text", text: g }]
524
- });
525
- }
526
- g && (yield {
527
- content: [{ type: "text", text: g }]
528
- });
529
- }
530
- };
531
- }
532
- const ct = /* @__PURE__ */ new Map();
533
- function ea(e, r) {
489
+ const ye = /* @__PURE__ */ new Map();
490
+ function ra(e, r) {
534
491
  return {
535
492
  async list() {
536
493
  const t = [];
@@ -551,7 +508,7 @@ function ea(e, r) {
551
508
  }).filter((u) => u !== null) };
552
509
  },
553
510
  async initialize(t) {
554
- return { remoteId: ct.get(t) || t, externalId: void 0 };
511
+ return { remoteId: ye.get(t) || t, externalId: void 0 };
555
512
  },
556
513
  async rename(t, a) {
557
514
  await e.updateChat(t, { title: a });
@@ -587,17 +544,17 @@ function ea(e, r) {
587
544
  },
588
545
  // Add a method to update the remoteId mapping when chat ID is received
589
546
  updateRemoteId(t, a) {
590
- ct.set(t, a), r?.(t, a);
547
+ ye.set(t, a), r?.(t, a);
591
548
  },
592
549
  // Provider component that adds thread-specific history adapter
593
550
  unstable_Provider: ({ children: t }) => {
594
- const i = Ct()?.remoteId, o = rt.useMemo(
551
+ const i = Ct()?.remoteId, o = at.useMemo(
595
552
  () => ({
596
553
  async load() {
597
554
  if (!i) return { messages: [] };
598
555
  try {
599
556
  const u = await e.getChat(i);
600
- return !u.messages || u.messages.length === 0 ? { messages: [] } : { messages: u.messages.map((l) => Yr(l)) };
557
+ return !u.messages || u.messages.length === 0 ? { messages: [] } : { messages: u.messages.map((s) => ta(s)) };
601
558
  } catch (u) {
602
559
  return console.error("Failed to load messages for thread:", i, u), { messages: [] };
603
560
  }
@@ -606,12 +563,70 @@ function ea(e, r) {
606
563
  }
607
564
  }),
608
565
  [i, e]
609
- ), n = rt.useMemo(() => ({ history: o }), [o]);
610
- return /* @__PURE__ */ d(gr, { adapters: n, children: t });
566
+ ), n = at.useMemo(() => ({ history: o }), [o]);
567
+ return /* @__PURE__ */ d(yr, { adapters: n, children: t });
568
+ }
569
+ };
570
+ }
571
+ const ut = /* @__PURE__ */ new Map();
572
+ function Dt(e, r) {
573
+ const { modelId: t, systemPrompt: a, ephemeral: i, onChatCreated: o, onUserMessage: n, onThreadIdUpdate: u } = r;
574
+ let c;
575
+ return {
576
+ async *run(s) {
577
+ const { messages: f, abortSignal: l, context: p } = s, b = p?.threadId;
578
+ let h = b;
579
+ if (!h && f.length > 0) {
580
+ const w = f.find((I) => I.role === "user");
581
+ w && (h = (typeof w.content == "string" ? w.content : Array.isArray(w.content) && w.content.find((P) => P.type === "text")?.text || "").substring(0, 50));
582
+ }
583
+ let x;
584
+ b && (x = ye.get(b)), !x && h && (x = ut.get(h)), !x && c && (x = c), n?.();
585
+ let y = f, g = -1;
586
+ for (let w = f.length - 1; w >= 0; w--)
587
+ if (f[w].role === "assistant") {
588
+ g = w;
589
+ break;
590
+ }
591
+ (x || g >= 0) && g >= 0 && (y = f.slice(g + 1));
592
+ const v = {
593
+ messages: ea(y),
594
+ chatId: x || null,
595
+ // Use server chatId if available
596
+ systemPrompt: a,
597
+ ephemeral: i,
598
+ stream: !0
599
+ };
600
+ t && t.trim() !== "" && (v.modelId = t);
601
+ const M = await e.createOrContinueChat(v, l);
602
+ let N = "", A;
603
+ for await (const w of Yr(M, l)) {
604
+ if (l?.aborted)
605
+ throw new Error("Request aborted");
606
+ const I = w.id || w.chatId;
607
+ I && !A && (A = I, c = I, o?.(I), b && u && (u(b, I), ye.set(b, I)), h && ut.set(h, I));
608
+ const P = w.delta;
609
+ if (P != null && (N += P), w.type === "message" || w.content) {
610
+ const j = w.content || "";
611
+ N += j;
612
+ }
613
+ if (w.message && (N += w.message.content || ""), w.tool_calls, w.finished) {
614
+ N && (yield {
615
+ content: [{ type: "text", text: N }]
616
+ });
617
+ break;
618
+ }
619
+ N && (yield {
620
+ content: [{ type: "text", text: N }]
621
+ });
622
+ }
623
+ N && (yield {
624
+ content: [{ type: "text", text: N }]
625
+ });
611
626
  }
612
627
  };
613
628
  }
614
- function Dt() {
629
+ function Rt() {
615
630
  return {
616
631
  accept: ".pdf,.docx,.txt,.md,.csv,.json,image/*",
617
632
  async add({ file: e }) {
@@ -652,7 +667,7 @@ function Dt() {
652
667
  }
653
668
  };
654
669
  }
655
- function ta({
670
+ function aa({
656
671
  children: e,
657
672
  baseUrl: r,
658
673
  sessionToken: t,
@@ -662,72 +677,72 @@ function ta({
662
677
  onModelChange: n,
663
678
  ephemeral: u = !1,
664
679
  systemPrompt: c,
665
- initialThreadId: l,
680
+ initialThreadId: s,
666
681
  onError: f,
667
- onChatCreated: s,
682
+ onChatCreated: l,
668
683
  onUserMessage: p,
669
- onThreadIdUpdate: x,
684
+ onThreadIdUpdate: b,
670
685
  onChatsLoaded: h,
671
- enableAttachments: y = !1
686
+ enableAttachments: x = !1
672
687
  }) {
673
- const g = E(
674
- () => new Mt(r, t || void 0, a),
688
+ const y = z(
689
+ () => new Lt(r, t || void 0, a),
675
690
  [r, t, a]
676
- ), [b, k] = N(o || null);
677
- P(() => {
691
+ ), [g, k] = S(o || null);
692
+ E(() => {
678
693
  o && k(o);
679
694
  }, [o]);
680
- const w = ee(
681
- (T) => {
682
- s?.(T);
695
+ const v = ee(
696
+ (A) => {
697
+ l?.(A);
683
698
  },
684
- [s]
685
- ), A = ee(
686
- (T, S) => {
687
- x?.(T, S);
699
+ [l]
700
+ ), M = ee(
701
+ (A, w) => {
702
+ b?.(A, w);
688
703
  },
689
- [x]
690
- ), I = E(() => Lt(g, {
691
- modelId: b || void 0,
704
+ [b]
705
+ ), N = z(() => Dt(y, {
706
+ modelId: g || void 0,
692
707
  // Pass undefined if not set (backend resolves it)
693
708
  systemPrompt: c,
694
709
  ephemeral: u,
695
- onChatCreated: w,
710
+ onChatCreated: v,
696
711
  onUserMessage: p
697
- }), [g, b, c, u, w, p]);
698
- return i === "singleChat" ? /* @__PURE__ */ d(ra, { modelAdapter: I, enableAttachments: y, children: e }) : /* @__PURE__ */ d(
699
- aa,
712
+ }), [y, g, c, u, v, p]);
713
+ return i === "singleChat" ? /* @__PURE__ */ d(na, { modelAdapter: N, enableAttachments: x, children: e }) : /* @__PURE__ */ d(
714
+ ia,
700
715
  {
701
- client: g,
716
+ client: y,
702
717
  modelAdapterOptions: {
703
- modelId: b || void 0,
718
+ modelId: g || void 0,
704
719
  systemPrompt: c,
705
720
  ephemeral: u,
706
- onChatCreated: w,
721
+ onChatCreated: v,
707
722
  onUserMessage: p
708
723
  },
709
- initialThreadId: l,
724
+ initialThreadId: s,
710
725
  onChatsLoaded: h,
711
- onThreadIdUpdate: A,
726
+ onThreadIdUpdate: M,
712
727
  onError: f,
713
- enableAttachments: y,
728
+ enableAttachments: x,
714
729
  children: e
715
730
  }
716
731
  );
717
732
  }
718
- function ra({
733
+ function na({
719
734
  modelAdapter: e,
720
735
  enableAttachments: r,
721
736
  children: t
722
737
  }) {
723
- const a = E(() => r ? Dt() : void 0, [r]), i = vt(e, {
738
+ const a = z(() => r ? Rt() : void 0, [r]), i = Tt(e, {
724
739
  adapters: {
725
740
  ...a && { attachments: a }
726
741
  }
727
742
  });
728
- return /* @__PURE__ */ d(Tt, { runtime: i, children: t });
743
+ return /* @__PURE__ */ d(At, { runtime: i, children: t });
729
744
  }
730
- function aa({
745
+ function ia({
731
746
  client: e,
732
747
  modelAdapterOptions: r,
733
748
  initialThreadId: t,
@@ -737,39 +752,39 @@ function aa({
737
752
  enableAttachments: n,
738
753
  children: u
739
754
  }) {
740
- const c = E(() => ea(e, (y, g) => {
741
- i?.(y, g);
742
- }), [e, i]), l = ee(
743
- (y, g) => {
744
- c.updateRemoteId && c.updateRemoteId(y, g), i?.(y, g);
755
+ const c = z(() => ra(e, (x, y) => {
756
+ i?.(x, y);
757
+ }), [e, i]), s = ee(
758
+ (x, y) => {
759
+ c.updateRemoteId && c.updateRemoteId(x, y), i?.(x, y);
745
760
  },
746
761
  [c, i]
747
- ), f = E(() => ({
762
+ ), f = z(() => ({
748
763
  ...c,
749
764
  async list() {
750
- const y = await c.list();
751
- return a?.(), y;
765
+ const x = await c.list();
766
+ return a?.(), x;
752
767
  }
753
768
  }), [c, a]);
754
- P(() => {
769
+ E(() => {
755
770
  window.__cuadraThreadListAdapter = f, window.__cuadraThreadListRuntime = null;
756
771
  }, [f]);
757
- const s = E(() => Lt(e, {
772
+ const l = z(() => Dt(e, {
758
773
  ...r,
759
- onThreadIdUpdate: l
760
- }), [e, r, l]), p = E(() => n ? Dt() : void 0, [n]), x = ee(() => vt(s, {
774
+ onThreadIdUpdate: s
775
+ }), [e, r, s]), p = z(() => n ? Rt() : void 0, [n]), b = ee(() => Tt(l, {
761
776
  adapters: {
762
777
  ...p && { attachments: p }
763
778
  }
764
- }), [s, p]), h = br({
779
+ }), [l, p]), h = xr({
765
780
  adapter: f,
766
- runtimeHook: x
781
+ runtimeHook: b
767
782
  });
768
- return P(() => {
783
+ return E(() => {
769
784
  window.__cuadraThreadListRuntime = h;
770
- }, [h]), /* @__PURE__ */ d(Tt, { runtime: h, children: u });
785
+ }, [h]), /* @__PURE__ */ d(At, { runtime: h, children: u });
771
786
  }
772
- function ut(e, r) {
787
+ function st(e, r) {
773
788
  const t = String(e);
774
789
  if (typeof r != "string")
775
790
  throw new TypeError("Expected character");
@@ -778,8 +793,8 @@ function ut(e, r) {
778
793
  a++, i = t.indexOf(r, i + r.length);
779
794
  return a;
780
795
  }
781
- const ue = we(/[A-Za-z]/), We = we(/[\dA-Za-z]/);
782
- function na(e) {
796
+ const ue = ve(/[A-Za-z]/), Be = ve(/[\dA-Za-z]/);
797
+ function oa(e) {
783
798
  return (
784
799
  // Special whitespace codes (which have negative values), C0 and Control
785
800
  // character DEL
@@ -789,20 +804,20 @@ function na(e) {
789
804
  function Y(e) {
790
805
  return e !== null && e < -2;
791
806
  }
792
- function F(e) {
807
+ function _(e) {
793
808
  return e !== null && (e < 0 || e === 32);
794
809
  }
795
- function W(e) {
810
+ function B(e) {
796
811
  return e === -2 || e === -1 || e === 32;
797
812
  }
798
- const ke = we(/\p{P}|\p{S}/u), V = we(/\s/);
799
- function we(e) {
813
+ const we = ve(/\p{P}|\p{S}/u), K = ve(/\s/);
814
+ function ve(e) {
800
815
  return r;
801
816
  function r(t) {
802
817
  return t !== null && t > -1 && e.test(String.fromCharCode(t));
803
818
  }
804
819
  }
805
- function ia(e) {
820
+ function ca(e) {
806
821
  if (typeof e != "string")
807
822
  throw new TypeError("Expected a string");
808
823
  return e.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
@@ -824,29 +839,29 @@ const Ce = (
824
839
  */
825
840
  (function(e) {
826
841
  if (e == null)
827
- return la;
842
+ return da;
828
843
  if (typeof e == "function")
829
- return ve(e);
844
+ return Te(e);
830
845
  if (typeof e == "object")
831
- return Array.isArray(e) ? oa(e) : (
846
+ return Array.isArray(e) ? ua(e) : (
832
847
  // Cast because `ReadonlyArray` goes into the above but `isArray`
833
848
  // narrows to `Array`.
834
- ca(
849
+ sa(
835
850
  /** @type {Props} */
836
851
  e
837
852
  )
838
853
  );
839
854
  if (typeof e == "string")
840
- return ua(e);
855
+ return la(e);
841
856
  throw new Error("Expected function, string, or object as test");
842
857
  })
843
858
  );
844
- function oa(e) {
859
+ function ua(e) {
845
860
  const r = [];
846
861
  let t = -1;
847
862
  for (; ++t < e.length; )
848
863
  r[t] = Ce(e[t]);
849
- return ve(a);
864
+ return Te(a);
850
865
  function a(...i) {
851
866
  let o = -1;
852
867
  for (; ++o < r.length; )
@@ -854,12 +869,12 @@ function oa(e) {
854
869
  return !1;
855
870
  }
856
871
  }
857
- function ca(e) {
872
+ function sa(e) {
858
873
  const r = (
859
874
  /** @type {Record<string, unknown>} */
860
875
  e
861
876
  );
862
- return ve(t);
877
+ return Te(t);
863
878
  function t(a) {
864
879
  const i = (
865
880
  /** @type {Record<string, unknown>} */
@@ -872,16 +887,16 @@ function ca(e) {
872
887
  return !0;
873
888
  }
874
889
  }
875
- function ua(e) {
876
- return ve(r);
890
+ function la(e) {
891
+ return Te(r);
877
892
  function r(t) {
878
893
  return t && t.type === e;
879
894
  }
880
895
  }
881
- function ve(e) {
896
+ function Te(e) {
882
897
  return r;
883
898
  function r(t, a, i) {
884
- return !!(sa(t) && e.call(
899
+ return !!(fa(t) && e.call(
885
900
  this,
886
901
  t,
887
902
  typeof a == "number" ? a : void 0,
@@ -889,105 +904,105 @@ function ve(e) {
889
904
  ));
890
905
  }
891
906
  }
892
- function la() {
907
+ function da() {
893
908
  return !0;
894
909
  }
895
- function sa(e) {
910
+ function fa(e) {
896
911
  return e !== null && typeof e == "object" && "type" in e;
897
912
  }
898
- const Rt = [], da = !0, $e = !1, fa = "skip";
899
- function Pt(e, r, t, a) {
913
+ const Pt = [], ha = !0, Oe = !1, ma = "skip";
914
+ function Et(e, r, t, a) {
900
915
  let i;
901
916
  typeof r == "function" && typeof t != "function" ? (a = t, t = r) : i = r;
902
917
  const o = Ce(i), n = a ? -1 : 1;
903
918
  u(e, void 0, [])();
904
- function u(c, l, f) {
905
- const s = (
919
+ function u(c, s, f) {
920
+ const l = (
906
921
  /** @type {Record<string, unknown>} */
907
922
  c && typeof c == "object" ? c : {}
908
923
  );
909
- if (typeof s.type == "string") {
910
- const x = (
924
+ if (typeof l.type == "string") {
925
+ const b = (
911
926
  // `hast`
912
- typeof s.tagName == "string" ? s.tagName : (
927
+ typeof l.tagName == "string" ? l.tagName : (
913
928
  // `xast`
914
- typeof s.name == "string" ? s.name : void 0
929
+ typeof l.name == "string" ? l.name : void 0
915
930
  )
916
931
  );
917
932
  Object.defineProperty(p, "name", {
918
- value: "node (" + (c.type + (x ? "<" + x + ">" : "")) + ")"
933
+ value: "node (" + (c.type + (b ? "<" + b + ">" : "")) + ")"
919
934
  });
920
935
  }
921
936
  return p;
922
937
  function p() {
923
- let x = Rt, h, y, g;
924
- if ((!r || o(c, l, f[f.length - 1] || void 0)) && (x = ha(t(c, f)), x[0] === $e))
925
- return x;
938
+ let b = Pt, h, x, y;
939
+ if ((!r || o(c, s, f[f.length - 1] || void 0)) && (b = pa(t(c, f)), b[0] === Oe))
940
+ return b;
926
941
  if ("children" in c && c.children) {
927
- const b = (
942
+ const g = (
928
943
  /** @type {UnistParent} */
929
944
  c
930
945
  );
931
- if (b.children && x[0] !== fa)
932
- for (y = (a ? b.children.length : -1) + n, g = f.concat(b); y > -1 && y < b.children.length; ) {
933
- const k = b.children[y];
934
- if (h = u(k, y, g)(), h[0] === $e)
946
+ if (g.children && b[0] !== ma)
947
+ for (x = (a ? g.children.length : -1) + n, y = f.concat(g); x > -1 && x < g.children.length; ) {
948
+ const k = g.children[x];
949
+ if (h = u(k, x, y)(), h[0] === Oe)
935
950
  return h;
936
- y = typeof h[1] == "number" ? h[1] : y + n;
951
+ x = typeof h[1] == "number" ? h[1] : x + n;
937
952
  }
938
953
  }
939
- return x;
954
+ return b;
940
955
  }
941
956
  }
942
957
  }
943
- function ha(e) {
944
- return Array.isArray(e) ? e : typeof e == "number" ? [da, e] : e == null ? Rt : [e];
958
+ function pa(e) {
959
+ return Array.isArray(e) ? e : typeof e == "number" ? [ha, e] : e == null ? Pt : [e];
945
960
  }
946
- function ma(e, r, t) {
947
- const i = Ce((t || {}).ignore || []), o = pa(r);
961
+ function ga(e, r, t) {
962
+ const i = Ce((t || {}).ignore || []), o = ba(r);
948
963
  let n = -1;
949
964
  for (; ++n < o.length; )
950
- Pt(e, "text", u);
951
- function u(l, f) {
952
- let s = -1, p;
953
- for (; ++s < f.length; ) {
954
- const x = f[s], h = p ? p.children : void 0;
965
+ Et(e, "text", u);
966
+ function u(s, f) {
967
+ let l = -1, p;
968
+ for (; ++l < f.length; ) {
969
+ const b = f[l], h = p ? p.children : void 0;
955
970
  if (i(
956
- x,
957
- h ? h.indexOf(x) : void 0,
971
+ b,
972
+ h ? h.indexOf(b) : void 0,
958
973
  p
959
974
  ))
960
975
  return;
961
- p = x;
976
+ p = b;
962
977
  }
963
978
  if (p)
964
- return c(l, f);
979
+ return c(s, f);
965
980
  }
966
- function c(l, f) {
967
- const s = f[f.length - 1], p = o[n][0], x = o[n][1];
981
+ function c(s, f) {
982
+ const l = f[f.length - 1], p = o[n][0], b = o[n][1];
968
983
  let h = 0;
969
- const g = s.children.indexOf(l);
970
- let b = !1, k = [];
984
+ const y = l.children.indexOf(s);
985
+ let g = !1, k = [];
971
986
  p.lastIndex = 0;
972
- let w = p.exec(l.value);
973
- for (; w; ) {
974
- const A = w.index, I = {
975
- index: w.index,
976
- input: w.input,
977
- stack: [...f, l]
987
+ let v = p.exec(s.value);
988
+ for (; v; ) {
989
+ const M = v.index, N = {
990
+ index: v.index,
991
+ input: v.input,
992
+ stack: [...f, s]
978
993
  };
979
- let T = x(...w, I);
980
- if (typeof T == "string" && (T = T.length > 0 ? { type: "text", value: T } : void 0), T === !1 ? p.lastIndex = A + 1 : (h !== A && k.push({
994
+ let A = b(...v, N);
995
+ if (typeof A == "string" && (A = A.length > 0 ? { type: "text", value: A } : void 0), A === !1 ? p.lastIndex = M + 1 : (h !== M && k.push({
981
996
  type: "text",
982
- value: l.value.slice(h, A)
983
- }), Array.isArray(T) ? k.push(...T) : T && k.push(T), h = A + w[0].length, b = !0), !p.global)
997
+ value: s.value.slice(h, M)
998
+ }), Array.isArray(A) ? k.push(...A) : A && k.push(A), h = M + v[0].length, g = !0), !p.global)
984
999
  break;
985
- w = p.exec(l.value);
1000
+ v = p.exec(s.value);
986
1001
  }
987
- return b ? (h < l.value.length && k.push({ type: "text", value: l.value.slice(h) }), s.children.splice(g, 1, ...k)) : k = [l], g + k.length;
1002
+ return g ? (h < s.value.length && k.push({ type: "text", value: s.value.slice(h) }), l.children.splice(y, 1, ...k)) : k = [s], y + k.length;
988
1003
  }
989
1004
  }
990
- function pa(e) {
1005
+ function ba(e) {
991
1006
  const r = [];
992
1007
  if (!Array.isArray(e))
993
1008
  throw new TypeError("Expected find and replace tuple or list of tuples");
@@ -995,98 +1010,98 @@ function pa(e) {
995
1010
  let a = -1;
996
1011
  for (; ++a < t.length; ) {
997
1012
  const i = t[a];
998
- r.push([ga(i[0]), ba(i[1])]);
1013
+ r.push([ya(i[0]), xa(i[1])]);
999
1014
  }
1000
1015
  return r;
1001
1016
  }
1002
- function ga(e) {
1003
- return typeof e == "string" ? new RegExp(ia(e), "g") : e;
1017
+ function ya(e) {
1018
+ return typeof e == "string" ? new RegExp(ca(e), "g") : e;
1004
1019
  }
1005
- function ba(e) {
1020
+ function xa(e) {
1006
1021
  return typeof e == "function" ? e : function() {
1007
1022
  return e;
1008
1023
  };
1009
1024
  }
1010
- const Le = "phrasing", De = ["autolink", "link", "image", "label"];
1011
- function xa() {
1025
+ const De = "phrasing", Re = ["autolink", "link", "image", "label"];
1026
+ function ka() {
1012
1027
  return {
1013
- transforms: [Aa],
1028
+ transforms: [Ia],
1014
1029
  enter: {
1015
- literalAutolink: ka,
1016
- literalAutolinkEmail: Re,
1017
- literalAutolinkHttp: Re,
1018
- literalAutolinkWww: Re
1030
+ literalAutolink: va,
1031
+ literalAutolinkEmail: Pe,
1032
+ literalAutolinkHttp: Pe,
1033
+ literalAutolinkWww: Pe
1019
1034
  },
1020
1035
  exit: {
1021
- literalAutolink: Ta,
1022
- literalAutolinkEmail: va,
1023
- literalAutolinkHttp: wa,
1024
- literalAutolinkWww: Ca
1036
+ literalAutolink: Na,
1037
+ literalAutolinkEmail: Aa,
1038
+ literalAutolinkHttp: Ca,
1039
+ literalAutolinkWww: Ta
1025
1040
  }
1026
1041
  };
1027
1042
  }
1028
- function ya() {
1043
+ function wa() {
1029
1044
  return {
1030
1045
  unsafe: [
1031
1046
  {
1032
1047
  character: "@",
1033
1048
  before: "[+\\-.\\w]",
1034
1049
  after: "[\\-.\\w]",
1035
- inConstruct: Le,
1036
- notInConstruct: De
1050
+ inConstruct: De,
1051
+ notInConstruct: Re
1037
1052
  },
1038
1053
  {
1039
1054
  character: ".",
1040
1055
  before: "[Ww]",
1041
1056
  after: "[\\-.\\w]",
1042
- inConstruct: Le,
1043
- notInConstruct: De
1057
+ inConstruct: De,
1058
+ notInConstruct: Re
1044
1059
  },
1045
1060
  {
1046
1061
  character: ":",
1047
1062
  before: "[ps]",
1048
1063
  after: "\\/",
1049
- inConstruct: Le,
1050
- notInConstruct: De
1064
+ inConstruct: De,
1065
+ notInConstruct: Re
1051
1066
  }
1052
1067
  ]
1053
1068
  };
1054
1069
  }
1055
- function ka(e) {
1070
+ function va(e) {
1056
1071
  this.enter({ type: "link", title: null, url: "", children: [] }, e);
1057
1072
  }
1058
- function Re(e) {
1073
+ function Pe(e) {
1059
1074
  this.config.enter.autolinkProtocol.call(this, e);
1060
1075
  }
1061
- function wa(e) {
1076
+ function Ca(e) {
1062
1077
  this.config.exit.autolinkProtocol.call(this, e);
1063
1078
  }
1064
- function Ca(e) {
1079
+ function Ta(e) {
1065
1080
  this.config.exit.data.call(this, e);
1066
1081
  const r = this.stack[this.stack.length - 1];
1067
1082
  r.type, r.url = "http://" + this.sliceSerialize(e);
1068
1083
  }
1069
- function va(e) {
1084
+ function Aa(e) {
1070
1085
  this.config.exit.autolinkEmail.call(this, e);
1071
1086
  }
1072
- function Ta(e) {
1087
+ function Na(e) {
1073
1088
  this.exit(e);
1074
1089
  }
1075
- function Aa(e) {
1076
- ma(
1090
+ function Ia(e) {
1091
+ ga(
1077
1092
  e,
1078
1093
  [
1079
- [/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi, Na],
1080
- [/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu, Ia]
1094
+ [/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi, Sa],
1095
+ [/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu, Ma]
1081
1096
  ],
1082
1097
  { ignore: ["link", "linkReference"] }
1083
1098
  );
1084
1099
  }
1085
- function Na(e, r, t, a, i) {
1100
+ function Sa(e, r, t, a, i) {
1086
1101
  let o = "";
1087
- if (!Ft(i) || (/^w/i.test(r) && (t = r + t, r = "", o = "http://"), !Sa(t)))
1102
+ if (!_t(i) || (/^w/i.test(r) && (t = r + t, r = "", o = "http://"), !La(t)))
1088
1103
  return !1;
1089
- const n = Ma(t + a);
1104
+ const n = Da(t + a);
1090
1105
  if (!n[0]) return !1;
1091
1106
  const u = {
1092
1107
  type: "link",
@@ -1096,10 +1111,10 @@ function Na(e, r, t, a, i) {
1096
1111
  };
1097
1112
  return n[1] ? [u, { type: "text", value: n[1] }] : u;
1098
1113
  }
1099
- function Ia(e, r, t, a) {
1114
+ function Ma(e, r, t, a) {
1100
1115
  return (
1101
1116
  // Not an expected previous character.
1102
- !Ft(a, !0) || // Label ends in not allowed character.
1117
+ !_t(a, !0) || // Label ends in not allowed character.
1103
1118
  /[-\d_]$/.test(t) ? !1 : {
1104
1119
  type: "link",
1105
1120
  title: null,
@@ -1108,41 +1123,41 @@ function Ia(e, r, t, a) {
1108
1123
  }
1109
1124
  );
1110
1125
  }
1111
- function Sa(e) {
1126
+ function La(e) {
1112
1127
  const r = e.split(".");
1113
1128
  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])));
1114
1129
  }
1115
- function Ma(e) {
1130
+ function Da(e) {
1116
1131
  const r = /[!"&'),.:;<>?\]}]+$/.exec(e);
1117
1132
  if (!r)
1118
1133
  return [e, void 0];
1119
1134
  e = e.slice(0, r.index);
1120
1135
  let t = r[0], a = t.indexOf(")");
1121
- const i = ut(e, "(");
1122
- let o = ut(e, ")");
1136
+ const i = st(e, "(");
1137
+ let o = st(e, ")");
1123
1138
  for (; a !== -1 && i > o; )
1124
1139
  e += t.slice(0, a + 1), t = t.slice(a + 1), a = t.indexOf(")"), o++;
1125
1140
  return [e, t];
1126
1141
  }
1127
- function Ft(e, r) {
1142
+ function _t(e, r) {
1128
1143
  const t = e.input.charCodeAt(e.index - 1);
1129
- return (e.index === 0 || V(t) || ke(t)) && // If it’s an email, the previous character should not be a slash.
1144
+ return (e.index === 0 || K(t) || we(t)) && // If it’s an email, the previous character should not be a slash.
1130
1145
  (!r || t !== 47);
1131
1146
  }
1132
- function se(e) {
1147
+ function le(e) {
1133
1148
  return e.replace(/[\t\n\r ]+/g, " ").replace(/^ | $/g, "").toLowerCase().toUpperCase();
1134
1149
  }
1135
- _t.peek = ja;
1136
- function La() {
1150
+ Ft.peek = Oa;
1151
+ function Ra() {
1137
1152
  this.buffer();
1138
1153
  }
1139
- function Da(e) {
1154
+ function Pa(e) {
1140
1155
  this.enter({ type: "footnoteReference", identifier: "", label: "" }, e);
1141
1156
  }
1142
- function Ra() {
1157
+ function Ea() {
1143
1158
  this.buffer();
1144
1159
  }
1145
- function Pa(e) {
1160
+ function _a(e) {
1146
1161
  this.enter(
1147
1162
  { type: "footnoteDefinition", identifier: "", label: "", children: [] },
1148
1163
  e
@@ -1150,26 +1165,26 @@ function Pa(e) {
1150
1165
  }
1151
1166
  function Fa(e) {
1152
1167
  const r = this.resume(), t = this.stack[this.stack.length - 1];
1153
- t.type, t.identifier = se(
1168
+ t.type, t.identifier = le(
1154
1169
  this.sliceSerialize(e)
1155
1170
  ).toLowerCase(), t.label = r;
1156
1171
  }
1157
- function _a(e) {
1172
+ function ja(e) {
1158
1173
  this.exit(e);
1159
1174
  }
1160
- function Ea(e) {
1175
+ function za(e) {
1161
1176
  const r = this.resume(), t = this.stack[this.stack.length - 1];
1162
- t.type, t.identifier = se(
1177
+ t.type, t.identifier = le(
1163
1178
  this.sliceSerialize(e)
1164
1179
  ).toLowerCase(), t.label = r;
1165
1180
  }
1166
- function za(e) {
1181
+ function $a(e) {
1167
1182
  this.exit(e);
1168
1183
  }
1169
- function ja() {
1184
+ function Oa() {
1170
1185
  return "[";
1171
1186
  }
1172
- function _t(e, r, t, a) {
1187
+ function Ft(e, r, t, a) {
1173
1188
  const i = t.createTracker(a);
1174
1189
  let o = i.move("[^");
1175
1190
  const n = t.enter("footnoteReference"), u = t.enter("reference");
@@ -1177,51 +1192,51 @@ function _t(e, r, t, a) {
1177
1192
  t.safe(t.associationId(e), { after: "]", before: o })
1178
1193
  ), u(), n(), o += i.move("]"), o;
1179
1194
  }
1180
- function $a() {
1195
+ function Ua() {
1181
1196
  return {
1182
1197
  enter: {
1183
- gfmFootnoteCallString: La,
1184
- gfmFootnoteCall: Da,
1185
- gfmFootnoteDefinitionLabelString: Ra,
1186
- gfmFootnoteDefinition: Pa
1198
+ gfmFootnoteCallString: Ra,
1199
+ gfmFootnoteCall: Pa,
1200
+ gfmFootnoteDefinitionLabelString: Ea,
1201
+ gfmFootnoteDefinition: _a
1187
1202
  },
1188
1203
  exit: {
1189
1204
  gfmFootnoteCallString: Fa,
1190
- gfmFootnoteCall: _a,
1191
- gfmFootnoteDefinitionLabelString: Ea,
1192
- gfmFootnoteDefinition: za
1205
+ gfmFootnoteCall: ja,
1206
+ gfmFootnoteDefinitionLabelString: za,
1207
+ gfmFootnoteDefinition: $a
1193
1208
  }
1194
1209
  };
1195
1210
  }
1196
- function Oa(e) {
1211
+ function Wa(e) {
1197
1212
  let r = !1;
1198
1213
  return e && e.firstLineBlank && (r = !0), {
1199
- handlers: { footnoteDefinition: t, footnoteReference: _t },
1214
+ handlers: { footnoteDefinition: t, footnoteReference: Ft },
1200
1215
  // This is on by default already.
1201
1216
  unsafe: [{ character: "[", inConstruct: ["label", "phrasing", "reference"] }]
1202
1217
  };
1203
1218
  function t(a, i, o, n) {
1204
1219
  const u = o.createTracker(n);
1205
1220
  let c = u.move("[^");
1206
- const l = o.enter("footnoteDefinition"), f = o.enter("label");
1221
+ const s = o.enter("footnoteDefinition"), f = o.enter("label");
1207
1222
  return c += u.move(
1208
1223
  o.safe(o.associationId(a), { before: c, after: "]" })
1209
1224
  ), f(), c += u.move("]:"), a.children && a.children.length > 0 && (u.shift(4), c += u.move(
1210
1225
  (r ? `
1211
1226
  ` : " ") + o.indentLines(
1212
1227
  o.containerFlow(a, u.current()),
1213
- r ? Et : Ua
1228
+ r ? jt : Ba
1214
1229
  )
1215
- )), l(), c;
1230
+ )), s(), c;
1216
1231
  }
1217
1232
  }
1218
- function Ua(e, r, t) {
1219
- return r === 0 ? e : Et(e, r, t);
1233
+ function Ba(e, r, t) {
1234
+ return r === 0 ? e : jt(e, r, t);
1220
1235
  }
1221
- function Et(e, r, t) {
1236
+ function jt(e, r, t) {
1222
1237
  return (t ? "" : " ") + e;
1223
1238
  }
1224
- const Wa = [
1239
+ const Ha = [
1225
1240
  "autolink",
1226
1241
  "destinationLiteral",
1227
1242
  "destinationRaw",
@@ -1229,30 +1244,30 @@ const Wa = [
1229
1244
  "titleQuote",
1230
1245
  "titleApostrophe"
1231
1246
  ];
1232
- zt.peek = Ka;
1233
- function Ba() {
1247
+ zt.peek = Ga;
1248
+ function qa() {
1234
1249
  return {
1235
1250
  canContainEols: ["delete"],
1236
- enter: { strikethrough: qa },
1237
- exit: { strikethrough: Xa }
1251
+ enter: { strikethrough: Xa },
1252
+ exit: { strikethrough: Ka }
1238
1253
  };
1239
1254
  }
1240
- function Ha() {
1255
+ function Va() {
1241
1256
  return {
1242
1257
  unsafe: [
1243
1258
  {
1244
1259
  character: "~",
1245
1260
  inConstruct: "phrasing",
1246
- notInConstruct: Wa
1261
+ notInConstruct: Ha
1247
1262
  }
1248
1263
  ],
1249
1264
  handlers: { delete: zt }
1250
1265
  };
1251
1266
  }
1252
- function qa(e) {
1267
+ function Xa(e) {
1253
1268
  this.enter({ type: "delete", children: [] }, e);
1254
1269
  }
1255
- function Xa(e) {
1270
+ function Ka(e) {
1256
1271
  this.exit(e);
1257
1272
  }
1258
1273
  function zt(e, r, t, a) {
@@ -1264,97 +1279,97 @@ function zt(e, r, t, a) {
1264
1279
  after: "~"
1265
1280
  }), n += i.move("~~"), o(), n;
1266
1281
  }
1267
- function Ka() {
1282
+ function Ga() {
1268
1283
  return "~";
1269
1284
  }
1270
- function Va(e) {
1285
+ function Za(e) {
1271
1286
  return e.length;
1272
1287
  }
1273
- function Ga(e, r) {
1274
- const t = r || {}, a = (t.align || []).concat(), i = t.stringLength || Va, o = [], n = [], u = [], c = [];
1275
- let l = 0, f = -1;
1288
+ function Ja(e, r) {
1289
+ const t = r || {}, a = (t.align || []).concat(), i = t.stringLength || Za, o = [], n = [], u = [], c = [];
1290
+ let s = 0, f = -1;
1276
1291
  for (; ++f < e.length; ) {
1277
- const y = [], g = [];
1278
- let b = -1;
1279
- for (e[f].length > l && (l = e[f].length); ++b < e[f].length; ) {
1280
- const k = Za(e[f][b]);
1292
+ const x = [], y = [];
1293
+ let g = -1;
1294
+ for (e[f].length > s && (s = e[f].length); ++g < e[f].length; ) {
1295
+ const k = Qa(e[f][g]);
1281
1296
  if (t.alignDelimiters !== !1) {
1282
- const w = i(k);
1283
- g[b] = w, (c[b] === void 0 || w > c[b]) && (c[b] = w);
1297
+ const v = i(k);
1298
+ y[g] = v, (c[g] === void 0 || v > c[g]) && (c[g] = v);
1284
1299
  }
1285
- y.push(k);
1300
+ x.push(k);
1286
1301
  }
1287
- n[f] = y, u[f] = g;
1302
+ n[f] = x, u[f] = y;
1288
1303
  }
1289
- let s = -1;
1304
+ let l = -1;
1290
1305
  if (typeof a == "object" && "length" in a)
1291
- for (; ++s < l; )
1292
- o[s] = lt(a[s]);
1306
+ for (; ++l < s; )
1307
+ o[l] = lt(a[l]);
1293
1308
  else {
1294
- const y = lt(a);
1295
- for (; ++s < l; )
1296
- o[s] = y;
1297
- }
1298
- s = -1;
1299
- const p = [], x = [];
1300
- for (; ++s < l; ) {
1301
- const y = o[s];
1302
- let g = "", b = "";
1303
- y === 99 ? (g = ":", b = ":") : y === 108 ? g = ":" : y === 114 && (b = ":");
1309
+ const x = lt(a);
1310
+ for (; ++l < s; )
1311
+ o[l] = x;
1312
+ }
1313
+ l = -1;
1314
+ const p = [], b = [];
1315
+ for (; ++l < s; ) {
1316
+ const x = o[l];
1317
+ let y = "", g = "";
1318
+ x === 99 ? (y = ":", g = ":") : x === 108 ? y = ":" : x === 114 && (g = ":");
1304
1319
  let k = t.alignDelimiters === !1 ? 1 : Math.max(
1305
1320
  1,
1306
- c[s] - g.length - b.length
1321
+ c[l] - y.length - g.length
1307
1322
  );
1308
- const w = g + "-".repeat(k) + b;
1309
- t.alignDelimiters !== !1 && (k = g.length + k + b.length, k > c[s] && (c[s] = k), x[s] = k), p[s] = w;
1323
+ const v = y + "-".repeat(k) + g;
1324
+ t.alignDelimiters !== !1 && (k = y.length + k + g.length, k > c[l] && (c[l] = k), b[l] = k), p[l] = v;
1310
1325
  }
1311
- n.splice(1, 0, p), u.splice(1, 0, x), f = -1;
1326
+ n.splice(1, 0, p), u.splice(1, 0, b), f = -1;
1312
1327
  const h = [];
1313
1328
  for (; ++f < n.length; ) {
1314
- const y = n[f], g = u[f];
1315
- s = -1;
1316
- const b = [];
1317
- for (; ++s < l; ) {
1318
- const k = y[s] || "";
1319
- let w = "", A = "";
1329
+ const x = n[f], y = u[f];
1330
+ l = -1;
1331
+ const g = [];
1332
+ for (; ++l < s; ) {
1333
+ const k = x[l] || "";
1334
+ let v = "", M = "";
1320
1335
  if (t.alignDelimiters !== !1) {
1321
- const I = c[s] - (g[s] || 0), T = o[s];
1322
- T === 114 ? w = " ".repeat(I) : T === 99 ? I % 2 ? (w = " ".repeat(I / 2 + 0.5), A = " ".repeat(I / 2 - 0.5)) : (w = " ".repeat(I / 2), A = w) : A = " ".repeat(I);
1336
+ const N = c[l] - (y[l] || 0), A = o[l];
1337
+ A === 114 ? v = " ".repeat(N) : A === 99 ? N % 2 ? (v = " ".repeat(N / 2 + 0.5), M = " ".repeat(N / 2 - 0.5)) : (v = " ".repeat(N / 2), M = v) : M = " ".repeat(N);
1323
1338
  }
1324
- t.delimiterStart !== !1 && !s && b.push("|"), t.padding !== !1 && // Don’t add the opening space if we’re not aligning and the cell is
1339
+ t.delimiterStart !== !1 && !l && g.push("|"), t.padding !== !1 && // Don’t add the opening space if we’re not aligning and the cell is
1325
1340
  // empty: there will be a closing space.
1326
- !(t.alignDelimiters === !1 && k === "") && (t.delimiterStart !== !1 || s) && b.push(" "), t.alignDelimiters !== !1 && b.push(w), b.push(k), t.alignDelimiters !== !1 && b.push(A), t.padding !== !1 && b.push(" "), (t.delimiterEnd !== !1 || s !== l - 1) && b.push("|");
1341
+ !(t.alignDelimiters === !1 && k === "") && (t.delimiterStart !== !1 || l) && g.push(" "), t.alignDelimiters !== !1 && g.push(v), g.push(k), t.alignDelimiters !== !1 && g.push(M), t.padding !== !1 && g.push(" "), (t.delimiterEnd !== !1 || l !== s - 1) && g.push("|");
1327
1342
  }
1328
1343
  h.push(
1329
- t.delimiterEnd === !1 ? b.join("").replace(/ +$/, "") : b.join("")
1344
+ t.delimiterEnd === !1 ? g.join("").replace(/ +$/, "") : g.join("")
1330
1345
  );
1331
1346
  }
1332
1347
  return h.join(`
1333
1348
  `);
1334
1349
  }
1335
- function Za(e) {
1350
+ function Qa(e) {
1336
1351
  return e == null ? "" : String(e);
1337
1352
  }
1338
1353
  function lt(e) {
1339
1354
  const r = typeof e == "string" ? e.codePointAt(0) : 0;
1340
1355
  return r === 67 || r === 99 ? 99 : r === 76 || r === 108 ? 108 : r === 82 || r === 114 ? 114 : 0;
1341
1356
  }
1342
- function Ja(e, r, t, a) {
1357
+ function Ya(e, r, t, a) {
1343
1358
  const i = t.enter("blockquote"), o = t.createTracker(a);
1344
1359
  o.move("> "), o.shift(2);
1345
1360
  const n = t.indentLines(
1346
1361
  t.containerFlow(e, o.current()),
1347
- Qa
1362
+ en
1348
1363
  );
1349
1364
  return i(), n;
1350
1365
  }
1351
- function Qa(e, r, t) {
1366
+ function en(e, r, t) {
1352
1367
  return ">" + (t ? "" : " ") + e;
1353
1368
  }
1354
- function Ya(e, r) {
1355
- return st(e, r.inConstruct, !0) && !st(e, r.notInConstruct, !1);
1369
+ function tn(e, r) {
1370
+ return dt(e, r.inConstruct, !0) && !dt(e, r.notInConstruct, !1);
1356
1371
  }
1357
- function st(e, r, t) {
1372
+ function dt(e, r, t) {
1358
1373
  if (typeof r == "string" && (r = [r]), !r || r.length === 0)
1359
1374
  return t;
1360
1375
  let a = -1;
@@ -1363,16 +1378,16 @@ function st(e, r, t) {
1363
1378
  return !0;
1364
1379
  return !1;
1365
1380
  }
1366
- function dt(e, r, t, a) {
1381
+ function ft(e, r, t, a) {
1367
1382
  let i = -1;
1368
1383
  for (; ++i < t.unsafe.length; )
1369
1384
  if (t.unsafe[i].character === `
1370
- ` && Ya(t.stack, t.unsafe[i]))
1385
+ ` && tn(t.stack, t.unsafe[i]))
1371
1386
  return /[ \t]/.test(a.before) ? "" : " ";
1372
1387
  return `\\
1373
1388
  `;
1374
1389
  }
1375
- function en(e, r) {
1390
+ function rn(e, r) {
1376
1391
  const t = String(e);
1377
1392
  let a = t.indexOf(r), i = a, o = 0, n = 0;
1378
1393
  if (typeof r != "string")
@@ -1381,13 +1396,13 @@ function en(e, r) {
1381
1396
  a === i ? ++o > n && (n = o) : o = 1, i = a + r.length, a = t.indexOf(r, i);
1382
1397
  return n;
1383
1398
  }
1384
- function tn(e, r) {
1399
+ function an(e, r) {
1385
1400
  return !!(r.options.fences === !1 && e.value && // If there’s no info…
1386
1401
  !e.lang && // And there’s a non-whitespace character…
1387
1402
  /[^ \r\n]/.test(e.value) && // And the value doesn’t start or end in a blank…
1388
1403
  !/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value));
1389
1404
  }
1390
- function rn(e) {
1405
+ function nn(e) {
1391
1406
  const r = e.options.fence || "`";
1392
1407
  if (r !== "`" && r !== "~")
1393
1408
  throw new Error(
@@ -1395,16 +1410,16 @@ function rn(e) {
1395
1410
  );
1396
1411
  return r;
1397
1412
  }
1398
- function an(e, r, t, a) {
1399
- const i = rn(t), o = e.value || "", n = i === "`" ? "GraveAccent" : "Tilde";
1400
- if (tn(e, t)) {
1401
- const s = t.enter("codeIndented"), p = t.indentLines(o, nn);
1402
- return s(), p;
1413
+ function on(e, r, t, a) {
1414
+ const i = nn(t), o = e.value || "", n = i === "`" ? "GraveAccent" : "Tilde";
1415
+ if (an(e, t)) {
1416
+ const l = t.enter("codeIndented"), p = t.indentLines(o, cn);
1417
+ return l(), p;
1403
1418
  }
1404
- const u = t.createTracker(a), c = i.repeat(Math.max(en(o, i) + 1, 3)), l = t.enter("codeFenced");
1419
+ const u = t.createTracker(a), c = i.repeat(Math.max(rn(o, i) + 1, 3)), s = t.enter("codeFenced");
1405
1420
  let f = u.move(c);
1406
1421
  if (e.lang) {
1407
- const s = t.enter(`codeFencedLang${n}`);
1422
+ const l = t.enter(`codeFencedLang${n}`);
1408
1423
  f += u.move(
1409
1424
  t.safe(e.lang, {
1410
1425
  before: f,
@@ -1412,10 +1427,10 @@ function an(e, r, t, a) {
1412
1427
  encode: ["`"],
1413
1428
  ...u.current()
1414
1429
  })
1415
- ), s();
1430
+ ), l();
1416
1431
  }
1417
1432
  if (e.lang && e.meta) {
1418
- const s = t.enter(`codeFencedMeta${n}`);
1433
+ const l = t.enter(`codeFencedMeta${n}`);
1419
1434
  f += u.move(" "), f += u.move(
1420
1435
  t.safe(e.meta, {
1421
1436
  before: f,
@@ -1424,16 +1439,16 @@ function an(e, r, t, a) {
1424
1439
  encode: ["`"],
1425
1440
  ...u.current()
1426
1441
  })
1427
- ), s();
1442
+ ), l();
1428
1443
  }
1429
1444
  return f += u.move(`
1430
1445
  `), o && (f += u.move(o + `
1431
- `)), f += u.move(c), l(), f;
1446
+ `)), f += u.move(c), s(), f;
1432
1447
  }
1433
- function nn(e, r, t) {
1448
+ function cn(e, r, t) {
1434
1449
  return (t ? "" : " ") + e;
1435
1450
  }
1436
- function Be(e) {
1451
+ function He(e) {
1437
1452
  const r = e.options.quote || '"';
1438
1453
  if (r !== '"' && r !== "'")
1439
1454
  throw new Error(
@@ -1441,37 +1456,37 @@ function Be(e) {
1441
1456
  );
1442
1457
  return r;
1443
1458
  }
1444
- function on(e, r, t, a) {
1445
- const i = Be(t), o = i === '"' ? "Quote" : "Apostrophe", n = t.enter("definition");
1459
+ function un(e, r, t, a) {
1460
+ const i = He(t), o = i === '"' ? "Quote" : "Apostrophe", n = t.enter("definition");
1446
1461
  let u = t.enter("label");
1447
1462
  const c = t.createTracker(a);
1448
- let l = c.move("[");
1449
- return l += c.move(
1463
+ let s = c.move("[");
1464
+ return s += c.move(
1450
1465
  t.safe(t.associationId(e), {
1451
- before: l,
1466
+ before: s,
1452
1467
  after: "]",
1453
1468
  ...c.current()
1454
1469
  })
1455
- ), l += c.move("]: "), u(), // If there’s no url, or…
1470
+ ), s += c.move("]: "), u(), // If there’s no url, or…
1456
1471
  !e.url || // If there are control characters or whitespace.
1457
- /[\0- \u007F]/.test(e.url) ? (u = t.enter("destinationLiteral"), l += c.move("<"), l += c.move(
1458
- t.safe(e.url, { before: l, after: ">", ...c.current() })
1459
- ), l += c.move(">")) : (u = t.enter("destinationRaw"), l += c.move(
1472
+ /[\0- \u007F]/.test(e.url) ? (u = t.enter("destinationLiteral"), s += c.move("<"), s += c.move(
1473
+ t.safe(e.url, { before: s, after: ">", ...c.current() })
1474
+ ), s += c.move(">")) : (u = t.enter("destinationRaw"), s += c.move(
1460
1475
  t.safe(e.url, {
1461
- before: l,
1476
+ before: s,
1462
1477
  after: e.title ? " " : `
1463
1478
  `,
1464
1479
  ...c.current()
1465
1480
  })
1466
- )), u(), e.title && (u = t.enter(`title${o}`), l += c.move(" " + i), l += c.move(
1481
+ )), u(), e.title && (u = t.enter(`title${o}`), s += c.move(" " + i), s += c.move(
1467
1482
  t.safe(e.title, {
1468
- before: l,
1483
+ before: s,
1469
1484
  after: i,
1470
1485
  ...c.current()
1471
1486
  })
1472
- ), l += c.move(i), u()), n(), l;
1487
+ ), s += c.move(i), u()), n(), s;
1473
1488
  }
1474
- function cn(e) {
1489
+ function sn(e) {
1475
1490
  const r = e.options.emphasis || "*";
1476
1491
  if (r !== "*" && r !== "_")
1477
1492
  throw new Error(
@@ -1479,16 +1494,16 @@ function cn(e) {
1479
1494
  );
1480
1495
  return r;
1481
1496
  }
1482
- function le(e) {
1497
+ function se(e) {
1483
1498
  return "&#x" + e.toString(16).toUpperCase() + ";";
1484
1499
  }
1485
1500
  function xe(e) {
1486
- if (e === null || F(e) || V(e))
1501
+ if (e === null || _(e) || K(e))
1487
1502
  return 1;
1488
- if (ke(e))
1503
+ if (we(e))
1489
1504
  return 2;
1490
1505
  }
1491
- function ye(e, r, t) {
1506
+ function ke(e, r, t) {
1492
1507
  const a = xe(e), i = xe(r);
1493
1508
  return a === void 0 ? i === void 0 ? (
1494
1509
  // Letter inside:
@@ -1521,9 +1536,9 @@ function ye(e, r, t) {
1521
1536
  { inside: !1, outside: !1 }
1522
1537
  );
1523
1538
  }
1524
- jt.peek = un;
1525
- function jt(e, r, t, a) {
1526
- const i = cn(t), o = t.enter("emphasis"), n = t.createTracker(a), u = n.move(i);
1539
+ $t.peek = ln;
1540
+ function $t(e, r, t, a) {
1541
+ const i = sn(t), o = t.enter("emphasis"), n = t.createTracker(a), u = n.move(i);
1527
1542
  let c = n.move(
1528
1543
  t.containerPhrasing(e, {
1529
1544
  after: i,
@@ -1531,75 +1546,75 @@ function jt(e, r, t, a) {
1531
1546
  ...n.current()
1532
1547
  })
1533
1548
  );
1534
- const l = c.charCodeAt(0), f = ye(
1549
+ const s = c.charCodeAt(0), f = ke(
1535
1550
  a.before.charCodeAt(a.before.length - 1),
1536
- l,
1551
+ s,
1537
1552
  i
1538
1553
  );
1539
- f.inside && (c = le(l) + c.slice(1));
1540
- const s = c.charCodeAt(c.length - 1), p = ye(a.after.charCodeAt(0), s, i);
1541
- p.inside && (c = c.slice(0, -1) + le(s));
1542
- const x = n.move(i);
1554
+ f.inside && (c = se(s) + c.slice(1));
1555
+ const l = c.charCodeAt(c.length - 1), p = ke(a.after.charCodeAt(0), l, i);
1556
+ p.inside && (c = c.slice(0, -1) + se(l));
1557
+ const b = n.move(i);
1543
1558
  return o(), t.attentionEncodeSurroundingInfo = {
1544
1559
  after: p.outside,
1545
1560
  before: f.outside
1546
- }, u + c + x;
1561
+ }, u + c + b;
1547
1562
  }
1548
- function un(e, r, t) {
1563
+ function ln(e, r, t) {
1549
1564
  return t.options.emphasis || "*";
1550
1565
  }
1551
- function ln(e, r, t, a) {
1566
+ function dn(e, r, t, a) {
1552
1567
  let i, o, n;
1553
- typeof r == "function" && typeof t != "function" ? (o = void 0, n = r, i = t) : (o = r, n = t, i = a), Pt(e, o, u, i);
1554
- function u(c, l) {
1555
- const f = l[l.length - 1], s = f ? f.children.indexOf(c) : void 0;
1556
- return n(c, s, f);
1568
+ typeof r == "function" && typeof t != "function" ? (o = void 0, n = r, i = t) : (o = r, n = t, i = a), Et(e, o, u, i);
1569
+ function u(c, s) {
1570
+ const f = s[s.length - 1], l = f ? f.children.indexOf(c) : void 0;
1571
+ return n(c, l, f);
1557
1572
  }
1558
1573
  }
1559
- const sn = {};
1560
- function $t(e, r) {
1561
- const t = sn, a = typeof t.includeImageAlt == "boolean" ? t.includeImageAlt : !0, i = typeof t.includeHtml == "boolean" ? t.includeHtml : !0;
1562
- return Ot(e, a, i);
1574
+ const fn = {};
1575
+ function Ot(e, r) {
1576
+ const t = fn, a = typeof t.includeImageAlt == "boolean" ? t.includeImageAlt : !0, i = typeof t.includeHtml == "boolean" ? t.includeHtml : !0;
1577
+ return Ut(e, a, i);
1563
1578
  }
1564
- function Ot(e, r, t) {
1565
- if (dn(e)) {
1579
+ function Ut(e, r, t) {
1580
+ if (hn(e)) {
1566
1581
  if ("value" in e)
1567
1582
  return e.type === "html" && !t ? "" : e.value;
1568
1583
  if (r && "alt" in e && e.alt)
1569
1584
  return e.alt;
1570
1585
  if ("children" in e)
1571
- return ft(e.children, r, t);
1586
+ return ht(e.children, r, t);
1572
1587
  }
1573
- return Array.isArray(e) ? ft(e, r, t) : "";
1588
+ return Array.isArray(e) ? ht(e, r, t) : "";
1574
1589
  }
1575
- function ft(e, r, t) {
1590
+ function ht(e, r, t) {
1576
1591
  const a = [];
1577
1592
  let i = -1;
1578
1593
  for (; ++i < e.length; )
1579
- a[i] = Ot(e[i], r, t);
1594
+ a[i] = Ut(e[i], r, t);
1580
1595
  return a.join("");
1581
1596
  }
1582
- function dn(e) {
1597
+ function hn(e) {
1583
1598
  return !!(e && typeof e == "object");
1584
1599
  }
1585
- function fn(e, r) {
1600
+ function mn(e, r) {
1586
1601
  let t = !1;
1587
- return ln(e, function(a) {
1602
+ return dn(e, function(a) {
1588
1603
  if ("value" in a && /\r?\n|\r/.test(a.value) || a.type === "break")
1589
- return t = !0, $e;
1590
- }), !!((!e.depth || e.depth < 3) && $t(e) && (r.options.setext || t));
1604
+ return t = !0, Oe;
1605
+ }), !!((!e.depth || e.depth < 3) && Ot(e) && (r.options.setext || t));
1591
1606
  }
1592
- function hn(e, r, t, a) {
1607
+ function pn(e, r, t, a) {
1593
1608
  const i = Math.max(Math.min(6, e.depth || 1), 1), o = t.createTracker(a);
1594
- if (fn(e, t)) {
1595
- const f = t.enter("headingSetext"), s = t.enter("phrasing"), p = t.containerPhrasing(e, {
1609
+ if (mn(e, t)) {
1610
+ const f = t.enter("headingSetext"), l = t.enter("phrasing"), p = t.containerPhrasing(e, {
1596
1611
  ...o.current(),
1597
1612
  before: `
1598
1613
  `,
1599
1614
  after: `
1600
1615
  `
1601
1616
  });
1602
- return s(), f(), p + `
1617
+ return l(), f(), p + `
1603
1618
  ` + (i === 1 ? "=" : "-").repeat(
1604
1619
  // The whole size…
1605
1620
  p.length - // Minus the position of the character after the last EOL (or
@@ -1610,76 +1625,76 @@ function hn(e, r, t, a) {
1610
1625
  }
1611
1626
  const n = "#".repeat(i), u = t.enter("headingAtx"), c = t.enter("phrasing");
1612
1627
  o.move(n + " ");
1613
- let l = t.containerPhrasing(e, {
1628
+ let s = t.containerPhrasing(e, {
1614
1629
  before: "# ",
1615
1630
  after: `
1616
1631
  `,
1617
1632
  ...o.current()
1618
1633
  });
1619
- return /^[\t ]/.test(l) && (l = le(l.charCodeAt(0)) + l.slice(1)), l = l ? n + " " + l : n, t.options.closeAtx && (l += " " + n), c(), u(), l;
1634
+ return /^[\t ]/.test(s) && (s = se(s.charCodeAt(0)) + s.slice(1)), s = s ? n + " " + s : n, t.options.closeAtx && (s += " " + n), c(), u(), s;
1620
1635
  }
1621
- Ut.peek = mn;
1622
- function Ut(e) {
1636
+ Wt.peek = gn;
1637
+ function Wt(e) {
1623
1638
  return e.value || "";
1624
1639
  }
1625
- function mn() {
1640
+ function gn() {
1626
1641
  return "<";
1627
1642
  }
1628
- Wt.peek = pn;
1629
- function Wt(e, r, t, a) {
1630
- const i = Be(t), o = i === '"' ? "Quote" : "Apostrophe", n = t.enter("image");
1643
+ Bt.peek = bn;
1644
+ function Bt(e, r, t, a) {
1645
+ const i = He(t), o = i === '"' ? "Quote" : "Apostrophe", n = t.enter("image");
1631
1646
  let u = t.enter("label");
1632
1647
  const c = t.createTracker(a);
1633
- let l = c.move("![");
1634
- return l += c.move(
1635
- t.safe(e.alt, { before: l, after: "]", ...c.current() })
1636
- ), l += c.move("]("), u(), // If there’s no url but there is a title…
1648
+ let s = c.move("![");
1649
+ return s += c.move(
1650
+ t.safe(e.alt, { before: s, after: "]", ...c.current() })
1651
+ ), s += c.move("]("), u(), // If there’s no url but there is a title…
1637
1652
  !e.url && e.title || // If there are control characters or whitespace.
1638
- /[\0- \u007F]/.test(e.url) ? (u = t.enter("destinationLiteral"), l += c.move("<"), l += c.move(
1639
- t.safe(e.url, { before: l, after: ">", ...c.current() })
1640
- ), l += c.move(">")) : (u = t.enter("destinationRaw"), l += c.move(
1653
+ /[\0- \u007F]/.test(e.url) ? (u = t.enter("destinationLiteral"), s += c.move("<"), s += c.move(
1654
+ t.safe(e.url, { before: s, after: ">", ...c.current() })
1655
+ ), s += c.move(">")) : (u = t.enter("destinationRaw"), s += c.move(
1641
1656
  t.safe(e.url, {
1642
- before: l,
1657
+ before: s,
1643
1658
  after: e.title ? " " : ")",
1644
1659
  ...c.current()
1645
1660
  })
1646
- )), u(), e.title && (u = t.enter(`title${o}`), l += c.move(" " + i), l += c.move(
1661
+ )), u(), e.title && (u = t.enter(`title${o}`), s += c.move(" " + i), s += c.move(
1647
1662
  t.safe(e.title, {
1648
- before: l,
1663
+ before: s,
1649
1664
  after: i,
1650
1665
  ...c.current()
1651
1666
  })
1652
- ), l += c.move(i), u()), l += c.move(")"), n(), l;
1667
+ ), s += c.move(i), u()), s += c.move(")"), n(), s;
1653
1668
  }
1654
- function pn() {
1669
+ function bn() {
1655
1670
  return "!";
1656
1671
  }
1657
- Bt.peek = gn;
1658
- function Bt(e, r, t, a) {
1672
+ Ht.peek = yn;
1673
+ function Ht(e, r, t, a) {
1659
1674
  const i = e.referenceType, o = t.enter("imageReference");
1660
1675
  let n = t.enter("label");
1661
1676
  const u = t.createTracker(a);
1662
1677
  let c = u.move("![");
1663
- const l = t.safe(e.alt, {
1678
+ const s = t.safe(e.alt, {
1664
1679
  before: c,
1665
1680
  after: "]",
1666
1681
  ...u.current()
1667
1682
  });
1668
- c += u.move(l + "]["), n();
1683
+ c += u.move(s + "]["), n();
1669
1684
  const f = t.stack;
1670
1685
  t.stack = [], n = t.enter("reference");
1671
- const s = t.safe(t.associationId(e), {
1686
+ const l = t.safe(t.associationId(e), {
1672
1687
  before: c,
1673
1688
  after: "]",
1674
1689
  ...u.current()
1675
1690
  });
1676
- return n(), t.stack = f, o(), i === "full" || !l || l !== s ? c += u.move(s + "]") : i === "shortcut" ? c = c.slice(0, -1) : c += u.move("]"), c;
1691
+ return n(), t.stack = f, o(), i === "full" || !s || s !== l ? c += u.move(l + "]") : i === "shortcut" ? c = c.slice(0, -1) : c += u.move("]"), c;
1677
1692
  }
1678
- function gn() {
1693
+ function yn() {
1679
1694
  return "!";
1680
1695
  }
1681
- Ht.peek = bn;
1682
- function Ht(e, r, t) {
1696
+ qt.peek = xn;
1697
+ function qt(e, r, t) {
1683
1698
  let a = e.value || "", i = "`", o = -1;
1684
1699
  for (; new RegExp("(^|[^`])" + i + "([^`]|$)").test(a); )
1685
1700
  i += "`";
@@ -1688,17 +1703,17 @@ function Ht(e, r, t) {
1688
1703
  let c;
1689
1704
  if (n.atBreak)
1690
1705
  for (; c = u.exec(a); ) {
1691
- let l = c.index;
1692
- a.charCodeAt(l) === 10 && a.charCodeAt(l - 1) === 13 && l--, a = a.slice(0, l) + " " + a.slice(c.index + 1);
1706
+ let s = c.index;
1707
+ a.charCodeAt(s) === 10 && a.charCodeAt(s - 1) === 13 && s--, a = a.slice(0, s) + " " + a.slice(c.index + 1);
1693
1708
  }
1694
1709
  }
1695
1710
  return i + a + i;
1696
1711
  }
1697
- function bn() {
1712
+ function xn() {
1698
1713
  return "`";
1699
1714
  }
1700
- function qt(e, r) {
1701
- const t = $t(e);
1715
+ function Vt(e, r) {
1716
+ const t = Ot(e);
1702
1717
  return !!(!r.options.resourceLink && // If there’s a url…
1703
1718
  e.url && // And there’s a no title…
1704
1719
  !e.title && // And the content of `node` is a single text node…
@@ -1708,76 +1723,76 @@ function qt(e, r) {
1708
1723
  // references don’t work), space, or angle brackets…
1709
1724
  !/[\0- <>\u007F]/.test(e.url));
1710
1725
  }
1711
- Xt.peek = xn;
1726
+ Xt.peek = kn;
1712
1727
  function Xt(e, r, t, a) {
1713
- const i = Be(t), o = i === '"' ? "Quote" : "Apostrophe", n = t.createTracker(a);
1728
+ const i = He(t), o = i === '"' ? "Quote" : "Apostrophe", n = t.createTracker(a);
1714
1729
  let u, c;
1715
- if (qt(e, t)) {
1730
+ if (Vt(e, t)) {
1716
1731
  const f = t.stack;
1717
1732
  t.stack = [], u = t.enter("autolink");
1718
- let s = n.move("<");
1719
- return s += n.move(
1733
+ let l = n.move("<");
1734
+ return l += n.move(
1720
1735
  t.containerPhrasing(e, {
1721
- before: s,
1736
+ before: l,
1722
1737
  after: ">",
1723
1738
  ...n.current()
1724
1739
  })
1725
- ), s += n.move(">"), u(), t.stack = f, s;
1740
+ ), l += n.move(">"), u(), t.stack = f, l;
1726
1741
  }
1727
1742
  u = t.enter("link"), c = t.enter("label");
1728
- let l = n.move("[");
1729
- return l += n.move(
1743
+ let s = n.move("[");
1744
+ return s += n.move(
1730
1745
  t.containerPhrasing(e, {
1731
- before: l,
1746
+ before: s,
1732
1747
  after: "](",
1733
1748
  ...n.current()
1734
1749
  })
1735
- ), l += n.move("]("), c(), // If there’s no url but there is a title…
1750
+ ), s += n.move("]("), c(), // If there’s no url but there is a title…
1736
1751
  !e.url && e.title || // If there are control characters or whitespace.
1737
- /[\0- \u007F]/.test(e.url) ? (c = t.enter("destinationLiteral"), l += n.move("<"), l += n.move(
1738
- t.safe(e.url, { before: l, after: ">", ...n.current() })
1739
- ), l += n.move(">")) : (c = t.enter("destinationRaw"), l += n.move(
1752
+ /[\0- \u007F]/.test(e.url) ? (c = t.enter("destinationLiteral"), s += n.move("<"), s += n.move(
1753
+ t.safe(e.url, { before: s, after: ">", ...n.current() })
1754
+ ), s += n.move(">")) : (c = t.enter("destinationRaw"), s += n.move(
1740
1755
  t.safe(e.url, {
1741
- before: l,
1756
+ before: s,
1742
1757
  after: e.title ? " " : ")",
1743
1758
  ...n.current()
1744
1759
  })
1745
- )), c(), e.title && (c = t.enter(`title${o}`), l += n.move(" " + i), l += n.move(
1760
+ )), c(), e.title && (c = t.enter(`title${o}`), s += n.move(" " + i), s += n.move(
1746
1761
  t.safe(e.title, {
1747
- before: l,
1762
+ before: s,
1748
1763
  after: i,
1749
1764
  ...n.current()
1750
1765
  })
1751
- ), l += n.move(i), c()), l += n.move(")"), u(), l;
1766
+ ), s += n.move(i), c()), s += n.move(")"), u(), s;
1752
1767
  }
1753
- function xn(e, r, t) {
1754
- return qt(e, t) ? "<" : "[";
1768
+ function kn(e, r, t) {
1769
+ return Vt(e, t) ? "<" : "[";
1755
1770
  }
1756
- Kt.peek = yn;
1771
+ Kt.peek = wn;
1757
1772
  function Kt(e, r, t, a) {
1758
1773
  const i = e.referenceType, o = t.enter("linkReference");
1759
1774
  let n = t.enter("label");
1760
1775
  const u = t.createTracker(a);
1761
1776
  let c = u.move("[");
1762
- const l = t.containerPhrasing(e, {
1777
+ const s = t.containerPhrasing(e, {
1763
1778
  before: c,
1764
1779
  after: "]",
1765
1780
  ...u.current()
1766
1781
  });
1767
- c += u.move(l + "]["), n();
1782
+ c += u.move(s + "]["), n();
1768
1783
  const f = t.stack;
1769
1784
  t.stack = [], n = t.enter("reference");
1770
- const s = t.safe(t.associationId(e), {
1785
+ const l = t.safe(t.associationId(e), {
1771
1786
  before: c,
1772
1787
  after: "]",
1773
1788
  ...u.current()
1774
1789
  });
1775
- return n(), t.stack = f, o(), i === "full" || !l || l !== s ? c += u.move(s + "]") : i === "shortcut" ? c = c.slice(0, -1) : c += u.move("]"), c;
1790
+ return n(), t.stack = f, o(), i === "full" || !s || s !== l ? c += u.move(l + "]") : i === "shortcut" ? c = c.slice(0, -1) : c += u.move("]"), c;
1776
1791
  }
1777
- function yn() {
1792
+ function wn() {
1778
1793
  return "[";
1779
1794
  }
1780
- function He(e) {
1795
+ function qe(e) {
1781
1796
  const r = e.options.bullet || "*";
1782
1797
  if (r !== "*" && r !== "+" && r !== "-")
1783
1798
  throw new Error(
@@ -1785,8 +1800,8 @@ function He(e) {
1785
1800
  );
1786
1801
  return r;
1787
1802
  }
1788
- function kn(e) {
1789
- const r = He(e), t = e.options.bulletOther;
1803
+ function vn(e) {
1804
+ const r = qe(e), t = e.options.bulletOther;
1790
1805
  if (!t)
1791
1806
  return r === "*" ? "-" : "*";
1792
1807
  if (t !== "*" && t !== "+" && t !== "-")
@@ -1799,7 +1814,7 @@ function kn(e) {
1799
1814
  );
1800
1815
  return t;
1801
1816
  }
1802
- function wn(e) {
1817
+ function Cn(e) {
1803
1818
  const r = e.options.bulletOrdered || ".";
1804
1819
  if (r !== "." && r !== ")")
1805
1820
  throw new Error(
@@ -1807,7 +1822,7 @@ function wn(e) {
1807
1822
  );
1808
1823
  return r;
1809
1824
  }
1810
- function Vt(e) {
1825
+ function Gt(e) {
1811
1826
  const r = e.options.rule || "*";
1812
1827
  if (r !== "*" && r !== "-" && r !== "_")
1813
1828
  throw new Error(
@@ -1815,10 +1830,10 @@ function Vt(e) {
1815
1830
  );
1816
1831
  return r;
1817
1832
  }
1818
- function Cn(e, r, t, a) {
1833
+ function Tn(e, r, t, a) {
1819
1834
  const i = t.enter("list"), o = t.bulletCurrent;
1820
- let n = e.ordered ? wn(t) : He(t);
1821
- const u = e.ordered ? n === "." ? ")" : "." : kn(t);
1835
+ let n = e.ordered ? Cn(t) : qe(t);
1836
+ const u = e.ordered ? n === "." ? ")" : "." : vn(t);
1822
1837
  let c = r && t.bulletLastUsed ? n === t.bulletLastUsed : !1;
1823
1838
  if (!e.ordered) {
1824
1839
  const f = e.children ? e.children[0] : void 0;
@@ -1827,11 +1842,11 @@ function Cn(e, r, t, a) {
1827
1842
  (n === "*" || n === "-") && // Empty first list item:
1828
1843
  f && (!f.children || !f.children[0]) && // Directly in two other list items:
1829
1844
  t.stack[t.stack.length - 1] === "list" && t.stack[t.stack.length - 2] === "listItem" && t.stack[t.stack.length - 3] === "list" && t.stack[t.stack.length - 4] === "listItem" && // That are each the first child.
1830
- t.indexStack[t.indexStack.length - 1] === 0 && t.indexStack[t.indexStack.length - 2] === 0 && t.indexStack[t.indexStack.length - 3] === 0 && (c = !0), Vt(t) === n && f
1845
+ t.indexStack[t.indexStack.length - 1] === 0 && t.indexStack[t.indexStack.length - 2] === 0 && t.indexStack[t.indexStack.length - 3] === 0 && (c = !0), Gt(t) === n && f
1831
1846
  ) {
1832
- let s = -1;
1833
- for (; ++s < e.children.length; ) {
1834
- const p = e.children[s];
1847
+ let l = -1;
1848
+ for (; ++l < e.children.length; ) {
1849
+ const p = e.children[l];
1835
1850
  if (p && p.type === "listItem" && p.children && p.children[0] && p.children[0].type === "thematicBreak") {
1836
1851
  c = !0;
1837
1852
  break;
@@ -1840,10 +1855,10 @@ function Cn(e, r, t, a) {
1840
1855
  }
1841
1856
  }
1842
1857
  c && (n = u), t.bulletCurrent = n;
1843
- const l = t.containerFlow(e, a);
1844
- return t.bulletLastUsed = n, t.bulletCurrent = o, i(), l;
1858
+ const s = t.containerFlow(e, a);
1859
+ return t.bulletLastUsed = n, t.bulletCurrent = o, i(), s;
1845
1860
  }
1846
- function vn(e) {
1861
+ function An(e) {
1847
1862
  const r = e.options.listItemIndent || "one";
1848
1863
  if (r !== "tab" && r !== "one" && r !== "mixed")
1849
1864
  throw new Error(
@@ -1851,28 +1866,28 @@ function vn(e) {
1851
1866
  );
1852
1867
  return r;
1853
1868
  }
1854
- function Tn(e, r, t, a) {
1855
- const i = vn(t);
1856
- let o = t.bulletCurrent || He(t);
1869
+ function Nn(e, r, t, a) {
1870
+ const i = An(t);
1871
+ let o = t.bulletCurrent || qe(t);
1857
1872
  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);
1858
1873
  let n = o.length + 1;
1859
1874
  (i === "tab" || i === "mixed" && (r && r.type === "list" && r.spread || e.spread)) && (n = Math.ceil(n / 4) * 4);
1860
1875
  const u = t.createTracker(a);
1861
1876
  u.move(o + " ".repeat(n - o.length)), u.shift(n);
1862
- const c = t.enter("listItem"), l = t.indentLines(
1877
+ const c = t.enter("listItem"), s = t.indentLines(
1863
1878
  t.containerFlow(e, u.current()),
1864
1879
  f
1865
1880
  );
1866
- return c(), l;
1867
- function f(s, p, x) {
1868
- return p ? (x ? "" : " ".repeat(n)) + s : (x ? o : o + " ".repeat(n - o.length)) + s;
1881
+ return c(), s;
1882
+ function f(l, p, b) {
1883
+ return p ? (b ? "" : " ".repeat(n)) + l : (b ? o : o + " ".repeat(n - o.length)) + l;
1869
1884
  }
1870
1885
  }
1871
- function An(e, r, t, a) {
1886
+ function In(e, r, t, a) {
1872
1887
  const i = t.enter("paragraph"), o = t.enter("phrasing"), n = t.containerPhrasing(e, a);
1873
1888
  return o(), i(), n;
1874
1889
  }
1875
- const Nn = (
1890
+ const Sn = (
1876
1891
  /** @type {(node?: unknown) => node is Exclude<PhrasingContent, Html>} */
1877
1892
  Ce([
1878
1893
  "break",
@@ -1898,12 +1913,12 @@ const Nn = (
1898
1913
  "textDirective"
1899
1914
  ])
1900
1915
  );
1901
- function In(e, r, t, a) {
1916
+ function Mn(e, r, t, a) {
1902
1917
  return (e.children.some(function(n) {
1903
- return Nn(n);
1918
+ return Sn(n);
1904
1919
  }) ? t.containerPhrasing : t.containerFlow).call(t, e, a);
1905
1920
  }
1906
- function Sn(e) {
1921
+ function Ln(e) {
1907
1922
  const r = e.options.strong || "*";
1908
1923
  if (r !== "*" && r !== "_")
1909
1924
  throw new Error(
@@ -1911,9 +1926,9 @@ function Sn(e) {
1911
1926
  );
1912
1927
  return r;
1913
1928
  }
1914
- Gt.peek = Mn;
1915
- function Gt(e, r, t, a) {
1916
- const i = Sn(t), o = t.enter("strong"), n = t.createTracker(a), u = n.move(i + i);
1929
+ Zt.peek = Dn;
1930
+ function Zt(e, r, t, a) {
1931
+ const i = Ln(t), o = t.enter("strong"), n = t.createTracker(a), u = n.move(i + i);
1917
1932
  let c = n.move(
1918
1933
  t.containerPhrasing(e, {
1919
1934
  after: i,
@@ -1921,27 +1936,27 @@ function Gt(e, r, t, a) {
1921
1936
  ...n.current()
1922
1937
  })
1923
1938
  );
1924
- const l = c.charCodeAt(0), f = ye(
1939
+ const s = c.charCodeAt(0), f = ke(
1925
1940
  a.before.charCodeAt(a.before.length - 1),
1926
- l,
1941
+ s,
1927
1942
  i
1928
1943
  );
1929
- f.inside && (c = le(l) + c.slice(1));
1930
- const s = c.charCodeAt(c.length - 1), p = ye(a.after.charCodeAt(0), s, i);
1931
- p.inside && (c = c.slice(0, -1) + le(s));
1932
- const x = n.move(i + i);
1944
+ f.inside && (c = se(s) + c.slice(1));
1945
+ const l = c.charCodeAt(c.length - 1), p = ke(a.after.charCodeAt(0), l, i);
1946
+ p.inside && (c = c.slice(0, -1) + se(l));
1947
+ const b = n.move(i + i);
1933
1948
  return o(), t.attentionEncodeSurroundingInfo = {
1934
1949
  after: p.outside,
1935
1950
  before: f.outside
1936
- }, u + c + x;
1951
+ }, u + c + b;
1937
1952
  }
1938
- function Mn(e, r, t) {
1953
+ function Dn(e, r, t) {
1939
1954
  return t.options.strong || "*";
1940
1955
  }
1941
- function Ln(e, r, t, a) {
1956
+ function Rn(e, r, t, a) {
1942
1957
  return t.safe(e.value, a);
1943
1958
  }
1944
- function Dn(e) {
1959
+ function Pn(e) {
1945
1960
  const r = e.options.ruleRepetition || 3;
1946
1961
  if (r < 3)
1947
1962
  throw new Error(
@@ -1949,46 +1964,46 @@ function Dn(e) {
1949
1964
  );
1950
1965
  return r;
1951
1966
  }
1952
- function Rn(e, r, t) {
1953
- const a = (Vt(t) + (t.options.ruleSpaces ? " " : "")).repeat(Dn(t));
1967
+ function En(e, r, t) {
1968
+ const a = (Gt(t) + (t.options.ruleSpaces ? " " : "")).repeat(Pn(t));
1954
1969
  return t.options.ruleSpaces ? a.slice(0, -1) : a;
1955
1970
  }
1956
- const Zt = {
1957
- blockquote: Ja,
1958
- break: dt,
1959
- code: an,
1960
- definition: on,
1961
- emphasis: jt,
1962
- hardBreak: dt,
1963
- heading: hn,
1964
- html: Ut,
1965
- image: Wt,
1966
- imageReference: Bt,
1967
- inlineCode: Ht,
1971
+ const Jt = {
1972
+ blockquote: Ya,
1973
+ break: ft,
1974
+ code: on,
1975
+ definition: un,
1976
+ emphasis: $t,
1977
+ hardBreak: ft,
1978
+ heading: pn,
1979
+ html: Wt,
1980
+ image: Bt,
1981
+ imageReference: Ht,
1982
+ inlineCode: qt,
1968
1983
  link: Xt,
1969
1984
  linkReference: Kt,
1970
- list: Cn,
1971
- listItem: Tn,
1972
- paragraph: An,
1973
- root: In,
1974
- strong: Gt,
1975
- text: Ln,
1976
- thematicBreak: Rn
1985
+ list: Tn,
1986
+ listItem: Nn,
1987
+ paragraph: In,
1988
+ root: Mn,
1989
+ strong: Zt,
1990
+ text: Rn,
1991
+ thematicBreak: En
1977
1992
  };
1978
- function Pn() {
1993
+ function _n() {
1979
1994
  return {
1980
1995
  enter: {
1981
1996
  table: Fn,
1982
- tableData: ht,
1983
- tableHeader: ht,
1984
- tableRow: En
1997
+ tableData: mt,
1998
+ tableHeader: mt,
1999
+ tableRow: zn
1985
2000
  },
1986
2001
  exit: {
1987
- codeText: zn,
1988
- table: _n,
1989
- tableData: Pe,
1990
- tableHeader: Pe,
1991
- tableRow: Pe
2002
+ codeText: $n,
2003
+ table: jn,
2004
+ tableData: Ee,
2005
+ tableHeader: Ee,
2006
+ tableRow: Ee
1992
2007
  }
1993
2008
  };
1994
2009
  }
@@ -2005,28 +2020,28 @@ function Fn(e) {
2005
2020
  e
2006
2021
  ), this.data.inTable = !0;
2007
2022
  }
2008
- function _n(e) {
2023
+ function jn(e) {
2009
2024
  this.exit(e), this.data.inTable = void 0;
2010
2025
  }
2011
- function En(e) {
2026
+ function zn(e) {
2012
2027
  this.enter({ type: "tableRow", children: [] }, e);
2013
2028
  }
2014
- function Pe(e) {
2029
+ function Ee(e) {
2015
2030
  this.exit(e);
2016
2031
  }
2017
- function ht(e) {
2032
+ function mt(e) {
2018
2033
  this.enter({ type: "tableCell", children: [] }, e);
2019
2034
  }
2020
- function zn(e) {
2035
+ function $n(e) {
2021
2036
  let r = this.resume();
2022
- this.data.inTable && (r = r.replace(/\\([\\|])/g, jn));
2037
+ this.data.inTable && (r = r.replace(/\\([\\|])/g, On));
2023
2038
  const t = this.stack[this.stack.length - 1];
2024
2039
  t.type, t.value = r, this.exit(e);
2025
2040
  }
2026
- function jn(e, r) {
2041
+ function On(e, r) {
2027
2042
  return r === "|" ? r : e;
2028
2043
  }
2029
- function $n(e) {
2044
+ function Un(e) {
2030
2045
  const r = e || {}, t = r.tableCellPadding, a = r.tablePipeAlign, i = r.stringLength, o = t ? " " : "|";
2031
2046
  return {
2032
2047
  unsafe: [
@@ -2055,24 +2070,24 @@ function $n(e) {
2055
2070
  tableRow: u
2056
2071
  }
2057
2072
  };
2058
- function n(x, h, y, g) {
2059
- return l(f(x, y, g), x.align);
2073
+ function n(b, h, x, y) {
2074
+ return s(f(b, x, y), b.align);
2060
2075
  }
2061
- function u(x, h, y, g) {
2062
- const b = s(x, y, g), k = l([b]);
2076
+ function u(b, h, x, y) {
2077
+ const g = l(b, x, y), k = s([g]);
2063
2078
  return k.slice(0, k.indexOf(`
2064
2079
  `));
2065
2080
  }
2066
- function c(x, h, y, g) {
2067
- const b = y.enter("tableCell"), k = y.enter("phrasing"), w = y.containerPhrasing(x, {
2068
- ...g,
2081
+ function c(b, h, x, y) {
2082
+ const g = x.enter("tableCell"), k = x.enter("phrasing"), v = x.containerPhrasing(b, {
2083
+ ...y,
2069
2084
  before: o,
2070
2085
  after: o
2071
2086
  });
2072
- return k(), b(), w;
2087
+ return k(), g(), v;
2073
2088
  }
2074
- function l(x, h) {
2075
- return Ga(x, {
2089
+ function s(b, h) {
2090
+ return Ja(b, {
2076
2091
  align: h,
2077
2092
  // @ts-expect-error: `markdown-table` types should support `null`.
2078
2093
  alignDelimiters: a,
@@ -2082,47 +2097,47 @@ function $n(e) {
2082
2097
  stringLength: i
2083
2098
  });
2084
2099
  }
2085
- function f(x, h, y) {
2086
- const g = x.children;
2087
- let b = -1;
2088
- const k = [], w = h.enter("table");
2089
- for (; ++b < g.length; )
2090
- k[b] = s(g[b], h, y);
2091
- return w(), k;
2100
+ function f(b, h, x) {
2101
+ const y = b.children;
2102
+ let g = -1;
2103
+ const k = [], v = h.enter("table");
2104
+ for (; ++g < y.length; )
2105
+ k[g] = l(y[g], h, x);
2106
+ return v(), k;
2092
2107
  }
2093
- function s(x, h, y) {
2094
- const g = x.children;
2095
- let b = -1;
2096
- const k = [], w = h.enter("tableRow");
2097
- for (; ++b < g.length; )
2098
- k[b] = c(g[b], x, h, y);
2099
- return w(), k;
2108
+ function l(b, h, x) {
2109
+ const y = b.children;
2110
+ let g = -1;
2111
+ const k = [], v = h.enter("tableRow");
2112
+ for (; ++g < y.length; )
2113
+ k[g] = c(y[g], b, h, x);
2114
+ return v(), k;
2100
2115
  }
2101
- function p(x, h, y) {
2102
- let g = Zt.inlineCode(x, h, y);
2103
- return y.stack.includes("tableCell") && (g = g.replace(/\|/g, "\\$&")), g;
2116
+ function p(b, h, x) {
2117
+ let y = Jt.inlineCode(b, h, x);
2118
+ return x.stack.includes("tableCell") && (y = y.replace(/\|/g, "\\$&")), y;
2104
2119
  }
2105
2120
  }
2106
- function On() {
2121
+ function Wn() {
2107
2122
  return {
2108
2123
  exit: {
2109
- taskListCheckValueChecked: mt,
2110
- taskListCheckValueUnchecked: mt,
2111
- paragraph: Wn
2124
+ taskListCheckValueChecked: pt,
2125
+ taskListCheckValueUnchecked: pt,
2126
+ paragraph: Hn
2112
2127
  }
2113
2128
  };
2114
2129
  }
2115
- function Un() {
2130
+ function Bn() {
2116
2131
  return {
2117
2132
  unsafe: [{ atBreak: !0, character: "-", after: "[:|-]" }],
2118
- handlers: { listItem: Bn }
2133
+ handlers: { listItem: qn }
2119
2134
  };
2120
2135
  }
2121
- function mt(e) {
2136
+ function pt(e) {
2122
2137
  const r = this.stack[this.stack.length - 2];
2123
2138
  r.type, r.checked = e.type === "taskListCheckValueChecked";
2124
2139
  }
2125
- function Wn(e) {
2140
+ function Hn(e) {
2126
2141
  const r = this.stack[this.stack.length - 2];
2127
2142
  if (r && r.type === "listItem" && typeof r.checked == "boolean") {
2128
2143
  const t = this.stack[this.stack.length - 1];
@@ -2143,35 +2158,35 @@ function Wn(e) {
2143
2158
  }
2144
2159
  this.exit(e);
2145
2160
  }
2146
- function Bn(e, r, t, a) {
2161
+ function qn(e, r, t, a) {
2147
2162
  const i = e.children[0], o = typeof e.checked == "boolean" && i && i.type === "paragraph", n = "[" + (e.checked ? "x" : " ") + "] ", u = t.createTracker(a);
2148
2163
  o && u.move(n);
2149
- let c = Zt.listItem(e, r, t, {
2164
+ let c = Jt.listItem(e, r, t, {
2150
2165
  ...a,
2151
2166
  ...u.current()
2152
2167
  });
2153
- return o && (c = c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/, l)), c;
2154
- function l(f) {
2168
+ return o && (c = c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/, s)), c;
2169
+ function s(f) {
2155
2170
  return f + n;
2156
2171
  }
2157
2172
  }
2158
- function Hn() {
2173
+ function Vn() {
2159
2174
  return [
2160
- xa(),
2161
- $a(),
2162
- Ba(),
2163
- Pn(),
2164
- On()
2175
+ ka(),
2176
+ Ua(),
2177
+ qa(),
2178
+ _n(),
2179
+ Wn()
2165
2180
  ];
2166
2181
  }
2167
- function qn(e) {
2182
+ function Xn(e) {
2168
2183
  return {
2169
2184
  extensions: [
2170
- ya(),
2171
- Oa(e),
2172
- Ha(),
2173
- $n(e),
2174
- Un()
2185
+ wa(),
2186
+ Wa(e),
2187
+ Va(),
2188
+ Un(e),
2189
+ Bn()
2175
2190
  ]
2176
2191
  };
2177
2192
  }
@@ -2184,24 +2199,24 @@ function be(e, r, t, a) {
2184
2199
  for (t && e.splice(r, t); o < a.length; )
2185
2200
  n = a.slice(o, o + 1e4), n.unshift(r, 0), e.splice(...n), o += 1e4, r += 1e4;
2186
2201
  }
2187
- const pt = {}.hasOwnProperty;
2188
- function Xn(e) {
2202
+ const gt = {}.hasOwnProperty;
2203
+ function Kn(e) {
2189
2204
  const r = {};
2190
2205
  let t = -1;
2191
2206
  for (; ++t < e.length; )
2192
- Kn(r, e[t]);
2207
+ Gn(r, e[t]);
2193
2208
  return r;
2194
2209
  }
2195
- function Kn(e, r) {
2210
+ function Gn(e, r) {
2196
2211
  let t;
2197
2212
  for (t in r) {
2198
- const i = (pt.call(e, t) ? e[t] : void 0) || (e[t] = {}), o = r[t];
2213
+ const i = (gt.call(e, t) ? e[t] : void 0) || (e[t] = {}), o = r[t];
2199
2214
  let n;
2200
2215
  if (o)
2201
2216
  for (n in o) {
2202
- pt.call(i, n) || (i[n] = []);
2217
+ gt.call(i, n) || (i[n] = []);
2203
2218
  const u = o[n];
2204
- Vn(
2219
+ Zn(
2205
2220
  // @ts-expect-error Looks like a list.
2206
2221
  i[n],
2207
2222
  Array.isArray(u) ? u : u ? [u] : []
@@ -2209,115 +2224,115 @@ function Kn(e, r) {
2209
2224
  }
2210
2225
  }
2211
2226
  }
2212
- function Vn(e, r) {
2227
+ function Zn(e, r) {
2213
2228
  let t = -1;
2214
2229
  const a = [];
2215
2230
  for (; ++t < r.length; )
2216
2231
  (r[t].add === "after" ? e : a).push(r[t]);
2217
2232
  be(e, 0, 0, a);
2218
2233
  }
2219
- const Gn = {
2220
- tokenize: ti,
2221
- partial: !0
2222
- }, Jt = {
2223
- tokenize: ri,
2224
- partial: !0
2225
- }, Qt = {
2234
+ const Jn = {
2226
2235
  tokenize: ai,
2227
2236
  partial: !0
2228
- }, Yt = {
2237
+ }, Qt = {
2229
2238
  tokenize: ni,
2230
2239
  partial: !0
2231
- }, Zn = {
2240
+ }, Yt = {
2232
2241
  tokenize: ii,
2233
2242
  partial: !0
2234
2243
  }, er = {
2235
- name: "wwwAutolink",
2236
- tokenize: Yn,
2237
- previous: rr
2244
+ tokenize: oi,
2245
+ partial: !0
2246
+ }, Qn = {
2247
+ tokenize: ci,
2248
+ partial: !0
2238
2249
  }, tr = {
2239
- name: "protocolAutolink",
2240
- tokenize: ei,
2250
+ name: "wwwAutolink",
2251
+ tokenize: ti,
2241
2252
  previous: ar
2242
- }, q = {
2243
- name: "emailAutolink",
2244
- tokenize: Qn,
2253
+ }, rr = {
2254
+ name: "protocolAutolink",
2255
+ tokenize: ri,
2245
2256
  previous: nr
2246
- }, z = {};
2247
- function Jn() {
2257
+ }, V = {
2258
+ name: "emailAutolink",
2259
+ tokenize: ei,
2260
+ previous: ir
2261
+ }, $ = {};
2262
+ function Yn() {
2248
2263
  return {
2249
- text: z
2264
+ text: $
2250
2265
  };
2251
2266
  }
2252
- let K = 48;
2253
- for (; K < 123; )
2254
- z[K] = q, K++, K === 58 ? K = 65 : K === 91 && (K = 97);
2255
- z[43] = q;
2256
- z[45] = q;
2257
- z[46] = q;
2258
- z[95] = q;
2259
- z[72] = [q, tr];
2260
- z[104] = [q, tr];
2261
- z[87] = [q, er];
2262
- z[119] = [q, er];
2263
- function Qn(e, r, t) {
2267
+ let X = 48;
2268
+ for (; X < 123; )
2269
+ $[X] = V, X++, X === 58 ? X = 65 : X === 91 && (X = 97);
2270
+ $[43] = V;
2271
+ $[45] = V;
2272
+ $[46] = V;
2273
+ $[95] = V;
2274
+ $[72] = [V, rr];
2275
+ $[104] = [V, rr];
2276
+ $[87] = [V, tr];
2277
+ $[119] = [V, tr];
2278
+ function ei(e, r, t) {
2264
2279
  const a = this;
2265
2280
  let i, o;
2266
2281
  return n;
2267
- function n(s) {
2268
- return !Oe(s) || !nr.call(a, a.previous) || qe(a.events) ? t(s) : (e.enter("literalAutolink"), e.enter("literalAutolinkEmail"), u(s));
2282
+ function n(l) {
2283
+ return !Ue(l) || !ir.call(a, a.previous) || Ve(a.events) ? t(l) : (e.enter("literalAutolink"), e.enter("literalAutolinkEmail"), u(l));
2269
2284
  }
2270
- function u(s) {
2271
- return Oe(s) ? (e.consume(s), u) : s === 64 ? (e.consume(s), c) : t(s);
2285
+ function u(l) {
2286
+ return Ue(l) ? (e.consume(l), u) : l === 64 ? (e.consume(l), c) : t(l);
2272
2287
  }
2273
- function c(s) {
2274
- return s === 46 ? e.check(Zn, f, l)(s) : s === 45 || s === 95 || We(s) ? (o = !0, e.consume(s), c) : f(s);
2288
+ function c(l) {
2289
+ return l === 46 ? e.check(Qn, f, s)(l) : l === 45 || l === 95 || Be(l) ? (o = !0, e.consume(l), c) : f(l);
2275
2290
  }
2276
- function l(s) {
2277
- return e.consume(s), i = !0, c;
2291
+ function s(l) {
2292
+ return e.consume(l), i = !0, c;
2278
2293
  }
2279
- function f(s) {
2280
- return o && i && ue(a.previous) ? (e.exit("literalAutolinkEmail"), e.exit("literalAutolink"), r(s)) : t(s);
2294
+ function f(l) {
2295
+ return o && i && ue(a.previous) ? (e.exit("literalAutolinkEmail"), e.exit("literalAutolink"), r(l)) : t(l);
2281
2296
  }
2282
2297
  }
2283
- function Yn(e, r, t) {
2298
+ function ti(e, r, t) {
2284
2299
  const a = this;
2285
2300
  return i;
2286
2301
  function i(n) {
2287
- return n !== 87 && n !== 119 || !rr.call(a, a.previous) || qe(a.events) ? t(n) : (e.enter("literalAutolink"), e.enter("literalAutolinkWww"), e.check(Gn, e.attempt(Jt, e.attempt(Qt, o), t), t)(n));
2302
+ return n !== 87 && n !== 119 || !ar.call(a, a.previous) || Ve(a.events) ? t(n) : (e.enter("literalAutolink"), e.enter("literalAutolinkWww"), e.check(Jn, e.attempt(Qt, e.attempt(Yt, o), t), t)(n));
2288
2303
  }
2289
2304
  function o(n) {
2290
2305
  return e.exit("literalAutolinkWww"), e.exit("literalAutolink"), r(n);
2291
2306
  }
2292
2307
  }
2293
- function ei(e, r, t) {
2308
+ function ri(e, r, t) {
2294
2309
  const a = this;
2295
2310
  let i = "", o = !1;
2296
2311
  return n;
2297
- function n(s) {
2298
- return (s === 72 || s === 104) && ar.call(a, a.previous) && !qe(a.events) ? (e.enter("literalAutolink"), e.enter("literalAutolinkHttp"), i += String.fromCodePoint(s), e.consume(s), u) : t(s);
2312
+ function n(l) {
2313
+ return (l === 72 || l === 104) && nr.call(a, a.previous) && !Ve(a.events) ? (e.enter("literalAutolink"), e.enter("literalAutolinkHttp"), i += String.fromCodePoint(l), e.consume(l), u) : t(l);
2299
2314
  }
2300
- function u(s) {
2301
- if (ue(s) && i.length < 5)
2302
- return i += String.fromCodePoint(s), e.consume(s), u;
2303
- if (s === 58) {
2315
+ function u(l) {
2316
+ if (ue(l) && i.length < 5)
2317
+ return i += String.fromCodePoint(l), e.consume(l), u;
2318
+ if (l === 58) {
2304
2319
  const p = i.toLowerCase();
2305
2320
  if (p === "http" || p === "https")
2306
- return e.consume(s), c;
2321
+ return e.consume(l), c;
2307
2322
  }
2308
- return t(s);
2323
+ return t(l);
2309
2324
  }
2310
- function c(s) {
2311
- return s === 47 ? (e.consume(s), o ? l : (o = !0, c)) : t(s);
2325
+ function c(l) {
2326
+ return l === 47 ? (e.consume(l), o ? s : (o = !0, c)) : t(l);
2312
2327
  }
2313
- function l(s) {
2314
- return s === null || na(s) || F(s) || V(s) || ke(s) ? t(s) : e.attempt(Jt, e.attempt(Qt, f), t)(s);
2328
+ function s(l) {
2329
+ return l === null || oa(l) || _(l) || K(l) || we(l) ? t(l) : e.attempt(Qt, e.attempt(Yt, f), t)(l);
2315
2330
  }
2316
- function f(s) {
2317
- return e.exit("literalAutolinkHttp"), e.exit("literalAutolink"), r(s);
2331
+ function f(l) {
2332
+ return e.exit("literalAutolinkHttp"), e.exit("literalAutolink"), r(l);
2318
2333
  }
2319
2334
  }
2320
- function ti(e, r, t) {
2335
+ function ai(e, r, t) {
2321
2336
  let a = 0;
2322
2337
  return i;
2323
2338
  function i(n) {
@@ -2327,40 +2342,40 @@ function ti(e, r, t) {
2327
2342
  return n === null ? t(n) : r(n);
2328
2343
  }
2329
2344
  }
2330
- function ri(e, r, t) {
2345
+ function ni(e, r, t) {
2331
2346
  let a, i, o;
2332
2347
  return n;
2333
- function n(l) {
2334
- return l === 46 || l === 95 ? e.check(Yt, c, u)(l) : l === null || F(l) || V(l) || l !== 45 && ke(l) ? c(l) : (o = !0, e.consume(l), n);
2348
+ function n(s) {
2349
+ return s === 46 || s === 95 ? e.check(er, c, u)(s) : s === null || _(s) || K(s) || s !== 45 && we(s) ? c(s) : (o = !0, e.consume(s), n);
2335
2350
  }
2336
- function u(l) {
2337
- return l === 95 ? a = !0 : (i = a, a = void 0), e.consume(l), n;
2351
+ function u(s) {
2352
+ return s === 95 ? a = !0 : (i = a, a = void 0), e.consume(s), n;
2338
2353
  }
2339
- function c(l) {
2340
- return i || a || !o ? t(l) : r(l);
2354
+ function c(s) {
2355
+ return i || a || !o ? t(s) : r(s);
2341
2356
  }
2342
2357
  }
2343
- function ai(e, r) {
2358
+ function ii(e, r) {
2344
2359
  let t = 0, a = 0;
2345
2360
  return i;
2346
2361
  function i(n) {
2347
- 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(Yt, r, o)(n) : n === null || F(n) || V(n) ? r(n) : (e.consume(n), i);
2362
+ 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(er, r, o)(n) : n === null || _(n) || K(n) ? r(n) : (e.consume(n), i);
2348
2363
  }
2349
2364
  function o(n) {
2350
2365
  return n === 41 && a++, e.consume(n), i;
2351
2366
  }
2352
2367
  }
2353
- function ni(e, r, t) {
2368
+ function oi(e, r, t) {
2354
2369
  return a;
2355
2370
  function a(u) {
2356
2371
  return u === 33 || u === 34 || u === 39 || u === 41 || u === 42 || u === 44 || u === 46 || u === 58 || u === 59 || u === 63 || u === 95 || u === 126 ? (e.consume(u), a) : u === 38 ? (e.consume(u), o) : u === 93 ? (e.consume(u), i) : (
2357
2372
  // `<` is an end.
2358
2373
  u === 60 || // So is whitespace.
2359
- u === null || F(u) || V(u) ? r(u) : t(u)
2374
+ u === null || _(u) || K(u) ? r(u) : t(u)
2360
2375
  );
2361
2376
  }
2362
2377
  function i(u) {
2363
- return u === null || u === 40 || u === 91 || F(u) || V(u) ? r(u) : a(u);
2378
+ return u === null || u === 40 || u === 91 || _(u) || K(u) ? r(u) : a(u);
2364
2379
  }
2365
2380
  function o(u) {
2366
2381
  return ue(u) ? n(u) : t(u);
@@ -2369,28 +2384,28 @@ function ni(e, r, t) {
2369
2384
  return u === 59 ? (e.consume(u), a) : ue(u) ? (e.consume(u), n) : t(u);
2370
2385
  }
2371
2386
  }
2372
- function ii(e, r, t) {
2387
+ function ci(e, r, t) {
2373
2388
  return a;
2374
2389
  function a(o) {
2375
2390
  return e.consume(o), i;
2376
2391
  }
2377
2392
  function i(o) {
2378
- return We(o) ? t(o) : r(o);
2393
+ return Be(o) ? t(o) : r(o);
2379
2394
  }
2380
2395
  }
2381
- function rr(e) {
2382
- return e === null || e === 40 || e === 42 || e === 95 || e === 91 || e === 93 || e === 126 || F(e);
2383
- }
2384
2396
  function ar(e) {
2385
- return !ue(e);
2397
+ return e === null || e === 40 || e === 42 || e === 95 || e === 91 || e === 93 || e === 126 || _(e);
2386
2398
  }
2387
2399
  function nr(e) {
2388
- return !(e === 47 || Oe(e));
2400
+ return !ue(e);
2389
2401
  }
2390
- function Oe(e) {
2391
- return e === 43 || e === 45 || e === 46 || e === 95 || We(e);
2402
+ function ir(e) {
2403
+ return !(e === 47 || Ue(e));
2392
2404
  }
2393
- function qe(e) {
2405
+ function Ue(e) {
2406
+ return e === 43 || e === 45 || e === 46 || e === 95 || Be(e);
2407
+ }
2408
+ function Ve(e) {
2394
2409
  let r = e.length, t = !1;
2395
2410
  for (; r--; ) {
2396
2411
  const a = e[r][1];
@@ -2405,7 +2420,7 @@ function qe(e) {
2405
2420
  }
2406
2421
  return e.length > 0 && !t && (e[e.length - 1][1]._gfmAutolinkLiteralWalkedInto = !0), t;
2407
2422
  }
2408
- function oi(e, r, t) {
2423
+ function ui(e, r, t) {
2409
2424
  const a = [];
2410
2425
  let i = -1;
2411
2426
  for (; ++i < e.length; ) {
@@ -2414,61 +2429,61 @@ function oi(e, r, t) {
2414
2429
  }
2415
2430
  return r;
2416
2431
  }
2417
- function B(e, r, t, a) {
2432
+ function H(e, r, t, a) {
2418
2433
  const i = a ? a - 1 : Number.POSITIVE_INFINITY;
2419
2434
  let o = 0;
2420
2435
  return n;
2421
2436
  function n(c) {
2422
- return W(c) ? (e.enter(t), u(c)) : r(c);
2437
+ return B(c) ? (e.enter(t), u(c)) : r(c);
2423
2438
  }
2424
2439
  function u(c) {
2425
- return W(c) && o++ < i ? (e.consume(c), u) : (e.exit(t), r(c));
2440
+ return B(c) && o++ < i ? (e.consume(c), u) : (e.exit(t), r(c));
2426
2441
  }
2427
2442
  }
2428
- const ci = {
2443
+ const si = {
2429
2444
  partial: !0,
2430
- tokenize: ui
2445
+ tokenize: li
2431
2446
  };
2432
- function ui(e, r, t) {
2447
+ function li(e, r, t) {
2433
2448
  return a;
2434
2449
  function a(o) {
2435
- return W(o) ? B(e, i, "linePrefix")(o) : i(o);
2450
+ return B(o) ? H(e, i, "linePrefix")(o) : i(o);
2436
2451
  }
2437
2452
  function i(o) {
2438
2453
  return o === null || Y(o) ? r(o) : t(o);
2439
2454
  }
2440
2455
  }
2441
- const li = {
2442
- tokenize: bi,
2456
+ const di = {
2457
+ tokenize: xi,
2443
2458
  partial: !0
2444
2459
  };
2445
- function si() {
2460
+ function fi() {
2446
2461
  return {
2447
2462
  document: {
2448
2463
  91: {
2449
2464
  name: "gfmFootnoteDefinition",
2450
- tokenize: mi,
2465
+ tokenize: gi,
2451
2466
  continuation: {
2452
- tokenize: pi
2467
+ tokenize: bi
2453
2468
  },
2454
- exit: gi
2469
+ exit: yi
2455
2470
  }
2456
2471
  },
2457
2472
  text: {
2458
2473
  91: {
2459
2474
  name: "gfmFootnoteCall",
2460
- tokenize: hi
2475
+ tokenize: pi
2461
2476
  },
2462
2477
  93: {
2463
2478
  name: "gfmPotentialFootnoteCall",
2464
2479
  add: "after",
2465
- tokenize: di,
2466
- resolveTo: fi
2480
+ tokenize: hi,
2481
+ resolveTo: mi
2467
2482
  }
2468
2483
  }
2469
2484
  };
2470
2485
  }
2471
- function di(e, r, t) {
2486
+ function hi(e, r, t) {
2472
2487
  const a = this;
2473
2488
  let i = a.events.length;
2474
2489
  const o = a.parser.gfmFootnotes || (a.parser.gfmFootnotes = []);
@@ -2486,14 +2501,14 @@ function di(e, r, t) {
2486
2501
  function u(c) {
2487
2502
  if (!n || !n._balanced)
2488
2503
  return t(c);
2489
- const l = se(a.sliceSerialize({
2504
+ const s = le(a.sliceSerialize({
2490
2505
  start: n.end,
2491
2506
  end: a.now()
2492
2507
  }));
2493
- return l.codePointAt(0) !== 94 || !o.includes(l.slice(1)) ? t(c) : (e.enter("gfmFootnoteCallLabelMarker"), e.consume(c), e.exit("gfmFootnoteCallLabelMarker"), r(c));
2508
+ return s.codePointAt(0) !== 94 || !o.includes(s.slice(1)) ? t(c) : (e.enter("gfmFootnoteCallLabelMarker"), e.consume(c), e.exit("gfmFootnoteCallLabelMarker"), r(c));
2494
2509
  }
2495
2510
  }
2496
- function fi(e, r) {
2511
+ function mi(e, r) {
2497
2512
  let t = e.length;
2498
2513
  for (; t--; )
2499
2514
  if (e[t][1].type === "labelImage" && e[t][0] === "enter") {
@@ -2543,44 +2558,44 @@ function fi(e, r) {
2543
2558
  ];
2544
2559
  return e.splice(t, e.length - t + 1, ...u), e;
2545
2560
  }
2546
- function hi(e, r, t) {
2561
+ function pi(e, r, t) {
2547
2562
  const a = this, i = a.parser.gfmFootnotes || (a.parser.gfmFootnotes = []);
2548
2563
  let o = 0, n;
2549
2564
  return u;
2550
- function u(s) {
2551
- return e.enter("gfmFootnoteCall"), e.enter("gfmFootnoteCallLabelMarker"), e.consume(s), e.exit("gfmFootnoteCallLabelMarker"), c;
2565
+ function u(l) {
2566
+ return e.enter("gfmFootnoteCall"), e.enter("gfmFootnoteCallLabelMarker"), e.consume(l), e.exit("gfmFootnoteCallLabelMarker"), c;
2552
2567
  }
2553
- function c(s) {
2554
- return s !== 94 ? t(s) : (e.enter("gfmFootnoteCallMarker"), e.consume(s), e.exit("gfmFootnoteCallMarker"), e.enter("gfmFootnoteCallString"), e.enter("chunkString").contentType = "string", l);
2568
+ function c(l) {
2569
+ return l !== 94 ? t(l) : (e.enter("gfmFootnoteCallMarker"), e.consume(l), e.exit("gfmFootnoteCallMarker"), e.enter("gfmFootnoteCallString"), e.enter("chunkString").contentType = "string", s);
2555
2570
  }
2556
- function l(s) {
2571
+ function s(l) {
2557
2572
  if (
2558
2573
  // Too long.
2559
2574
  o > 999 || // Closing brace with nothing.
2560
- s === 93 && !n || // Space or tab is not supported by GFM for some reason.
2575
+ l === 93 && !n || // Space or tab is not supported by GFM for some reason.
2561
2576
  // `\n` and `[` not being supported makes sense.
2562
- s === null || s === 91 || F(s)
2577
+ l === null || l === 91 || _(l)
2563
2578
  )
2564
- return t(s);
2565
- if (s === 93) {
2579
+ return t(l);
2580
+ if (l === 93) {
2566
2581
  e.exit("chunkString");
2567
2582
  const p = e.exit("gfmFootnoteCallString");
2568
- return i.includes(se(a.sliceSerialize(p))) ? (e.enter("gfmFootnoteCallLabelMarker"), e.consume(s), e.exit("gfmFootnoteCallLabelMarker"), e.exit("gfmFootnoteCall"), r) : t(s);
2583
+ return i.includes(le(a.sliceSerialize(p))) ? (e.enter("gfmFootnoteCallLabelMarker"), e.consume(l), e.exit("gfmFootnoteCallLabelMarker"), e.exit("gfmFootnoteCall"), r) : t(l);
2569
2584
  }
2570
- return F(s) || (n = !0), o++, e.consume(s), s === 92 ? f : l;
2585
+ return _(l) || (n = !0), o++, e.consume(l), l === 92 ? f : s;
2571
2586
  }
2572
- function f(s) {
2573
- return s === 91 || s === 92 || s === 93 ? (e.consume(s), o++, l) : l(s);
2587
+ function f(l) {
2588
+ return l === 91 || l === 92 || l === 93 ? (e.consume(l), o++, s) : s(l);
2574
2589
  }
2575
2590
  }
2576
- function mi(e, r, t) {
2591
+ function gi(e, r, t) {
2577
2592
  const a = this, i = a.parser.gfmFootnotes || (a.parser.gfmFootnotes = []);
2578
2593
  let o, n = 0, u;
2579
2594
  return c;
2580
2595
  function c(h) {
2581
- return e.enter("gfmFootnoteDefinition")._container = !0, e.enter("gfmFootnoteDefinitionLabel"), e.enter("gfmFootnoteDefinitionLabelMarker"), e.consume(h), e.exit("gfmFootnoteDefinitionLabelMarker"), l;
2596
+ return e.enter("gfmFootnoteDefinition")._container = !0, e.enter("gfmFootnoteDefinitionLabel"), e.enter("gfmFootnoteDefinitionLabelMarker"), e.consume(h), e.exit("gfmFootnoteDefinitionLabelMarker"), s;
2582
2597
  }
2583
- function l(h) {
2598
+ function s(h) {
2584
2599
  return h === 94 ? (e.enter("gfmFootnoteDefinitionMarker"), e.consume(h), e.exit("gfmFootnoteDefinitionMarker"), e.enter("gfmFootnoteDefinitionLabelString"), e.enter("chunkString").contentType = "string", f) : t(h);
2585
2600
  }
2586
2601
  function f(h) {
@@ -2589,41 +2604,41 @@ function mi(e, r, t) {
2589
2604
  n > 999 || // Closing brace with nothing.
2590
2605
  h === 93 && !u || // Space or tab is not supported by GFM for some reason.
2591
2606
  // `\n` and `[` not being supported makes sense.
2592
- h === null || h === 91 || F(h)
2607
+ h === null || h === 91 || _(h)
2593
2608
  )
2594
2609
  return t(h);
2595
2610
  if (h === 93) {
2596
2611
  e.exit("chunkString");
2597
- const y = e.exit("gfmFootnoteDefinitionLabelString");
2598
- return o = se(a.sliceSerialize(y)), e.enter("gfmFootnoteDefinitionLabelMarker"), e.consume(h), e.exit("gfmFootnoteDefinitionLabelMarker"), e.exit("gfmFootnoteDefinitionLabel"), p;
2612
+ const x = e.exit("gfmFootnoteDefinitionLabelString");
2613
+ return o = le(a.sliceSerialize(x)), e.enter("gfmFootnoteDefinitionLabelMarker"), e.consume(h), e.exit("gfmFootnoteDefinitionLabelMarker"), e.exit("gfmFootnoteDefinitionLabel"), p;
2599
2614
  }
2600
- return F(h) || (u = !0), n++, e.consume(h), h === 92 ? s : f;
2615
+ return _(h) || (u = !0), n++, e.consume(h), h === 92 ? l : f;
2601
2616
  }
2602
- function s(h) {
2617
+ function l(h) {
2603
2618
  return h === 91 || h === 92 || h === 93 ? (e.consume(h), n++, f) : f(h);
2604
2619
  }
2605
2620
  function p(h) {
2606
- return h === 58 ? (e.enter("definitionMarker"), e.consume(h), e.exit("definitionMarker"), i.includes(o) || i.push(o), B(e, x, "gfmFootnoteDefinitionWhitespace")) : t(h);
2621
+ return h === 58 ? (e.enter("definitionMarker"), e.consume(h), e.exit("definitionMarker"), i.includes(o) || i.push(o), H(e, b, "gfmFootnoteDefinitionWhitespace")) : t(h);
2607
2622
  }
2608
- function x(h) {
2623
+ function b(h) {
2609
2624
  return r(h);
2610
2625
  }
2611
2626
  }
2612
- function pi(e, r, t) {
2613
- return e.check(ci, r, e.attempt(li, r, t));
2627
+ function bi(e, r, t) {
2628
+ return e.check(si, r, e.attempt(di, r, t));
2614
2629
  }
2615
- function gi(e) {
2630
+ function yi(e) {
2616
2631
  e.exit("gfmFootnoteDefinition");
2617
2632
  }
2618
- function bi(e, r, t) {
2633
+ function xi(e, r, t) {
2619
2634
  const a = this;
2620
- return B(e, i, "gfmFootnoteDefinitionIndent", 5);
2635
+ return H(e, i, "gfmFootnoteDefinitionIndent", 5);
2621
2636
  function i(o) {
2622
2637
  const n = a.events[a.events.length - 1];
2623
2638
  return n && n[1].type === "gfmFootnoteDefinitionIndent" && n[2].sliceSerialize(n[1], !0).length === 4 ? r(o) : t(o);
2624
2639
  }
2625
2640
  }
2626
- function xi(e) {
2641
+ function ki(e) {
2627
2642
  let t = (e || {}).singleTilde;
2628
2643
  const a = {
2629
2644
  name: "strikethrough",
@@ -2645,21 +2660,21 @@ function xi(e) {
2645
2660
  let c = -1;
2646
2661
  for (; ++c < n.length; )
2647
2662
  if (n[c][0] === "enter" && n[c][1].type === "strikethroughSequenceTemporary" && n[c][1]._close) {
2648
- let l = c;
2649
- for (; l--; )
2650
- if (n[l][0] === "exit" && n[l][1].type === "strikethroughSequenceTemporary" && n[l][1]._open && // If the sizes are the same:
2651
- n[c][1].end.offset - n[c][1].start.offset === n[l][1].end.offset - n[l][1].start.offset) {
2652
- n[c][1].type = "strikethroughSequence", n[l][1].type = "strikethroughSequence";
2663
+ let s = c;
2664
+ for (; s--; )
2665
+ if (n[s][0] === "exit" && n[s][1].type === "strikethroughSequenceTemporary" && n[s][1]._open && // If the sizes are the same:
2666
+ n[c][1].end.offset - n[c][1].start.offset === n[s][1].end.offset - n[s][1].start.offset) {
2667
+ n[c][1].type = "strikethroughSequence", n[s][1].type = "strikethroughSequence";
2653
2668
  const f = {
2654
2669
  type: "strikethrough",
2655
- start: Object.assign({}, n[l][1].start),
2670
+ start: Object.assign({}, n[s][1].start),
2656
2671
  end: Object.assign({}, n[c][1].end)
2657
- }, s = {
2672
+ }, l = {
2658
2673
  type: "strikethroughText",
2659
- start: Object.assign({}, n[l][1].end),
2674
+ start: Object.assign({}, n[s][1].end),
2660
2675
  end: Object.assign({}, n[c][1].start)
2661
- }, p = [["enter", f, u], ["enter", n[l][1], u], ["exit", n[l][1], u], ["enter", s, u]], x = u.parser.constructs.insideSpan.null;
2662
- x && be(p, p.length, 0, oi(x, n.slice(l + 1, c), u)), be(p, p.length, 0, [["exit", s, u], ["enter", n[c][1], u], ["exit", n[c][1], u], ["exit", f, u]]), be(n, l - 1, c - l + 3, p), c = l + p.length - 2;
2676
+ }, p = [["enter", f, u], ["enter", n[s][1], u], ["exit", n[s][1], u], ["enter", l, u]], b = u.parser.constructs.insideSpan.null;
2677
+ b && be(p, p.length, 0, ui(b, n.slice(s + 1, c), u)), be(p, p.length, 0, [["exit", l, u], ["enter", n[c][1], u], ["exit", n[c][1], u], ["exit", f, u]]), be(n, s - 1, c - s + 3, p), c = s + p.length - 2;
2663
2678
  break;
2664
2679
  }
2665
2680
  }
@@ -2668,23 +2683,23 @@ function xi(e) {
2668
2683
  return n;
2669
2684
  }
2670
2685
  function o(n, u, c) {
2671
- const l = this.previous, f = this.events;
2672
- let s = 0;
2686
+ const s = this.previous, f = this.events;
2687
+ let l = 0;
2673
2688
  return p;
2674
2689
  function p(h) {
2675
- return l === 126 && f[f.length - 1][1].type !== "characterEscape" ? c(h) : (n.enter("strikethroughSequenceTemporary"), x(h));
2690
+ return s === 126 && f[f.length - 1][1].type !== "characterEscape" ? c(h) : (n.enter("strikethroughSequenceTemporary"), b(h));
2676
2691
  }
2677
- function x(h) {
2678
- const y = xe(l);
2692
+ function b(h) {
2693
+ const x = xe(s);
2679
2694
  if (h === 126)
2680
- return s > 1 ? c(h) : (n.consume(h), s++, x);
2681
- if (s < 2 && !t) return c(h);
2682
- const g = n.exit("strikethroughSequenceTemporary"), b = xe(h);
2683
- return g._open = !b || b === 2 && !!y, g._close = !y || y === 2 && !!b, u(h);
2695
+ return l > 1 ? c(h) : (n.consume(h), l++, b);
2696
+ if (l < 2 && !t) return c(h);
2697
+ const y = n.exit("strikethroughSequenceTemporary"), g = xe(h);
2698
+ return y._open = !g || g === 2 && !!x, y._close = !x || x === 2 && !!g, u(h);
2684
2699
  }
2685
2700
  }
2686
2701
  }
2687
- class yi {
2702
+ class wi {
2688
2703
  /**
2689
2704
  * Create a new edit map.
2690
2705
  */
@@ -2700,7 +2715,7 @@ class yi {
2700
2715
  * @returns {undefined}
2701
2716
  */
2702
2717
  add(r, t, a) {
2703
- ki(this, r, t, a);
2718
+ vi(this, r, t, a);
2704
2719
  }
2705
2720
  // To do: add this when moving to `micromark`.
2706
2721
  // /**
@@ -2739,7 +2754,7 @@ class yi {
2739
2754
  this.map.length = 0;
2740
2755
  }
2741
2756
  }
2742
- function ki(e, r, t, a) {
2757
+ function vi(e, r, t, a) {
2743
2758
  let i = 0;
2744
2759
  if (!(t === 0 && a.length === 0)) {
2745
2760
  for (; i < e.map.length; ) {
@@ -2752,7 +2767,7 @@ function ki(e, r, t, a) {
2752
2767
  e.map.push([r, t, a]);
2753
2768
  }
2754
2769
  }
2755
- function wi(e, r) {
2770
+ function Ci(e, r) {
2756
2771
  let t = !1;
2757
2772
  const a = [];
2758
2773
  for (; r < e.length; ) {
@@ -2772,107 +2787,107 @@ function wi(e, r) {
2772
2787
  }
2773
2788
  return a;
2774
2789
  }
2775
- function Ci() {
2790
+ function Ti() {
2776
2791
  return {
2777
2792
  flow: {
2778
2793
  null: {
2779
2794
  name: "table",
2780
- tokenize: vi,
2781
- resolveAll: Ti
2795
+ tokenize: Ai,
2796
+ resolveAll: Ni
2782
2797
  }
2783
2798
  }
2784
2799
  };
2785
2800
  }
2786
- function vi(e, r, t) {
2801
+ function Ai(e, r, t) {
2787
2802
  const a = this;
2788
2803
  let i = 0, o = 0, n;
2789
2804
  return u;
2790
2805
  function u(m) {
2791
- let X = a.events.length - 1;
2792
- for (; X > -1; ) {
2793
- const O = a.events[X][1].type;
2794
- if (O === "lineEnding" || // Note: markdown-rs uses `whitespace` instead of `linePrefix`
2795
- O === "linePrefix") X--;
2806
+ let j = a.events.length - 1;
2807
+ for (; j > -1; ) {
2808
+ const U = a.events[j][1].type;
2809
+ if (U === "lineEnding" || // Note: markdown-rs uses `whitespace` instead of `linePrefix`
2810
+ U === "linePrefix") j--;
2796
2811
  else break;
2797
2812
  }
2798
- const $ = X > -1 ? a.events[X][1].type : null, G = $ === "tableHead" || $ === "tableRow" ? T : c;
2799
- return G === T && a.parser.lazy[a.now().line] ? t(m) : G(m);
2813
+ const O = j > -1 ? a.events[j][1].type : null, G = O === "tableHead" || O === "tableRow" ? A : c;
2814
+ return G === A && a.parser.lazy[a.now().line] ? t(m) : G(m);
2800
2815
  }
2801
2816
  function c(m) {
2802
- return e.enter("tableHead"), e.enter("tableRow"), l(m);
2817
+ return e.enter("tableHead"), e.enter("tableRow"), s(m);
2803
2818
  }
2804
- function l(m) {
2819
+ function s(m) {
2805
2820
  return m === 124 || (n = !0, o += 1), f(m);
2806
2821
  }
2807
2822
  function f(m) {
2808
- return m === null ? t(m) : Y(m) ? o > 1 ? (o = 0, a.interrupt = !0, e.exit("tableRow"), e.enter("lineEnding"), e.consume(m), e.exit("lineEnding"), x) : t(m) : W(m) ? B(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"), s(m)));
2823
+ return m === null ? t(m) : Y(m) ? o > 1 ? (o = 0, a.interrupt = !0, e.exit("tableRow"), e.enter("lineEnding"), e.consume(m), e.exit("lineEnding"), b) : t(m) : B(m) ? H(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"), l(m)));
2809
2824
  }
2810
- function s(m) {
2811
- return m === null || m === 124 || F(m) ? (e.exit("data"), f(m)) : (e.consume(m), m === 92 ? p : s);
2825
+ function l(m) {
2826
+ return m === null || m === 124 || _(m) ? (e.exit("data"), f(m)) : (e.consume(m), m === 92 ? p : l);
2812
2827
  }
2813
2828
  function p(m) {
2814
- return m === 92 || m === 124 ? (e.consume(m), s) : s(m);
2829
+ return m === 92 || m === 124 ? (e.consume(m), l) : l(m);
2815
2830
  }
2816
- function x(m) {
2817
- return a.interrupt = !1, a.parser.lazy[a.now().line] ? t(m) : (e.enter("tableDelimiterRow"), n = !1, W(m) ? B(e, h, "linePrefix", a.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(m) : h(m));
2831
+ function b(m) {
2832
+ return a.interrupt = !1, a.parser.lazy[a.now().line] ? t(m) : (e.enter("tableDelimiterRow"), n = !1, B(m) ? H(e, h, "linePrefix", a.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(m) : h(m));
2818
2833
  }
2819
2834
  function h(m) {
2820
- return m === 45 || m === 58 ? g(m) : m === 124 ? (n = !0, e.enter("tableCellDivider"), e.consume(m), e.exit("tableCellDivider"), y) : I(m);
2835
+ return m === 45 || m === 58 ? y(m) : m === 124 ? (n = !0, e.enter("tableCellDivider"), e.consume(m), e.exit("tableCellDivider"), x) : N(m);
2836
+ }
2837
+ function x(m) {
2838
+ return B(m) ? H(e, y, "whitespace")(m) : y(m);
2821
2839
  }
2822
2840
  function y(m) {
2823
- return W(m) ? B(e, g, "whitespace")(m) : g(m);
2841
+ return m === 58 ? (o += 1, n = !0, e.enter("tableDelimiterMarker"), e.consume(m), e.exit("tableDelimiterMarker"), g) : m === 45 ? (o += 1, g(m)) : m === null || Y(m) ? M(m) : N(m);
2824
2842
  }
2825
2843
  function g(m) {
2826
- return m === 58 ? (o += 1, n = !0, e.enter("tableDelimiterMarker"), e.consume(m), e.exit("tableDelimiterMarker"), b) : m === 45 ? (o += 1, b(m)) : m === null || Y(m) ? A(m) : I(m);
2827
- }
2828
- function b(m) {
2829
- return m === 45 ? (e.enter("tableDelimiterFiller"), k(m)) : I(m);
2844
+ return m === 45 ? (e.enter("tableDelimiterFiller"), k(m)) : N(m);
2830
2845
  }
2831
2846
  function k(m) {
2832
- return m === 45 ? (e.consume(m), k) : m === 58 ? (n = !0, e.exit("tableDelimiterFiller"), e.enter("tableDelimiterMarker"), e.consume(m), e.exit("tableDelimiterMarker"), w) : (e.exit("tableDelimiterFiller"), w(m));
2847
+ return m === 45 ? (e.consume(m), k) : m === 58 ? (n = !0, e.exit("tableDelimiterFiller"), e.enter("tableDelimiterMarker"), e.consume(m), e.exit("tableDelimiterMarker"), v) : (e.exit("tableDelimiterFiller"), v(m));
2833
2848
  }
2834
- function w(m) {
2835
- return W(m) ? B(e, A, "whitespace")(m) : A(m);
2849
+ function v(m) {
2850
+ return B(m) ? H(e, M, "whitespace")(m) : M(m);
2836
2851
  }
2837
- function A(m) {
2838
- return m === 124 ? h(m) : m === null || Y(m) ? !n || i !== o ? I(m) : (e.exit("tableDelimiterRow"), e.exit("tableHead"), r(m)) : I(m);
2852
+ function M(m) {
2853
+ return m === 124 ? h(m) : m === null || Y(m) ? !n || i !== o ? N(m) : (e.exit("tableDelimiterRow"), e.exit("tableHead"), r(m)) : N(m);
2839
2854
  }
2840
- function I(m) {
2855
+ function N(m) {
2841
2856
  return t(m);
2842
2857
  }
2843
- function T(m) {
2844
- return e.enter("tableRow"), S(m);
2858
+ function A(m) {
2859
+ return e.enter("tableRow"), w(m);
2845
2860
  }
2846
- function S(m) {
2847
- return m === 124 ? (e.enter("tableCellDivider"), e.consume(m), e.exit("tableCellDivider"), S) : m === null || Y(m) ? (e.exit("tableRow"), r(m)) : W(m) ? B(e, S, "whitespace")(m) : (e.enter("data"), M(m));
2861
+ function w(m) {
2862
+ return m === 124 ? (e.enter("tableCellDivider"), e.consume(m), e.exit("tableCellDivider"), w) : m === null || Y(m) ? (e.exit("tableRow"), r(m)) : B(m) ? H(e, w, "whitespace")(m) : (e.enter("data"), I(m));
2848
2863
  }
2849
- function M(m) {
2850
- return m === null || m === 124 || F(m) ? (e.exit("data"), S(m)) : (e.consume(m), m === 92 ? j : M);
2864
+ function I(m) {
2865
+ return m === null || m === 124 || _(m) ? (e.exit("data"), w(m)) : (e.consume(m), m === 92 ? P : I);
2851
2866
  }
2852
- function j(m) {
2853
- return m === 92 || m === 124 ? (e.consume(m), M) : M(m);
2867
+ function P(m) {
2868
+ return m === 92 || m === 124 ? (e.consume(m), I) : I(m);
2854
2869
  }
2855
2870
  }
2856
- function Ti(e, r) {
2857
- let t = -1, a = !0, i = 0, o = [0, 0, 0, 0], n = [0, 0, 0, 0], u = !1, c = 0, l, f, s;
2858
- const p = new yi();
2871
+ function Ni(e, r) {
2872
+ let t = -1, a = !0, i = 0, o = [0, 0, 0, 0], n = [0, 0, 0, 0], u = !1, c = 0, s, f, l;
2873
+ const p = new wi();
2859
2874
  for (; ++t < e.length; ) {
2860
- const x = e[t], h = x[1];
2861
- x[0] === "enter" ? h.type === "tableHead" ? (u = !1, c !== 0 && (gt(p, r, c, l, f), f = void 0, c = 0), l = {
2875
+ const b = e[t], h = b[1];
2876
+ b[0] === "enter" ? h.type === "tableHead" ? (u = !1, c !== 0 && (bt(p, r, c, s, f), f = void 0, c = 0), s = {
2862
2877
  type: "table",
2863
2878
  start: Object.assign({}, h.start),
2864
2879
  // Note: correct end is set later.
2865
2880
  end: Object.assign({}, h.end)
2866
- }, p.add(t, 0, [["enter", l, r]])) : h.type === "tableRow" || h.type === "tableDelimiterRow" ? (a = !0, s = void 0, o = [0, 0, 0, 0], n = [0, t + 1, 0, 0], u && (u = !1, f = {
2881
+ }, p.add(t, 0, [["enter", s, r]])) : h.type === "tableRow" || h.type === "tableDelimiterRow" ? (a = !0, l = void 0, o = [0, 0, 0, 0], n = [0, t + 1, 0, 0], u && (u = !1, f = {
2867
2882
  type: "tableBody",
2868
2883
  start: Object.assign({}, h.start),
2869
2884
  // Note: correct end is set later.
2870
2885
  end: Object.assign({}, h.end)
2871
- }, p.add(t, 0, [["enter", f, r]])), i = h.type === "tableDelimiterRow" ? 2 : f ? 3 : 1) : i && (h.type === "data" || h.type === "tableDelimiterMarker" || h.type === "tableDelimiterFiller") ? (a = !1, n[2] === 0 && (o[1] !== 0 && (n[0] = n[1], s = ge(p, r, o, i, void 0, s), o = [0, 0, 0, 0]), n[2] = t)) : h.type === "tableCellDivider" && (a ? a = !1 : (o[1] !== 0 && (n[0] = n[1], s = ge(p, r, o, i, void 0, s)), o = n, n = [o[1], t, 0, 0])) : h.type === "tableHead" ? (u = !0, c = t) : h.type === "tableRow" || h.type === "tableDelimiterRow" ? (c = t, o[1] !== 0 ? (n[0] = n[1], s = ge(p, r, o, i, t, s)) : n[1] !== 0 && (s = ge(p, r, n, i, t, s)), i = 0) : i && (h.type === "data" || h.type === "tableDelimiterMarker" || h.type === "tableDelimiterFiller") && (n[3] = t);
2886
+ }, p.add(t, 0, [["enter", f, r]])), i = h.type === "tableDelimiterRow" ? 2 : f ? 3 : 1) : i && (h.type === "data" || h.type === "tableDelimiterMarker" || h.type === "tableDelimiterFiller") ? (a = !1, n[2] === 0 && (o[1] !== 0 && (n[0] = n[1], l = ge(p, r, o, i, void 0, l), o = [0, 0, 0, 0]), n[2] = t)) : h.type === "tableCellDivider" && (a ? a = !1 : (o[1] !== 0 && (n[0] = n[1], l = ge(p, r, o, i, void 0, l)), o = n, n = [o[1], t, 0, 0])) : h.type === "tableHead" ? (u = !0, c = t) : h.type === "tableRow" || h.type === "tableDelimiterRow" ? (c = t, o[1] !== 0 ? (n[0] = n[1], l = ge(p, r, o, i, t, l)) : n[1] !== 0 && (l = ge(p, r, n, i, t, l)), i = 0) : i && (h.type === "data" || h.type === "tableDelimiterMarker" || h.type === "tableDelimiterFiller") && (n[3] = t);
2872
2887
  }
2873
- for (c !== 0 && gt(p, r, c, l, f), p.consume(r.events), t = -1; ++t < r.events.length; ) {
2874
- const x = r.events[t];
2875
- x[0] === "enter" && x[1].type === "table" && (x[1]._align = wi(r.events, t));
2888
+ for (c !== 0 && bt(p, r, c, s, f), p.consume(r.events), t = -1; ++t < r.events.length; ) {
2889
+ const b = r.events[t];
2890
+ b[0] === "enter" && b[1].type === "table" && (b[1]._align = Ci(r.events, t));
2876
2891
  }
2877
2892
  return e;
2878
2893
  }
@@ -2886,23 +2901,23 @@ function ge(e, r, t, a, i, o) {
2886
2901
  // Note: correct end is set later.
2887
2902
  end: Object.assign({}, c)
2888
2903
  }, e.add(t[1], 0, [["enter", o, r]]), t[2] !== 0) {
2889
- const l = Q(r.events, t[2]), f = Q(r.events, t[3]), s = {
2904
+ const s = Q(r.events, t[2]), f = Q(r.events, t[3]), l = {
2890
2905
  type: u,
2891
- start: Object.assign({}, l),
2906
+ start: Object.assign({}, s),
2892
2907
  end: Object.assign({}, f)
2893
2908
  };
2894
- if (e.add(t[2], 0, [["enter", s, r]]), a !== 2) {
2895
- const p = r.events[t[2]], x = r.events[t[3]];
2896
- if (p[1].end = Object.assign({}, x[1].end), p[1].type = "chunkText", p[1].contentType = "text", t[3] > t[2] + 1) {
2897
- const h = t[2] + 1, y = t[3] - t[2] - 1;
2898
- e.add(h, y, []);
2909
+ if (e.add(t[2], 0, [["enter", l, r]]), a !== 2) {
2910
+ const p = r.events[t[2]], b = r.events[t[3]];
2911
+ if (p[1].end = Object.assign({}, b[1].end), p[1].type = "chunkText", p[1].contentType = "text", t[3] > t[2] + 1) {
2912
+ const h = t[2] + 1, x = t[3] - t[2] - 1;
2913
+ e.add(h, x, []);
2899
2914
  }
2900
2915
  }
2901
- e.add(t[3] + 1, 0, [["exit", s, r]]);
2916
+ e.add(t[3] + 1, 0, [["exit", l, r]]);
2902
2917
  }
2903
2918
  return i !== void 0 && (o.end = Object.assign({}, Q(r.events, i)), e.add(i, 0, [["exit", o, r]]), o = void 0), o;
2904
2919
  }
2905
- function gt(e, r, t, a, i) {
2920
+ function bt(e, r, t, a, i) {
2906
2921
  const o = [], n = Q(r.events, t);
2907
2922
  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);
2908
2923
  }
@@ -2910,18 +2925,18 @@ function Q(e, r) {
2910
2925
  const t = e[r], a = t[0] === "enter" ? "start" : "end";
2911
2926
  return t[1][a];
2912
2927
  }
2913
- const Ai = {
2928
+ const Ii = {
2914
2929
  name: "tasklistCheck",
2915
- tokenize: Ii
2930
+ tokenize: Mi
2916
2931
  };
2917
- function Ni() {
2932
+ function Si() {
2918
2933
  return {
2919
2934
  text: {
2920
- 91: Ai
2935
+ 91: Ii
2921
2936
  }
2922
2937
  };
2923
2938
  }
2924
- function Ii(e, r, t) {
2939
+ function Mi(e, r, t) {
2925
2940
  const a = this;
2926
2941
  return i;
2927
2942
  function i(c) {
@@ -2933,52 +2948,52 @@ function Ii(e, r, t) {
2933
2948
  );
2934
2949
  }
2935
2950
  function o(c) {
2936
- return F(c) ? (e.enter("taskListCheckValueUnchecked"), e.consume(c), e.exit("taskListCheckValueUnchecked"), n) : c === 88 || c === 120 ? (e.enter("taskListCheckValueChecked"), e.consume(c), e.exit("taskListCheckValueChecked"), n) : t(c);
2951
+ return _(c) ? (e.enter("taskListCheckValueUnchecked"), e.consume(c), e.exit("taskListCheckValueUnchecked"), n) : c === 88 || c === 120 ? (e.enter("taskListCheckValueChecked"), e.consume(c), e.exit("taskListCheckValueChecked"), n) : t(c);
2937
2952
  }
2938
2953
  function n(c) {
2939
2954
  return c === 93 ? (e.enter("taskListCheckMarker"), e.consume(c), e.exit("taskListCheckMarker"), e.exit("taskListCheck"), u) : t(c);
2940
2955
  }
2941
2956
  function u(c) {
2942
- return Y(c) ? r(c) : W(c) ? e.check({
2943
- tokenize: Si
2957
+ return Y(c) ? r(c) : B(c) ? e.check({
2958
+ tokenize: Li
2944
2959
  }, r, t)(c) : t(c);
2945
2960
  }
2946
2961
  }
2947
- function Si(e, r, t) {
2948
- return B(e, a, "whitespace");
2962
+ function Li(e, r, t) {
2963
+ return H(e, a, "whitespace");
2949
2964
  function a(i) {
2950
2965
  return i === null ? t(i) : r(i);
2951
2966
  }
2952
2967
  }
2953
- function Mi(e) {
2954
- return Xn([
2955
- Jn(),
2956
- si(),
2957
- xi(e),
2958
- Ci(),
2959
- Ni()
2968
+ function Di(e) {
2969
+ return Kn([
2970
+ Yn(),
2971
+ fi(),
2972
+ ki(e),
2973
+ Ti(),
2974
+ Si()
2960
2975
  ]);
2961
2976
  }
2962
- const Li = {};
2963
- function Di(e) {
2977
+ const Ri = {};
2978
+ function Pi(e) {
2964
2979
  const r = (
2965
2980
  /** @type {Processor<Root>} */
2966
2981
  this
2967
- ), t = e || Li, a = r.data(), i = a.micromarkExtensions || (a.micromarkExtensions = []), o = a.fromMarkdownExtensions || (a.fromMarkdownExtensions = []), n = a.toMarkdownExtensions || (a.toMarkdownExtensions = []);
2968
- i.push(Mi(t)), o.push(Hn()), n.push(qn(t));
2982
+ ), t = e || Ri, a = r.data(), i = a.micromarkExtensions || (a.micromarkExtensions = []), o = a.fromMarkdownExtensions || (a.fromMarkdownExtensions = []), n = a.toMarkdownExtensions || (a.toMarkdownExtensions = []);
2983
+ i.push(Di(t)), o.push(Vn()), n.push(Xn(t));
2969
2984
  }
2970
2985
  function L(...e) {
2971
2986
  return e.filter(Boolean).join(" ");
2972
2987
  }
2973
- const Ri = ({ content: e }) => /* @__PURE__ */ d(
2974
- Tr,
2988
+ const Ei = ({ content: e }) => /* @__PURE__ */ d(
2989
+ Nr,
2975
2990
  {
2976
- remarkPlugins: [Di],
2991
+ remarkPlugins: [Pi],
2977
2992
  className: "cuadra-aui-md",
2978
- components: _i,
2993
+ components: ji,
2979
2994
  children: e
2980
2995
  }
2981
- ), ir = mr(Ri), Pi = ({ language: e, code: r }) => {
2996
+ ), or = gr(Ei), _i = ({ language: e, code: r }) => {
2982
2997
  const { isCopied: t, copyToClipboard: a } = Fi();
2983
2998
  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: [
2984
2999
  /* @__PURE__ */ d("span", { className: "cuadra-lowercase [&>span]:cuadra-text-xs cuadra-font-brand", children: e }),
@@ -2991,7 +3006,7 @@ const Ri = ({ content: e }) => /* @__PURE__ */ d(
2991
3006
  className: "cuadra-p-1 cuadra-rounded hover:cuadra-bg-muted cuadra-transition-colors",
2992
3007
  "aria-label": "Copy code",
2993
3008
  children: [
2994
- !t && /* @__PURE__ */ d($r, { className: "cuadra-h-4 cuadra-w-4" }),
3009
+ !t && /* @__PURE__ */ d(Ur, { className: "cuadra-h-4 cuadra-w-4" }),
2995
3010
  t && /* @__PURE__ */ d(Fr, { className: "cuadra-h-4 cuadra-w-4" })
2996
3011
  ]
2997
3012
  }
@@ -3000,13 +3015,13 @@ const Ri = ({ content: e }) => /* @__PURE__ */ d(
3000
3015
  }, Fi = ({
3001
3016
  copiedDuration: e = 3e3
3002
3017
  } = {}) => {
3003
- const [r, t] = N(!1);
3018
+ const [r, t] = S(!1);
3004
3019
  return { isCopied: r, copyToClipboard: (i) => {
3005
3020
  i && navigator.clipboard.writeText(i).then(() => {
3006
3021
  t(!0), setTimeout(() => t(!1), e);
3007
3022
  });
3008
3023
  } };
3009
- }, _i = Cr({
3024
+ }, ji = Tr({
3010
3025
  h1: ({ className: e, ...r }) => /* @__PURE__ */ d(
3011
3026
  "h1",
3012
3027
  {
@@ -3107,7 +3122,7 @@ const Ri = ({ content: e }) => /* @__PURE__ */ d(
3107
3122
  }
3108
3123
  ),
3109
3124
  code: function({ className: r, ...t }) {
3110
- const a = vr();
3125
+ const a = Ar();
3111
3126
  return /* @__PURE__ */ d(
3112
3127
  "code",
3113
3128
  {
@@ -3116,28 +3131,28 @@ const Ri = ({ content: e }) => /* @__PURE__ */ d(
3116
3131
  }
3117
3132
  );
3118
3133
  },
3119
- CodeHeader: Pi
3120
- }), bt = [
3134
+ CodeHeader: _i
3135
+ }), yt = [
3121
3136
  "Sending question…",
3122
3137
  "Understanding your need…",
3123
3138
  "Scanning data…",
3124
3139
  "Comparing results…",
3125
3140
  "Composing answer…"
3126
3141
  ];
3127
- function Ei({ active: e }) {
3128
- const [r, t] = N(0);
3129
- return P(() => {
3142
+ function zi({ active: e }) {
3143
+ const [r, t] = S(0);
3144
+ return E(() => {
3130
3145
  if (!e) {
3131
3146
  t(0);
3132
3147
  return;
3133
3148
  }
3134
3149
  const a = window.setInterval(() => {
3135
- t((i) => i >= bt.length - 1 ? (window.clearInterval(a), i) : i + 1);
3150
+ t((i) => i >= yt.length - 1 ? (window.clearInterval(a), i) : i + 1);
3136
3151
  }, 2500);
3137
3152
  return () => window.clearInterval(a);
3138
3153
  }, [e]), e ? /* @__PURE__ */ C("span", { className: "cuadra-text-xs cuadra-text-muted-foreground cuadra-font-brand", children: [
3139
3154
  "Thinking… ",
3140
- bt[r]
3155
+ yt[r]
3141
3156
  ] }) : null;
3142
3157
  }
3143
3158
  function xt({
@@ -3148,33 +3163,33 @@ function xt({
3148
3163
  inputPlaceholder: i = "Type your message...",
3149
3164
  enableAttachments: o = !1
3150
3165
  } = {}) {
3151
- const n = xr(), [u, c] = N(!1), [l, f] = N(null), [s, p] = N(!1);
3152
- return P(() => {
3166
+ const n = kr(), [u, c] = S(!1), [s, f] = S(null), [l, p] = S(!1);
3167
+ return E(() => {
3153
3168
  if (!n) {
3154
3169
  c(!1);
3155
3170
  return;
3156
3171
  }
3157
3172
  try {
3158
- const x = n?.store;
3159
- if (!x) {
3173
+ const b = n?.store;
3174
+ if (!b) {
3160
3175
  c(!1);
3161
3176
  return;
3162
3177
  }
3163
- const h = x.subscribe?.((g) => {
3164
- const b = g?.threadId, k = g?.messages || [], w = g?.isLoadingHistory || !1, A = k.length;
3165
- b && b !== l && f(b), c(w && A === 0);
3166
- const T = k.some(
3167
- (S) => S.role === "assistant" && !!S.content && (Array.isArray(S.content) ? S.content.some((M) => typeof M == "object" && M?.text ? M.text.trim().length > 0 : !1) : typeof S.content == "string" ? S.content.trim().length > 0 : !1)
3178
+ const h = b.subscribe?.((y) => {
3179
+ const g = y?.threadId, k = y?.messages || [], v = y?.isLoadingHistory || !1, M = k.length;
3180
+ g && g !== s && f(g), c(v && M === 0);
3181
+ const A = k.some(
3182
+ (w) => w.role === "assistant" && !!w.content && (Array.isArray(w.content) ? w.content.some((I) => typeof I == "object" && I?.text ? I.text.trim().length > 0 : !1) : typeof w.content == "string" ? w.content.trim().length > 0 : !1)
3168
3183
  );
3169
- p(T);
3170
- }), y = x.getState?.();
3171
- if (y) {
3172
- const g = y?.threadId, b = y?.messages || [], k = y?.isLoadingHistory || !1, w = b.length;
3173
- g && g !== l && f(g), c(k && w === 0);
3174
- const I = b.some(
3175
- (T) => T.role === "assistant" && !!T.content && (Array.isArray(T.content) ? T.content.some((S) => typeof S == "object" && S?.text ? S.text.trim().length > 0 : !1) : typeof T.content == "string" ? T.content.trim().length > 0 : !1)
3184
+ p(A);
3185
+ }), x = b.getState?.();
3186
+ if (x) {
3187
+ const y = x?.threadId, g = x?.messages || [], k = x?.isLoadingHistory || !1, v = g.length;
3188
+ y && y !== s && f(y), c(k && v === 0);
3189
+ const N = g.some(
3190
+ (A) => A.role === "assistant" && !!A.content && (Array.isArray(A.content) ? A.content.some((w) => typeof w == "object" && w?.text ? w.text.trim().length > 0 : !1) : typeof A.content == "string" ? A.content.trim().length > 0 : !1)
3176
3191
  );
3177
- p(I);
3192
+ p(N);
3178
3193
  }
3179
3194
  return () => {
3180
3195
  h && h();
@@ -3182,18 +3197,18 @@ function xt({
3182
3197
  } catch {
3183
3198
  c(!1);
3184
3199
  }
3185
- }, [n, l]), /* @__PURE__ */ C(ne.Root, { className: "cuadra-bg-inherit cuadra-flex cuadra-flex-col cuadra-w-full cuadra-h-full", children: [
3200
+ }, [n, s]), /* @__PURE__ */ C(ne.Root, { className: "cuadra-bg-inherit cuadra-flex cuadra-flex-col cuadra-w-full cuadra-h-full", children: [
3186
3201
  /* @__PURE__ */ d(
3187
3202
  ne.Viewport,
3188
3203
  {
3189
3204
  className: "cuadra-w-full cuadra-bg-inherit cuadra-px-4 cuadra-flex-1 cuadra-min-h-0 cuadra-overflow-y-auto cuadra-relative scrollbar-thin cuadra-pt-4",
3190
3205
  style: t ? { paddingTop: t } : void 0,
3191
3206
  children: u ? /* @__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: [
3192
- /* @__PURE__ */ d(It, { className: "cuadra-h-6 cuadra-w-6 cuadra-animate-spin cuadra-text-muted-foreground" }),
3207
+ /* @__PURE__ */ d(St, { className: "cuadra-h-6 cuadra-w-6 cuadra-animate-spin cuadra-text-muted-foreground" }),
3193
3208
  /* @__PURE__ */ d("p", { className: "cuadra-text-sm cuadra-text-muted-foreground font-brand", children: "Loading messages..." })
3194
- ] }) }) : /* @__PURE__ */ C(H, { children: [
3209
+ ] }) }) : /* @__PURE__ */ C(q, { children: [
3195
3210
  /* @__PURE__ */ d(ne.Empty, { children: /* @__PURE__ */ d(
3196
- zi,
3211
+ $i,
3197
3212
  {
3198
3213
  title: e,
3199
3214
  subtitle: r,
@@ -3204,12 +3219,12 @@ function xt({
3204
3219
  ne.Messages,
3205
3220
  {
3206
3221
  components: {
3207
- UserMessage: ji,
3208
- AssistantMessage: $i
3222
+ UserMessage: Oi,
3223
+ AssistantMessage: Ui
3209
3224
  }
3210
3225
  }
3211
3226
  ),
3212
- /* @__PURE__ */ d(ne.If, { running: !0, children: !s && /* @__PURE__ */ d("div", { className: "cuadra-mt-2 cuadra-max-w-2xl", children: /* @__PURE__ */ d(Ei, { active: !0 }) }) })
3227
+ /* @__PURE__ */ d(ne.If, { running: !0, children: !l && /* @__PURE__ */ d("div", { className: "cuadra-mt-2 cuadra-max-w-2xl", children: /* @__PURE__ */ d(zi, { active: !0 }) }) })
3213
3228
  ] })
3214
3229
  }
3215
3230
  ),
@@ -3219,16 +3234,16 @@ function xt({
3219
3234
  {
3220
3235
  components: {
3221
3236
  Attachment: () => {
3222
- const x = At(({ attachment: h }) => h);
3223
- return x ? /* @__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: [
3224
- /* @__PURE__ */ d("span", { className: "cuadra-text-xs cuadra-text-muted-foreground font-brand", children: x.name || "Attachment" }),
3225
- /* @__PURE__ */ d(yr.Remove, { asChild: !0, children: /* @__PURE__ */ d(
3237
+ const b = Nt(({ attachment: h }) => h);
3238
+ return b ? /* @__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: [
3239
+ /* @__PURE__ */ d("span", { className: "cuadra-text-xs cuadra-text-muted-foreground font-brand", children: b.name || "Attachment" }),
3240
+ /* @__PURE__ */ d(wr.Remove, { asChild: !0, children: /* @__PURE__ */ d(
3226
3241
  "button",
3227
3242
  {
3228
3243
  type: "button",
3229
3244
  className: "cuadra-flex cuadra-items-center cuadra-justify-center cuadra-size-4 cuadra-rounded hover:cuadra-bg-background cuadra-transition-colors",
3230
3245
  "aria-label": "Remove attachment",
3231
- children: /* @__PURE__ */ d(Ue, { className: "cuadra-h-3 cuadra-w-3 cuadra-text-muted-foreground" })
3246
+ children: /* @__PURE__ */ d(We, { className: "cuadra-h-3 cuadra-w-3 cuadra-text-muted-foreground" })
3232
3247
  }
3233
3248
  ) })
3234
3249
  ] }) : null;
@@ -3246,7 +3261,7 @@ function xt({
3246
3261
  {
3247
3262
  rows: 3,
3248
3263
  placeholder: i,
3249
- className: "cuadra-flex cuadra-min-h-[80px] cuadra-w-full cuadra-rounded-md cuadra-border cuadra-border-border cuadra-bg-background cuadra-px-3 cuadra-py-2 cuadra-text-base placeholder:cuadra-text-muted-foreground focus-visible:cuadra-outline-none disabled:cuadra-cursor-not-allowed disabled:cuadra-opacity-50 cuadra-resize-none font-brand",
3264
+ className: "cuadra-flex cuadra-min-h-[80px] cuadra-w-full cuadra-rounded-md cuadra-border cuadra-border-border cuadra-bg-background cuadra-px-3 cuadra-py-2 cuadra-text-base cuadra-text-foreground placeholder:cuadra-text-muted-foreground focus-visible:cuadra-outline-none disabled:cuadra-cursor-not-allowed disabled:cuadra-opacity-50 cuadra-resize-none font-brand",
3250
3265
  style: {
3251
3266
  paddingRight: o ? "5rem" : "3rem",
3252
3267
  fontSize: "1rem",
@@ -3272,7 +3287,7 @@ function xt({
3272
3287
  right: "3rem"
3273
3288
  },
3274
3289
  "aria-label": "Attach file",
3275
- children: /* @__PURE__ */ d(St, { className: "cuadra-h-4 cuadra-w-4 cuadra-text-muted-foreground", strokeWidth: 1.5 })
3290
+ children: /* @__PURE__ */ d(Mt, { className: "cuadra-h-4 cuadra-w-4 cuadra-text-muted-foreground", strokeWidth: 1.5 })
3276
3291
  }
3277
3292
  )
3278
3293
  }
@@ -3290,15 +3305,15 @@ function xt({
3290
3305
  },
3291
3306
  "aria-label": "Send message",
3292
3307
  type: "button",
3293
- children: /* @__PURE__ */ d(Rr, { className: "cuadra-h-4 cuadra-w-4" })
3308
+ children: /* @__PURE__ */ d(Er, { className: "cuadra-h-4 cuadra-w-4" })
3294
3309
  }
3295
3310
  ) })
3296
3311
  ] })
3297
3312
  ] })
3298
3313
  ] });
3299
3314
  }
3300
- function zi({ title: e, subtitle: r, suggestions: t }) {
3301
- const a = kr(), i = async (o) => {
3315
+ function $i({ title: e, subtitle: r, suggestions: t }) {
3316
+ const a = vr(), i = async (o) => {
3302
3317
  try {
3303
3318
  a.composer().setText(o), await new Promise((n) => setTimeout(n, 10)), a.composer().send();
3304
3319
  } catch {
@@ -3314,7 +3329,7 @@ function zi({ title: e, subtitle: r, suggestions: t }) {
3314
3329
  {
3315
3330
  type: "button",
3316
3331
  onClick: () => i(o.prompt),
3317
- className: "cuadra-w-full cuadra-text-center cuadra-px-4 cuadra-py-3 cuadra-rounded-lg cuadra-border cuadra-border-border cuadra-bg-background cuadra-text-sm font-brand cuadra-cursor-pointer focus:cuadra-outline-none focus:cuadra-ring-0",
3332
+ className: "cuadra-w-full cuadra-text-center cuadra-px-4 cuadra-py-3 cuadra-rounded-lg cuadra-border cuadra-border-border cuadra-bg-background cuadra-text-sm cuadra-text-foreground font-brand cuadra-cursor-pointer focus:cuadra-outline-none focus:cuadra-ring-0",
3318
3333
  style: { borderWidth: "1px" },
3319
3334
  children: o.prompt
3320
3335
  },
@@ -3322,14 +3337,14 @@ function zi({ title: e, subtitle: r, suggestions: t }) {
3322
3337
  )) })
3323
3338
  ] }) });
3324
3339
  }
3325
- function ji() {
3340
+ function Oi() {
3326
3341
  return /* @__PURE__ */ C(oe.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: [
3327
3342
  /* @__PURE__ */ d(
3328
3343
  oe.Attachments,
3329
3344
  {
3330
3345
  components: {
3331
3346
  Attachment: () => {
3332
- const e = At(({ attachment: o }) => o);
3347
+ const e = Nt(({ attachment: o }) => o);
3333
3348
  if (!e) return null;
3334
3349
  const r = e.type === "image", t = e.file, a = e.content?.find((o) => o.type === "image"), i = t ? URL.createObjectURL(t) : a?.image;
3335
3350
  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(
@@ -3341,7 +3356,7 @@ function ji() {
3341
3356
  style: { borderWidth: "1px" }
3342
3357
  }
3343
3358
  ) : /* @__PURE__ */ C("div", { className: "cuadra-flex cuadra-items-center cuadra-gap-2 cuadra-rounded-lg cuadra-border cuadra-border-border cuadra-bg-muted cuadra-px-3 cuadra-py-2", children: [
3344
- /* @__PURE__ */ d(St, { className: "cuadra-h-4 cuadra-w-4 cuadra-text-muted-foreground" }),
3359
+ /* @__PURE__ */ d(Mt, { className: "cuadra-h-4 cuadra-w-4 cuadra-text-muted-foreground" }),
3345
3360
  /* @__PURE__ */ d("span", { className: "cuadra-text-sm cuadra-text-foreground font-brand", children: e.name || "Attachment" })
3346
3361
  ] }) });
3347
3362
  }
@@ -3368,7 +3383,7 @@ function ji() {
3368
3383
  oe.Parts,
3369
3384
  {
3370
3385
  components: {
3371
- Text: ({ text: e }) => /* @__PURE__ */ d(ir, { content: e || "" })
3386
+ Text: ({ text: e }) => /* @__PURE__ */ d(or, { content: e || "" })
3372
3387
  }
3373
3388
  }
3374
3389
  )
@@ -3376,7 +3391,7 @@ function ji() {
3376
3391
  )
3377
3392
  ] });
3378
3393
  }
3379
- function $i() {
3394
+ function Ui() {
3380
3395
  return /* @__PURE__ */ d(oe.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__ */ d(
3381
3396
  "div",
3382
3397
  {
@@ -3390,14 +3405,14 @@ function $i() {
3390
3405
  oe.Parts,
3391
3406
  {
3392
3407
  components: {
3393
- Text: ({ text: e }) => /* @__PURE__ */ d(ir, { content: e || "" })
3408
+ Text: ({ text: e }) => /* @__PURE__ */ d(or, { content: e || "" })
3394
3409
  }
3395
3410
  }
3396
3411
  )
3397
3412
  }
3398
3413
  ) });
3399
3414
  }
3400
- const or = ({ className: e = "", theme: r = "system" }) => {
3415
+ const cr = ({ className: e = "", theme: r = "system" }) => {
3401
3416
  const t = () => {
3402
3417
  if (typeof window > "u") return "light";
3403
3418
  if (r === "system") {
@@ -3405,10 +3420,10 @@ const or = ({ className: e = "", theme: r = "system" }) => {
3405
3420
  return n || (window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light");
3406
3421
  }
3407
3422
  return r;
3408
- }, [a, i] = N(t);
3409
- return P(() => {
3423
+ }, [a, i] = S(t);
3424
+ return E(() => {
3410
3425
  r !== "system" && i(r);
3411
- }, [r]), P(() => {
3426
+ }, [r]), E(() => {
3412
3427
  const n = document.documentElement;
3413
3428
  n.classList.remove("light", "dark"), n.classList.add(a), r === "system" && localStorage.setItem("theme", a);
3414
3429
  }, [a, r]), /* @__PURE__ */ d(
@@ -3422,7 +3437,7 @@ const or = ({ className: e = "", theme: r = "system" }) => {
3422
3437
  disabled: r !== "system",
3423
3438
  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}`,
3424
3439
  children: /* @__PURE__ */ d(
3425
- zr,
3440
+ $r,
3426
3441
  {
3427
3442
  className: `cuadra-h-4 cuadra-w-4 cuadra-transition-colors ${a === "dark" ? "cuadra-text-primary" : "cuadra-text-gray-400"}`
3428
3443
  }
@@ -3430,33 +3445,33 @@ const or = ({ className: e = "", theme: r = "system" }) => {
3430
3445
  }
3431
3446
  );
3432
3447
  };
3433
- function Oi({ onThreadSelect: e }) {
3434
- const r = Ct(), t = wr((g) => g.threadId), [a, i] = N(null), o = r?.id === t, n = a === r?.id, [u, c] = N(!1), [l, f] = N(r?.title || ""), [s, p] = N(!1), [x, h] = N(!1), y = async () => {
3435
- if (!r?.remoteId || !l || l === r.title) {
3448
+ function Wi({ onThreadSelect: e }) {
3449
+ const r = Ct(), t = Cr((y) => y.threadId), [a, i] = S(null), o = r?.id === t, n = a === r?.id, [u, c] = S(!1), [s, f] = S(r?.title || ""), [l, p] = S(!1), [b, h] = S(!1), x = async () => {
3450
+ if (!r?.remoteId || !s || s === r.title) {
3436
3451
  c(!1);
3437
3452
  return;
3438
3453
  }
3439
3454
  try {
3440
3455
  h(!0);
3441
- const g = window.__cuadraThreadListAdapter;
3442
- g && typeof g.rename == "function" && await g.rename(r.remoteId, l), c(!1), p(!1);
3456
+ const y = window.__cuadraThreadListAdapter;
3457
+ y && typeof y.rename == "function" && await y.rename(r.remoteId, s), c(!1), p(!1);
3443
3458
  } catch {
3444
3459
  c(!1), p(!1);
3445
3460
  } finally {
3446
3461
  h(!1);
3447
3462
  }
3448
3463
  };
3449
- return P(() => {
3464
+ return E(() => {
3450
3465
  r?.title && !u && f(r.title);
3451
3466
  }, [r?.title, u]), r ? /* @__PURE__ */ d(
3452
- Me.Root,
3467
+ Le.Root,
3453
3468
  {
3454
3469
  className: `group cuadra-relative cuadra-flex cuadra-items-center cuadra-gap-3 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"}`,
3455
3470
  style: { marginBottom: "0.5rem" },
3456
3471
  onMouseEnter: () => i(r.id),
3457
3472
  onMouseLeave: () => i(null),
3458
3473
  children: /* @__PURE__ */ C(
3459
- Me.Trigger,
3474
+ Le.Trigger,
3460
3475
  {
3461
3476
  className: "cuadra-p-3 cuadra-flex-1 cuadra-flex cuadra-items-center cuadra-justify-between cuadra-w-full cuadra-min-w-0 cuadra-cursor-pointer",
3462
3477
  onClick: () => e?.(),
@@ -3465,32 +3480,32 @@ function Oi({ onThreadSelect: e }) {
3465
3480
  "input",
3466
3481
  {
3467
3482
  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",
3468
- value: l,
3469
- onChange: (g) => f(g.target.value),
3470
- onKeyDown: (g) => {
3471
- g.key === "Enter" && y(), g.key === "Escape" && (c(!1), f(r.title || ""));
3483
+ value: s,
3484
+ onChange: (y) => f(y.target.value),
3485
+ onKeyDown: (y) => {
3486
+ y.key === "Enter" && x(), y.key === "Escape" && (c(!1), f(r.title || ""));
3472
3487
  },
3473
- disabled: x,
3488
+ disabled: b,
3474
3489
  autoFocus: !0,
3475
- onClick: (g) => g.stopPropagation()
3490
+ onClick: (y) => y.stopPropagation()
3476
3491
  }
3477
- ) : /* @__PURE__ */ C(H, { children: [
3492
+ ) : /* @__PURE__ */ C(q, { children: [
3478
3493
  /* @__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" }),
3479
3494
  r.updatedAt && /* @__PURE__ */ d("span", { className: "cuadra-text-xs cuadra-text-muted-foreground cuadra-mt-1 font-brand", children: new Date(r.updatedAt).toLocaleDateString() })
3480
3495
  ] }) }),
3481
- /* @__PURE__ */ d("div", { className: "cuadra-ml-2 cuadra-flex-shrink-0 cuadra-w-6 cuadra-h-6 cuadra-flex cuadra-items-center cuadra-justify-center", children: (n || o || s) && /* @__PURE__ */ C("div", { className: "cuadra-relative", children: [
3496
+ /* @__PURE__ */ d("div", { className: "cuadra-ml-2 cuadra-flex-shrink-0 cuadra-w-6 cuadra-h-6 cuadra-flex cuadra-items-center cuadra-justify-center", children: (n || o || l) && /* @__PURE__ */ C("div", { className: "cuadra-relative", children: [
3482
3497
  /* @__PURE__ */ d(
3483
3498
  "button",
3484
3499
  {
3485
3500
  className: "cuadra-p-1 cuadra-rounded hover:cuadra-bg-background/50 cuadra-transition-colors",
3486
- onClick: (g) => {
3487
- g.stopPropagation(), p(!s);
3501
+ onClick: (y) => {
3502
+ y.stopPropagation(), p(!l);
3488
3503
  },
3489
3504
  "aria-label": "Thread options",
3490
- children: /* @__PURE__ */ d(Ur, { className: "cuadra-h-4 cuadra-w-4 cuadra-text-muted-foreground" })
3505
+ children: /* @__PURE__ */ d(Br, { className: "cuadra-h-4 cuadra-w-4 cuadra-text-muted-foreground" })
3491
3506
  }
3492
3507
  ),
3493
- s && /* @__PURE__ */ C(H, { children: [
3508
+ l && /* @__PURE__ */ C(q, { children: [
3494
3509
  /* @__PURE__ */ d(
3495
3510
  "div",
3496
3511
  {
@@ -3502,30 +3517,30 @@ function Oi({ onThreadSelect: e }) {
3502
3517
  "button",
3503
3518
  {
3504
3519
  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",
3505
- onClick: (g) => {
3506
- g.stopPropagation(), y();
3520
+ onClick: (y) => {
3521
+ y.stopPropagation(), x();
3507
3522
  },
3508
- disabled: x,
3523
+ disabled: b,
3509
3524
  children: "Save"
3510
3525
  }
3511
- ) : /* @__PURE__ */ C(H, { children: [
3526
+ ) : /* @__PURE__ */ C(q, { children: [
3512
3527
  /* @__PURE__ */ d(
3513
3528
  "button",
3514
3529
  {
3515
3530
  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",
3516
- onClick: (g) => {
3517
- g.stopPropagation(), c(!0), f(r.title || ""), p(!1);
3531
+ onClick: (y) => {
3532
+ y.stopPropagation(), c(!0), f(r.title || ""), p(!1);
3518
3533
  },
3519
3534
  children: "Rename"
3520
3535
  }
3521
3536
  ),
3522
3537
  /* @__PURE__ */ d("div", { className: "cuadra-border-t cuadra-border-border" }),
3523
- /* @__PURE__ */ d(Me.Delete, { asChild: !0, children: /* @__PURE__ */ d(
3538
+ /* @__PURE__ */ d(Le.Delete, { asChild: !0, children: /* @__PURE__ */ d(
3524
3539
  "button",
3525
3540
  {
3526
3541
  className: "cuadra-w-full cuadra-px-3 cuadra-py-2 cuadra-text-sm cuadra-text-left cuadra-text-destructive hover:cuadra-bg-muted cuadra-transition-colors font-brand",
3527
- onClick: (g) => {
3528
- g.stopPropagation(), p(!1);
3542
+ onClick: (y) => {
3543
+ y.stopPropagation(), p(!1);
3529
3544
  },
3530
3545
  children: "Delete"
3531
3546
  }
@@ -3539,13 +3554,13 @@ function Oi({ onThreadSelect: e }) {
3539
3554
  }
3540
3555
  ) : null;
3541
3556
  }
3542
- function yt({
3557
+ function kt({
3543
3558
  onThreadSelect: e,
3544
3559
  showThemeToggle: r,
3545
3560
  theme: t,
3546
3561
  onLogout: a
3547
3562
  }) {
3548
- return /* @__PURE__ */ C(Se.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: [
3563
+ return /* @__PURE__ */ C(Me.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: [
3549
3564
  /* @__PURE__ */ d("div", { className: "cuadra-border-b cuadra-border-border cuadra-flex cuadra-items-center cuadra-justify-end cuadra-transition-all cuadra-duration-300 cuadra-h-16 cuadra-px-4", children: /* @__PURE__ */ d(
3550
3565
  "button",
3551
3566
  {
@@ -3553,27 +3568,27 @@ function yt({
3553
3568
  onClick: e,
3554
3569
  className: "cuadra-flex md:cuadra-hidden 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",
3555
3570
  "aria-label": "Close",
3556
- children: /* @__PURE__ */ d(Ue, { className: "cuadra-h-4 cuadra-w-4 cuadra-text-foreground" })
3571
+ children: /* @__PURE__ */ d(We, { className: "cuadra-h-4 cuadra-w-4 cuadra-text-foreground" })
3557
3572
  }
3558
3573
  ) }),
3559
3574
  /* @__PURE__ */ C("div", { className: "cuadra-flex-1 cuadra-overflow-y-auto cuadra-p-2 scrollbar-thin", children: [
3560
3575
  /* @__PURE__ */ d(
3561
- Se.New,
3576
+ Me.New,
3562
3577
  {
3563
3578
  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",
3564
3579
  onClick: () => e?.(),
3565
3580
  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: [
3566
- /* @__PURE__ */ d(Gr, { className: "cuadra-h-4 cuadra-w-4 cuadra-text-muted-foreground" }),
3581
+ /* @__PURE__ */ d(Jr, { className: "cuadra-h-4 cuadra-w-4 cuadra-text-muted-foreground" }),
3567
3582
  /* @__PURE__ */ d("h4", { className: "cuadra-text-sm cuadra-font-normal cuadra-text-foreground font-brand", children: "New Chat" })
3568
3583
  ] }) })
3569
3584
  }
3570
3585
  ),
3571
3586
  /* @__PURE__ */ d("div", { className: "cuadra-my-2 cuadra-border-t cuadra-border-border" }),
3572
3587
  /* @__PURE__ */ d(
3573
- Se.Items,
3588
+ Me.Items,
3574
3589
  {
3575
3590
  components: {
3576
- ThreadListItem: (i) => /* @__PURE__ */ d(Oi, { ...i, onThreadSelect: e })
3591
+ ThreadListItem: (i) => /* @__PURE__ */ d(Wi, { ...i, onThreadSelect: e })
3577
3592
  }
3578
3593
  }
3579
3594
  )
@@ -3586,18 +3601,18 @@ function yt({
3586
3601
  onClick: a,
3587
3602
  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",
3588
3603
  "aria-label": "Logout",
3589
- children: /* @__PURE__ */ d(Hr, { className: "cuadra-h-4 cuadra-w-4 cuadra-text-foreground" })
3604
+ children: /* @__PURE__ */ d(Vr, { className: "cuadra-h-4 cuadra-w-4 cuadra-text-foreground" })
3590
3605
  }
3591
3606
  ),
3592
- r && /* @__PURE__ */ d(or, { theme: t })
3607
+ r && /* @__PURE__ */ d(cr, { theme: t })
3593
3608
  ] })
3594
3609
  ] });
3595
3610
  }
3596
- const Ui = `
3611
+ const Bi = `
3597
3612
  @keyframes rotate {
3598
3613
  100% { transform: rotate(1turn); }
3599
3614
  }
3600
- `, Fe = ({
3615
+ `, _e = ({
3601
3616
  children: e,
3602
3617
  className: r = "",
3603
3618
  paddingX: t = "px-0",
@@ -3606,8 +3621,8 @@ const Ui = `
3606
3621
  style: o,
3607
3622
  contentStyle: n,
3608
3623
  rotating: u = !1
3609
- }) => /* @__PURE__ */ C(H, { children: [
3610
- /* @__PURE__ */ d("style", { children: Ui }),
3624
+ }) => /* @__PURE__ */ C(q, { children: [
3625
+ /* @__PURE__ */ d("style", { children: Bi }),
3611
3626
  /* @__PURE__ */ C(
3612
3627
  "div",
3613
3628
  {
@@ -3617,19 +3632,17 @@ const Ui = `
3617
3632
  /* @__PURE__ */ d(
3618
3633
  "div",
3619
3634
  {
3620
- className: "cuadra-absolute md:cuadra-rounded-xl",
3635
+ className: `cuadra-absolute md:cuadra-rounded-xl cuadra-textured-card-border ${u ? "cuadra-textured-card-border-rotating" : ""}`,
3621
3636
  style: u ? {
3622
3637
  left: "-100%",
3623
3638
  top: "-100%",
3624
3639
  width: "300%",
3625
3640
  height: "300%",
3626
- backgroundImage: "conic-gradient(#F4633A, #FF7A4D, #FF8C5C, #F4633A, #FF7A4D, #FF8C5C)",
3627
3641
  backgroundRepeat: "no-repeat",
3628
3642
  backgroundSize: "cover",
3629
3643
  backgroundPosition: "center",
3630
3644
  animation: "rotate 4s linear infinite"
3631
3645
  } : {
3632
- backgroundImage: "linear-gradient(to right, #F4633A, #FF7A4D, #FF8C5C, #F4633A)",
3633
3646
  backgroundSize: "cover",
3634
3647
  backgroundPosition: "center",
3635
3648
  backgroundRepeat: "no-repeat",
@@ -3654,7 +3667,7 @@ const Ui = `
3654
3667
  ]
3655
3668
  }
3656
3669
  )
3657
- ] }), kt = ({
3670
+ ] }), wt = ({
3658
3671
  currentModel: e,
3659
3672
  models: r,
3660
3673
  modelsLoading: t,
@@ -3664,59 +3677,59 @@ const Ui = `
3664
3677
  showThemeToggle: n = !0,
3665
3678
  theme: u = "system",
3666
3679
  onMobileMenuClick: c,
3667
- showMobileMenuButton: l = !1
3680
+ showMobileMenuButton: s = !1
3668
3681
  }) => {
3669
- const [f, s] = N(!1), [p, x] = N(!1), h = ze(null);
3670
- P(() => {
3671
- const b = (k) => {
3672
- h.current && !h.current.contains(k.target) && s(!1);
3682
+ const [f, l] = S(!1), [p, b] = S(!1), h = ze(null);
3683
+ E(() => {
3684
+ const g = (k) => {
3685
+ h.current && !h.current.contains(k.target) && l(!1);
3673
3686
  };
3674
- return f && document.addEventListener("mousedown", b), () => {
3675
- document.removeEventListener("mousedown", b);
3687
+ return f && document.addEventListener("mousedown", g), () => {
3688
+ document.removeEventListener("mousedown", g);
3676
3689
  };
3677
3690
  }, [f]);
3678
- const y = r.find((b) => b.id === e), g = (b) => {
3679
- i(b), s(!1), x(!1);
3691
+ const x = r.find((g) => g.id === e), y = (g) => {
3692
+ i(g), l(!1), b(!1);
3680
3693
  };
3681
3694
  return /* @__PURE__ */ C("div", { className: "cuadra-h-16 cuadra-px-4 cuadra-border-b cuadra-border-border cuadra-flex cuadra-items-center cuadra-justify-between cuadra-bg-background", children: [
3682
3695
  /* @__PURE__ */ C("div", { className: "cuadra-flex cuadra-items-center cuadra-gap-2", children: [
3683
- l && /* @__PURE__ */ d(
3696
+ s && /* @__PURE__ */ d(
3684
3697
  "button",
3685
3698
  {
3686
3699
  type: "button",
3687
3700
  onClick: c,
3688
3701
  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 md:cuadra-hidden",
3689
3702
  "aria-label": "Toggle thread list",
3690
- children: /* @__PURE__ */ d(Xr, { className: "cuadra-h-4 cuadra-w-4 cuadra-text-foreground" })
3703
+ children: /* @__PURE__ */ d(Kr, { className: "cuadra-h-4 cuadra-w-4 cuadra-text-foreground" })
3691
3704
  }
3692
3705
  ),
3693
- n && /* @__PURE__ */ d("div", { className: "cuadra-hidden md:cuadra-flex cuadra-items-center cuadra-gap-2", children: /* @__PURE__ */ d(or, { theme: u }) })
3706
+ n && /* @__PURE__ */ d("div", { className: "cuadra-hidden md:cuadra-flex cuadra-items-center cuadra-gap-2", children: /* @__PURE__ */ d(cr, { theme: u }) })
3694
3707
  ] }),
3695
3708
  /* @__PURE__ */ C("div", { className: "cuadra-flex cuadra-items-center cuadra-gap-2 md:cuadra-ml-0 cuadra-ml-auto", children: [
3696
3709
  !o && /* @__PURE__ */ d("label", { className: "cuadra-hidden md:cuadra-inline cuadra-text-sm cuadra-text-muted-foreground cuadra-font-brand", children: "Model" }),
3697
- 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(H, { children: [
3710
+ 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(q, { children: [
3698
3711
  /* @__PURE__ */ C("div", { ref: h, className: "cuadra-hidden md:cuadra-block cuadra-relative cuadra-w-48", children: [
3699
3712
  /* @__PURE__ */ C(
3700
3713
  "button",
3701
3714
  {
3702
3715
  type: "button",
3703
- onClick: () => s(!f),
3716
+ onClick: () => l(!f),
3704
3717
  disabled: t || r.length === 0 || !!a,
3705
3718
  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",
3706
3719
  children: [
3707
- /* @__PURE__ */ d("span", { className: y ? "cuadra-text-foreground" : "cuadra-text-muted-foreground", children: y?.name || "Select model" }),
3708
- /* @__PURE__ */ d(ot, { className: "cuadra-ml-2 cuadra-h-4 cuadra-w-4 cuadra-opacity-50" })
3720
+ /* @__PURE__ */ d("span", { className: x ? "cuadra-text-foreground" : "cuadra-text-muted-foreground", children: x?.name || "Select model" }),
3721
+ /* @__PURE__ */ d(ct, { className: "cuadra-ml-2 cuadra-h-4 cuadra-w-4 cuadra-opacity-50" })
3709
3722
  ]
3710
3723
  }
3711
3724
  ),
3712
- f && r.length > 0 && /* @__PURE__ */ d("div", { className: "cuadra-absolute cuadra-z-50 cuadra-mt-1 cuadra-w-full cuadra-min-w-[8rem] cuadra-overflow-hidden cuadra-rounded-md glass-popover cuadra-text-popover-foreground cuadra-animate-in fade-in-80 cuadra-border cuadra-border-border cuadra-bg-popover cuadra-shadow-md", children: /* @__PURE__ */ d("div", { className: "cuadra-p-1", children: r.map((b) => /* @__PURE__ */ C(
3725
+ f && r.length > 0 && /* @__PURE__ */ d("div", { className: "cuadra-absolute cuadra-z-50 cuadra-mt-1 cuadra-w-full cuadra-min-w-[8rem] cuadra-overflow-hidden cuadra-rounded-md glass-popover cuadra-text-popover-foreground cuadra-animate-in fade-in-80 cuadra-border cuadra-border-border cuadra-bg-popover cuadra-shadow-md", children: /* @__PURE__ */ d("div", { className: "cuadra-p-1", children: r.map((g) => /* @__PURE__ */ C(
3713
3726
  "button",
3714
3727
  {
3715
3728
  type: "button",
3716
- onClick: () => g(b.id),
3717
- className: `cuadra-relative cuadra-flex cuadra-w-full cuadra-cursor-pointer cuadra-select-none cuadra-items-center cuadra-rounded-sm cuadra-py-1.5 cuadra-pl-8 cuadra-pr-2 cuadra-text-sm cuadra-outline-none focus:cuadra-bg-secondary focus:cuadra-text-secondary-foreground font-brand cuadra-transition-colors ${e === b.id ? "cuadra-bg-secondary cuadra-text-secondary-foreground" : "hover:cuadra-bg-secondary/50"}`,
3729
+ onClick: () => y(g.id),
3730
+ className: `cuadra-relative cuadra-flex cuadra-w-full cuadra-cursor-pointer cuadra-select-none cuadra-items-center cuadra-rounded-sm cuadra-py-1.5 cuadra-pl-8 cuadra-pr-2 cuadra-text-sm cuadra-outline-none focus:cuadra-bg-secondary focus:cuadra-text-secondary-foreground font-brand cuadra-transition-colors ${e === g.id ? "cuadra-bg-secondary cuadra-text-secondary-foreground" : "hover:cuadra-bg-secondary/50"}`,
3718
3731
  children: [
3719
- e === b.id && /* @__PURE__ */ d("span", { className: "cuadra-absolute cuadra-left-2 cuadra-flex cuadra-h-3.5 cuadra-w-3.5 cuadra-items-center cuadra-justify-center", children: /* @__PURE__ */ d(
3732
+ e === g.id && /* @__PURE__ */ d("span", { className: "cuadra-absolute cuadra-left-2 cuadra-flex cuadra-h-3.5 cuadra-w-3.5 cuadra-items-center cuadra-justify-center", children: /* @__PURE__ */ d(
3720
3733
  "svg",
3721
3734
  {
3722
3735
  xmlns: "http://www.w3.org/2000/svg",
@@ -3735,32 +3748,32 @@ const Ui = `
3735
3748
  )
3736
3749
  }
3737
3750
  ) }),
3738
- /* @__PURE__ */ d("span", { children: b.name })
3751
+ /* @__PURE__ */ d("span", { children: g.name })
3739
3752
  ]
3740
3753
  },
3741
- b.id
3754
+ g.id
3742
3755
  )) }) })
3743
3756
  ] }),
3744
3757
  /* @__PURE__ */ C(
3745
3758
  "button",
3746
3759
  {
3747
3760
  type: "button",
3748
- onClick: () => x(!0),
3761
+ onClick: () => b(!0),
3749
3762
  disabled: t || r.length === 0 || !!a,
3750
3763
  className: "cuadra-flex md:cuadra-hidden 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",
3751
3764
  children: [
3752
- /* @__PURE__ */ d("span", { className: y ? "cuadra-text-foreground" : "cuadra-text-muted-foreground", children: y?.name || "Select model" }),
3753
- /* @__PURE__ */ d(ot, { className: "cuadra-ml-2 cuadra-h-4 cuadra-w-4 cuadra-opacity-50" })
3765
+ /* @__PURE__ */ d("span", { className: x ? "cuadra-text-foreground" : "cuadra-text-muted-foreground", children: x?.name || "Select model" }),
3766
+ /* @__PURE__ */ d(ct, { className: "cuadra-ml-2 cuadra-h-4 cuadra-w-4 cuadra-opacity-50" })
3754
3767
  ]
3755
3768
  }
3756
3769
  ),
3757
- p && typeof document < "u" && je(
3758
- /* @__PURE__ */ C(H, { children: [
3770
+ p && typeof document < "u" && $e(
3771
+ /* @__PURE__ */ C(q, { children: [
3759
3772
  /* @__PURE__ */ d(
3760
3773
  "div",
3761
3774
  {
3762
3775
  className: "cuadra-fixed cuadra-inset-0 cuadra-bg-black/50 cuadra-z-50 md:cuadra-hidden",
3763
- onClick: () => x(!1)
3776
+ onClick: () => b(!1)
3764
3777
  }
3765
3778
  ),
3766
3779
  /* @__PURE__ */ C("div", { className: "cuadra-fixed cuadra-inset-0 cuadra-z-50 cuadra-flex cuadra-flex-col cuadra-bg-background md:cuadra-hidden", children: [
@@ -3770,22 +3783,22 @@ const Ui = `
3770
3783
  "button",
3771
3784
  {
3772
3785
  type: "button",
3773
- onClick: () => x(!1),
3786
+ onClick: () => b(!1),
3774
3787
  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",
3775
3788
  "aria-label": "Close",
3776
- children: /* @__PURE__ */ d(Ue, { className: "cuadra-h-4 cuadra-w-4 cuadra-text-foreground" })
3789
+ children: /* @__PURE__ */ d(We, { className: "cuadra-h-4 cuadra-w-4 cuadra-text-foreground" })
3777
3790
  }
3778
3791
  )
3779
3792
  ] }),
3780
- /* @__PURE__ */ d("div", { className: "cuadra-flex-1 cuadra-overflow-y-auto cuadra-p-4", children: t ? /* @__PURE__ */ d("div", { className: "cuadra-flex cuadra-items-center cuadra-justify-center cuadra-py-8", children: /* @__PURE__ */ d("span", { className: "cuadra-text-muted-foreground cuadra-text-sm cuadra-font-brand", children: "Loading models..." }) }) : a ? /* @__PURE__ */ d("div", { className: "cuadra-flex cuadra-items-center cuadra-justify-center cuadra-py-8", children: /* @__PURE__ */ d("span", { className: "cuadra-text-destructive cuadra-text-sm cuadra-font-brand", children: "Failed to load models" }) }) : r.length === 0 ? /* @__PURE__ */ d("div", { className: "cuadra-flex cuadra-items-center cuadra-justify-center cuadra-py-8", children: /* @__PURE__ */ d("span", { className: "cuadra-text-muted-foreground cuadra-text-sm cuadra-font-brand", children: "No models available" }) }) : /* @__PURE__ */ d("div", { className: "cuadra-space-y-2", children: r.map((b) => /* @__PURE__ */ C(
3793
+ /* @__PURE__ */ d("div", { className: "cuadra-flex-1 cuadra-overflow-y-auto cuadra-p-4", children: t ? /* @__PURE__ */ d("div", { className: "cuadra-flex cuadra-items-center cuadra-justify-center cuadra-py-8", children: /* @__PURE__ */ d("span", { className: "cuadra-text-muted-foreground cuadra-text-sm cuadra-font-brand", children: "Loading models..." }) }) : a ? /* @__PURE__ */ d("div", { className: "cuadra-flex cuadra-items-center cuadra-justify-center cuadra-py-8", children: /* @__PURE__ */ d("span", { className: "cuadra-text-destructive cuadra-text-sm cuadra-font-brand", children: "Failed to load models" }) }) : r.length === 0 ? /* @__PURE__ */ d("div", { className: "cuadra-flex cuadra-items-center cuadra-justify-center cuadra-py-8", children: /* @__PURE__ */ d("span", { className: "cuadra-text-muted-foreground cuadra-text-sm cuadra-font-brand", children: "No models available" }) }) : /* @__PURE__ */ d("div", { className: "cuadra-space-y-2", children: r.map((g) => /* @__PURE__ */ C(
3781
3794
  "button",
3782
3795
  {
3783
3796
  type: "button",
3784
- onClick: () => g(b.id),
3785
- className: `cuadra-w-full cuadra-flex cuadra-items-center cuadra-justify-between cuadra-rounded-lg cuadra-border cuadra-px-4 cuadra-py-4 cuadra-text-left cuadra-transition-colors font-brand cuadra-bg-background cuadra-text-foreground cuadra-border-border hover:cuadra-bg-muted ${e === b.id ? "cuadra-border-primary" : ""}`,
3797
+ onClick: () => y(g.id),
3798
+ className: `cuadra-w-full cuadra-flex cuadra-items-center cuadra-justify-between cuadra-rounded-lg cuadra-border cuadra-px-4 cuadra-py-4 cuadra-text-left cuadra-transition-colors font-brand cuadra-bg-background cuadra-text-foreground cuadra-border-border hover:cuadra-bg-muted ${e === g.id ? "cuadra-border-primary" : ""}`,
3786
3799
  children: [
3787
- /* @__PURE__ */ d("span", { className: "cuadra-text-base cuadra-font-normal", children: b.name }),
3788
- e === b.id && /* @__PURE__ */ d(
3800
+ /* @__PURE__ */ d("span", { className: "cuadra-text-base cuadra-font-normal", children: g.name }),
3801
+ e === g.id && /* @__PURE__ */ d(
3789
3802
  "svg",
3790
3803
  {
3791
3804
  xmlns: "http://www.w3.org/2000/svg",
@@ -3807,7 +3820,7 @@ const Ui = `
3807
3820
  )
3808
3821
  ]
3809
3822
  },
3810
- b.id
3823
+ g.id
3811
3824
  )) }) })
3812
3825
  ] })
3813
3826
  ] }),
@@ -3816,9 +3829,9 @@ const Ui = `
3816
3829
  ] })
3817
3830
  ] })
3818
3831
  ] });
3819
- }, Wi = pr(void 0), _e = ({ children: e, value: r }) => /* @__PURE__ */ d(Wi.Provider, { value: r, children: e });
3820
- function Bi() {
3821
- P(() => {
3832
+ }, Hi = br(void 0), Fe = ({ children: e, value: r }) => /* @__PURE__ */ d(Hi.Provider, { value: r, children: e });
3833
+ function qi() {
3834
+ E(() => {
3822
3835
  if (document.querySelector("style[data-cuadra-uikit]"))
3823
3836
  return;
3824
3837
  const r = document.createElement("div");
@@ -3840,8 +3853,8 @@ function Bi() {
3840
3853
  }, document.head.appendChild(a), o) break;
3841
3854
  }, []);
3842
3855
  }
3843
- const Hi = ({ config: e }) => {
3844
- Bi();
3856
+ const Vi = ({ config: e }) => {
3857
+ qi();
3845
3858
  const {
3846
3859
  baseUrl: r,
3847
3860
  proxyUrl: t,
@@ -3851,87 +3864,87 @@ const Hi = ({ config: e }) => {
3851
3864
  modelId: n,
3852
3865
  onModelChange: u,
3853
3866
  ephemeral: c = !1,
3854
- systemPrompt: l,
3867
+ systemPrompt: s,
3855
3868
  initialThreadId: f,
3856
- welcomeTitle: s,
3869
+ welcomeTitle: l,
3857
3870
  welcomeSubtitle: p,
3858
- extraTopPadding: x,
3871
+ extraTopPadding: b,
3859
3872
  suggestions: h,
3860
- inputPlaceholder: y,
3861
- showThemeToggle: g = !0,
3862
- theme: b = "system",
3873
+ inputPlaceholder: x,
3874
+ showThemeToggle: y = !0,
3875
+ theme: g = "system",
3863
3876
  onError: k,
3864
- onChatCreated: w,
3865
- onUserMessage: A,
3866
- onThreadIdUpdate: I,
3867
- onLogout: T,
3868
- enableAttachments: S = !1
3869
- } = e, [M, j] = N(!1), [m, X] = N(null), [$, G] = N(null), [O, Te] = N(!1), Ae = ze(null), de = (v) => {
3870
- if (v < 30) return !0;
3871
- if (Ae.current) {
3872
- const D = Ae.current.getBoundingClientRect();
3873
- if (v - D.left < 30) return !0;
3877
+ onChatCreated: v,
3878
+ onUserMessage: M,
3879
+ onThreadIdUpdate: N,
3880
+ onLogout: A,
3881
+ enableAttachments: w = !1
3882
+ } = e, [I, P] = S(!1), [m, j] = S(null), [O, G] = S(null), [U, Ae] = S(!1), Ne = ze(null), de = (T) => {
3883
+ if (T < 30) return !0;
3884
+ if (Ne.current) {
3885
+ const D = Ne.current.getBoundingClientRect();
3886
+ if (T - D.left < 30) return !0;
3874
3887
  }
3875
3888
  return !1;
3876
- }, Xe = (v) => {
3877
- const R = v.touches[0].clientX;
3878
- (de(R) || M) && (X(R), G(R), Te(!0));
3879
- }, Ke = (v) => {
3880
- if (m === null || !O) return;
3881
- const D = v.touches[0];
3889
+ }, Xe = (T) => {
3890
+ const R = T.touches[0].clientX;
3891
+ (de(R) || I) && (j(R), G(R), Ae(!0));
3892
+ }, Ke = (T) => {
3893
+ if (m === null || !U) return;
3894
+ const D = T.touches[0];
3882
3895
  G(D.clientX);
3883
- }, Ve = () => {
3884
- if (m === null || $ === null) {
3885
- Te(!1);
3896
+ }, Ge = () => {
3897
+ if (m === null || O === null) {
3898
+ Ae(!1);
3886
3899
  return;
3887
3900
  }
3888
- const v = $ - m, D = 50, R = 0.3, tt = Math.abs(v) / 300;
3889
- v > D && !M && m !== null ? de(m) && j(!0) : ((v < -D || v < 0 && tt > R) && M || M && v < -20 && tt > R) && j(!1), X(null), G(null), Te(!1);
3890
- }, cr = () => {
3891
- if (O && m !== null && $ !== null) {
3892
- const v = $ - m;
3893
- if (M)
3894
- return `translateX(${Math.min(0, v)}px)`;
3901
+ const T = O - m, D = 50, R = 0.3, rt = Math.abs(T) / 300;
3902
+ T > D && !I && m !== null ? de(m) && P(!0) : ((T < -D || T < 0 && rt > R) && I || I && T < -20 && rt > R) && P(!1), j(null), G(null), Ae(!1);
3903
+ }, sr = () => {
3904
+ if (U && m !== null && O !== null) {
3905
+ const T = O - m;
3906
+ if (I)
3907
+ return `translateX(${Math.min(0, T)}px)`;
3895
3908
  if (m !== null && de(m))
3896
- return `translateX(${Math.min(0, -320 + v)}px)`;
3909
+ return `translateX(${Math.min(0, -320 + T)}px)`;
3897
3910
  }
3898
- return M ? "translateX(0)" : "translateX(-100%)";
3899
- }, ur = () => {
3900
- if (!O || m === null || $ === null)
3901
- return M ? 0.5 : 0;
3902
- const D = $ - m;
3903
- return M ? Math.max(0, Math.min(1, (320 + D) / 320)) * 0.5 : m !== null && de(m) ? Math.max(0, Math.min(1, (D + 320) / 320)) * 0.5 : 0;
3904
- }, fe = t || r || "", he = !!t, Ge = E(
3905
- () => new Mt(fe, a || void 0, he),
3911
+ return I ? "translateX(0)" : "translateX(-100%)";
3912
+ }, lr = () => {
3913
+ if (!U || m === null || O === null)
3914
+ return I ? 0.5 : 0;
3915
+ const D = O - m;
3916
+ return I ? Math.max(0, Math.min(1, (320 + D) / 320)) * 0.5 : m !== null && de(m) ? Math.max(0, Math.min(1, (D + 320) / 320)) * 0.5 : 0;
3917
+ }, fe = t || r || "", he = !!t, Ze = z(
3918
+ () => new Lt(fe, a || void 0, he),
3906
3919
  [fe, a, he]
3907
- ), [Z, lr] = N(null), [te, Ze] = N(!1), [re, Je] = N(null), [sr, Qe] = N(!1);
3908
- P(() => {
3909
- i === "multiChat" && Qe(!0);
3920
+ ), [Z, dr] = S(null), [te, Je] = S(!1), [re, Qe] = S(null), [fr, Ye] = S(!1);
3921
+ E(() => {
3922
+ i === "multiChat" && Ye(!0);
3910
3923
  }, [i]);
3911
3924
  const J = ee(async () => {
3912
3925
  if (o === "selector") {
3913
- Ze(!0), Je(null);
3926
+ Je(!0), Qe(null);
3914
3927
  try {
3915
- const v = await Ge.listModels();
3916
- lr(v);
3917
- } catch (v) {
3918
- Je(v instanceof Error ? v : new Error("Failed to load models"));
3928
+ const T = await Ze.listModels();
3929
+ dr(T);
3930
+ } catch (T) {
3931
+ Qe(T instanceof Error ? T : new Error("Failed to load models"));
3919
3932
  } finally {
3920
- Ze(!1);
3933
+ Je(!1);
3921
3934
  }
3922
3935
  }
3923
- }, [Ge, o]);
3924
- P(() => {
3936
+ }, [Ze, o]);
3937
+ E(() => {
3925
3938
  o === "selector" && J();
3926
- }, [o, J]), P(() => (typeof window < "u" && (window.__cuadraUIKitRefetchModels = J), () => {
3939
+ }, [o, J]), E(() => (typeof window < "u" && (window.__cuadraUIKitRefetchModels = J), () => {
3927
3940
  typeof window < "u" && delete window.__cuadraUIKitRefetchModels;
3928
3941
  }), [J]);
3929
- const [U, Ye] = N(
3942
+ const [W, et] = S(
3930
3943
  o === "fixed" && n || null
3931
- ), et = ze(U), ae = ee(
3932
- (v) => {
3933
- const D = et.current;
3934
- Ye(v), et.current = v, u?.(v), D !== null && D !== v && i === "multiChat" && setTimeout(() => {
3944
+ ), tt = ze(W), ae = ee(
3945
+ (T) => {
3946
+ const D = tt.current;
3947
+ et(T), tt.current = T, u?.(T), D !== null && D !== T && i === "multiChat" && setTimeout(() => {
3935
3948
  const R = window.__cuadraThreadListRuntime;
3936
3949
  if (R?.threads?.switchToNewThread)
3937
3950
  try {
@@ -3952,52 +3965,52 @@ const Hi = ({ config: e }) => {
3952
3965
  },
3953
3966
  [u, i]
3954
3967
  );
3955
- P(() => {
3956
- if (o === "selector" && Z?.items && Z.items.length > 0 && !U) {
3957
- const v = Z.items[0];
3958
- if (v?.id) {
3959
- const D = v.id;
3960
- Ye(D), u?.(D);
3968
+ E(() => {
3969
+ if (o === "selector" && Z?.items && Z.items.length > 0 && !W) {
3970
+ const T = Z.items[0];
3971
+ if (T?.id) {
3972
+ const D = T.id;
3973
+ et(D), u?.(D);
3961
3974
  }
3962
3975
  }
3963
- }, [o, Z?.items, U, u]);
3964
- const dr = o === "fixed" ? !!n : !!U, me = E(
3965
- () => (Z?.items || []).filter((v) => v?.id && v?.displayName).map((v) => ({ id: v.id, name: v.displayName })),
3976
+ }, [o, Z?.items, W, u]);
3977
+ const hr = o === "fixed" ? !!n : !!W, me = z(
3978
+ () => (Z?.items || []).filter((T) => T?.id && T?.displayName).map((T) => ({ id: T.id, name: T.displayName })),
3966
3979
  [Z]
3967
- ), Ne = E(
3980
+ ), Ie = z(
3968
3981
  () => ({
3969
- currentModelId: U || "",
3982
+ currentModelId: W || "",
3970
3983
  models: me,
3971
3984
  modelsLoading: te,
3972
3985
  modelsError: re,
3973
3986
  onModelChange: ae,
3974
3987
  refetchModels: J
3975
3988
  }),
3976
- [U, me, te, re, ae, J]
3989
+ [W, me, te, re, ae, J]
3977
3990
  );
3978
- return o === "selector" && te || i === "multiChat" && sr ? /* @__PURE__ */ d(_e, { value: Ne, children: /* @__PURE__ */ d(Fe, { 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(It, { className: "cuadra-h-6 cuadra-w-6 cuadra-animate-spin cuadra-text-muted-foreground" }) }) }) }) : o === "selector" && !dr && re ? /* @__PURE__ */ d(_e, { value: Ne, children: /* @__PURE__ */ d(Fe, { 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(_e, { value: Ne, children: /* @__PURE__ */ d(
3979
- ta,
3991
+ return o === "selector" && te || i === "multiChat" && fr ? /* @__PURE__ */ d(Fe, { value: Ie, children: /* @__PURE__ */ d(_e, { 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(St, { className: "cuadra-h-6 cuadra-w-6 cuadra-animate-spin cuadra-text-muted-foreground" }) }) }) }) : o === "selector" && !hr && re ? /* @__PURE__ */ d(Fe, { value: Ie, children: /* @__PURE__ */ d(_e, { 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(Fe, { value: Ie, children: /* @__PURE__ */ d(
3992
+ aa,
3980
3993
  {
3981
3994
  baseUrl: he ? fe : r || fe,
3982
3995
  sessionToken: a,
3983
3996
  isProxyMode: he,
3984
3997
  mode: i,
3985
3998
  modelMode: o,
3986
- modelId: U || n || void 0,
3999
+ modelId: W || n || void 0,
3987
4000
  onModelChange: ae,
3988
4001
  ephemeral: c,
3989
- systemPrompt: l,
4002
+ systemPrompt: s,
3990
4003
  initialThreadId: f,
3991
- enableAttachments: S,
4004
+ enableAttachments: w,
3992
4005
  onError: k,
3993
- onChatCreated: w,
3994
- onUserMessage: A,
3995
- onThreadIdUpdate: I,
4006
+ onChatCreated: v,
4007
+ onUserMessage: M,
4008
+ onThreadIdUpdate: N,
3996
4009
  onChatsLoaded: () => {
3997
- i === "multiChat" && Qe(!1);
4010
+ i === "multiChat" && Ye(!1);
3998
4011
  },
3999
4012
  children: /* @__PURE__ */ d(
4000
- Fe,
4013
+ _e,
4001
4014
  {
4002
4015
  paddingX: "cuadra-px-0",
4003
4016
  paddingY: "cuadra-py-0",
@@ -4011,56 +4024,56 @@ const Hi = ({ config: e }) => {
4011
4024
  style: { height: "100%" },
4012
4025
  onTouchStart: Xe,
4013
4026
  onTouchMove: Ke,
4014
- onTouchEnd: Ve,
4015
- children: i === "multiChat" ? /* @__PURE__ */ C(H, { children: [
4016
- typeof document < "u" && je(
4027
+ onTouchEnd: Ge,
4028
+ children: i === "multiChat" ? /* @__PURE__ */ C(q, { children: [
4029
+ typeof document < "u" && $e(
4017
4030
  /* @__PURE__ */ d(
4018
4031
  "div",
4019
4032
  {
4020
- className: `cuadra-fixed cuadra-inset-0 cuadra-bg-black cuadra-z-40 md:cuadra-hidden cuadra-transition-opacity cuadra-duration-300 ${M || O ? "" : "cuadra-pointer-events-none"}`,
4021
- style: { opacity: ur() },
4022
- onClick: () => j(!1)
4033
+ className: `cuadra-fixed cuadra-inset-0 cuadra-bg-black cuadra-z-40 md:cuadra-hidden cuadra-transition-opacity cuadra-duration-300 ${I || U ? "" : "cuadra-pointer-events-none"}`,
4034
+ style: { opacity: lr() },
4035
+ onClick: () => P(!1)
4023
4036
  }
4024
4037
  ),
4025
4038
  document.body
4026
4039
  ),
4027
- typeof document < "u" && /* @__PURE__ */ C(H, { children: [
4040
+ typeof document < "u" && /* @__PURE__ */ C(q, { children: [
4028
4041
  /* @__PURE__ */ d(
4029
4042
  "div",
4030
4043
  {
4031
4044
  className: "cuadra-hidden md:cuadra-block !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 cuadra-relative",
4032
4045
  style: { borderRightWidth: "1px", height: "100%" },
4033
4046
  children: /* @__PURE__ */ d(
4034
- yt,
4047
+ kt,
4035
4048
  {
4036
- onThreadSelect: () => j(!1),
4037
- showThemeToggle: g,
4038
- theme: b,
4039
- onLogout: T
4049
+ onThreadSelect: () => P(!1),
4050
+ showThemeToggle: y,
4051
+ theme: g,
4052
+ onLogout: A
4040
4053
  }
4041
4054
  )
4042
4055
  }
4043
4056
  ),
4044
- typeof document < "u" && je(
4057
+ typeof document < "u" && $e(
4045
4058
  /* @__PURE__ */ d(
4046
4059
  "div",
4047
4060
  {
4048
- 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 ${M || O ? "" : "cuadra-pointer-events-none"}`,
4061
+ 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 ${I || U ? "" : "cuadra-pointer-events-none"}`,
4049
4062
  style: {
4050
4063
  borderRightWidth: "1px",
4051
- transform: cr(),
4052
- transition: O ? "none" : "transform 0.3s ease-in-out"
4064
+ transform: sr(),
4065
+ transition: U ? "none" : "transform 0.3s ease-in-out"
4053
4066
  },
4054
4067
  onTouchStart: Xe,
4055
4068
  onTouchMove: Ke,
4056
- onTouchEnd: Ve,
4069
+ onTouchEnd: Ge,
4057
4070
  children: /* @__PURE__ */ d(
4058
- yt,
4071
+ kt,
4059
4072
  {
4060
- onThreadSelect: () => j(!1),
4061
- showThemeToggle: g,
4062
- theme: b,
4063
- onLogout: T
4073
+ onThreadSelect: () => P(!1),
4074
+ showThemeToggle: y,
4075
+ theme: g,
4076
+ onLogout: A
4064
4077
  }
4065
4078
  )
4066
4079
  }
@@ -4068,54 +4081,54 @@ const Hi = ({ config: e }) => {
4068
4081
  document.body
4069
4082
  )
4070
4083
  ] }),
4071
- /* @__PURE__ */ C("div", { ref: Ae, className: "cuadra-flex-1 cuadra-flex cuadra-flex-col", children: [
4084
+ /* @__PURE__ */ C("div", { ref: Ne, className: "cuadra-flex-1 cuadra-flex cuadra-flex-col", children: [
4072
4085
  o === "selector" && /* @__PURE__ */ d(
4073
- kt,
4086
+ wt,
4074
4087
  {
4075
- currentModel: U || "",
4088
+ currentModel: W || "",
4076
4089
  models: me,
4077
4090
  modelsLoading: te,
4078
4091
  modelsError: re,
4079
4092
  onModelChange: ae,
4080
- showThemeToggle: g,
4081
- theme: b,
4082
- onMobileMenuClick: () => j(!M),
4093
+ showThemeToggle: y,
4094
+ theme: g,
4095
+ onMobileMenuClick: () => P(!I),
4083
4096
  showMobileMenuButton: i === "multiChat"
4084
4097
  }
4085
4098
  ),
4086
4099
  /* @__PURE__ */ d("div", { className: "cuadra-flex-1 cuadra-relative cuadra-min-h-0 cuadra-space-y-4 cuadra-p-4", children: /* @__PURE__ */ d(
4087
4100
  xt,
4088
4101
  {
4089
- welcomeTitle: s,
4102
+ welcomeTitle: l,
4090
4103
  welcomeSubtitle: p,
4091
- extraTopPadding: x,
4104
+ extraTopPadding: b,
4092
4105
  suggestions: h,
4093
- inputPlaceholder: y,
4094
- enableAttachments: S
4106
+ inputPlaceholder: x,
4107
+ enableAttachments: w
4095
4108
  }
4096
4109
  ) })
4097
4110
  ] })
4098
4111
  ] }) : /* @__PURE__ */ C("div", { className: "cuadra-flex-1 cuadra-flex cuadra-flex-col", children: [
4099
4112
  o === "selector" && /* @__PURE__ */ d(
4100
- kt,
4113
+ wt,
4101
4114
  {
4102
- currentModel: U || "",
4115
+ currentModel: W || "",
4103
4116
  models: me,
4104
4117
  modelsLoading: te,
4105
4118
  modelsError: re,
4106
4119
  onModelChange: ae,
4107
- showThemeToggle: g,
4108
- theme: b
4120
+ showThemeToggle: y,
4121
+ theme: g
4109
4122
  }
4110
4123
  ),
4111
4124
  /* @__PURE__ */ d("div", { className: "cuadra-flex-1 cuadra-relative cuadra-min-h-0 cuadra-space-y-4 cuadra-p-4", children: /* @__PURE__ */ d(
4112
4125
  xt,
4113
4126
  {
4114
- welcomeTitle: s,
4127
+ welcomeTitle: l,
4115
4128
  welcomeSubtitle: p,
4116
- extraTopPadding: x,
4129
+ extraTopPadding: b,
4117
4130
  suggestions: h,
4118
- inputPlaceholder: y
4131
+ inputPlaceholder: x
4119
4132
  }
4120
4133
  ) })
4121
4134
  ] })
@@ -4126,7 +4139,73 @@ const Hi = ({ config: e }) => {
4126
4139
  }
4127
4140
  ) }) });
4128
4141
  };
4129
- function Qi(e) {
4142
+ function Xi(e, r = ":root") {
4143
+ if (typeof document > "u")
4144
+ return;
4145
+ const t = document.documentElement;
4146
+ if (e.light && Gi(e.light, t), e.dark) {
4147
+ let a = document.getElementById("cuadra-theme-dark");
4148
+ a || (a = document.createElement("style"), a.id = "cuadra-theme-dark", document.head.appendChild(a));
4149
+ const i = Zi(e.dark);
4150
+ a.textContent = `.dark { ${i} }`;
4151
+ }
4152
+ }
4153
+ const Ki = {
4154
+ background: "background",
4155
+ foreground: "foreground",
4156
+ card: "card",
4157
+ cardForeground: "card-foreground",
4158
+ popover: "popover",
4159
+ popoverForeground: "popover-foreground",
4160
+ primary: "primary",
4161
+ primaryForeground: "primary-foreground",
4162
+ primaryLight: "primary-light",
4163
+ primaryLighter: "primary-lighter",
4164
+ secondary: "secondary",
4165
+ secondaryForeground: "secondary-foreground",
4166
+ muted: "muted",
4167
+ mutedForeground: "muted-foreground",
4168
+ accent: "accent",
4169
+ accentForeground: "accent-foreground",
4170
+ border: "border",
4171
+ input: "input",
4172
+ ring: "ring",
4173
+ destructive: "destructive",
4174
+ destructiveForeground: "destructive-foreground",
4175
+ success: "success",
4176
+ successForeground: "success-foreground",
4177
+ info: "info",
4178
+ infoForeground: "info-foreground",
4179
+ warning: "warning",
4180
+ warningForeground: "warning-foreground"
4181
+ };
4182
+ function ur(e) {
4183
+ const r = Ki[e];
4184
+ return r ? `--cuadra-${r}` : `--cuadra-${e.replace(/([A-Z])/g, "-$1").toLowerCase()}`;
4185
+ }
4186
+ function Gi(e, r) {
4187
+ Object.entries(e).forEach(([t, a]) => {
4188
+ if (a) {
4189
+ const i = ur(t);
4190
+ r.style.setProperty(i, a);
4191
+ }
4192
+ });
4193
+ }
4194
+ function Zi(e) {
4195
+ return Object.entries(e).map(([r, t]) => t ? `${ur(r)}: ${t};` : "").filter(Boolean).join(" ");
4196
+ }
4197
+ function no() {
4198
+ if (typeof document > "u")
4199
+ return;
4200
+ const e = document.documentElement;
4201
+ Array.from(e.style).filter((a) => a.startsWith("--cuadra-")).forEach((a) => e.style.removeProperty(a));
4202
+ const t = document.getElementById("cuadra-theme-dark");
4203
+ t && t.remove();
4204
+ }
4205
+ function io(e) {
4206
+ E(() => {
4207
+ e.customTheme && Xi(e.customTheme);
4208
+ }, [e.customTheme]);
4130
4209
  const r = {
4131
4210
  baseUrl: e.baseUrl,
4132
4211
  proxyUrl: e.proxyUrl,
@@ -4154,9 +4233,11 @@ function Qi(e) {
4154
4233
  enableAttachments: e.enableAttachments,
4155
4234
  containerClass: e.className
4156
4235
  };
4157
- return /* @__PURE__ */ d(Hi, { config: r });
4236
+ return /* @__PURE__ */ d(Vi, { config: r });
4158
4237
  }
4159
4238
  export {
4160
- Qi as CuadraChat
4239
+ io as CuadraChat,
4240
+ Xi as applyTheme,
4241
+ no as removeTheme
4161
4242
  };
4162
4243
  //# sourceMappingURL=index.mjs.map