markdown-flow-ui 0.2.31 → 0.2.32

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 (37) hide show
  1. package/README.md +3 -3
  2. package/dist/_virtual/index.es3.js +5 -4
  3. package/dist/_virtual/index.es3.js.map +1 -1
  4. package/dist/_virtual/index.es4.js +4 -5
  5. package/dist/_virtual/index.es4.js.map +1 -1
  6. package/dist/_virtual/index.es8.js +2 -2
  7. package/dist/_virtual/index.es9.js +2 -2
  8. package/dist/_virtual/index3.cjs +1 -1
  9. package/dist/_virtual/index4.cjs +1 -1
  10. package/dist/_virtual/index8.cjs +1 -1
  11. package/dist/_virtual/index9.cjs +1 -1
  12. package/dist/components/ContentRender/ContentRender.cjs +2 -2
  13. package/dist/components/ContentRender/ContentRender.cjs.map +1 -1
  14. package/dist/components/ContentRender/ContentRender.d.ts +1 -1
  15. package/dist/components/ContentRender/ContentRender.es.js +183 -172
  16. package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
  17. package/dist/components/ContentRender/utils/video-markdown-run.cjs +13 -13
  18. package/dist/components/ContentRender/utils/video-markdown-run.cjs.map +1 -1
  19. package/dist/components/ContentRender/utils/video-markdown-run.es.js +223 -217
  20. package/dist/components/ContentRender/utils/video-markdown-run.es.js.map +1 -1
  21. package/dist/components/ui/inputGroup/textarea.cjs +1 -1
  22. package/dist/components/ui/inputGroup/textarea.es.js +1 -1
  23. package/dist/node_modules/@braintree/sanitize-url/dist/index.cjs +1 -1
  24. package/dist/node_modules/@braintree/sanitize-url/dist/index.es.js +1 -1
  25. package/dist/node_modules/classnames/index.cjs +1 -1
  26. package/dist/node_modules/classnames/index.es.js +1 -1
  27. package/dist/node_modules/rc-input/es/BaseInput.cjs +1 -1
  28. package/dist/node_modules/rc-input/es/BaseInput.es.js +1 -1
  29. package/dist/node_modules/rc-textarea/es/ResizableTextArea.cjs +1 -1
  30. package/dist/node_modules/rc-textarea/es/ResizableTextArea.es.js +1 -1
  31. package/dist/node_modules/rc-textarea/es/TextArea.cjs +1 -1
  32. package/dist/node_modules/rc-textarea/es/TextArea.es.js +1 -1
  33. package/dist/node_modules/rc-textarea/es/index.cjs +1 -1
  34. package/dist/node_modules/rc-textarea/es/index.es.js +1 -1
  35. package/dist/node_modules/remark-flow/dist/interaction-plugin-core.cjs +1 -1
  36. package/dist/node_modules/remark-flow/dist/interaction-plugin-core.es.js +1 -1
  37. package/package.json +1 -1
@@ -2,183 +2,183 @@ import { decodeString as j } from "../../../node_modules/micromark-util-decode-s
2
2
  import { getMarkdownSourceAnalysis as U } from "./inline-code-ranges.es.js";
3
3
  import { normalizeInlineHtml as K } from "./normalize-inline-html.es.js";
4
4
  import { readHtmlMarkup as L, findStreamingHtmlElementEnd as q, isHtmlRawTextTag as D } from "./html-block-end.es.js";
5
- const F = "contentRenderVisibility", E = (e, a) => {
6
- let i = 0, n = e.length;
7
- for (; i < n; ) {
8
- const c = i + n >>> 1;
9
- e[c] < a ? i = c + 1 : n = c;
5
+ const F = "contentRenderVisibility", b = (e, a) => {
6
+ let o = 0, n = e.length;
7
+ for (; o < n; ) {
8
+ const d = o + n >>> 1;
9
+ e[d] < a ? o = d + 1 : n = d;
10
10
  }
11
- return i;
12
- }, W = (e, a) => Math.max(0, E(e.offsets, a + 1) - 1), R = (e) => {
13
- const a = e.position?.start?.offset, i = e.position?.end?.offset;
14
- return a === void 0 || i === void 0 ? void 0 : { start: a, end: i };
11
+ return o;
12
+ }, N = (e, a) => Math.max(0, b(e.offsets, a + 1) - 1), R = (e) => {
13
+ const a = e.position?.start?.offset, o = e.position?.end?.offset;
14
+ return a === void 0 || o === void 0 ? void 0 : { start: a, end: o };
15
15
  }, nt = (e) => e.data?.[F], G = (e, a) => {
16
- let i = 0, n = 0;
17
- for (; i < e.length; ) {
18
- const c = e.indexOf("<", i);
19
- if (c === -1) break;
20
- for (; a[n]?.end <= c; ) n += 1;
21
- if (a[n]?.start <= c) {
22
- i = a[n].end;
16
+ let o = 0, n = 0;
17
+ for (; o < e.length; ) {
18
+ const d = e.indexOf("<", o);
19
+ if (d === -1) break;
20
+ for (; a[n]?.end <= d; ) n += 1;
21
+ if (a[n]?.start <= d) {
22
+ o = a[n].end;
23
23
  continue;
24
24
  }
25
- let l = 0;
26
- for (let o = c - 1; o >= 0 && e[o] === "\\"; o -= 1)
27
- l += 1;
28
- if (l % 2) {
29
- i = c + 1;
25
+ let p = 0;
26
+ for (let u = d - 1; u >= 0 && e[u] === "\\"; u -= 1)
27
+ p += 1;
28
+ if (p % 2) {
29
+ o = d + 1;
30
30
  continue;
31
31
  }
32
- const u = L(e, c);
33
- if (u.kind === "incomplete")
34
- return /^<svg(?=[\s/>]|$)/i.test(e.slice(c)) ? { start: c, end: e.length } : void 0;
35
- i = u.kind === "tag" && !u.closing && !u.selfClosing && D(u.name) ? q(e, c) : u.kind === "invalid" ? c + 1 : u.end;
32
+ const i = L(e, d);
33
+ if (i.kind === "incomplete")
34
+ return /^<svg(?=[\s/>]|$)/i.test(e.slice(d)) ? { start: d, end: e.length } : void 0;
35
+ o = i.kind === "tag" && !i.closing && !i.selfClosing && D(i.name) ? q(e, d) : i.kind === "invalid" ? d + 1 : i.end;
36
36
  }
37
37
  }, J = (e, a) => {
38
38
  if (e === a) return;
39
- const i = [];
39
+ const o = [];
40
40
  let n = 0;
41
- for (let c = 0; c < a.length; c += 1) {
42
- if (n = e.indexOf(a[c], n), n === -1)
41
+ for (let d = 0; d < a.length; d += 1) {
42
+ if (n = e.indexOf(a[d], n), n === -1)
43
43
  throw new Error("HTML normalization changed source characters");
44
- i.push(++n);
44
+ o.push(++n);
45
45
  }
46
- return i;
47
- }, z = (e, a, i = !1) => e.rawEnds ? i ? a === 0 ? 0 : e.rawEnds[a - 1] : a === e.markdownSource.length ? e.fullSource.length : e.rawEnds[a] - 1 : a, H = (e, a) => a && {
46
+ return o;
47
+ }, z = (e, a, o = !1) => e.rawEnds ? o ? a === 0 ? 0 : e.rawEnds[a - 1] : a === e.markdownSource.length ? e.fullSource.length : e.rawEnds[a] - 1 : a, W = (e, a) => a && {
48
48
  start: z(e, a.start),
49
49
  end: z(e, a.end, !0)
50
50
  }, Q = (e, a) => {
51
51
  if (!e.rawEnds) return;
52
- const i = [0], n = /\r\n|\r|\n/g;
53
- let c;
54
- for (; c = n.exec(e.fullSource); )
55
- i.push(c.index + c[0].length);
56
- const l = (o, f) => {
57
- if (o?.offset === void 0) return o;
58
- const d = z(e, o.offset, f), g = E(i, d + 1);
59
- return { line: g, column: d - i[g - 1] + 1, offset: d };
60
- }, u = (o) => {
61
- const f = o === a ? e.sourceTree.position : o.position;
62
- f && (o.position = {
63
- start: l(f.start, !1),
64
- end: l(f.end, !0)
65
- }), "children" in o && o.children.forEach(u);
52
+ const o = [0], n = /\r\n|\r|\n/g;
53
+ let d;
54
+ for (; d = n.exec(e.fullSource); )
55
+ o.push(d.index + d[0].length);
56
+ const p = (u, l) => {
57
+ if (u?.offset === void 0) return u;
58
+ const c = z(e, u.offset, l), f = b(o, c + 1);
59
+ return { line: f, column: c - o[f - 1] + 1, offset: c };
60
+ }, i = (u) => {
61
+ const l = u === a ? e.sourceTree.position : u.position;
62
+ l && (u.position = {
63
+ start: p(l.start, !1),
64
+ end: p(l.end, !0)
65
+ }), "children" in u && u.children.forEach(i);
66
66
  };
67
- u(a);
67
+ i(a);
68
68
  }, rt = (e, a) => {
69
- const i = [];
69
+ const o = [];
70
70
  let n = "";
71
- for (const d of e)
72
- i.push(n.length), n += d.value;
73
- const c = a ?? U(n), l = K(n, c.markdown), u = J(n, l), o = u ? U(l) : c, f = e.flatMap(
74
- (d, g) => d.type === "markdown" && d.immediate ? [
71
+ for (const c of e)
72
+ o.push(n.length), n += c.value;
73
+ const d = a ?? U(n), p = K(n, d.markdown), i = J(n, p), u = i ? U(p) : d, l = e.flatMap(
74
+ (c, f) => c.type === "markdown" && c.immediate ? [
75
75
  {
76
- start: u ? E(u, i[g] + 1) : i[g],
77
- end: u ? E(u, i[g] + d.value.length) + 1 : i[g] + d.value.length
76
+ start: i ? b(i, o[f] + 1) : o[f],
77
+ end: i ? b(i, o[f] + c.value.length) + 1 : o[f] + c.value.length
78
78
  }
79
79
  ] : []
80
80
  );
81
81
  return {
82
82
  fullSource: n,
83
- markdownSource: l,
84
- rawEnds: u,
83
+ markdownSource: p,
84
+ rawEnds: i,
85
85
  segments: e,
86
- offsets: i,
86
+ offsets: o,
87
87
  immediateOffsets: e.flatMap(
88
- (d, g) => d.type === "markdown" && d.immediate && !d.pending ? [i[g]] : []
88
+ (c, f) => c.type === "markdown" && c.immediate && !c.pending ? [o[f]] : []
89
89
  ),
90
- sourceTree: o.tree,
91
- pendingMetadata: o.metadata.filter(
92
- (d) => d.pending && d.end === l.length
90
+ sourceTree: u.tree,
91
+ pendingMetadata: u.metadata.filter(
92
+ (c) => c.pending && c.end === p.length
93
93
  ),
94
94
  incompleteSvg: G(
95
- l,
96
- [...o.literal, ...f].sort(
97
- (d, g) => d.start - g.start
95
+ p,
96
+ [...u.literal, ...l].sort(
97
+ (c, f) => c.start - f.start
98
98
  )
99
99
  ),
100
100
  visibility: /* @__PURE__ */ new WeakMap()
101
101
  };
102
- }, B = (e, a, i = "markdown") => {
103
- const n = [], c = /\\[!-/:-@[-`{-~]|&(?:#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});|\r\n|\r|[\s\S]/gi, l = e.slice(a.start, a.end);
104
- let u;
105
- for (; u = c.exec(l); ) {
106
- const o = u[0], d = (i === "code" || i === "html" && o.startsWith("\\") ? o : j(o)).replace(
102
+ }, B = (e, a, o = "markdown") => {
103
+ const n = [], d = /\\[!-/:-@[-`{-~]|&(?:#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});|\r\n|\r|[\s\S]/gi, p = e.slice(a.start, a.end);
104
+ let i;
105
+ for (; i = d.exec(p); ) {
106
+ const u = i[0], c = (o === "code" || o === "html" && u.startsWith("\\") ? u : j(u)).replace(
107
107
  /\r\n|\r/g,
108
108
  `
109
109
  `
110
110
  );
111
- for (let g = 0; g < d.length; g += 1)
111
+ for (let f = 0; f < c.length; f += 1)
112
112
  n.push({
113
- character: d[g],
114
- end: a.start + u.index + (d === o ? g + 1 : o.length)
113
+ character: c[f],
114
+ end: a.start + i.index + (c === u ? f + 1 : u.length)
115
115
  });
116
116
  }
117
117
  return n;
118
118
  }, X = (e, a) => {
119
- const i = /^`+/.exec(e.slice(a.start, a.end))?.[0] ?? "", n = B(
119
+ const o = /^`+/.exec(e.slice(a.start, a.end))?.[0] ?? "", n = B(
120
120
  e,
121
- { start: a.start + i.length, end: a.end - i.length },
121
+ { start: a.start + o.length, end: a.end - o.length },
122
122
  "code"
123
- ).map((c) => ({
124
- ...c,
125
- character: c.character === `
126
- ` ? " " : c.character
123
+ ).map((d) => ({
124
+ ...d,
125
+ character: d.character === `
126
+ ` ? " " : d.character
127
127
  }));
128
128
  return n.length > a.value.length && n[0]?.character === " " && n.at(-1)?.character === " " ? n.slice(1, -1) : n;
129
129
  }, Y = (e, a) => {
130
- const i = e.slice(a.start, a.end), n = /^(?:`{3,}|~{3,})/.test(i);
131
- let c = a.start + (n ? i.indexOf(`
130
+ const o = e.slice(a.start, a.end), n = /^(?:`{3,}|~{3,})/.test(o);
131
+ let d = a.start + (n ? o.indexOf(`
132
132
  `) + 1 : 0);
133
- const l = [];
134
- for (const u of a.value.split(`
133
+ const p = [];
134
+ for (const i of a.value.split(`
135
135
  `)) {
136
- const o = e.indexOf(`
137
- `, c), f = o === -1 ? a.end : Math.min(o, a.end), d = e[f - 1] === "\r" ? f - 1 : f, g = Math.max(c, d - u.length);
138
- for (let M = 0; M < u.length; M += 1)
139
- l.push({ character: u[M], end: g + M + 1 });
140
- l.push({ character: `
141
- `, end: Math.min(a.end, f + 1) }), c = f + 1;
136
+ const u = e.indexOf(`
137
+ `, d), l = u === -1 ? a.end : Math.min(u, a.end), c = e[l - 1] === "\r" ? l - 1 : l, f = Math.max(d, c - i.length);
138
+ for (let M = 0; M < i.length; M += 1)
139
+ p.push({ character: i[M], end: f + M + 1 });
140
+ p.push({ character: `
141
+ `, end: Math.min(a.end, l + 1) }), d = l + 1;
142
142
  }
143
- return l;
143
+ return p;
144
144
  }, st = (e) => {
145
145
  const a = structuredClone(e.sourceTree);
146
146
  if (e.pendingMetadata.length) {
147
- const f = [0];
147
+ const l = [0];
148
148
  for (let h = 0; h < e.markdownSource.length; h += 1)
149
149
  e.markdownSource[h] === `
150
- ` && f.push(h + 1);
151
- const d = (h) => {
152
- const k = E(f, h + 1);
153
- return { line: k, column: h - f[k - 1] + 1, offset: h };
154
- }, g = e.pendingMetadata.map(({ start: h }) => h), M = (h) => {
150
+ ` && l.push(h + 1);
151
+ const c = (h) => {
152
+ const k = b(l, h + 1);
153
+ return { line: k, column: h - l[k - 1] + 1, offset: h };
154
+ }, f = e.pendingMetadata.map(({ start: h }) => h), M = (h) => {
155
155
  h.children = h.children?.flatMap((k) => {
156
156
  k.children && M(k);
157
157
  const y = R(k);
158
158
  if (k.type !== "html" || !k.value || !y) return [k];
159
159
  let S = Math.max(
160
160
  0,
161
- E(g, y.start + 1) - 1
161
+ b(f, y.start + 1) - 1
162
162
  );
163
163
  for (; e.pendingMetadata[S]?.end <= y.start; ) S += 1;
164
- if (!e.pendingMetadata[S] || g[S] >= y.end)
164
+ if (!e.pendingMetadata[S] || f[S] >= y.end)
165
165
  return [k];
166
- const N = k.value, $ = e.markdownSource.slice(y.start, y.end);
166
+ const I = k.value, $ = e.markdownSource.slice(y.start, y.end);
167
167
  let C;
168
- if ($ !== N) {
168
+ if ($ !== I) {
169
169
  let r = 0;
170
- C = N.split("").map((s) => (r = $.indexOf(s, r), y.start + ++r));
170
+ C = I.split("").map((s) => (r = $.indexOf(s, r), y.start + ++r));
171
171
  }
172
- const A = (r) => C ? E(C, r + 1) : r - y.start, T = [];
172
+ const V = (r) => C ? b(C, r + 1) : r - y.start, T = [];
173
173
  let O = y.start;
174
174
  const t = (r, s) => {
175
175
  if (r <= O) return;
176
- const w = N.slice(A(O), A(r));
176
+ const w = I.slice(V(O), V(r));
177
177
  T.push({
178
178
  ...k,
179
179
  type: s ? "text" : "html",
180
180
  value: s ? j(w) : w,
181
- position: { start: d(O), end: d(r) }
181
+ position: { start: c(O), end: c(r) }
182
182
  }), O = r;
183
183
  };
184
184
  for (; e.pendingMetadata[S]?.start < y.end; ) {
@@ -190,100 +190,100 @@ const F = "contentRenderVisibility", E = (e, a) => {
190
190
  };
191
191
  M(a);
192
192
  }
193
- const i = e.incompleteSvg;
194
- if (!i) return a;
195
- const n = e.markdownSource.slice(0, i.start), c = {
193
+ const o = e.incompleteSvg;
194
+ if (!o) return a;
195
+ const n = e.markdownSource.slice(0, o.start), d = {
196
196
  line: n.split(`
197
197
  `).length,
198
- column: i.start - n.lastIndexOf(`
198
+ column: o.start - n.lastIndexOf(`
199
199
  `),
200
- offset: i.start
201
- }, l = {
200
+ offset: o.start
201
+ }, p = {
202
202
  type: "element",
203
203
  data: { hName: "svg" },
204
204
  children: [],
205
- position: { start: c, end: a.position.end }
205
+ position: { start: d, end: a.position.end }
206
206
  };
207
- let u = !1;
208
- const o = (f) => {
209
- f.children = f.children?.flatMap((d) => {
210
- const g = R(d);
211
- if (!g || g.end <= i.start) return [d];
212
- if (g.start > i.start || u) return [];
213
- if (d.children)
214
- return o(d), [d];
215
- const M = B(e.markdownSource, g);
207
+ let i = !1;
208
+ const u = (l) => {
209
+ l.children = l.children?.flatMap((c) => {
210
+ const f = R(c);
211
+ if (!f || f.end <= o.start) return [c];
212
+ if (f.start > o.start || i) return [];
213
+ if (c.children)
214
+ return u(c), [c];
215
+ const M = B(e.markdownSource, f);
216
216
  let h = 0, k = 0;
217
- for (const S of (d.value ?? "").split("")) {
217
+ for (const S of (c.value ?? "").split("")) {
218
218
  for (; M[h] && M[h].character !== S; )
219
219
  h += 1;
220
- if (!M[h] || M[h].end > i.start) break;
220
+ if (!M[h] || M[h].end > o.start) break;
221
221
  h += 1, k += 1;
222
222
  }
223
223
  const y = k ? [
224
224
  {
225
- ...d,
226
- value: d.value.slice(0, k),
227
- position: { start: d.position.start, end: c }
225
+ ...c,
226
+ value: c.value.slice(0, k),
227
+ position: { start: c.position.start, end: d }
228
228
  }
229
229
  ] : [];
230
- return u = !0, [...y, l];
230
+ return i = !0, [...y, p];
231
231
  });
232
232
  };
233
- return o(a), a;
234
- }, at = (e, a, i = (n) => n) => {
233
+ return u(a), a;
234
+ }, at = (e, a, o = (n) => n) => {
235
235
  const n = {
236
236
  ...e,
237
237
  visibility: /* @__PURE__ */ new WeakMap()
238
238
  };
239
239
  Q(n, a);
240
- const c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Set(), o = (t) => {
241
- const r = H(n, R(t));
242
- if (r && t.type !== "root" && "children" in t && u.add(`${r.start}:${r.end}`), r && t.type === "listItem" && typeof t.checked == "boolean") {
240
+ const d = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), u = (t) => {
241
+ const r = W(n, R(t));
242
+ if (r && t.type !== "root" && "children" in t && i.add(`${r.start}:${r.end}`), r && t.type === "listItem" && typeof t.checked == "boolean") {
243
243
  const s = R(t), w = n.markdownSource.indexOf("[", s.start), m = n.markdownSource.indexOf("]", w + 1) + 1;
244
244
  if (w >= s.start && m > w && m <= s.end) {
245
- const b = H(n, { start: w, end: m });
246
- l.set(`${r.start}:${r.end}`, b);
247
- const v = t.children[0], p = v && H(n, R(v));
248
- v?.type === "paragraph" && p && l.set(
249
- `${p.start}:${p.end}`,
250
- b
245
+ const E = W(n, { start: w, end: m });
246
+ p.set(`${r.start}:${r.end}`, E);
247
+ const v = t.children[0], g = v && W(n, R(v));
248
+ v?.type === "paragraph" && g && p.set(
249
+ `${g.start}:${g.end}`,
250
+ E
251
251
  );
252
252
  }
253
253
  }
254
- if (r && "value" in t && typeof t.value == "string" && c.set(`${r.start}:${r.end}`, {
254
+ if (r && "value" in t && typeof t.value == "string" && d.set(`${r.start}:${r.end}`, {
255
255
  ...r,
256
256
  value: t.value,
257
257
  type: t.type
258
258
  }), "children" in t)
259
259
  for (const s of t.children)
260
- o(s);
260
+ u(s);
261
261
  };
262
- o(n.sourceTree);
263
- const f = (t) => {
262
+ u(n.sourceTree);
263
+ const l = (t) => {
264
264
  const r = t.properties.className;
265
265
  return Array.isArray(r) && r.some(
266
266
  (s) => s === "language-math" || s === "math-inline" || s === "math-display"
267
267
  );
268
- }, d = (t, r) => {
268
+ }, c = (t, r) => {
269
269
  t.children = t.children.map((s) => {
270
270
  if (s.type !== "element") return s;
271
271
  const w = R(s) ?? r;
272
- if ((f(s) || s.tagName === "pre" && s.children.some((b) => b.type === "element" && f(b))) && w) {
273
- const b = {
272
+ if ((l(s) || s.tagName === "pre" && s.children.some((E) => E.type === "element" && l(E))) && w) {
273
+ const E = {
274
274
  type: "element",
275
275
  tagName: "span",
276
276
  properties: {},
277
277
  children: [s],
278
278
  position: s.position
279
279
  };
280
- return n.visibility.set(b, { range: w, atomic: !0 }), b;
280
+ return n.visibility.set(E, { range: w, atomic: !0 }), E;
281
281
  }
282
- return d(s, w), s;
282
+ return c(s, w), s;
283
283
  });
284
284
  };
285
- d(a), n.tree = i(a);
286
- const g = /* @__PURE__ */ new WeakMap(), M = (t) => {
285
+ c(a), n.tree = o(a);
286
+ const f = /* @__PURE__ */ new WeakMap(), M = (t) => {
287
287
  const r = R(t);
288
288
  let s;
289
289
  if ("children" in t)
@@ -294,26 +294,26 @@ const F = "contentRenderVisibility", E = (e, a) => {
294
294
  end: Math.max(s.end, m.end)
295
295
  } : m);
296
296
  }
297
- return !r && s && g.set(t, s), r ?? s;
297
+ return !r && s && f.set(t, s), r ?? s;
298
298
  };
299
299
  M(n.tree);
300
300
  const h = (t) => {
301
- const r = E(n.immediateOffsets, t.start);
301
+ const r = b(n.immediateOffsets, t.start);
302
302
  if (n.immediateOffsets[r] < t.end) return !0;
303
303
  const s = n.immediateOffsets[r - 1];
304
304
  if (s === void 0) return !1;
305
- const w = W(n, s);
305
+ const w = N(n, s);
306
306
  return t.start < s + n.segments[w].value.length;
307
307
  }, k = (t) => t.units ??= t.source?.type === "code" ? Y(n.fullSource, t.source) : t.source?.type === "inlineCode" ? X(n.fullSource, t.source) : B(n.fullSource, t.range, t.mode), y = n.pendingMetadata.map(
308
- (t) => H(n, t)
309
- ), S = y.map(({ start: t }) => t), N = (t) => {
310
- const r = y[E(S, t.start + 1) - 1];
308
+ (t) => W(n, t)
309
+ ), S = y.map(({ start: t }) => t), I = (t) => {
310
+ const r = y[b(S, t.start + 1) - 1];
311
311
  return !!(r && t.end <= r.end);
312
- }, $ = [...c.values()].filter(
312
+ }, $ = [...d.values()].filter(
313
313
  ({ type: t }) => t === "html"
314
- ), C = [...c.values()].filter(
314
+ ), C = [...d.values()].filter(
315
315
  ({ type: t }) => t === "flowInteraction"
316
- ), A = C.map(({ start: t }) => t), T = (t) => {
316
+ ), V = C.map(({ start: t }) => t), T = (t) => {
317
317
  let r = 0, s = $.length;
318
318
  for (; r < s; ) {
319
319
  const m = r + s >>> 1;
@@ -327,32 +327,32 @@ const F = "contentRenderVisibility", E = (e, a) => {
327
327
  const v = Math.max(
328
328
  r.rawCursor,
329
329
  r.units?.[r.index - 1]?.end ?? 0
330
- ), p = C[E(A, v)];
331
- p && p.end <= r.range.end && (s = p);
330
+ ), g = C[b(V, v)];
331
+ g && g.end <= r.range.end && (s = g);
332
332
  }
333
- if (!s && t.type === "element" && t.tagName === "input" && t.properties.type === "checkbox" && t.properties.disabled === !0 && r && (s = l.get(
333
+ if (!s && t.type === "element" && t.tagName === "input" && t.properties.type === "checkbox" && t.properties.disabled === !0 && r && (s = p.get(
334
334
  `${r.range.start}:${r.range.end}`
335
335
  )), !s && t.type === "element" && t.tagName === "br" && r) {
336
336
  const v = k(r);
337
- let p = r.index;
338
- for (; p < v.length && (v[p].end <= r.rawCursor || v[p].character !== `
337
+ let g = r.index;
338
+ for (; g < v.length && (v[g].end <= r.rawCursor || v[g].character !== `
339
339
  `); )
340
- p += 1;
341
- const x = v[p]?.end;
342
- x !== void 0 && (r.index = p + 1, s = {
340
+ g += 1;
341
+ const x = v[g]?.end;
342
+ x !== void 0 && (r.index = g + 1, s = {
343
343
  start: x - (n.fullSource.slice(x - 2, x) === `\r
344
344
  ` ? 2 : 1),
345
345
  end: x
346
346
  });
347
347
  }
348
- s ??= g.get(t);
349
- const w = s && c.get(`${s.start}:${s.end}`);
348
+ s ??= f.get(t);
349
+ const w = s && d.get(`${s.start}:${s.end}`);
350
350
  let m = r;
351
- const b = w?.type === "code" || w?.type === "inlineCode";
351
+ const E = w?.type === "code" || w?.type === "inlineCode";
352
352
  if (s && (!r || s.start !== r.range.start || s.end !== r.range.end) && (m = {
353
353
  range: s,
354
354
  source: w,
355
- mode: b ? "code" : N(s) ? "markdown" : T(s) ? "html" : r?.mode ?? "markdown",
355
+ mode: E ? "code" : I(s) ? "markdown" : T(s) ? "html" : r?.mode ?? "markdown",
356
356
  index: 0,
357
357
  rawCursor: s.start
358
358
  }), t.type === "text" && m) {
@@ -360,41 +360,41 @@ const F = "contentRenderVisibility", E = (e, a) => {
360
360
  return;
361
361
  const v = k(m);
362
362
  for (; v[m.index]?.end <= m.rawCursor; ) m.index += 1;
363
- const p = [], x = t.value.split("");
363
+ const g = [], x = t.value.split("");
364
364
  m.breakEnd !== void 0 && x[0] === `
365
- ` && !t.position?.start && (p.push(m.breakEnd), x.shift()), m.breakEnd = void 0;
366
- for (const I of x) {
367
- for (; m.index < v.length && v[m.index].character !== I; )
365
+ ` && !t.position?.start && (g.push(m.breakEnd), x.shift()), m.breakEnd = void 0;
366
+ for (const A of x) {
367
+ for (; m.index < v.length && v[m.index].character !== A; )
368
368
  m.index += 1;
369
- p.push(v[m.index]?.end ?? m.range.end), m.index += 1;
369
+ g.push(v[m.index]?.end ?? m.range.end), m.index += 1;
370
370
  }
371
- n.visibility.set(t, { ends: p });
371
+ n.visibility.set(t, { ends: g });
372
372
  } else if (t.type === "element") {
373
373
  if (n.visibility.get(t)?.atomic) return;
374
- const p = s ?? m?.range;
375
- if (p) {
376
- const I = !(t.tagName === "input" || t.tagName === "a" || t.tagName.startsWith("custom-") || t.tagName === "svg") && (t.children.length > 0 || !t.position && u.has(
377
- `${p.start}:${p.end}`
378
- )), P = W(n, p.start), V = n.segments[P];
374
+ const g = s ?? m?.range;
375
+ if (g) {
376
+ const A = !(t.tagName === "input" || t.tagName === "a" || t.tagName.startsWith("custom-") || t.tagName === "svg") && (t.children.length > 0 || !t.position && i.has(
377
+ `${g.start}:${g.end}`
378
+ )), P = N(n, g.start), H = n.segments[P];
379
379
  n.visibility.set(t, {
380
- range: p,
381
- structural: I,
380
+ range: g,
381
+ structural: A,
382
382
  svg: t.tagName === "svg",
383
383
  immediate: (
384
384
  // Ancestors of immediate HTML keep their stable host elements.
385
385
  // Leaves inside a received HTML span share its budget.
386
- (I || t.children.length > 0) && h(p) || V.type === "markdown" && V.immediate && !V.pending && p.end <= n.offsets[P] + V.value.length
386
+ (A || t.children.length > 0) && h(g) || H.type === "markdown" && H.immediate && !H.pending && g.end <= n.offsets[P] + H.value.length
387
387
  )
388
388
  });
389
389
  }
390
390
  t.tagName === "br" && s && r && !T(s) && (r.breakEnd = s.end);
391
391
  }
392
392
  if ("children" in t) {
393
- for (const p of t.children) O(p, m);
393
+ for (const g of t.children) O(g, m);
394
394
  const v = n.visibility.get(t);
395
395
  if (v?.structural && v.range)
396
- for (const p of t.children) {
397
- const x = n.visibility.get(p)?.range;
396
+ for (const g of t.children) {
397
+ const x = n.visibility.get(g)?.range;
398
398
  x && x.start < v.range.start && (v.range = { ...v.range, start: x.start });
399
399
  }
400
400
  }
@@ -403,54 +403,60 @@ const F = "contentRenderVisibility", E = (e, a) => {
403
403
  return O(n.tree), n;
404
404
  }, it = (e, a) => {
405
405
  if (!e.tree) throw new Error("Video Markdown run has not been prepared");
406
- const i = e.segments.map(
407
- (l, u) => e.offsets[u] + (l.type === "markdown" && l.immediate ? l.pending ? 0 : l.value.length : Math.min(
406
+ const o = e.segments.map(
407
+ (i, u) => e.offsets[u] + (i.type === "markdown" && i.pending ? 0 : Math.min(
408
408
  a[u]?.value.length ?? 0,
409
- l.value.length
409
+ i.value.length
410
410
  ))
411
- ), n = (l) => l <= i[W(e, l - 1)], c = (l, u = !1) => {
412
- const o = e.visibility.get(l);
413
- if (l.type === "text") {
414
- let f = l.value.length;
415
- if (!u && o?.ends)
416
- for (f = 0; f < o.ends.length && n(o.ends[f]); )
417
- f += 1;
418
- return { ...l, value: l.value.slice(0, f) };
411
+ ), n = (i) => i <= o[N(e, i - 1)], d = (i) => {
412
+ const u = b(e.immediateOffsets, i.start), l = e.immediateOffsets[u];
413
+ if (l < i.end && o[N(e, l)] > l)
414
+ return !0;
415
+ const c = e.immediateOffsets[u - 1];
416
+ return c !== void 0 && i.start < o[N(e, c)];
417
+ }, p = (i, u = !1) => {
418
+ const l = e.visibility.get(i);
419
+ if (i.type === "text") {
420
+ let c = i.value.length;
421
+ if (!u && l?.ends)
422
+ for (c = 0; c < l.ends.length && n(l.ends[c]); )
423
+ c += 1;
424
+ return { ...i, value: i.value.slice(0, c) };
419
425
  }
420
- if ("children" in l) {
421
- const f = l.children.map(
422
- (d) => c(d, u || !!o?.atomic)
426
+ if ("children" in i) {
427
+ const c = i.children.map(
428
+ (f) => p(f, u || !!l?.atomic)
423
429
  );
424
- if (l.type === "element") {
425
- const d = {
426
- ...l,
427
- properties: { ...l.properties },
428
- children: f
430
+ if (i.type === "element") {
431
+ const f = {
432
+ ...i,
433
+ properties: { ...i.properties },
434
+ children: c
429
435
  };
430
- if (o?.range) {
431
- const g = !!o.immediate || n(o.structural ? o.range.start + 1 : o.range.end), M = o.svg ? i[W(e, o.range.start)] : o.range.start;
432
- d.data = {
433
- ...l.data,
436
+ if (l?.range) {
437
+ const M = !!l.immediate && d(l.range) || n(l.structural ? l.range.start + 1 : l.range.end), h = l.svg ? o[N(e, l.range.start)] : l.range.start;
438
+ f.data = {
439
+ ...i.data,
434
440
  [F]: {
435
- ...o,
436
- active: g,
437
- svgSource: o.svg ? e.fullSource.slice(
438
- o.range.start,
441
+ ...l,
442
+ active: M,
443
+ svgSource: l.svg ? e.fullSource.slice(
444
+ l.range.start,
439
445
  Math.min(
440
- o.range.end,
441
- Math.max(o.range.start, M)
446
+ l.range.end,
447
+ Math.max(l.range.start, h)
442
448
  )
443
449
  ) : void 0
444
450
  }
445
451
  };
446
452
  }
447
- return d;
453
+ return f;
448
454
  }
449
- return { ...l, children: f };
455
+ return { ...i, children: c };
450
456
  }
451
- return { ...l };
457
+ return { ...i };
452
458
  };
453
- return c(e.tree);
459
+ return p(e.tree);
454
460
  };
455
461
  export {
456
462
  st as cloneVideoMarkdownSourceTree,