markdown-flow-ui 0.2.28 → 0.2.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +5 -0
  2. package/dist/_virtual/interaction-syntax.cjs +2 -0
  3. package/dist/_virtual/interaction-syntax.cjs.map +1 -0
  4. package/dist/_virtual/interaction-syntax.es.js +5 -0
  5. package/dist/_virtual/interaction-syntax.es.js.map +1 -0
  6. package/dist/components/ContentRender/ContentRender.cjs +2 -2
  7. package/dist/components/ContentRender/ContentRender.cjs.map +1 -1
  8. package/dist/components/ContentRender/ContentRender.d.ts +2 -0
  9. package/dist/components/ContentRender/ContentRender.es.js +368 -358
  10. package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
  11. package/dist/components/ContentRender/utils/html-block-end.cjs +2 -0
  12. package/dist/components/ContentRender/utils/html-block-end.cjs.map +1 -0
  13. package/dist/components/ContentRender/utils/html-block-end.d.ts +6 -0
  14. package/dist/components/ContentRender/utils/html-block-end.es.js +104 -0
  15. package/dist/components/ContentRender/utils/html-block-end.es.js.map +1 -0
  16. package/dist/components/ContentRender/utils/html-block-end.test.d.ts +1 -0
  17. package/dist/components/ContentRender/utils/split-content.cjs +3 -3
  18. package/dist/components/ContentRender/utils/split-content.cjs.map +1 -1
  19. package/dist/components/ContentRender/utils/split-content.d.ts +1 -1
  20. package/dist/components/ContentRender/utils/split-content.es.js +220 -129
  21. package/dist/components/ContentRender/utils/split-content.es.js.map +1 -1
  22. package/dist/node_modules/remark-flow/dist/interaction-plugin-core.cjs +1 -1
  23. package/dist/node_modules/remark-flow/dist/interaction-plugin-core.cjs.map +1 -1
  24. package/dist/node_modules/remark-flow/dist/interaction-plugin-core.es.js +55 -29
  25. package/dist/node_modules/remark-flow/dist/interaction-plugin-core.es.js.map +1 -1
  26. package/dist/node_modules/remark-flow/dist/interaction-syntax.cjs +2 -0
  27. package/dist/node_modules/remark-flow/dist/interaction-syntax.cjs.map +1 -0
  28. package/dist/node_modules/remark-flow/dist/interaction-syntax.es.js +80 -0
  29. package/dist/node_modules/remark-flow/dist/interaction-syntax.es.js.map +1 -0
  30. package/dist/node_modules/remark-flow/dist/remark-custom-variable.cjs +1 -1
  31. package/dist/node_modules/remark-flow/dist/remark-custom-variable.cjs.map +1 -1
  32. package/dist/node_modules/remark-flow/dist/remark-custom-variable.es.js +8 -7
  33. package/dist/node_modules/remark-flow/dist/remark-custom-variable.es.js.map +1 -1
  34. package/dist/node_modules/remark-flow/dist/remark-flow.cjs +1 -1
  35. package/dist/node_modules/remark-flow/dist/remark-flow.cjs.map +1 -1
  36. package/dist/node_modules/remark-flow/dist/remark-flow.es.js +13 -16
  37. package/dist/node_modules/remark-flow/dist/remark-flow.es.js.map +1 -1
  38. package/dist/node_modules/remark-flow/dist/remark-interaction.cjs +1 -1
  39. package/dist/node_modules/remark-flow/dist/remark-interaction.cjs.map +1 -1
  40. package/dist/node_modules/remark-flow/dist/remark-interaction.es.js +9 -8
  41. package/dist/node_modules/remark-flow/dist/remark-interaction.es.js.map +1 -1
  42. package/package.json +2 -2
@@ -1,417 +1,438 @@
1
- import { jsx as r, jsxs as He } from "react/jsx-runtime";
2
- import Q, { useMemo as C, useState as be, useRef as v, useEffect as P } from "react";
3
- import qe from "../../_virtual/index.es.js";
1
+ import { jsx as n, jsxs as je } from "react/jsx-runtime";
2
+ import U, { useMemo as B, useState as Ne, useRef as g, useEffect as P } from "react";
3
+ import Qe from "../../_virtual/index.es.js";
4
4
  import { sanitizeInvalidTagName as Pe } from "./utils/sanitize-invalid-tag-name.es.js";
5
- import { stripSvgTextLineBreaks as Qe } from "./utils/strip-svg-text-line-breaks.es.js";
5
+ import { stripSvgTextLineBreaks as Ue } from "./utils/strip-svg-text-line-breaks.es.js";
6
6
  /* empty css */
7
7
  /* empty css */
8
8
  /* empty css */
9
9
  /* empty css */
10
- import je, { CodeBlockContext as Ue } from "./CodeBlock.es.js";
11
- import Ke from "./plugins/CustomVariable.es.js";
12
- import ie from "./plugins/MermaidChart.es.js";
13
- import { preserveCustomVariableProperties as Oe, restoreCustomVariableProperties as Xe } from "./utils/custom-variable-props.es.js";
14
- import { subsetLanguages as Ye, highlightLanguages as Ze } from "./utils/highlight-languages.es.js";
15
- import { parseMarkdownSegments as Be, mermaidBlockIsComplete as Je } from "./utils/mermaid-parse.es.js";
16
- import { normalizeInlineHtml as Se } from "./utils/normalize-inline-html.es.js";
17
- import et from "./IframeSandbox.es.js";
18
- import { getTrailingTypewriterGrapheme as ae, appendContentAwareTypewriterQueue as Re, consumeContentAwareTypewriterQueue as tt, CONTENT_AWARE_TYPEWRITER_TICK_BUDGET as rt, isContentAwareTypewriterQueueEmpty as nt } from "./utils/typewriter-pacing.es.js";
19
- import { splitContentSegments as ot } from "./utils/split-content.es.js";
20
- import { getInteractionDefaultValues as st } from "../../lib/interaction-defaults.es.js";
21
- import { getMarkdownFlowDirection as at, getMarkdownFlowLanguage as it } from "../../lib/locale.es.js";
22
- import { getContentRenderLocaleTexts as Le } from "./contentRenderI18n.es.js";
23
- import { Markdown as ct } from "../../node_modules/react-markdown/lib/index.es.js";
24
- import lt from "../../node_modules/rehype-raw/lib/index.es.js";
25
- import ut from "../../node_modules/rehype-highlight/lib/index.es.js";
26
- import dt from "../../node_modules/rehype-katex/lib/index.es.js";
27
- import mt from "../../node_modules/remark-gfm/lib/index.es.js";
28
- import pt from "../../node_modules/remark-math/lib/index.es.js";
29
- import ht from "../../node_modules/remark-breaks/lib/index.es.js";
30
- const ft = /<(script|style|link|iframe|html|head|body|meta|title|base|template|div|section|article|main)\b/i, gt = 2, Ne = ({ svg: t }) => {
31
- const n = v(null);
10
+ import Ke, { CodeBlockContext as Oe } from "./CodeBlock.es.js";
11
+ import Ye from "./plugins/CustomVariable.es.js";
12
+ import le from "./plugins/MermaidChart.es.js";
13
+ import { preserveCustomVariableProperties as Xe, restoreCustomVariableProperties as Ze } from "./utils/custom-variable-props.es.js";
14
+ import { subsetLanguages as Je, highlightLanguages as et } from "./utils/highlight-languages.es.js";
15
+ import { parseMarkdownSegments as Le, mermaidBlockIsComplete as tt } from "./utils/mermaid-parse.es.js";
16
+ import { normalizeInlineHtml as Ae } from "./utils/normalize-inline-html.es.js";
17
+ import nt from "./IframeSandbox.es.js";
18
+ import { getTrailingTypewriterGrapheme as ue, appendContentAwareTypewriterQueue as Me, consumeContentAwareTypewriterQueue as rt, CONTENT_AWARE_TYPEWRITER_TICK_BUDGET as ot, isContentAwareTypewriterQueueEmpty as st } from "./utils/typewriter-pacing.es.js";
19
+ import { splitContentSegments as at } from "./utils/split-content.es.js";
20
+ import { getInteractionDefaultValues as it } from "../../lib/interaction-defaults.es.js";
21
+ import { getMarkdownFlowDirection as ct, getMarkdownFlowLanguage as ut } from "../../lib/locale.es.js";
22
+ import { getContentRenderLocaleTexts as De } from "./contentRenderI18n.es.js";
23
+ import { Markdown as lt } from "../../node_modules/react-markdown/lib/index.es.js";
24
+ import dt from "../../node_modules/rehype-raw/lib/index.es.js";
25
+ import mt from "../../node_modules/rehype-highlight/lib/index.es.js";
26
+ import pt from "../../node_modules/rehype-katex/lib/index.es.js";
27
+ import ht from "../../node_modules/remark-gfm/lib/index.es.js";
28
+ import ft from "../../node_modules/remark-math/lib/index.es.js";
29
+ import gt from "../../node_modules/remark-breaks/lib/index.es.js";
30
+ const vt = 2, $e = ({ svg: t }) => {
31
+ const r = g(null);
32
32
  return P(() => {
33
- const o = n.current;
33
+ const o = r.current;
34
34
  if (!o) return;
35
- const s = o.shadowRoot ?? o.attachShadow({ mode: "open" }), k = "content-render-svg-style";
36
- let u = s.getElementById(k);
37
- u || (u = document.createElement("style"), u.id = k, u.textContent = `
35
+ const a = o.shadowRoot ?? o.attachShadow({ mode: "open" }), T = "content-render-svg-style";
36
+ let m = a.getElementById(T);
37
+ m || (m = document.createElement("style"), m.id = T, m.textContent = `
38
38
  svg { height: auto; display: inline-block; }
39
39
  svg.content-render-svg-el--responsive { width: 100%; max-width: 100%; }
40
40
  svg.content-render-svg-el--fixed { max-width: none; }
41
- `, s.appendChild(u)), Array.from(s.childNodes).filter(
42
- (a) => a !== u
43
- ).forEach((a) => s.removeChild(a));
44
- const G = document.createElement("template"), D = Qe(t);
45
- G.innerHTML = D, s.append(G.content.cloneNode(!0));
46
- let d = !1, F = !1;
47
- s.querySelectorAll("svg").forEach((a) => {
48
- const z = a.getAttribute("viewBox");
49
- if (!z) return;
50
- const W = z.trim().split(/[\s,]+/).map((T) => Number(T));
51
- if (W.length !== 4 || W.some(Number.isNaN)) return;
52
- const [, , E, S] = W, L = a.getAttribute("width"), V = a.getAttribute("height"), j = (T) => {
53
- if (!T) return !1;
54
- const c = T.trim().toLowerCase();
55
- return c === "auto" || c.endsWith("%");
56
- }, U = (T) => {
57
- if (!T) return null;
58
- const c = T.trim().toLowerCase();
59
- if (c === "auto" || c.endsWith("%"))
41
+ `, a.appendChild(m)), Array.from(a.childNodes).filter(
42
+ (i) => i !== m
43
+ ).forEach((i) => a.removeChild(i));
44
+ const G = document.createElement("template"), V = Ue(t);
45
+ G.innerHTML = V, a.append(G.content.cloneNode(!0));
46
+ let p = !1, z = !1;
47
+ a.querySelectorAll("svg").forEach((i) => {
48
+ const _ = i.getAttribute("viewBox");
49
+ if (!_) return;
50
+ const q = _.trim().split(/[\s,]+/).map((y) => Number(y));
51
+ if (q.length !== 4 || q.some(Number.isNaN)) return;
52
+ const [, , D, R] = q, A = i.getAttribute("width"), E = i.getAttribute("height"), K = (y) => {
53
+ if (!y) return !1;
54
+ const u = y.trim().toLowerCase();
55
+ return u === "auto" || u.endsWith("%");
56
+ }, O = (y) => {
57
+ if (!y) return null;
58
+ const u = y.trim().toLowerCase();
59
+ if (u === "auto" || u.endsWith("%"))
60
60
  return null;
61
- const M = Number.parseFloat(c);
61
+ const M = Number.parseFloat(u);
62
62
  return Number.isNaN(M) ? null : M;
63
- }, Y = j(L), Z = j(V), K = !L || L === "0", O = !V || V === "0", J = U(L), ee = U(V);
64
- if (Y || Z || K && O || J === E && ee === S) {
65
- d = !0, a.classList.add("content-render-svg-el--responsive"), a.classList.remove("content-render-svg-el--fixed"), a.style.width = "100%", a.style.height = "auto", !a.style.aspectRatio && S > 0 && (a.style.aspectRatio = `${E} / ${S}`);
63
+ }, ee = K(A), te = K(E), Y = !A || A === "0", X = !E || E === "0", ne = O(A), re = O(E);
64
+ if (ee || te || Y && X || ne === D && re === R) {
65
+ p = !0, i.classList.add("content-render-svg-el--responsive"), i.classList.remove("content-render-svg-el--fixed"), i.style.width = "100%", i.style.height = "auto", !i.style.aspectRatio && R > 0 && (i.style.aspectRatio = `${D} / ${R}`);
66
66
  return;
67
67
  }
68
- F = !0, a.classList.add("content-render-svg-el--fixed"), a.classList.remove("content-render-svg-el--responsive"), K && E > 0 && a.setAttribute("width", `${E}`), O && S > 0 && a.setAttribute("height", `${S}`);
68
+ z = !0, i.classList.add("content-render-svg-el--fixed"), i.classList.remove("content-render-svg-el--responsive"), Y && D > 0 && i.setAttribute("width", `${D}`), X && R > 0 && i.setAttribute("height", `${R}`);
69
69
  });
70
- const _ = d && !F;
71
- o.classList.toggle("content-render-svg--responsive", _), o.classList.toggle("content-render-svg--fixed", !_);
72
- }, [t]), /* @__PURE__ */ r("div", { className: "content-render-svg-scroll", children: /* @__PURE__ */ r("div", { className: "content-render-svg", ref: n }) });
73
- }, ce = Q.createContext(
70
+ const W = p && !z;
71
+ o.classList.toggle("content-render-svg--responsive", W), o.classList.toggle("content-render-svg--fixed", !W);
72
+ }, [t]), /* @__PURE__ */ n("div", { className: "content-render-svg-scroll", children: /* @__PURE__ */ n("div", { className: "content-render-svg", ref: r }) });
73
+ }, de = U.createContext(
74
74
  null
75
75
  ), xt = (t) => {
76
- const n = Q.useContext(ce), o = Q.useContext(Ue);
77
- if (!n)
76
+ const r = U.useContext(de), o = U.useContext(Oe);
77
+ if (!r)
78
78
  throw new Error("Markdown code renderer requires ContentRender context.");
79
- const { className: s, children: k, ...u } = t;
80
- if (/language-(\w+)/.exec(s || "")?.[1] === "mermaid") {
81
- const D = k?.toString().replace(/\n$/, "") || "", d = Je(
82
- n.current.renderContent,
83
- D
79
+ const { className: a, children: T, ...m } = t;
80
+ if (/language-(\w+)/.exec(a || "")?.[1] === "mermaid") {
81
+ const V = T?.toString().replace(/\n$/, "") || "", p = tt(
82
+ r.current.renderContent,
83
+ V
84
84
  );
85
- return /* @__PURE__ */ r(
86
- ie,
85
+ return /* @__PURE__ */ n(
86
+ le,
87
87
  {
88
- chart: D,
89
- frozen: d,
90
- messages: n.current.mermaidMessages
88
+ chart: V,
89
+ frozen: p,
90
+ messages: r.current.mermaidMessages
91
91
  }
92
92
  );
93
93
  }
94
- return /* @__PURE__ */ r(
94
+ return /* @__PURE__ */ n(
95
95
  "code",
96
96
  {
97
- className: s,
98
- ...u,
99
- dir: u.dir ?? (o ? void 0 : "ltr"),
100
- children: k
97
+ className: a,
98
+ ...m,
99
+ dir: m.dir ?? (o ? void 0 : "ltr"),
100
+ children: T
101
101
  }
102
102
  );
103
- }, vt = [
104
- mt,
105
- pt,
106
- qe,
107
- ht
108
- ], Tt = [
109
- Oe,
110
- lt,
111
- Pe,
103
+ }, yt = [
104
+ ht,
105
+ ft,
106
+ Qe,
107
+ gt
108
+ ], Ct = [
112
109
  Xe,
113
- [ut, { languages: Ze, subset: Ye }],
114
- dt
115
- ], Ae = ({ content: t, components: n, locale: o }) => {
116
- const s = Le(o);
117
- return /* @__PURE__ */ r("div", { className: "markdown-renderer", children: /* @__PURE__ */ r(
118
- ct,
110
+ dt,
111
+ Pe,
112
+ Ze,
113
+ [mt, { languages: et, subset: Je }],
114
+ pt
115
+ ], Ve = ({ content: t, components: r, locale: o }) => {
116
+ const a = De(o);
117
+ return /* @__PURE__ */ n("div", { className: "markdown-renderer", children: /* @__PURE__ */ n(
118
+ lt,
119
119
  {
120
- remarkPlugins: vt,
121
- rehypePlugins: Tt,
120
+ remarkPlugins: yt,
121
+ rehypePlugins: Ct,
122
122
  remarkRehypeOptions: {
123
- footnoteLabel: s.footnoteLabel,
124
- footnoteBackLabel: (k, u) => {
125
- const A = String(k + 1) + (u > 1 ? `-${u}` : "");
126
- return s.footnoteBackLabel.replace("{reference}", A);
123
+ footnoteLabel: a.footnoteLabel,
124
+ footnoteBackLabel: (T, m) => {
125
+ const L = String(T + 1) + (m > 1 ? `-${m}` : "");
126
+ return a.footnoteBackLabel.replace("{reference}", L);
127
127
  }
128
128
  },
129
- components: n,
129
+ components: r,
130
130
  children: t
131
131
  }
132
132
  ) });
133
- }, yt = (t) => {
133
+ }, Tt = (t) => {
134
134
  if (t.length <= 1) return t;
135
- const n = [];
135
+ const r = [];
136
136
  return t.forEach((o) => {
137
137
  if (o.type === "sandbox") {
138
- n.push(o);
138
+ r.push(o);
139
139
  return;
140
140
  }
141
- const s = n[n.length - 1];
142
- if (s && s.type !== "sandbox") {
143
- n[n.length - 1] = {
141
+ const a = r[r.length - 1];
142
+ if (a && a.type !== "sandbox") {
143
+ r[r.length - 1] = {
144
144
  type: "markdown",
145
- value: `${s.value}${o.value}`
145
+ value: `${a.value}${o.value}`
146
146
  };
147
147
  return;
148
148
  }
149
- n.push({ type: "markdown", value: o.value });
150
- }), n;
151
- }, Ct = (t, n) => {
152
- const o = Math.max(1, n), s = Array.from(t);
149
+ r.push({ type: "markdown", value: o.value });
150
+ }), r;
151
+ }, kt = (t, r) => {
152
+ const o = Math.max(1, r), a = Array.from(t);
153
153
  return {
154
- chunk: s.slice(0, o).join(""),
155
- rest: s.slice(o).join("")
154
+ chunk: a.slice(0, o).join(""),
155
+ rest: a.slice(o).join("")
156
156
  };
157
- }, kt = (t, n) => t === n ? !0 : !t || !n || t.length !== n.length ? !1 : t.every((o, s) => o === n[s]), wt = (t) => {
158
- const n = v(t);
159
- return kt(n.current, t) || (n.current = t), n.current;
160
- }, tr = ({
157
+ }, wt = (t, r) => t === r ? !0 : !t || !r || t.length !== r.length ? !1 : t.every((o, a) => o === r[a]), bt = (t) => {
158
+ const r = g(t);
159
+ return wt(r.current, t) || (r.current = t), r.current;
160
+ }, nn = ({
161
161
  content: t,
162
- contentType: n,
162
+ contentType: r,
163
163
  locale: o,
164
- lang: s,
165
- dir: k,
166
- customRenderBar: u,
167
- onSend: A,
164
+ lang: a,
165
+ dir: T,
166
+ customRenderBar: m,
167
+ onSend: L,
168
168
  typingSpeed: G = 30,
169
- enableTypewriter: D = !1,
170
- typewriterPacing: d = "fixed",
171
- onTypeFinished: F,
172
- onTypewriterStateChange: _,
173
- userInput: a,
174
- interactionDefaultValueOptions: z,
175
- defaultButtonText: W,
176
- defaultInputText: E,
177
- defaultSelectedValues: S,
178
- readonly: L = !1,
179
- confirmButtonText: V,
180
- copyButtonText: j,
181
- copiedButtonText: U,
182
- sandboxLoadingText: Y,
183
- sandboxStyleLoadingText: Z,
184
- sandboxScriptLoadingText: K,
185
- disableSandboxLoadingOverlay: O = !1,
186
- sandboxFullscreenButtonText: J,
187
- sandboxExitFullscreenButtonText: ee,
188
- sandboxMode: le = "content",
189
- onClickCustomButtonAfterContent: te,
190
- beforeSend: T
169
+ enableTypewriter: V = !1,
170
+ typewriterPacing: p = "fixed",
171
+ onTypeFinished: z,
172
+ onTypewriterStateChange: W,
173
+ userInput: i,
174
+ interactionDefaultValueOptions: _,
175
+ defaultButtonText: q,
176
+ defaultInputText: D,
177
+ defaultSelectedValues: R,
178
+ readonly: A = !1,
179
+ confirmButtonText: E,
180
+ copyButtonText: K,
181
+ copiedButtonText: O,
182
+ sandboxLoadingText: ee,
183
+ sandboxStyleLoadingText: te,
184
+ sandboxScriptLoadingText: Y,
185
+ disableSandboxLoadingOverlay: X = !1,
186
+ sandboxFullscreenButtonText: ne,
187
+ sandboxExitFullscreenButtonText: re,
188
+ sandboxMode: me = "content",
189
+ onClickCustomButtonAfterContent: oe,
190
+ beforeSend: y
191
191
  // tooltipMinLength,
192
192
  }) => {
193
- const c = Le(o), M = C(
193
+ const u = De(o), M = B(
194
194
  () => ({
195
- loading: c.mermaidLoadingText,
196
- emptyChart: c.mermaidEmptyChartText,
197
- error: c.mermaidErrorText
195
+ loading: u.mermaidLoadingText,
196
+ emptyChart: u.mermaidEmptyChartText,
197
+ error: u.mermaidErrorText
198
198
  }),
199
- [c]
200
- ), H = k ?? at(o), q = s ?? it(o), ue = V || c.confirmButtonText, de = j || c.copyButtonText, me = U || c.copiedButtonText, Me = J || c.sandboxFullscreenButtonText, $e = ee || c.sandboxExitFullscreenButtonText, m = !!D && (!n || n === "text"), pe = Math.max(0, G), De = d === "fixed" ? t : void 0, [w, he] = be(
201
- () => m ? "" : t
202
- ), X = v(w), h = v(""), g = v({
199
+ [u]
200
+ ), H = T ?? ct(o), j = a ?? ut(o), pe = E || u.confirmButtonText, he = K || u.copyButtonText, fe = O || u.copiedButtonText, Ee = ne || u.sandboxFullscreenButtonText, Ie = re || u.sandboxExitFullscreenButtonText, l = !!V && (!r || r === "text"), Z = B(
201
+ () => Tt(at(t, !0, !0)),
202
+ [t]
203
+ ), se = Z.some(
204
+ (e) => e.type === "sandbox"
205
+ ), c = se ? Z.filter((e) => e.type !== "sandbox").map((e) => e.value).join("") : t, ge = Math.max(0, G), Fe = p === "fixed" ? c : void 0, [v, ve] = Ne(
206
+ () => l ? "" : c
207
+ ), J = g(v), f = g(""), x = g({
203
208
  tokens: [],
204
209
  head: 0,
205
210
  trailingGrapheme: ""
206
- }), R = v(0), fe = v(m), ge = v(d), xe = v(t), re = v(!1), [Ee, Ve] = be(0);
211
+ }), S = g(0), xe = g(l), ye = g(p), Ce = g(c), Te = g(t), ae = g(!1), [Ge, ze] = Ne(0);
207
212
  P(() => {
208
- const e = fe.current, i = ge.current, p = xe.current, b = !!h.current;
209
- fe.current = m, ge.current = d, xe.current = t, (t !== p || m !== e) && (re.current = !1);
210
- const f = () => {
211
- h.current = "", g.current = {
213
+ const e = xe.current, s = ye.current, h = Ce.current, k = !!f.current, C = Te.current !== t;
214
+ Te.current = t, xe.current = l, ye.current = p, Ce.current = c, (C || l !== e) && (ae.current = !1);
215
+ const Q = () => {
216
+ f.current = "", x.current = {
212
217
  tokens: [],
213
218
  head: 0,
214
219
  trailingGrapheme: ""
215
- }, R.current = 0;
216
- }, $ = (I) => {
217
- X.current = I, he(I);
220
+ }, S.current = 0;
221
+ }, w = (F) => {
222
+ J.current = F, ve(F);
218
223
  };
219
- if (!m) {
220
- f(), $(t);
224
+ if (!l) {
225
+ Q(), w(c);
221
226
  return;
222
227
  }
223
- e || (f(), $(""));
224
- const x = e ? X.current : "";
225
- if (!t.startsWith(x)) {
226
- f(), $(t), d === "content-aware" && (g.current = {
228
+ e || (Q(), w(""));
229
+ const $ = e ? J.current : "";
230
+ if (!c.startsWith($)) {
231
+ Q(), w(c), p === "content-aware" && (x.current = {
227
232
  tokens: [],
228
233
  head: 0,
229
- trailingGrapheme: ae(t)
234
+ trailingGrapheme: ue(c)
230
235
  });
231
236
  return;
232
237
  }
233
- let N = t.slice(x.length);
238
+ let N = c.slice($.length);
234
239
  if (!N) {
235
- h.current = "", R.current = 0, g.current = d === "content-aware" ? {
240
+ f.current = "", S.current = 0, x.current = p === "content-aware" ? {
236
241
  tokens: [],
237
242
  head: 0,
238
- trailingGrapheme: ae(x)
243
+ trailingGrapheme: ue($)
239
244
  } : { tokens: [], head: 0, trailingGrapheme: "" };
240
245
  return;
241
246
  }
242
- if (d === "content-aware") {
243
- const I = p.slice(
244
- x.length
247
+ if (p === "content-aware") {
248
+ const F = h.slice(
249
+ $.length
245
250
  );
246
- if (e && i === "content-aware" && t.startsWith(p) && h.current === I) {
247
- const B = Re(
248
- g.current,
249
- t.slice(p.length)
251
+ if (e && s === "content-aware" && c.startsWith(h) && f.current === F) {
252
+ const b = Me(
253
+ x.current,
254
+ c.slice(h.length)
250
255
  );
251
- g.current = B.queue, B.immediateChunk && (N = N.slice(
252
- B.immediateChunk.length
253
- ), $(`${x}${B.immediateChunk}`));
256
+ x.current = b.queue, b.immediateChunk && (N = N.slice(
257
+ b.immediateChunk.length
258
+ ), w(`${$}${b.immediateChunk}`));
254
259
  } else {
255
- const B = Re(
260
+ const b = Me(
256
261
  {
257
262
  tokens: [],
258
263
  head: 0,
259
- trailingGrapheme: ae(x)
264
+ trailingGrapheme: ue($)
260
265
  },
261
266
  N
262
267
  );
263
- g.current = B.queue, B.immediateChunk && (N = N.slice(
264
- B.immediateChunk.length
265
- ), $(`${x}${B.immediateChunk}`)), R.current = 0;
268
+ x.current = b.queue, b.immediateChunk && (N = N.slice(
269
+ b.immediateChunk.length
270
+ ), w(`${$}${b.immediateChunk}`)), S.current = 0;
266
271
  }
267
272
  } else
268
- g.current = {
273
+ x.current = {
269
274
  tokens: [],
270
275
  head: 0,
271
276
  trailingGrapheme: ""
272
- }, R.current = 0;
273
- h.current = N, !b && N && Ve((I) => I + 1);
274
- }, [t, m, d]), P(() => {
275
- m && (re.current || h.current || w !== t || (re.current = !0, F?.()));
276
- }, [t, w, m, F]), P(() => {
277
- if (!m || !h.current)
277
+ }, S.current = 0;
278
+ f.current = N, !k && N && ze((F) => F + 1);
279
+ }, [t, c, l, p]), P(() => {
280
+ l && (ae.current || f.current || v !== c || (ae.current = !0, z?.()));
281
+ }, [
282
+ t,
283
+ c,
284
+ v,
285
+ l,
286
+ z
287
+ ]), P(() => {
288
+ if (!l || !f.current)
278
289
  return;
279
290
  const e = window.setTimeout(() => {
280
- if (!h.current)
291
+ if (!f.current)
281
292
  return;
282
- let i = "";
283
- if (d === "content-aware") {
284
- const b = tt(
285
- g.current,
286
- R.current + rt
293
+ let s = "";
294
+ if (p === "content-aware") {
295
+ const k = rt(
296
+ x.current,
297
+ S.current + ot
287
298
  );
288
- i = b.chunk, g.current = b.queue, nt(b.queue) ? R.current = 0 : R.current = b.remainingBudget;
299
+ s = k.chunk, x.current = k.queue, st(k.queue) ? S.current = 0 : S.current = k.remainingBudget;
289
300
  } else
290
- i = Ct(
291
- h.current,
292
- gt
301
+ s = kt(
302
+ f.current,
303
+ vt
293
304
  ).chunk;
294
- if (!i)
305
+ if (!s)
295
306
  return;
296
- h.current = h.current.slice(i.length), h.current || (g.current = d === "content-aware" ? {
307
+ f.current = f.current.slice(s.length), f.current || (x.current = p === "content-aware" ? {
297
308
  tokens: [],
298
309
  head: 0,
299
- trailingGrapheme: g.current.trailingGrapheme
300
- } : { tokens: [], head: 0, trailingGrapheme: "" }, R.current = 0);
301
- const p = `${X.current}${i}`;
302
- X.current = p, he(p);
303
- }, pe);
310
+ trailingGrapheme: x.current.trailingGrapheme
311
+ } : { tokens: [], head: 0, trailingGrapheme: "" }, S.current = 0);
312
+ const h = `${J.current}${s}`;
313
+ J.current = h, ve(h);
314
+ }, ge);
304
315
  return () => window.clearTimeout(e);
305
316
  }, [
306
- w,
307
- De,
308
- m,
309
- d,
310
- pe,
311
- Ee
317
+ v,
318
+ Fe,
319
+ l,
320
+ p,
321
+ ge,
322
+ Ge
312
323
  ]);
313
- const ve = C(
324
+ const ke = B(
314
325
  () => ({
315
- isTypewriterEnabled: m,
316
- isTyping: m && w !== t,
317
- isComplete: w === t,
318
- renderedLength: w.length,
326
+ isTypewriterEnabled: l,
327
+ isTyping: l && v !== c,
328
+ isComplete: v === c,
329
+ renderedLength: t.length - Math.max(0, c.length - v.length),
319
330
  totalLength: t.length
320
331
  }),
321
- [t, w, m]
332
+ [t, c, v, l]
322
333
  );
323
334
  P(() => {
324
- _?.(ve);
325
- }, [_, ve]);
326
- const y = m ? w : t, ne = C(
327
- () => Se(y),
328
- [y]
329
- ), oe = C(
330
- () => st(
331
- y,
332
- a,
333
- z
335
+ W?.(ke);
336
+ }, [W, ke]);
337
+ const we = B(() => {
338
+ let e = 0;
339
+ return Z.map((s) => {
340
+ if (s.type === "sandbox" || !l) return s;
341
+ const h = v.slice(
342
+ e,
343
+ e + s.value.length
344
+ );
345
+ return e += s.value.length, { ...s, value: h };
346
+ });
347
+ }, [Z, v, l]), I = se ? we.map((e) => e.value).join("") : l ? v : t, ie = B(
348
+ () => Ae(I),
349
+ [I]
350
+ ), ce = B(
351
+ () => it(
352
+ I,
353
+ i,
354
+ _
334
355
  ),
335
- [z, y, a]
336
- ), Te = W?.trim() || oe.buttonText, ye = E?.trim() || oe.inputText, Ie = C(
337
- () => a ? a.split(",").map((e) => e.trim()).filter(Boolean) : void 0,
338
- [a]
339
- ), Ge = S?.length ? S : oe.selectedValues || Ie, Ce = wt(
340
- Ge
341
- ), l = v({
356
+ [_, I, i]
357
+ ), be = q?.trim() || ce.buttonText, Be = D?.trim() || ce.inputText, We = B(
358
+ () => i ? i.split(",").map((e) => e.trim()).filter(Boolean) : void 0,
359
+ [i]
360
+ ), _e = R?.length ? R : ce.selectedValues || We, Re = bt(
361
+ _e
362
+ ), d = g({
342
363
  direction: H,
343
- language: q,
364
+ language: j,
344
365
  mermaidMessages: M,
345
- beforeSend: T,
366
+ beforeSend: y,
346
367
  locale: o,
347
- onClickCustomButtonAfterContent: te,
348
- onSend: A,
349
- readonly: L,
350
- renderContent: y,
351
- resolvedConfirmButtonText: ue,
352
- resolvedCopiedButtonText: me,
353
- resolvedCopyButtonText: de,
354
- resolvedDefaultButtonText: Te,
355
- resolvedDefaultInputText: ye,
356
- resolvedDefaultSelectedValues: Ce
368
+ onClickCustomButtonAfterContent: oe,
369
+ onSend: L,
370
+ readonly: A,
371
+ renderContent: I,
372
+ resolvedConfirmButtonText: pe,
373
+ resolvedCopiedButtonText: fe,
374
+ resolvedCopyButtonText: he,
375
+ resolvedDefaultButtonText: be,
376
+ resolvedDefaultInputText: Be,
377
+ resolvedDefaultSelectedValues: Re
357
378
  });
358
- l.current = {
379
+ d.current = {
359
380
  direction: H,
360
- language: q,
381
+ language: j,
361
382
  mermaidMessages: M,
362
- beforeSend: T,
383
+ beforeSend: y,
363
384
  locale: o,
364
- onClickCustomButtonAfterContent: te,
365
- onSend: A,
366
- readonly: L,
367
- renderContent: y,
368
- resolvedConfirmButtonText: ue,
369
- resolvedCopiedButtonText: me,
370
- resolvedCopyButtonText: de,
371
- resolvedDefaultButtonText: Te,
372
- resolvedDefaultInputText: ye,
373
- resolvedDefaultSelectedValues: Ce
385
+ onClickCustomButtonAfterContent: oe,
386
+ onSend: L,
387
+ readonly: A,
388
+ renderContent: I,
389
+ resolvedConfirmButtonText: pe,
390
+ resolvedCopiedButtonText: fe,
391
+ resolvedCopyButtonText: he,
392
+ resolvedDefaultButtonText: be,
393
+ resolvedDefaultInputText: Be,
394
+ resolvedDefaultSelectedValues: Re
374
395
  };
375
- const ke = C(
396
+ const Se = B(
376
397
  () => ({
377
398
  "custom-button-after-content": ({
378
399
  children: e
379
- }) => /* @__PURE__ */ r(
400
+ }) => /* @__PURE__ */ n(
380
401
  "button",
381
402
  {
382
403
  className: "content-render-custom-button-after-content",
383
- onClick: l.current.onClickCustomButtonAfterContent,
384
- children: /* @__PURE__ */ r("span", { className: "content-render-custom-button-after-content-inner", children: e })
404
+ onClick: d.current.onClickCustomButtonAfterContent,
405
+ children: /* @__PURE__ */ n("span", { className: "content-render-custom-button-after-content-inner", children: e })
385
406
  }
386
407
  ),
387
- "custom-variable": (e) => /* @__PURE__ */ r(
388
- Ke,
408
+ "custom-variable": (e) => /* @__PURE__ */ n(
409
+ Ye,
389
410
  {
390
411
  ...e,
391
- readonly: l.current.readonly,
392
- defaultButtonText: l.current.resolvedDefaultButtonText,
393
- defaultInputText: l.current.resolvedDefaultInputText,
394
- defaultSelectedValues: l.current.resolvedDefaultSelectedValues,
395
- onSend: l.current.onSend,
396
- beforeSend: l.current.beforeSend,
397
- locale: l.current.locale,
398
- dir: l.current.direction,
399
- lang: l.current.language,
400
- confirmButtonText: l.current.resolvedConfirmButtonText
412
+ readonly: d.current.readonly,
413
+ defaultButtonText: d.current.resolvedDefaultButtonText,
414
+ defaultInputText: d.current.resolvedDefaultInputText,
415
+ defaultSelectedValues: d.current.resolvedDefaultSelectedValues,
416
+ onSend: d.current.onSend,
417
+ beforeSend: d.current.beforeSend,
418
+ locale: d.current.locale,
419
+ dir: d.current.direction,
420
+ lang: d.current.language,
421
+ confirmButtonText: d.current.resolvedConfirmButtonText
401
422
  }
402
423
  ),
403
424
  code: xt,
404
- table: ({ ...e }) => /* @__PURE__ */ r("div", { className: "content-render-table-container", children: /* @__PURE__ */ r("table", { className: "content-render-table", ...e }) }),
405
- th: ({ ...e }) => /* @__PURE__ */ r("th", { className: "content-render-th", ...e }),
406
- td: ({ ...e }) => /* @__PURE__ */ r("td", { className: "content-render-td", ...e }),
407
- tr: ({ ...e }) => /* @__PURE__ */ r("tr", { className: "content-render-tr", ...e }),
408
- li: ({ node: e, ...i }) => {
409
- const p = e?.properties?.className;
410
- return typeof p == "string" && p.includes("task-list-item") || Array.isArray(p) && p.includes("task-list-item") ? /* @__PURE__ */ r("li", { className: "content-render-task-list-item", ...i }) : /* @__PURE__ */ r("li", { ...i });
425
+ table: ({ ...e }) => /* @__PURE__ */ n("div", { className: "content-render-table-container", children: /* @__PURE__ */ n("table", { className: "content-render-table", ...e }) }),
426
+ th: ({ ...e }) => /* @__PURE__ */ n("th", { className: "content-render-th", ...e }),
427
+ td: ({ ...e }) => /* @__PURE__ */ n("td", { className: "content-render-td", ...e }),
428
+ tr: ({ ...e }) => /* @__PURE__ */ n("tr", { className: "content-render-tr", ...e }),
429
+ li: ({ node: e, ...s }) => {
430
+ const h = e?.properties?.className;
431
+ return typeof h == "string" && h.includes("task-list-item") || Array.isArray(h) && h.includes("task-list-item") ? /* @__PURE__ */ n("li", { className: "content-render-task-list-item", ...s }) : /* @__PURE__ */ n("li", { ...s });
411
432
  },
412
- ol: ({ ...e }) => /* @__PURE__ */ r("ol", { className: "content-render-ol", ...e }),
413
- ul: ({ ...e }) => /* @__PURE__ */ r("ul", { className: "content-render-ul", ...e }),
414
- input: ({ ...e }) => e.type === "checkbox" ? /* @__PURE__ */ r(
433
+ ol: ({ ...e }) => /* @__PURE__ */ n("ol", { className: "content-render-ol", ...e }),
434
+ ul: ({ ...e }) => /* @__PURE__ */ n("ul", { className: "content-render-ul", ...e }),
435
+ input: ({ ...e }) => e.type === "checkbox" ? /* @__PURE__ */ n(
415
436
  "input",
416
437
  {
417
438
  type: "checkbox",
@@ -419,70 +440,59 @@ const ft = /<(script|style|link|iframe|html|head|body|meta|title|base|template|d
419
440
  disabled: !0,
420
441
  ...e
421
442
  }
422
- ) : /* @__PURE__ */ r("input", { ...e }),
423
- a: ({ children: e, ...i }) => /* @__PURE__ */ r("a", { target: "_blank", rel: "noopener noreferrer", ...i, children: e }),
424
- pre: (e) => /* @__PURE__ */ r(
425
- je,
443
+ ) : /* @__PURE__ */ n("input", { ...e }),
444
+ a: ({ children: e, ...s }) => /* @__PURE__ */ n("a", { target: "_blank", rel: "noopener noreferrer", ...s, children: e }),
445
+ pre: (e) => /* @__PURE__ */ n(
446
+ Ke,
426
447
  {
427
448
  ...e,
428
- copyButtonText: l.current.resolvedCopyButtonText,
429
- copiedButtonText: l.current.resolvedCopiedButtonText
449
+ copyButtonText: d.current.resolvedCopyButtonText,
450
+ copiedButtonText: d.current.resolvedCopiedButtonText
430
451
  }
431
452
  )
432
453
  }),
433
454
  []
434
- ), we = C(
435
- () => ft.test(y),
436
- [y]
437
- ), se = C(
438
- () => we ? ot(y, !0) : [],
439
- [y, we]
440
- ), Fe = se.some(
441
- (e) => e.type === "sandbox"
442
- ), _e = C(
443
- () => yt(se),
444
- [se]
445
- ), ze = C(
446
- () => Be(ne),
447
- [ne]
448
- ), We = (e, i) => {
449
- const p = Se(e);
450
- return Be(p).map((f, $) => {
451
- const x = `${i}-${f.type}-${$}`;
452
- return f.type === "text" ? /* @__PURE__ */ r(
453
- ce.Provider,
455
+ ), qe = B(
456
+ () => Le(ie),
457
+ [ie]
458
+ ), He = (e, s) => {
459
+ const h = Ae(e);
460
+ return Le(h).map((C, Q) => {
461
+ const w = `${s}-${C.type}-${Q}`;
462
+ return C.type === "text" ? /* @__PURE__ */ n(
463
+ de.Provider,
454
464
  {
455
- value: l,
456
- children: /* @__PURE__ */ r(
457
- Ae,
465
+ value: d,
466
+ children: /* @__PURE__ */ n(
467
+ Ve,
458
468
  {
459
469
  locale: o,
460
- components: ke,
461
- content: f.value
470
+ components: Se,
471
+ content: C.value
462
472
  }
463
473
  )
464
474
  },
465
- x
466
- ) : f.type === "mermaid" ? /* @__PURE__ */ r(
467
- ie,
475
+ w
476
+ ) : C.type === "mermaid" ? /* @__PURE__ */ n(
477
+ le,
468
478
  {
469
- chart: f.value,
470
- frozen: !f.complete,
479
+ chart: C.value,
480
+ frozen: !C.complete,
471
481
  messages: M
472
482
  },
473
- x
474
- ) : f.type === "svg" ? /* @__PURE__ */ r(Ne, { svg: f.value }, x) : null;
483
+ w
484
+ ) : C.type === "svg" ? /* @__PURE__ */ n($e, { svg: C.value }, w) : null;
475
485
  });
476
486
  };
477
- return Fe ? /* @__PURE__ */ r(
487
+ return se ? /* @__PURE__ */ n(
478
488
  "div",
479
489
  {
480
490
  className: "content-render markdown-body",
481
491
  dir: H,
482
- lang: q,
483
- children: _e.map(
484
- (e, i) => e.type === "sandbox" ? /* @__PURE__ */ r(
485
- et,
492
+ lang: j,
493
+ children: we.map(
494
+ (e, s) => e.type === "sandbox" ? /* @__PURE__ */ n(
495
+ nt,
486
496
  {
487
497
  hideFullScreen: !0,
488
498
  type: "sandbox",
@@ -490,67 +500,67 @@ const ft = /<(script|style|link|iframe|html|head|body|meta|title|base|template|d
490
500
  className: "content-render-iframe",
491
501
  locale: o,
492
502
  dir: H,
493
- lang: q,
494
- loadingText: Y,
495
- styleLoadingText: Z,
496
- scriptLoadingText: K,
497
- disableLoadingOverlay: O,
498
- fullScreenButtonText: Me,
499
- exitFullScreenButtonText: $e,
500
- mode: le
503
+ lang: j,
504
+ loadingText: ee,
505
+ styleLoadingText: te,
506
+ scriptLoadingText: Y,
507
+ disableLoadingOverlay: X,
508
+ fullScreenButtonText: Ee,
509
+ exitFullScreenButtonText: Ie,
510
+ mode: me
501
511
  },
502
- `sandbox-${i}`
503
- ) : /* @__PURE__ */ r(Q.Fragment, { children: We(e.value, `md-${i}`) }, `md-${i}`)
512
+ `sandbox-${s}`
513
+ ) : /* @__PURE__ */ n(U.Fragment, { children: He(e.value, `md-${s}`) }, `md-${s}`)
504
514
  )
505
515
  }
506
- ) : /* @__PURE__ */ He(
516
+ ) : /* @__PURE__ */ je(
507
517
  "div",
508
518
  {
509
519
  className: "content-render markdown-body",
510
520
  dir: H,
511
- lang: q,
521
+ lang: j,
512
522
  children: [
513
- ze.map((e, i) => {
523
+ qe.map((e, s) => {
514
524
  if (e.type === "text")
515
- return /* @__PURE__ */ r(
516
- ce.Provider,
525
+ return /* @__PURE__ */ n(
526
+ de.Provider,
517
527
  {
518
- value: l,
519
- children: /* @__PURE__ */ r(
520
- Ae,
528
+ value: d,
529
+ children: /* @__PURE__ */ n(
530
+ Ve,
521
531
  {
522
532
  locale: o,
523
- components: ke,
533
+ components: Se,
524
534
  content: e.value
525
535
  }
526
536
  )
527
537
  },
528
- i
538
+ s
529
539
  );
530
540
  if (e.type === "mermaid")
531
- return /* @__PURE__ */ r(
532
- ie,
541
+ return /* @__PURE__ */ n(
542
+ le,
533
543
  {
534
544
  chart: e.value,
535
545
  frozen: !e.complete,
536
546
  messages: M
537
547
  },
538
- i
548
+ s
539
549
  );
540
550
  if (e.type === "svg")
541
- return /* @__PURE__ */ r(Ne, { svg: e.value }, i);
551
+ return /* @__PURE__ */ n($e, { svg: e.value }, s);
542
552
  }),
543
- u && /* @__PURE__ */ r("div", { className: "content-render-custom-bar", children: Q.createElement(u, {
553
+ m && /* @__PURE__ */ n("div", { className: "content-render-custom-bar", children: U.createElement(m, {
544
554
  content: t,
545
- displayContent: ne,
546
- onSend: A
555
+ displayContent: ie,
556
+ onSend: L
547
557
  }) })
548
558
  ]
549
559
  }
550
560
  );
551
561
  };
552
562
  export {
553
- Ae as MarkdownRenderer,
554
- tr as default
563
+ Ve as MarkdownRenderer,
564
+ nn as default
555
565
  };
556
566
  //# sourceMappingURL=ContentRender.es.js.map