@nivaro/react 0.3.24 → 0.3.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,48 +1,48 @@
1
- import { jsx as s, jsxs as g } from "react/jsx-runtime";
2
- import { useMemo as k, createContext as A, useState as C, useContext as S, Suspense as $, lazy as W } from "react";
1
+ import { jsx as l, jsxs as f } from "react/jsx-runtime";
2
+ import { useMemo as k, createContext as C, useState as S, useContext as $, Suspense as W, lazy as L } from "react";
3
3
  import { useOptionalNivaroClient as O, useNavigation as B } from "../../context.js";
4
- import { useGlossary as L, glossarySegments as T } from "../../lib/glossary.js";
5
- import { cn as b } from "../../lib/utils.js";
4
+ import { useGlossary as I, glossarySegments as T } from "../../lib/glossary.js";
5
+ import { cn as w } from "../../lib/utils.js";
6
6
  import { AutolinkedText as _ } from "../AutolinkedText.js";
7
- import { formatsFor as j, rowsOfBlock as I, listOf as M, chartOf as P } from "./answer-formats.js";
8
- import { useGlossaryHref as K, GlossaryMark as E } from "./GlossaryText.js";
7
+ import { formatsFor as j, rowsOfBlock as M, listOf as P, chartOf as E } from "./answer-formats.js";
8
+ import { useGlossaryHref as K, GlossaryMark as R } from "./GlossaryText.js";
9
9
  function F(t) {
10
10
  try {
11
- const e = JSON.parse(t), r = e.type === "line" || e.type === "pie" ? e.type : "bar", l = Array.isArray(e.data) ? e.data.map((n) => ({ label: String((n == null ? void 0 : n.label) ?? ""), value: Number(n == null ? void 0 : n.value) })).filter((n) => n.label && Number.isFinite(n.value)).slice(0, 40) : [];
12
- return l.length < 2 ? null : { type: r, title: typeof e.title == "string" ? e.title : void 0, data: l };
11
+ const e = JSON.parse(t), r = e.type === "line" || e.type === "pie" ? e.type : "bar", i = Array.isArray(e.data) ? e.data.map((n) => ({ label: String((n == null ? void 0 : n.label) ?? ""), value: Number(n == null ? void 0 : n.value) })).filter((n) => n.label && Number.isFinite(n.value)).slice(0, 40) : [];
12
+ return i.length < 2 ? null : { type: r, title: typeof e.title == "string" ? e.title : void 0, data: i };
13
13
  } catch {
14
14
  return null;
15
15
  }
16
16
  }
17
- const v = /^\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/;
18
- function N(t) {
17
+ const N = /^\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/;
18
+ function v(t) {
19
19
  return t.trim().replace(/^\|/, "").replace(/\|$/, "").split("|").map((e) => e.trim());
20
20
  }
21
- function R(t) {
21
+ function H(t) {
22
22
  return t.split(`
23
23
  `).flatMap((e) => {
24
24
  const r = e.trim();
25
- return !r.startsWith("|") || !/\|\s*\|\s*[:-]{2,}/.test(r) && !/\|\s+\|\s*\S/.test(r) ? [e] : (r.match(/\|\s+\|/g) ?? []).length < 1 ? [e] : r.split(/\|\s+(?=\|)/).map((l) => l.trim().endsWith("|") ? l.trim() : `${l.trim()} |`);
25
+ return !r.startsWith("|") || !/\|\s*\|\s*[:-]{2,}/.test(r) && !/\|\s+\|\s*\S/.test(r) ? [e] : (r.match(/\|\s+\|/g) ?? []).length < 1 ? [e] : r.split(/\|\s+(?=\|)/).map((i) => i.trim().endsWith("|") ? i.trim() : `${i.trim()} |`);
26
26
  }).join(`
27
27
  `);
28
28
  }
29
29
  function G(t) {
30
- const e = R(t.replace(/\r\n/g, `
30
+ const e = H(t.replace(/\r\n/g, `
31
31
  `)).split(`
32
32
  `), r = [];
33
- let l = [];
33
+ let i = [];
34
34
  const n = () => {
35
- l.length && r.push({ kind: "p", text: l.join(" ") }), l = [];
35
+ i.length && r.push({ kind: "p", text: i.join(" ") }), i = [];
36
36
  };
37
- for (let i = 0; i < e.length; i++) {
38
- const a = e[i].trim();
37
+ for (let s = 0; s < e.length; s++) {
38
+ const a = e[s].trim();
39
39
  if (a.startsWith("```")) {
40
40
  n();
41
- const c = a.slice(3).trim().toLowerCase(), d = [];
42
- for (i++; i < e.length && !e[i].trim().startsWith("```"); ) d.push(e[i++]);
43
- const f = d.join(`
44
- `), w = c === "chart" ? F(f) : null;
45
- r.push(w ? { kind: "chart", spec: w } : { kind: "code", text: f });
41
+ const o = a.slice(3).trim().toLowerCase(), d = [];
42
+ for (s++; s < e.length && !e[s].trim().startsWith("```"); ) d.push(e[s++]);
43
+ const x = d.join(`
44
+ `), b = o === "chart" ? F(x) : null;
45
+ r.push(b ? { kind: "chart", spec: b } : { kind: "code", text: x });
46
46
  continue;
47
47
  }
48
48
  if (a === "") {
@@ -54,93 +54,112 @@ function G(t) {
54
54
  n(), r.push({ kind: "h", level: u[1].length, text: u[2] });
55
55
  continue;
56
56
  }
57
- if (a.startsWith("|") && i + 1 < e.length && v.test(e[i + 1].trim())) {
57
+ if (a.startsWith("|") && s + 1 < e.length && N.test(e[s + 1].trim())) {
58
58
  n();
59
- const c = N(a), d = [];
60
- for (i += 2; i < e.length && e[i].trim().startsWith("|"); )
61
- v.test(e[i].trim()) || d.push(N(e[i])), i++;
62
- i--, r.push({ kind: "table", header: c, rows: d });
59
+ const o = v(a), d = [];
60
+ for (s += 2; s < e.length && e[s].trim().startsWith("|"); )
61
+ N.test(e[s].trim()) || d.push(v(e[s])), s++;
62
+ s--, r.push({ kind: "table", header: o, rows: d });
63
63
  continue;
64
64
  }
65
- const m = /^[-*•]\s+(.*)$/.exec(a);
66
- if (m) {
65
+ const h = /^[-*•]\s+(.*)$/.exec(a);
66
+ if (h) {
67
67
  n();
68
- const c = [m[1]];
69
- for (; i + 1 < e.length; ) {
70
- const d = /^[-*•]\s+(.*)$/.exec(e[i + 1].trim());
68
+ const o = [h[1]];
69
+ for (; s + 1 < e.length; ) {
70
+ const d = /^[-*•]\s+(.*)$/.exec(e[s + 1].trim());
71
71
  if (!d) break;
72
- c.push(d[1]), i++;
72
+ o.push(d[1]), s++;
73
73
  }
74
- r.push({ kind: "ul", items: c });
74
+ r.push({ kind: "ul", items: o });
75
75
  continue;
76
76
  }
77
- const o = /^\d+[.)]\s+(.*)$/.exec(a);
78
- if (o) {
77
+ const c = /^\d+[.)]\s+(.*)$/.exec(a);
78
+ if (c) {
79
79
  n();
80
- const c = [o[1]];
81
- for (; i + 1 < e.length; ) {
82
- const d = /^\d+[.)]\s+(.*)$/.exec(e[i + 1].trim());
80
+ const o = [c[1]];
81
+ for (; s + 1 < e.length; ) {
82
+ const d = /^\d+[.)]\s+(.*)$/.exec(e[s + 1].trim());
83
83
  if (!d) break;
84
- c.push(d[1]), i++;
84
+ o.push(d[1]), s++;
85
85
  }
86
- r.push({ kind: "ol", items: c });
86
+ r.push({ kind: "ol", items: o });
87
87
  continue;
88
88
  }
89
- l.push(a);
89
+ i.push(a);
90
90
  }
91
91
  return n(), r;
92
92
  }
93
- const H = /(\*\*[^*]+\*\*|`[^`]+`|\*[^*]+\*|\[[^\]]+\]\([^)]+\))/g;
93
+ const D = /(\*\*[^*]+\*\*|`[^`]+`|\*[^*]+\*|\[[^\]]+\]\([^)]+\))/g;
94
94
  function p(t, e = !1, r) {
95
- const l = [];
96
- let n = 0, i = 0;
97
- const h = (u) => e ? /* @__PURE__ */ s(_, { text: u, plain: !0 }, i++) : u, a = (u) => {
98
- if (!(r != null && r.terms.length)) return h(u);
99
- const m = T(u, r.terms, { once: r.once });
100
- return m.length === 1 && !m[0].term ? h(u) : m.map(
101
- (o) => {
102
- var c;
103
- return o.term ? /* @__PURE__ */ s(E, { term: o.term, href: (c = r.href) == null ? void 0 : c.call(r, o.term), children: o.text }, i++) : h(o.text);
95
+ const i = [];
96
+ let n = 0, s = 0;
97
+ const m = (u) => e ? /* @__PURE__ */ l(_, { text: u, plain: !0 }, s++) : u, a = (u) => {
98
+ if (!(r != null && r.terms.length)) return m(u);
99
+ const h = T(u, r.terms, { once: r.once });
100
+ return h.length === 1 && !h[0].term ? m(u) : h.map(
101
+ (c) => {
102
+ var o;
103
+ return c.term ? /* @__PURE__ */ l(R, { term: c.term, href: (o = r.href) == null ? void 0 : o.call(r, c.term), children: c.text }, s++) : m(c.text);
104
104
  }
105
105
  );
106
106
  };
107
- for (const u of t.matchAll(H)) {
108
- const m = u.index ?? 0;
109
- m > n && l.push(a(t.slice(n, m)));
110
- const o = u[0];
111
- if (o.startsWith("**")) l.push(/* @__PURE__ */ s("strong", { children: a(o.slice(2, -2)) }, i++));
112
- else if (o.startsWith("`"))
113
- l.push(
114
- /* @__PURE__ */ s(
107
+ for (const u of t.matchAll(D)) {
108
+ const h = u.index ?? 0;
109
+ h > n && i.push(a(t.slice(n, h)));
110
+ const c = u[0];
111
+ if (c.startsWith("**")) i.push(/* @__PURE__ */ l("strong", { children: a(c.slice(2, -2)) }, s++));
112
+ else if (c.startsWith("`"))
113
+ i.push(
114
+ /* @__PURE__ */ l(
115
115
  "code",
116
116
  {
117
117
  className: "rounded bg-black/[0.06] px-1 py-px font-mono text-[0.92em] dark:bg-white/10",
118
- children: o.slice(1, -1)
118
+ children: c.slice(1, -1)
119
119
  },
120
- i++
120
+ s++
121
121
  )
122
122
  );
123
- else if (o.startsWith("[")) {
124
- const c = /^\[([^\]]+)\]\(([^)]+)\)$/.exec(o);
125
- c && D(c[2]) ? l.push(/* @__PURE__ */ s(J, { href: c[2], label: c[1] }, i++)) : c && /^https?:\/\//.test(c[2]) ? l.push(
126
- /* @__PURE__ */ s(
127
- "a",
128
- {
129
- href: c[2],
130
- className: "underline underline-offset-2",
131
- target: "_blank",
132
- rel: "noreferrer",
133
- children: c[1]
134
- },
135
- i++
136
- )
137
- ) : l.push(o);
138
- } else l.push(/* @__PURE__ */ s("em", { children: o.slice(1, -1) }, i++));
139
- n = m + o.length;
123
+ else if (c.startsWith("[")) {
124
+ const o = /^\[([^\]]+)\]\(([^)]+)\)$/.exec(c);
125
+ o && z(o[2]) ? i.push(/* @__PURE__ */ l(q, { href: o[2], label: o[1] }, s++)) : o && y(o[2]) ? i.push(/* @__PURE__ */ l(U, { href: o[2], label: o[1] }, s++)) : i.push(c);
126
+ } else i.push(/* @__PURE__ */ l("em", { children: c.slice(1, -1) }, s++));
127
+ n = h + c.length;
128
+ }
129
+ return n < t.length && i.push(a(t.slice(n))), i;
130
+ }
131
+ function y(t) {
132
+ if (!/^https?:\/\/\S+$/i.test(t)) return null;
133
+ try {
134
+ const e = new URL(t);
135
+ return e.username || e.password ? null : e.hostname || null;
136
+ } catch {
137
+ return null;
140
138
  }
141
- return n < t.length && l.push(a(t.slice(n))), l;
142
139
  }
143
- function D(t) {
140
+ function U({ href: t, label: e }) {
141
+ const r = y(t) ?? "", i = e.trim() === t || e.trim() === r;
142
+ return /* @__PURE__ */ f(
143
+ "a",
144
+ {
145
+ href: t,
146
+ "data-ai-link": "external",
147
+ className: "underline underline-offset-2",
148
+ target: "_blank",
149
+ rel: "noopener noreferrer nofollow",
150
+ "data-tip": t,
151
+ children: [
152
+ i ? r : e,
153
+ !i && /* @__PURE__ */ f("span", { className: "ml-1 whitespace-nowrap text-[0.85em] opacity-70", children: [
154
+ "(",
155
+ r,
156
+ " ↗)"
157
+ ] })
158
+ ]
159
+ }
160
+ );
161
+ }
162
+ function z(t) {
144
163
  if (!/^\/(?![\\/])/.test(t)) return !1;
145
164
  for (let e = 0; e < t.length; e++) {
146
165
  const r = t.charCodeAt(e);
@@ -148,49 +167,49 @@ function D(t) {
148
167
  }
149
168
  return !0;
150
169
  }
151
- function z(t, e) {
170
+ function J(t, e) {
152
171
  return e && e !== "/help-videos" && /^\/help-videos(?=[?#/]|$)/.test(t) ? `${e}${t.slice(12)}` : t;
153
172
  }
154
- function J({ href: t, label: e }) {
155
- const r = B(), l = z(t, r.helpVideosPath);
156
- return /* @__PURE__ */ s(
173
+ function q({ href: t, label: e }) {
174
+ const r = B(), i = J(t, r.helpVideosPath);
175
+ return /* @__PURE__ */ l(
157
176
  "a",
158
177
  {
159
- href: l,
178
+ href: i,
160
179
  "data-ai-link": "in-app",
161
180
  className: "underline underline-offset-2",
162
181
  onClick: (n) => {
163
- n.defaultPrevented || n.button !== 0 || n.metaKey || n.ctrlKey || n.shiftKey || n.altKey || (n.preventDefault(), r.navigate(l));
182
+ n.defaultPrevented || n.button !== 0 || n.metaKey || n.ctrlKey || n.shiftKey || n.altKey || (n.preventDefault(), r.navigate(i));
164
183
  },
165
184
  children: e
166
185
  }
167
186
  );
168
187
  }
169
- function q({
188
+ function Q({
170
189
  header: t,
171
190
  rows: e,
172
191
  autolink: r
173
192
  }) {
174
- const l = t.length;
175
- return /* @__PURE__ */ g("div", { "data-ai-table": !0, className: "my-1.5", children: [
176
- /* @__PURE__ */ s("ul", { className: "flex flex-col gap-1.5 sm:hidden", children: e.map((n, i) => (
193
+ const i = t.length;
194
+ return /* @__PURE__ */ f("div", { "data-ai-table": !0, className: "my-1.5", children: [
195
+ /* @__PURE__ */ l("ul", { className: "flex flex-col gap-1.5 sm:hidden", children: e.map((n, s) => (
177
196
  // biome-ignore lint/suspicious/noArrayIndexKey: static content
178
- /* @__PURE__ */ g(
197
+ /* @__PURE__ */ f(
179
198
  "li",
180
199
  {
181
200
  className: "rounded-lg border border-black/10 bg-background/60 px-2.5 py-2 dark:border-white/10",
182
201
  children: [
183
- /* @__PURE__ */ s("div", { className: "font-semibold leading-snug", children: p(n[0] ?? "", r) }),
184
- n.slice(1, l).map(
185
- (h, a) => h ? (
202
+ /* @__PURE__ */ l("div", { className: "font-semibold leading-snug", children: p(n[0] ?? "", r) }),
203
+ n.slice(1, i).map(
204
+ (m, a) => m ? (
186
205
  // biome-ignore lint/suspicious/noArrayIndexKey: static content
187
- /* @__PURE__ */ g(
206
+ /* @__PURE__ */ f(
188
207
  "div",
189
208
  {
190
209
  className: "mt-1 grid grid-cols-[minmax(0,34%)_1fr] gap-2 text-[0.94em] leading-snug",
191
210
  children: [
192
- /* @__PURE__ */ s("span", { className: "text-muted-foreground", children: t[a + 1] }),
193
- /* @__PURE__ */ s("span", { className: "min-w-0 break-words", children: p(h, r) })
211
+ /* @__PURE__ */ l("span", { className: "text-muted-foreground", children: t[a + 1] }),
212
+ /* @__PURE__ */ l("span", { className: "min-w-0 break-words", children: p(m, r) })
194
213
  ]
195
214
  },
196
215
  a
@@ -199,31 +218,31 @@ function q({
199
218
  )
200
219
  ]
201
220
  },
202
- i
221
+ s
203
222
  )
204
223
  )) }),
205
- /* @__PURE__ */ s("div", { className: "hidden overflow-x-auto sm:block", children: /* @__PURE__ */ g("table", { className: "w-auto min-w-[50%] text-left", children: [
206
- /* @__PURE__ */ s("thead", { children: /* @__PURE__ */ s("tr", { className: "border-b border-black/10 text-[0.85em] uppercase tracking-wide text-muted-foreground dark:border-white/10", children: t.map((n, i) => (
224
+ /* @__PURE__ */ l("div", { className: "hidden overflow-x-auto sm:block", children: /* @__PURE__ */ f("table", { className: "w-auto min-w-[50%] text-left", children: [
225
+ /* @__PURE__ */ l("thead", { children: /* @__PURE__ */ l("tr", { className: "border-b border-black/10 text-[0.85em] uppercase tracking-wide text-muted-foreground dark:border-white/10", children: t.map((n, s) => (
207
226
  // biome-ignore lint/suspicious/noArrayIndexKey: static content
208
- /* @__PURE__ */ s("th", { className: "py-1 pr-4 font-medium", children: p(n) }, i)
227
+ /* @__PURE__ */ l("th", { className: "py-1 pr-4 font-medium", children: p(n) }, s)
209
228
  )) }) }),
210
- /* @__PURE__ */ s("tbody", { className: "divide-y divide-black/5 dark:divide-white/10", children: e.map((n, i) => (
229
+ /* @__PURE__ */ l("tbody", { className: "divide-y divide-black/5 dark:divide-white/10", children: e.map((n, s) => (
211
230
  // biome-ignore lint/suspicious/noArrayIndexKey: static content
212
- /* @__PURE__ */ s("tr", { className: "align-top", children: t.map((h, a) => (
231
+ /* @__PURE__ */ l("tr", { className: "align-top", children: t.map((m, a) => (
213
232
  // biome-ignore lint/suspicious/noArrayIndexKey: static content
214
- /* @__PURE__ */ s("td", { className: "max-w-[28rem] py-1 pr-4", children: p(n[a] ?? "", r) }, a)
215
- )) }, i)
233
+ /* @__PURE__ */ l("td", { className: "max-w-[28rem] py-1 pr-4", children: p(n[a] ?? "", r) }, a)
234
+ )) }, s)
216
235
  )) })
217
236
  ] }) })
218
237
  ] });
219
238
  }
220
- const Q = W(() => import("./AiChart.js").then((t) => ({ default: t.AiChart })));
221
- function U({ spec: t }) {
222
- const e = S(y);
223
- return /* @__PURE__ */ s(
224
- $,
239
+ const V = L(() => import("./AiChart.js").then((t) => ({ default: t.AiChart })));
240
+ function X({ spec: t }) {
241
+ const e = $(A);
242
+ return /* @__PURE__ */ l(
243
+ W,
225
244
  {
226
- fallback: /* @__PURE__ */ s(
245
+ fallback: /* @__PURE__ */ l(
227
246
  "div",
228
247
  {
229
248
  "data-ai-chart-loading": !0,
@@ -231,83 +250,84 @@ function U({ spec: t }) {
231
250
  style: { height: t.type === "pie" ? 220 : 200 }
232
251
  }
233
252
  ),
234
- children: /* @__PURE__ */ s(Q, { spec: t, onPoint: e })
253
+ children: /* @__PURE__ */ l(V, { spec: t, onPoint: e })
235
254
  }
236
255
  );
237
256
  }
238
- function x({ b: t, link: e, gl: r }) {
257
+ function g({ b: t, link: e, gl: r }) {
239
258
  switch (t.kind) {
240
259
  case "h":
241
- return /* @__PURE__ */ s("p", { className: b("font-semibold", t.level <= 2 ? "text-[1.05em]" : ""), children: p(t.text, e, r) });
260
+ return /* @__PURE__ */ l("p", { className: w("font-semibold", t.level <= 2 ? "text-[1.05em]" : ""), children: p(t.text, e, r) });
242
261
  case "ul":
243
- return /* @__PURE__ */ s("ul", { className: "list-disc space-y-0.5 pl-5", children: t.items.map((l, n) => (
262
+ return /* @__PURE__ */ l("ul", { className: "list-disc space-y-0.5 pl-5", children: t.items.map((i, n) => (
244
263
  // biome-ignore lint/suspicious/noArrayIndexKey: static content
245
- /* @__PURE__ */ s("li", { children: p(l, e, r) }, n)
264
+ /* @__PURE__ */ l("li", { children: p(i, e, r) }, n)
246
265
  )) });
247
266
  case "ol":
248
- return /* @__PURE__ */ s("ol", { className: "list-decimal space-y-0.5 pl-5", children: t.items.map((l, n) => (
267
+ return /* @__PURE__ */ l("ol", { className: "list-decimal space-y-0.5 pl-5", children: t.items.map((i, n) => (
249
268
  // biome-ignore lint/suspicious/noArrayIndexKey: static content
250
- /* @__PURE__ */ s("li", { children: p(l, e, r) }, n)
269
+ /* @__PURE__ */ l("li", { children: p(i, e, r) }, n)
251
270
  )) });
252
271
  case "code":
253
- return /* @__PURE__ */ s("pre", { className: "overflow-x-auto rounded-md bg-black/[0.05] p-2 font-mono text-[0.9em] dark:bg-white/10", children: t.text });
272
+ return /* @__PURE__ */ l("pre", { className: "overflow-x-auto rounded-md bg-black/[0.05] p-2 font-mono text-[0.9em] dark:bg-white/10", children: t.text });
254
273
  case "table":
255
- return /* @__PURE__ */ s(q, { header: t.header, rows: t.rows, autolink: e });
274
+ return /* @__PURE__ */ l(Q, { header: t.header, rows: t.rows, autolink: e });
256
275
  case "chart":
257
- return /* @__PURE__ */ s(U, { spec: t.spec });
276
+ return /* @__PURE__ */ l(X, { spec: t.spec });
258
277
  default:
259
- return /* @__PURE__ */ s("p", { children: p(t.text, e, r) });
278
+ return /* @__PURE__ */ l("p", { children: p(t.text, e, r) });
260
279
  }
261
280
  }
262
- const V = { table: "Table", chart: "Chart", list: "List" };
263
- function X({ b: t, link: e, gl: r }) {
264
- const l = k(() => j(t), [t]), [n, i] = C(l[0]), h = k(() => {
265
- if (n === l[0]) return t;
266
- const a = I(t);
281
+ const Y = { table: "Table", chart: "Chart", list: "List" };
282
+ function Z({ b: t, link: e, gl: r }) {
283
+ const i = k(() => j(t), [t]), [n, s] = S(i[0]), m = k(() => {
284
+ if (n === i[0]) return t;
285
+ const a = M(t);
267
286
  if (!a) return t;
268
287
  if (n === "table") return { kind: "table", header: a.header, rows: a.rows };
269
- if (n === "list") return { kind: "ul", items: M(a) };
270
- const u = P(a);
288
+ if (n === "list") return { kind: "ul", items: P(a) };
289
+ const u = E(a);
271
290
  return u ? { kind: "chart", spec: u } : t;
272
- }, [t, n, l]);
273
- return l.length < 2 ? /* @__PURE__ */ s(x, { b: t, link: e, gl: r }) : /* @__PURE__ */ g("div", { "data-ai-switchable": n, children: [
274
- /* @__PURE__ */ s("fieldset", { className: "mb-0.5 flex min-w-0 justify-end gap-0.5", "aria-label": "Show as", children: l.map((a) => /* @__PURE__ */ s(
291
+ }, [t, n, i]);
292
+ return i.length < 2 ? /* @__PURE__ */ l(g, { b: t, link: e, gl: r }) : /* @__PURE__ */ f("div", { "data-ai-switchable": n, children: [
293
+ /* @__PURE__ */ l("fieldset", { className: "mb-0.5 flex min-w-0 justify-end gap-0.5", "aria-label": "Show as", children: i.map((a) => /* @__PURE__ */ l(
275
294
  "button",
276
295
  {
277
296
  type: "button",
278
- onClick: () => i(a),
297
+ onClick: () => s(a),
279
298
  "aria-pressed": a === n,
280
299
  "data-ai-format": a,
281
- className: b(
300
+ className: w(
282
301
  "rounded px-1.5 py-px text-[10.5px] font-medium transition-colors",
283
302
  a === n ? "bg-accent text-foreground" : "text-muted-foreground hover:bg-muted hover:text-foreground"
284
303
  ),
285
- children: V[a]
304
+ children: Y[a]
286
305
  },
287
306
  a
288
307
  )) }),
289
- /* @__PURE__ */ s(x, { b: h, link: e, gl: r })
308
+ /* @__PURE__ */ l(g, { b: m, link: e, gl: r })
290
309
  ] });
291
310
  }
292
- const y = A(void 0);
293
- function ae({
311
+ const A = C(void 0);
312
+ function ce({
294
313
  content: t,
295
314
  className: e,
296
315
  autolink: r,
297
- switchable: l,
316
+ switchable: i,
298
317
  onChartPoint: n
299
318
  }) {
300
- const i = k(() => G(t), [t]), h = O(), a = r ?? h != null, u = L(), m = K(), o = u.length ? { terms: u, once: /* @__PURE__ */ new Set(), href: m } : void 0;
301
- return /* @__PURE__ */ s(y.Provider, { value: n, children: /* @__PURE__ */ s("div", { "data-ai-markdown": !0, className: b("space-y-1.5 [&_strong]:font-semibold", e), children: i.map((c, d) => {
302
- const f = `${c.kind}-${d}`;
303
- return l && Y.has(c.kind) ? /* @__PURE__ */ s(X, { b: c, link: a, gl: o }, f) : /* @__PURE__ */ s(x, { b: c, link: a, gl: o }, f);
319
+ const s = k(() => G(t), [t]), m = O(), a = r ?? m != null, u = I(), h = K(), c = u.length ? { terms: u, once: /* @__PURE__ */ new Set(), href: h } : void 0;
320
+ return /* @__PURE__ */ l(A.Provider, { value: n, children: /* @__PURE__ */ l("div", { "data-ai-markdown": !0, className: w("space-y-1.5 [&_strong]:font-semibold", e), children: s.map((o, d) => {
321
+ const x = `${o.kind}-${d}`;
322
+ return i && ee.has(o.kind) ? /* @__PURE__ */ l(Z, { b: o, link: a, gl: c }, x) : /* @__PURE__ */ l(g, { b: o, link: a, gl: c }, x);
304
323
  }) }) });
305
324
  }
306
- const Y = /* @__PURE__ */ new Set(["table", "chart", "ul", "ol"]);
325
+ const ee = /* @__PURE__ */ new Set(["table", "chart", "ul", "ol"]);
307
326
  export {
308
- ae as AiMarkdown,
309
- z as inAppHref,
310
- D as isSafeAppPath,
327
+ ce as AiMarkdown,
328
+ y as externalHost,
329
+ J as inAppHref,
330
+ z as isSafeAppPath,
311
331
  G as parseAiMarkdown,
312
332
  F as parseChartSpec,
313
333
  p as renderInline