@docfuse/markdown 0.1.0

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 (121) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +50 -0
  3. package/README.zh-CN.md +50 -0
  4. package/dist/Markdown-D33gcJbF.js +2116 -0
  5. package/dist/base.css +2 -0
  6. package/dist/client/chunks/client-DIoaSmq2.js +334 -0
  7. package/dist/client/chunks/gallery-BPqV7HsS.js +40 -0
  8. package/dist/client/chunks/image-BGExZy1g.js +36 -0
  9. package/dist/client/chunks/provider-DL6V8F7z.js +841 -0
  10. package/dist/client/chunks/react-runtime-ByABE9MG.js +10571 -0
  11. package/dist/client/chunks/serialized-BvfsNeRQ.js +3464 -0
  12. package/dist/client/chunks/table-DBiKAEbC.js +30 -0
  13. package/dist/client/index.js +4 -0
  14. package/dist/client/nativeBehaviors.d.ts +4 -0
  15. package/dist/client.d.ts +15 -0
  16. package/dist/compiler/analyze.d.ts +27 -0
  17. package/dist/compiler/assets.d.ts +29 -0
  18. package/dist/compiler/ast.d.ts +68 -0
  19. package/dist/compiler/createPipeline.d.ts +18 -0
  20. package/dist/compiler/defaultLabels.d.ts +28 -0
  21. package/dist/compiler/directiveValidation.d.ts +17 -0
  22. package/dist/compiler/highlighter.d.ts +3 -0
  23. package/dist/compiler/mdxModules.d.ts +19 -0
  24. package/dist/compiler/mdxPlugins.d.ts +16 -0
  25. package/dist/compiler/normalizeOptions.d.ts +16 -0
  26. package/dist/compiler/pluginPlan.d.ts +18 -0
  27. package/dist/compiler/plugins/code.d.ts +16 -0
  28. package/dist/compiler/plugins/directives.d.ts +24 -0
  29. package/dist/compiler/plugins/documentBlocks.d.ts +5 -0
  30. package/dist/compiler/plugins/tables.d.ts +5 -0
  31. package/dist/compiler/plugins.d.ts +24 -0
  32. package/dist/compiler/prepareMarkdown.d.ts +11 -0
  33. package/dist/compiler/sanitizeBoundary.d.ts +18 -0
  34. package/dist/compiler/stableJson.d.ts +2 -0
  35. package/dist/compiler/syntaxFeatures.d.ts +10 -0
  36. package/dist/compiler/types.d.ts +177 -0
  37. package/dist/components/blocks/MarkdownCodeBlock.d.ts +10 -0
  38. package/dist/components/blocks/MarkdownCopySnippet.d.ts +10 -0
  39. package/dist/components/blocks/MarkdownHeading.d.ts +13 -0
  40. package/dist/components/blocks/MarkdownImage.d.ts +16 -0
  41. package/dist/components/blocks/MarkdownTable.d.ts +12 -0
  42. package/dist/components/blocks/MarkdownTerminal.d.ts +9 -0
  43. package/dist/components/composite/MarkdownComposite.d.ts +37 -0
  44. package/dist/components/composite/MarkdownFileTree.d.ts +5 -0
  45. package/dist/components/composite/MarkdownTabs.d.ts +6 -0
  46. package/dist/components/gallery/ImageGallery.d.ts +25 -0
  47. package/dist/components/shared/MarkdownActions.d.ts +18 -0
  48. package/dist/components/shared/MarkdownDialog.d.ts +11 -0
  49. package/dist/components/shared/MarkdownFileIcon.d.ts +4 -0
  50. package/dist/components/shared/MarkdownIcon.d.ts +8 -0
  51. package/dist/components/shared/interactionConstants.d.ts +1 -0
  52. package/dist/components/shared/reactText.d.ts +14 -0
  53. package/dist/directiveValidation-BdIao7Yn.js +741 -0
  54. package/dist/file-icons/LICENSE +21 -0
  55. package/dist/file-icons/astro.svg +1 -0
  56. package/dist/file-icons/bun.svg +1 -0
  57. package/dist/file-icons/bun_light.svg +1 -0
  58. package/dist/file-icons/config.svg +1 -0
  59. package/dist/file-icons/console.svg +1 -0
  60. package/dist/file-icons/css.svg +1 -0
  61. package/dist/file-icons/database.svg +1 -0
  62. package/dist/file-icons/deno.svg +1 -0
  63. package/dist/file-icons/deno_light.svg +1 -0
  64. package/dist/file-icons/diff.svg +1 -0
  65. package/dist/file-icons/docker.svg +1 -0
  66. package/dist/file-icons/document.svg +1 -0
  67. package/dist/file-icons/download.svg +1 -0
  68. package/dist/file-icons/environment.svg +1 -0
  69. package/dist/file-icons/excel.svg +1 -0
  70. package/dist/file-icons/git.svg +1 -0
  71. package/dist/file-icons/github-actions.svg +1 -0
  72. package/dist/file-icons/go.svg +1 -0
  73. package/dist/file-icons/javascript.svg +1 -0
  74. package/dist/file-icons/json.svg +1 -0
  75. package/dist/file-icons/markdown.svg +1 -0
  76. package/dist/file-icons/nodejs.svg +1 -0
  77. package/dist/file-icons/npm.svg +1 -0
  78. package/dist/file-icons/pdf.svg +1 -0
  79. package/dist/file-icons/pnpm.svg +1 -0
  80. package/dist/file-icons/pnpm_light.svg +1 -0
  81. package/dist/file-icons/powerpoint.svg +1 -0
  82. package/dist/file-icons/python.svg +1 -0
  83. package/dist/file-icons/react.svg +1 -0
  84. package/dist/file-icons/rust.svg +1 -0
  85. package/dist/file-icons/sass.svg +1 -0
  86. package/dist/file-icons/settings.svg +1 -0
  87. package/dist/file-icons/svelte.svg +1 -0
  88. package/dist/file-icons/typescript.svg +1 -0
  89. package/dist/file-icons/vue.svg +1 -0
  90. package/dist/file-icons/word.svg +1 -0
  91. package/dist/file-icons/yaml.svg +1 -0
  92. package/dist/file-icons/yarn.svg +1 -0
  93. package/dist/index.d.ts +7 -0
  94. package/dist/index.js +6 -0
  95. package/dist/islands/gallery.d.ts +2 -0
  96. package/dist/islands/image.d.ts +2 -0
  97. package/dist/islands/options.d.ts +8 -0
  98. package/dist/islands/provider.d.ts +4 -0
  99. package/dist/islands/serialized.d.ts +4 -0
  100. package/dist/islands/table.d.ts +2 -0
  101. package/dist/islands.d.ts +13 -0
  102. package/dist/plugins-DQ-VUuCT.js +288 -0
  103. package/dist/prepareMarkdown-CHqN2JF5.js +852 -0
  104. package/dist/protocol/serializedNode.d.ts +3 -0
  105. package/dist/react/Markdown.d.ts +54 -0
  106. package/dist/react/componentMap.d.ts +172 -0
  107. package/dist/react/semanticOverrideProps.d.ts +4 -0
  108. package/dist/react/slots.d.ts +39 -0
  109. package/dist/react/urlTransform.d.ts +12 -0
  110. package/dist/server/analyze.d.ts +6 -0
  111. package/dist/server/analyze.js +132 -0
  112. package/dist/server/cache.d.ts +16 -0
  113. package/dist/server/createMarkdownRenderer.d.ts +39 -0
  114. package/dist/server.d.ts +5 -0
  115. package/dist/server.js +137 -0
  116. package/dist/shared/copyText.d.ts +2 -0
  117. package/dist/shared/fileKinds.d.ts +6 -0
  118. package/dist/theme.css +183 -0
  119. package/dist/theme.d.ts +167 -0
  120. package/dist/theme.js +228 -0
  121. package/package.json +110 -0
@@ -0,0 +1,852 @@
1
+ import $ from "remark-parse";
2
+ import I from "remark-rehype";
3
+ import { unified as M } from "unified";
4
+ import j from "rehype-slug";
5
+ import { remarkDefinitionList as z, defListHastHandlers as G } from "remark-definition-list";
6
+ import H from "remark-directive";
7
+ import _ from "remark-gfm";
8
+ import { visit as h, SKIP as v } from "unist-util-visit";
9
+ import { r as O, b as R, e as q, f as U, g as W, h as J, i as K, j as X, k as Z, l as V, n as Y, a as Q } from "./directiveValidation-BdIao7Yn.js";
10
+ import { D as ee, s as te } from "./Markdown-D33gcJbF.js";
11
+ import { n as re, m as ae, s as N, a as ne, b as oe } from "./plugins-DQ-VUuCT.js";
12
+ import ie from "@shikijs/rehype/core";
13
+ import { transformerMetaHighlight as se, transformerNotationHighlight as le, transformerNotationDiff as ce, transformerNotationFocus as pe, transformerNotationWordHighlight as me, transformerNotationErrorLevel as ue } from "@shikijs/transformers";
14
+ import { createHighlighterCore as fe } from "shiki/core";
15
+ import { createJavaScriptRegexEngine as de } from "shiki/engine/javascript";
16
+ import { bundledThemes as ge } from "shiki/themes";
17
+ const he = "vscode://schemas/color-theme", ye = "docfuse-dark", ke = "Docfuse Dark", be = "dark", ve = !0, we = { "editor.background": "#020610", "editor.foreground": "#E6EBF2" }, De = [{ scope: ["comment", "punctuation.definition.comment", "string.comment"], settings: { foreground: "#91A0B2", fontStyle: "italic" } }, { scope: ["keyword", "storage", "storage.type", "storage.modifier", "keyword.control", "keyword.other"], settings: { foreground: "#C6B5FF" } }, { scope: ["string", "string.quoted", "punctuation.definition.string"], settings: { foreground: "#9FD3A7" } }, { scope: ["constant.numeric", "constant.language.boolean", "constant.language.null", "constant.language.undefined"], settings: { foreground: "#F3D18A" } }, { scope: ["entity.name.function", "support.function", "variable.function", "meta.function-call"], settings: { foreground: "#9EC7F3" } }, { scope: ["entity.name.type", "entity.name.class", "support.type", "support.class", "entity.other.inherited-class"], settings: { foreground: "#8ED1CC" } }, { scope: ["variable", "variable.other", "variable.parameter", "meta.definition.variable.name"], settings: { foreground: "#E6EBF2" } }, { scope: ["variable.other.property", "support.variable.property", "meta.property-name", "meta.object-literal.key"], settings: { foreground: "#E3AFD2" } }, { scope: ["entity.name.tag", "meta.tag.sgml", "punctuation.definition.tag"], settings: { foreground: "#F0A89E" } }, { scope: ["entity.other.attribute-name"], settings: { foreground: "#F3D18A" } }, { scope: ["string.regexp", "source.regexp", "constant.other.character-class.regexp"], settings: { foreground: "#F0A89E" } }, { scope: ["keyword.operator", "punctuation", "meta.brace", "meta.delimiter"], settings: { foreground: "#AAB5C3" } }, { scope: ["markup.inserted", "punctuation.definition.inserted"], settings: { foreground: "#9FD3A7" } }, { scope: ["markup.deleted", "punctuation.definition.deleted", "invalid", "message.error"], settings: { foreground: "#F0A89E" } }, { scope: ["markup.heading", "markup.heading entity.name"], settings: { foreground: "#9EC7F3", fontStyle: "bold" } }, { scope: ["markup.bold"], settings: { foreground: "#E6EBF2", fontStyle: "bold" } }, { scope: ["markup.italic"], settings: { foreground: "#E6EBF2", fontStyle: "italic" } }], Le = {
18
+ $schema: he,
19
+ name: ye,
20
+ displayName: ke,
21
+ type: be,
22
+ semanticHighlighting: ve,
23
+ colors: we,
24
+ tokenColors: De
25
+ }, Ce = "vscode://schemas/color-theme", Ne = "docfuse-light", Se = "Docfuse Light", xe = "light", Fe = !0, Be = { "editor.background": "#F0F2F5", "editor.foreground": "#344054" }, Ae = [{ scope: ["comment", "punctuation.definition.comment", "string.comment"], settings: { foreground: "#98A2B3", fontStyle: "italic" } }, { scope: ["keyword", "storage", "storage.type", "storage.modifier", "keyword.control", "keyword.other"], settings: { foreground: "#7C6BC4" } }, { scope: ["string", "string.quoted", "punctuation.definition.string"], settings: { foreground: "#3D9A48" } }, { scope: ["constant.numeric", "constant.language.boolean", "constant.language.null", "constant.language.undefined"], settings: { foreground: "#C47A2A" } }, { scope: ["entity.name.function", "support.function", "variable.function", "meta.function-call"], settings: { foreground: "#4B8DF5" } }, { scope: ["entity.name.type", "entity.name.class", "support.type", "support.class", "entity.other.inherited-class"], settings: { foreground: "#2E8B8B" } }, { scope: ["variable", "variable.other", "variable.parameter", "meta.definition.variable.name"], settings: { foreground: "#344054" } }, { scope: ["variable.other.property", "support.variable.property", "meta.property-name", "meta.object-literal.key"], settings: { foreground: "#B05A9A" } }, { scope: ["entity.name.tag", "meta.tag.sgml", "punctuation.definition.tag"], settings: { foreground: "#DC5647" } }, { scope: ["entity.other.attribute-name"], settings: { foreground: "#C47A2A" } }, { scope: ["string.regexp", "source.regexp", "constant.other.character-class.regexp"], settings: { foreground: "#DC5647" } }, { scope: ["keyword.operator", "punctuation", "meta.brace", "meta.delimiter"], settings: { foreground: "#667085" } }, { scope: ["markup.inserted", "punctuation.definition.inserted"], settings: { foreground: "#3D9A48" } }, { scope: ["markup.deleted", "punctuation.definition.deleted", "invalid", "message.error"], settings: { foreground: "#DC5647" } }, { scope: ["markup.heading", "markup.heading entity.name"], settings: { foreground: "#4B8DF5", fontStyle: "bold" } }, { scope: ["markup.bold"], settings: { foreground: "#344054", fontStyle: "bold" } }, { scope: ["markup.italic"], settings: { foreground: "#344054", fontStyle: "italic" } }], Te = {
26
+ $schema: Ce,
27
+ name: Ne,
28
+ displayName: Se,
29
+ type: xe,
30
+ semanticHighlighting: Fe,
31
+ colors: Be,
32
+ tokenColors: Ae
33
+ }, S = {
34
+ light: Te,
35
+ dark: Le
36
+ };
37
+ function Pe(t) {
38
+ if (!t) return {};
39
+ const e = Object.entries(t);
40
+ return e.every(
41
+ ([a]) => a.length > 0 && a === a.trim().toLowerCase()
42
+ ) ? t : Object.fromEntries(
43
+ e.map(([a, n]) => [a.trim().toLowerCase(), n]).filter(([a]) => a.length > 0)
44
+ );
45
+ }
46
+ function Ee(t = {}) {
47
+ return {
48
+ htmlPolicy: t.html ?? "strip",
49
+ codeThemes: {
50
+ light: t.code?.themes?.light ?? S.light,
51
+ dark: t.code?.themes?.dark ?? S.dark
52
+ },
53
+ fallbackLanguage: t.code?.fallbackLanguage?.trim().toLowerCase() || "text",
54
+ codeLanguages: Pe(t.code?.languages),
55
+ unknownLanguage: t.code?.unknownLanguage ?? "warn",
56
+ features: {
57
+ callouts: t.features?.callouts !== !1,
58
+ tabs: t.features?.tabs !== !1,
59
+ codeGroups: t.features?.codeGroups !== !1,
60
+ steps: t.features?.steps !== !1,
61
+ terminals: t.features?.terminals !== !1,
62
+ documentBlocks: t.features?.documentBlocks !== !1,
63
+ tables: t.features?.tables ?? t.features?.documentBlocks ?? !0,
64
+ codeBlocks: t.features?.codeBlocks !== !1
65
+ },
66
+ labels: {
67
+ ...ee,
68
+ ...t.labels
69
+ },
70
+ plugins: re(t.plugins)
71
+ };
72
+ }
73
+ function $e(t) {
74
+ return String(t ?? "").replace(/^Markdown/, "").toLowerCase();
75
+ }
76
+ function B(t, e) {
77
+ if (!t || typeof t != "object" || !("properties" in t)) return !1;
78
+ const r = t.properties;
79
+ return r?.dataDfComponent === e || r?.["data-df-component"] === e;
80
+ }
81
+ function Ie(t, e) {
82
+ if (t.type !== "mdxJsxFlowElement" && t.type !== "mdxJsxTextElement") return !1;
83
+ const r = $e(t.name);
84
+ if (r === "terminal")
85
+ return e.markBehavior("terminal-toolbar"), !0;
86
+ if (r === "gallery") e.markBehavior("gallery");
87
+ else if (r === "filetree") e.markBehavior("file-tree");
88
+ else if (r === "table") e.markBehavior("table");
89
+ else if (r === "image") e.markBehavior("image");
90
+ else if (r === "codeblock") e.markBehavior("code-toolbar");
91
+ else if (r === "codegroup" || r === "tabs") e.markBehavior("tabs");
92
+ else return !1;
93
+ return !0;
94
+ }
95
+ const Me = (t) => (e) => {
96
+ h(e, (r) => {
97
+ Ie(r, t);
98
+ });
99
+ }, je = (t) => (e) => {
100
+ h(e, "code", (r) => {
101
+ const a = String(r.lang ?? "").toLowerCase(), n = String(r.meta ?? ""), o = n.match(/(?:title|filename|label)\s*=\s*["']([^"']+)["']|\[([^\]]+)\]/i), l = o?.[1]?.trim() || o?.[2]?.trim(), i = t.features.terminals && a === "terminal";
102
+ !n && !l && !i || (r.data = {
103
+ ...r.data,
104
+ hProperties: {
105
+ ...r.data?.hProperties,
106
+ ...n ? { metastring: n } : {},
107
+ ...l ? { title: l, dataDfFilename: l } : {},
108
+ ...i ? { title: l || t.labels.terminalTitle } : {}
109
+ }
110
+ });
111
+ });
112
+ }, ze = () => (t) => {
113
+ h(t, "element", (e) => {
114
+ if (e.tagName !== "pre") return;
115
+ const r = e.children.find(
116
+ (n) => n.type === "element" && n.tagName === "code"
117
+ ), a = String(
118
+ r?.properties?.dataDfFilename ?? r?.properties?.["data-df-filename"] ?? r?.properties?.title ?? r?.properties?.["data-title"] ?? ""
119
+ ).trim();
120
+ a && (e.properties = { ...e.properties, dataDfFilename: a });
121
+ });
122
+ };
123
+ function A(t, e = {}, r = []) {
124
+ return { type: "element", tagName: t, properties: e, children: r };
125
+ }
126
+ function L(t) {
127
+ return t ? t.type === "text" ? t.value : "children" in t ? t.children.map((e) => L(e)).join("") : "" : "";
128
+ }
129
+ function Ge(t) {
130
+ const e = t?.properties?.className ?? t?.properties?.class;
131
+ return Array.isArray(e) ? e.map(String) : typeof e == "string" ? e.split(/\s+/) : [];
132
+ }
133
+ function T(t) {
134
+ return t ? t.children.filter(
135
+ (e) => e.type === "element" && e.tagName === "span" && Ge(e).includes("line")
136
+ ) : [];
137
+ }
138
+ function He(t, e) {
139
+ const r = T(t);
140
+ return r.length > 0 ? r.map((a) => L(a)).join(`
141
+ `) : L(t ?? e).replace(/\n$/, "");
142
+ }
143
+ function _e(t, e) {
144
+ !t || T(t).length > 0 || (t.children = e.split(`
145
+ `).map((r) => A("span", { className: ["line"] }, r ? [{ type: "text", value: r }] : [])));
146
+ }
147
+ function P(t) {
148
+ const e = t?.properties.className ?? t?.properties.class, a = (Array.isArray(e) ? e : typeof e == "string" ? e.split(/\s+/) : []).find(
149
+ (n) => typeof n == "string" && n.startsWith("language-")
150
+ );
151
+ return typeof a == "string" ? a.slice(9).toLowerCase() : "";
152
+ }
153
+ const Oe = (t, e) => (r) => {
154
+ h(r, "element", (a, n, o) => {
155
+ if (a.tagName !== "pre" || !o || n === void 0 || B(o, "code-block"))
156
+ return;
157
+ const l = a.children.find(
158
+ (s) => s.type === "element" && s.tagName === "code"
159
+ ), i = P(l), c = L(l).replace(/\n$/, "");
160
+ if (e.features.terminals && i === "terminal")
161
+ return t.markBehavior("terminal-toolbar"), o.children[n] = A("div", {
162
+ className: ["df-terminal"],
163
+ dataDfComponent: "terminal",
164
+ dataDfBehavior: "terminal-toolbar",
165
+ dataDfSlot: "root",
166
+ dataDfTitle: String(l?.properties?.title ?? e.labels.terminalTitle),
167
+ dataDfSource: c,
168
+ dataDfCopyLabel: e.labels.copyTerminal,
169
+ dataDfCopyFailureLabel: e.labels.copyFailed
170
+ }), [v, n];
171
+ });
172
+ };
173
+ function D(t, e) {
174
+ return { type: "mdxJsxAttribute", name: t, value: e };
175
+ }
176
+ const Re = (t, e) => (r) => {
177
+ h(r, "code", (a, n, o) => {
178
+ if (!o || n === void 0) return;
179
+ const l = String(a.lang ?? "").toLowerCase(), i = String(a.value ?? ""), s = String(a.meta ?? "").match(/(?:title|label)\s*=\s*["']([^"']+)["']/i);
180
+ if (l === "terminal")
181
+ return e.features.terminals ? (t.markBehavior("terminal-toolbar"), o.children[n] = {
182
+ type: "mdxJsxFlowElement",
183
+ name: "Terminal",
184
+ attributes: [
185
+ D("title", s?.[1]?.trim() || e.labels.terminalTitle),
186
+ D("source", i),
187
+ D("copyLabel", e.labels.copyTerminal),
188
+ D("copyFailureLabel", e.labels.copyFailed)
189
+ ],
190
+ children: []
191
+ }, [v, n]) : void 0;
192
+ });
193
+ }, qe = (t, e, r = /* @__PURE__ */ new Set()) => (a) => {
194
+ h(a, "element", (n, o, l) => {
195
+ if (n.tagName !== "pre" || !l || o === void 0 || B(l, "code-block"))
196
+ return;
197
+ t.markBehavior("code-toolbar"), n.properties = { ...n.properties, dataDfSlot: "content" };
198
+ const i = n.children.find(
199
+ (b) => b.type === "element" && b.tagName === "code"
200
+ ), c = P(i);
201
+ if (c && r.has(c)) return;
202
+ const s = i?.properties?.className ?? i?.properties?.class, u = (Array.isArray(s) ? s : typeof s == "string" ? s.split(/\s+/) : []).find((b) => typeof b == "string" && b.startsWith("language-")), m = u ? u.slice(9) : "text", d = l.type === "element" ? l.properties : void 0, g = String(
203
+ n.properties?.dataDfFilename ?? n.properties?.["data-df-filename"] ?? d?.dataDfFilename ?? d?.["data-df-filename"] ?? i?.properties?.dataDfFilename ?? i?.properties?.["data-df-filename"] ?? i?.properties?.title ?? i?.properties?.["data-title"] ?? ""
204
+ ).trim(), k = He(i, n);
205
+ _e(i, k);
206
+ const f = {
207
+ type: "element",
208
+ tagName: "figure",
209
+ properties: {
210
+ className: ["df-code"],
211
+ dataDfComponent: "code-block",
212
+ dataDfBehavior: "code-toolbar",
213
+ dataDfSlot: "root",
214
+ dataDfLanguage: m,
215
+ ...g ? { dataDfFilename: g } : {},
216
+ dataDfSource: k,
217
+ dataDfCopyLabel: e.copyCode,
218
+ dataDfCopyFailureLabel: e.copyFailed
219
+ },
220
+ children: [n]
221
+ };
222
+ return l.children[o] = f, [v];
223
+ });
224
+ };
225
+ function C(t) {
226
+ if (!t) return "";
227
+ const e = t.properties;
228
+ return String(e.dataDfComponent ?? e["data-df-component"] ?? "");
229
+ }
230
+ const Ue = /* @__PURE__ */ new Map([
231
+ ["pdf", { kind: "pdf", badge: "PDF", label: "PDF document" }],
232
+ ["doc", { kind: "word", badge: "DOC", label: "Microsoft Word" }],
233
+ ["docx", { kind: "word", badge: "DOCX", label: "Microsoft Word" }],
234
+ ["ppt", { kind: "powerpoint", badge: "PPT", label: "Microsoft PowerPoint" }],
235
+ ["pptx", { kind: "powerpoint", badge: "PPTX", label: "Microsoft PowerPoint" }],
236
+ ["xls", { kind: "excel", badge: "XLS", label: "Microsoft Excel" }],
237
+ ["xlsx", { kind: "excel", badge: "XLSX", label: "Microsoft Excel" }]
238
+ ]);
239
+ function We(t) {
240
+ if (typeof t != "string" || !t.trim()) return;
241
+ const e = t.trim(), r = e.match(/^([a-z][a-z\d+.-]*):/i)?.[1]?.toLowerCase();
242
+ if (r && r !== "http" && r !== "https") return;
243
+ let a = (e.split("#")[0] ?? "").split("?")[0] ?? "";
244
+ try {
245
+ (r || e.startsWith("//")) && (a = new URL(e.startsWith("//") ? `https:${e}` : e).pathname);
246
+ } catch {
247
+ return;
248
+ }
249
+ const n = a.split("/").filter(Boolean).at(-1);
250
+ if (!n) return;
251
+ let o = n;
252
+ try {
253
+ o = decodeURIComponent(n);
254
+ } catch {
255
+ }
256
+ const l = o.toLowerCase().match(/\.([a-z\d]+)$/)?.[1], i = l ? Ue.get(l) : void 0;
257
+ return i ? { ...i, filename: o } : void 0;
258
+ }
259
+ function Je(t) {
260
+ const e = t.properties?.className;
261
+ return Array.isArray(e) ? e : typeof e == "string" ? e.split(/\s+/) : [];
262
+ }
263
+ function Ke(t, e, r) {
264
+ const a = t.properties ?? {}, n = C(t);
265
+ if (n === "gallery") {
266
+ e.markBehavior("gallery");
267
+ const o = typeof a.dataDfGalleryLabel == "string" && a.dataDfGalleryLabel.trim() ? a.dataDfGalleryLabel : typeof a["data-df-gallery-label"] == "string" && a["data-df-gallery-label"].trim() ? a["data-df-gallery-label"] : r.imageGallery;
268
+ t.properties = {
269
+ ...a,
270
+ dataDfGalleryLabel: o,
271
+ dataDfCloseLabel: r.closeImageGallery,
272
+ dataDfPreviousLabel: r.previousGalleryImage,
273
+ dataDfNextLabel: r.nextGalleryImage,
274
+ dataDfThumbnailsLabel: r.galleryThumbnails,
275
+ dataDfImageLabel: r.galleryImage
276
+ };
277
+ }
278
+ (n === "tabs" || n === "code-group") && e.markBehavior("tabs"), n === "details" && e.markBehavior("details"), n === "file-tree" && e.markBehavior("file-tree"), n === "code-block" && e.markBehavior("code-toolbar"), n === "copy-snippet" && (e.markBehavior("copy-snippet"), t.properties = {
279
+ ...a,
280
+ dataDfCopyLabel: r.copySnippet,
281
+ dataDfCopyFailureLabel: r.copyFailed
282
+ }), n === "table" && e.markBehavior("table"), n === "image" && e.markBehavior("image"), n === "terminal" && e.markBehavior("terminal-toolbar");
283
+ }
284
+ const Xe = (t, e) => (r) => {
285
+ h(r, "element", (a, n, o) => {
286
+ if (!o || n === void 0) return;
287
+ if (Ke(a, t, e), a.tagName === "input" && a.properties?.type === "checkbox") {
288
+ a.properties.ariaLabel = a.properties.checked ? e.taskCompleted : e.taskIncomplete;
289
+ return;
290
+ }
291
+ if (a.tagName === "section" && a.properties?.dataFootnotes !== void 0) {
292
+ a.properties = { ...a.properties, dataDfElement: "footnotes" };
293
+ return;
294
+ }
295
+ const l = o.type === "element" ? o : void 0;
296
+ if (a.tagName === "figure" && !C(a) && C(l) !== "gallery") {
297
+ const m = a.children.filter((f) => f.type !== "text" || f.value.trim() !== ""), d = m.find(
298
+ (f) => f.type === "element" && f.tagName === "img"
299
+ ), g = m.find(
300
+ (f) => f.type === "element" && f.tagName === "figcaption"
301
+ );
302
+ if (d && m.every(
303
+ (f) => f.type === "element" && (f.tagName === "img" || f.tagName === "figcaption")
304
+ )) {
305
+ const f = Array.isArray(a.properties?.className) ? a.properties.className : typeof a.properties?.className == "string" ? a.properties.className.split(/\s+/) : [];
306
+ t.markBehavior("image"), a.properties = {
307
+ ...a.properties,
308
+ className: [.../* @__PURE__ */ new Set([...f, "df-media-frame"])],
309
+ dataDfComponent: "image",
310
+ dataDfIsland: "image",
311
+ dataDfSlot: "root",
312
+ dataDfZoomLabel: e.zoomImage,
313
+ dataDfCloseLabel: e.closeImagePreview
314
+ }, g && (g.properties = { ...g.properties, dataDfSlot: "caption" });
315
+ return;
316
+ }
317
+ }
318
+ if (a.tagName === "details") {
319
+ t.markBehavior("details"), a.properties = {
320
+ ...a.properties,
321
+ dataDfComponent: "details",
322
+ dataDfBehavior: "details",
323
+ dataDfSlot: "root"
324
+ };
325
+ const m = a.children?.find(
326
+ (d) => d.type === "element" && d.tagName === "summary"
327
+ );
328
+ m && (m.properties = { ...m.properties, dataDfSlot: "summary" });
329
+ return;
330
+ }
331
+ if (/^h[2-6]$/.test(a.tagName) && a.properties?.id) {
332
+ t.markBehavior("heading"), a.properties = {
333
+ ...a.properties,
334
+ dataDfAnchor: `#${a.properties.id}`,
335
+ dataDfAnchorLabel: e.copySectionLink,
336
+ dataDfCopyFailureLabel: e.copyFailed
337
+ };
338
+ return;
339
+ }
340
+ if (a.tagName !== "p") return;
341
+ const i = a.children.filter((m) => m.type !== "text" || m.value.trim() !== ""), c = i[0];
342
+ if (i.length !== 1 || c?.type !== "element") return;
343
+ if (c.tagName === "a") {
344
+ const m = We(c.properties?.href);
345
+ return m ? (o.children[n] = {
346
+ ...c,
347
+ properties: {
348
+ ...c.properties,
349
+ className: [.../* @__PURE__ */ new Set([...Je(c), "df-file-link"])],
350
+ dataDfFileKind: m.kind,
351
+ dataDfElement: "file-link"
352
+ },
353
+ children: [
354
+ {
355
+ type: "element",
356
+ tagName: "span",
357
+ properties: {
358
+ className: ["df-file-icon"],
359
+ dataDfFileIcon: m.kind,
360
+ ariaHidden: "true"
361
+ },
362
+ children: []
363
+ },
364
+ {
365
+ type: "element",
366
+ tagName: "span",
367
+ properties: { className: ["df-file-details"] },
368
+ children: [
369
+ {
370
+ type: "element",
371
+ tagName: "span",
372
+ properties: { className: ["df-file-name"] },
373
+ children: [{ type: "text", value: m.filename }]
374
+ },
375
+ {
376
+ type: "element",
377
+ tagName: "span",
378
+ properties: { className: ["df-file-meta"] },
379
+ children: [{ type: "text", value: `${m.label} · ${m.badge}` }]
380
+ }
381
+ ]
382
+ },
383
+ {
384
+ type: "element",
385
+ tagName: "span",
386
+ properties: { className: ["df-file-download"], ariaHidden: "true" },
387
+ children: []
388
+ }
389
+ ]
390
+ }, [v]) : void 0;
391
+ }
392
+ if (c.tagName !== "img") return;
393
+ const s = c;
394
+ t.markBehavior("image");
395
+ const p = s.properties?.title, u = [s];
396
+ return p && u.push({
397
+ type: "element",
398
+ tagName: "figcaption",
399
+ properties: { dataDfSlot: "caption" },
400
+ children: [{ type: "text", value: String(p) }]
401
+ }), o.children[n] = {
402
+ type: "element",
403
+ tagName: "figure",
404
+ properties: {
405
+ className: ["df-media-frame"],
406
+ dataDfComponent: "image",
407
+ dataDfIsland: "image",
408
+ dataDfSlot: "root",
409
+ dataDfZoomLabel: e.zoomImage,
410
+ dataDfCloseLabel: e.closeImagePreview
411
+ },
412
+ children: u
413
+ }, [v];
414
+ });
415
+ };
416
+ function Ze(t, e) {
417
+ if (!t || typeof t != "object" || !("properties" in t)) return !1;
418
+ const r = t.properties;
419
+ return r?.dataDfComponent === e || r?.["data-df-component"] === e;
420
+ }
421
+ const Ve = (t, e) => (r) => {
422
+ h(r, "element", (a, n, o) => {
423
+ if (a.tagName !== "table" || !o || n === void 0 || Ze(o, "table")) return;
424
+ t.markBehavior("table");
425
+ const l = { ...a, properties: { ...a.properties, dataDfSlot: "table" } }, i = {
426
+ type: "element",
427
+ tagName: "figure",
428
+ properties: {
429
+ className: ["df-table-window"],
430
+ dataDfComponent: "table",
431
+ dataDfIsland: "table",
432
+ dataDfSlot: "root",
433
+ dataDfTableTitle: e.tableTitle,
434
+ dataDfCopyLabel: e.copyTableCsv,
435
+ dataDfCopyFailureLabel: e.copyFailed,
436
+ dataDfDownloadLabel: e.downloadTableCsv,
437
+ dataDfZoomLabel: e.zoomTable,
438
+ dataDfCloseLabel: e.closeTablePreview,
439
+ dataDfSortLabel: e.sortTableColumn,
440
+ // The raw HAST subtree lets the static React island hydrate the
441
+ // same table without reparsing Markdown or reading rendered HTML.
442
+ dataDfTable: te(l)
443
+ },
444
+ children: [l]
445
+ };
446
+ return o.children[n] = i, [v];
447
+ });
448
+ };
449
+ function Ye(t, e, r, a, n) {
450
+ const { features: o } = r, l = new Set(
451
+ r.plugins.flatMap((p) => p.fenceLanguages ?? []).map((p) => p.toLowerCase())
452
+ ), i = [z, _];
453
+ i.push(H), i.push([O, ae(r.plugins)]), (o.tabs || o.codeGroups) && i.push([R, r]), o.steps && i.push([q, r]), o.callouts && i.push(U), o.documentBlocks && i.push(W);
454
+ for (const p of r.plugins)
455
+ p.remarkPlugins && i.push(...p.remarkPlugins);
456
+ t === "mdx" ? (i.push([Me, e]), o.terminals && i.push([Re, e, r])) : (o.terminals || a.highlightedCode) && i.push([je, r]);
457
+ const c = [];
458
+ t === "markdown" && o.terminals && c.push([Oe, e, r]), o.documentBlocks && c.push(J), c.push(j), a.highlightedCode && c.push(ze), a.highlightedCode && n && c.push(n), o.documentBlocks && c.push([Xe, e, r.labels]), o.tables && c.push([Ve, e, r.labels]), o.codeBlocks && c.push([qe, e, r.labels, l]);
459
+ for (const p of r.plugins)
460
+ p.rehypePlugins && c.push(...p.rehypePlugins);
461
+ const s = {
462
+ ...G,
463
+ tabGroup: V,
464
+ tabItem: Z,
465
+ stepGroup: X,
466
+ stepItem: K
467
+ };
468
+ return { remarkPlugins: i, rehypePlugins: c, handlers: s };
469
+ }
470
+ function Qe() {
471
+ return {
472
+ name: "docfuse:fence-metadata",
473
+ pre(t) {
474
+ const r = String(this.options.meta?.__raw ?? "").match(/(?:title|filename|label)\s*=\s*["']([^"']+)["']|\[([^\]]+)\]/i), a = r?.[1]?.trim() || r?.[2]?.trim();
475
+ return a && (t.properties.dataDfFilename = a), t;
476
+ }
477
+ };
478
+ }
479
+ function et() {
480
+ return {
481
+ name: "docfuse:collapse-code-newlines",
482
+ code(t) {
483
+ return t.children = t.children.filter((e) => !(e.type === "text" && /^\n+$/.test(e.value))), t;
484
+ }
485
+ };
486
+ }
487
+ const tt = {
488
+ bash: () => import("@shikijs/langs/bash"),
489
+ c: () => import("@shikijs/langs/c"),
490
+ cpp: () => import("@shikijs/langs/cpp"),
491
+ csharp: () => import("@shikijs/langs/csharp"),
492
+ css: () => import("@shikijs/langs/css"),
493
+ diff: () => import("@shikijs/langs/diff"),
494
+ dockerfile: () => import("@shikijs/langs/dockerfile"),
495
+ dotenv: () => import("@shikijs/langs/dotenv"),
496
+ go: () => import("@shikijs/langs/go"),
497
+ graphql: () => import("@shikijs/langs/graphql"),
498
+ html: () => import("@shikijs/langs/html"),
499
+ java: () => import("@shikijs/langs/java"),
500
+ javascript: () => import("@shikijs/langs/javascript"),
501
+ json: () => import("@shikijs/langs/json"),
502
+ jsonc: () => import("@shikijs/langs/jsonc"),
503
+ jsx: () => import("@shikijs/langs/jsx"),
504
+ markdown: () => import("@shikijs/langs/markdown"),
505
+ mdx: () => import("@shikijs/langs/mdx"),
506
+ nginx: () => import("@shikijs/langs/nginx"),
507
+ php: () => import("@shikijs/langs/php"),
508
+ python: () => import("@shikijs/langs/python"),
509
+ ruby: () => import("@shikijs/langs/ruby"),
510
+ rust: () => import("@shikijs/langs/rust"),
511
+ scss: () => import("@shikijs/langs/scss"),
512
+ sql: () => import("@shikijs/langs/sql"),
513
+ tsx: () => import("@shikijs/langs/tsx"),
514
+ typescript: () => import("@shikijs/langs/typescript"),
515
+ vue: () => import("@shikijs/langs/vue"),
516
+ yaml: () => import("@shikijs/langs/yaml")
517
+ }, rt = {
518
+ bash: "bash",
519
+ c: "c",
520
+ "c++": "cpp",
521
+ cpp: "cpp",
522
+ cs: "csharp",
523
+ csharp: "csharp",
524
+ css: "css",
525
+ diff: "diff",
526
+ docker: "dockerfile",
527
+ dockerfile: "dockerfile",
528
+ dotenv: "dotenv",
529
+ env: "dotenv",
530
+ gql: "graphql",
531
+ go: "go",
532
+ graphql: "graphql",
533
+ htm: "html",
534
+ html: "html",
535
+ java: "java",
536
+ javascript: "javascript",
537
+ js: "javascript",
538
+ json: "json",
539
+ jsonc: "jsonc",
540
+ jsx: "jsx",
541
+ markdown: "markdown",
542
+ md: "markdown",
543
+ mdx: "mdx",
544
+ nginx: "nginx",
545
+ php: "php",
546
+ py: "python",
547
+ python: "python",
548
+ rb: "ruby",
549
+ ruby: "ruby",
550
+ rust: "rust",
551
+ rs: "rust",
552
+ sass: "scss",
553
+ scss: "scss",
554
+ sh: "bash",
555
+ shell: "bash",
556
+ sql: "sql",
557
+ ts: "typescript",
558
+ tsx: "tsx",
559
+ typescript: "typescript",
560
+ vue: "vue",
561
+ yml: "yaml",
562
+ yaml: "yaml",
563
+ zsh: "bash"
564
+ }, at = /* @__PURE__ */ new Set(["ansi", "text", "plaintext", "txt", "plain"]), y = /* @__PURE__ */ new Map(), nt = 8, x = /* @__PURE__ */ new WeakMap();
565
+ let ot = 1;
566
+ function F(t) {
567
+ if (typeof t != "string") return t;
568
+ const e = ge[t];
569
+ if (!e) throw new Error(`Unknown Shiki theme: ${t}`);
570
+ return e;
571
+ }
572
+ function it(t) {
573
+ const e = N(t.codeThemes) ?? `${String(t.codeThemes.light)}\0${String(t.codeThemes.dark)}`;
574
+ if (Object.keys(t.codeLanguages).length === 0) return e;
575
+ const r = N(t.codeLanguages);
576
+ if (r !== void 0) return `${e}\0${r}`;
577
+ const a = t.codeLanguages;
578
+ let n = x.get(a);
579
+ return n === void 0 && (n = ot++, x.set(a, n)), `${e}\0custom:${n}`;
580
+ }
581
+ function st(t, e) {
582
+ for (y.delete(t), y.set(t, e); y.size > nt; ) {
583
+ const r = y.keys().next().value;
584
+ if (r === void 0) break;
585
+ y.delete(r);
586
+ }
587
+ return e;
588
+ }
589
+ function lt(t) {
590
+ const e = it(t), r = y.get(e);
591
+ if (r)
592
+ return y.delete(e), y.set(e, r), r;
593
+ const a = fe({
594
+ themes: [F(t.codeThemes.light), F(t.codeThemes.dark)],
595
+ langs: [],
596
+ engine: de()
597
+ }).then((n) => ({ highlighter: n, loadedInputs: /* @__PURE__ */ new Set(), loadChain: Promise.resolve() })).catch((n) => {
598
+ throw y.get(e) === a && y.delete(e), n;
599
+ });
600
+ return st(e, a);
601
+ }
602
+ async function ct(t, e) {
603
+ const a = await (typeof t == "function" ? t() : t), n = typeof a == "object" && a !== null && "default" in a ? a.default : a, o = (Array.isArray(n) ? n : [n]).map((i) => ({
604
+ ...i,
605
+ aliases: i.aliases ? [...i.aliases] : void 0
606
+ })), l = o.find(
607
+ (i) => i.name === e || i.aliases?.includes(e)
608
+ ) ?? o.at(-1);
609
+ return l && l.name !== e && !l.aliases?.includes(e) && (l.aliases = [...l.aliases ?? [], e]), o;
610
+ }
611
+ function E(t, e) {
612
+ const r = e.codeLanguages[t];
613
+ if (r)
614
+ return {
615
+ key: `custom:${t}`,
616
+ input: () => ct(r, t)
617
+ };
618
+ const a = rt[t];
619
+ if (a)
620
+ return { key: `builtin:${a}`, input: tt[a] };
621
+ }
622
+ function pt(t, e, r) {
623
+ if (!(t.length === 0 || e.unknownLanguage === "plain-text")) {
624
+ if (e.unknownLanguage === "error")
625
+ throw new Error(
626
+ `Unsupported Markdown code language${t.length > 1 ? "s" : ""}: ${t.join(", ")}`
627
+ );
628
+ for (const a of t)
629
+ r.has(a) || (r.add(a), console.warn(
630
+ `[docfuse/markdown] Unsupported code language "${a}"; rendering it as ${e.fallbackLanguage}.`
631
+ ));
632
+ }
633
+ }
634
+ async function mt(t, e, r, a) {
635
+ const o = [.../* @__PURE__ */ new Set([...e, r.fallbackLanguage])].map((s) => s.trim().toLowerCase()).filter((s) => s && !at.has(s)).map((s) => ({ language: s, resolved: E(s, r) })), l = o.filter((s) => !s.resolved).map((s) => s.language);
636
+ pt(l, r, a);
637
+ const i = o.flatMap((s) => !s.resolved || t.loadedInputs.has(s.resolved.key) ? [] : [s.resolved]);
638
+ if (i.length === 0) return;
639
+ const c = t.loadChain.then(async () => {
640
+ for (const s of i)
641
+ t.loadedInputs.has(s.key) || (await t.highlighter.loadLanguage(s.input), t.loadedInputs.add(s.key));
642
+ });
643
+ t.loadChain = c.catch(() => {
644
+ }), await c;
645
+ }
646
+ async function ut(t, e, r = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set()) {
647
+ const n = await lt(e);
648
+ await mt(n, t, e, r);
649
+ const o = E(e.fallbackLanguage, e) ? e.fallbackLanguage : "text";
650
+ return () => {
651
+ const l = ie(n.highlighter, {
652
+ themes: e.codeThemes,
653
+ addLanguageClass: !0,
654
+ fallbackLanguage: o,
655
+ transformers: [
656
+ Qe(),
657
+ et(),
658
+ se(),
659
+ le(),
660
+ ce(),
661
+ pe(),
662
+ me(),
663
+ ue()
664
+ ]
665
+ });
666
+ return async (c, s) => {
667
+ const p = [];
668
+ h(c, "element", (u) => {
669
+ if (u.tagName !== "pre") return;
670
+ const m = u.children.find(
671
+ (f) => f.type === "element" && f.tagName === "code"
672
+ ), d = m?.properties.className;
673
+ if (!m || !Array.isArray(d)) return;
674
+ const g = d.find(
675
+ (f) => typeof f == "string" && f.startsWith("language-")
676
+ );
677
+ if (typeof g != "string") return;
678
+ const k = g.slice(9).toLowerCase();
679
+ a.has(k) && (p.push({ code: m, className: [...d] }), m.properties.className = d.filter((f) => f !== g));
680
+ });
681
+ try {
682
+ const u = await l(c, s, () => {
683
+ });
684
+ if (u instanceof Error) throw u;
685
+ } finally {
686
+ for (const u of p)
687
+ u.code.properties.className = u.className;
688
+ }
689
+ };
690
+ };
691
+ }
692
+ const ft = /* @__PURE__ */ new Set(["text", "plaintext", "txt", "plain"]), dt = /* @__PURE__ */ new Set(["terminal"]);
693
+ function gt(t, e) {
694
+ let r = 0, a = 0;
695
+ for (; r < t.length && a < e; ) {
696
+ if (t[r] === " ") a += 1;
697
+ else if (t[r] === " ") a += 4 - a % 4;
698
+ else break;
699
+ r += 1;
700
+ }
701
+ return a >= e ? t.slice(r) : void 0;
702
+ }
703
+ function ht(t, e) {
704
+ let r = t;
705
+ for (; ; ) {
706
+ const l = r.match(/^ {0,3}>[ \t]?/);
707
+ if (!l) break;
708
+ r = r.slice(l[0].length);
709
+ }
710
+ const a = e.listIndent > 0 ? gt(r, e.listIndent) : void 0, n = a ?? r, o = n.match(/^ {0,3}(?:[-+*]|\d{1,9}[.)])([ \t]+)(.*)$/);
711
+ if (o) {
712
+ const l = o[2] ?? "";
713
+ return e.listIndent = (a === void 0 ? 0 : e.listIndent) + n.length - l.length, l;
714
+ }
715
+ return a !== void 0 || r.trim() === "" ? n : (e.listIndent = 0, r);
716
+ }
717
+ function yt(t) {
718
+ const e = t.match(/^ {0,3}(`{3,}|~{3,})(.*)$/);
719
+ if (!e?.[1]) return;
720
+ const r = e[1][0], a = e[2]?.trim() ?? "";
721
+ if (!(r === "`" && a.includes("`")))
722
+ return {
723
+ marker: r,
724
+ size: e[1].length,
725
+ language: a.split(/\s+/, 1)[0]?.toLowerCase() || "text"
726
+ };
727
+ }
728
+ function kt(t, e) {
729
+ const r = t.match(/^ {0,3}(`+|~+)[ \t]*$/);
730
+ return r?.[1]?.[0] === e.marker && r[1].length >= e.size;
731
+ }
732
+ function bt(t, e = /* @__PURE__ */ new Set()) {
733
+ if (t === void 0) return { highlightedCode: !0, codeLanguages: [] };
734
+ const r = /* @__PURE__ */ new Set();
735
+ let a;
736
+ const n = { listIndent: 0 };
737
+ for (const l of t.split(/\r?\n/)) {
738
+ const i = ht(l, n);
739
+ if (a) {
740
+ kt(i, a) && (a = void 0);
741
+ continue;
742
+ }
743
+ const c = yt(i);
744
+ if (!c) continue;
745
+ a = c;
746
+ const { language: s } = c;
747
+ !dt.has(s) && !ft.has(s) && !e.has(s) && r.add(s);
748
+ }
749
+ const o = [...r];
750
+ return { highlightedCode: o.length > 0, codeLanguages: o };
751
+ }
752
+ const w = "dataDfCompilerBoundary";
753
+ function vt(t) {
754
+ const e = t.className;
755
+ return Array.isArray(e) ? e.map(String) : typeof e == "string" ? e.split(/\s+/) : [];
756
+ }
757
+ function wt(t) {
758
+ const e = t.properties ?? {};
759
+ return e.id !== void 0 || e.name !== void 0 || Object.keys(e).some((r) => r.startsWith("dataDf")) || vt(e).some((r) => r.startsWith("df-"));
760
+ }
761
+ function Dt(t) {
762
+ const e = `df-${globalThis.crypto.randomUUID()}-`, r = /* @__PURE__ */ new Map();
763
+ let a = 0;
764
+ const n = new RegExp(`^${e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\d+$`), o = {
765
+ ...t,
766
+ attributes: {
767
+ ...t.attributes,
768
+ div: [...t.attributes?.div ?? [], [w, n]]
769
+ }
770
+ };
771
+ return { mark: () => (s) => {
772
+ h(s, "element", (p) => {
773
+ if (!wt(p)) return;
774
+ const u = `${e}${a++}`;
775
+ r.set(u, {
776
+ tagName: p.tagName,
777
+ properties: { ...p.properties }
778
+ }), p.properties = { ...p.properties, [w]: u };
779
+ });
780
+ }, protect: () => (s) => {
781
+ h(s, "element", (p) => {
782
+ const u = p.properties?.[w];
783
+ typeof u != "string" || !r.has(u) || (p.tagName = "div", p.properties = { [w]: u });
784
+ });
785
+ }, restore: () => (s) => {
786
+ h(s, "element", (p) => {
787
+ const u = p.properties?.[w];
788
+ if (typeof u != "string") return;
789
+ const m = r.get(u);
790
+ m && (p.tagName = m.tagName, p.properties = m.properties, r.delete(u));
791
+ });
792
+ }, schema: o };
793
+ }
794
+ function Lt({
795
+ assets: t,
796
+ options: e,
797
+ rehypeRaw: r,
798
+ rehypeSanitize: a,
799
+ sanitizeSchema: n,
800
+ syntax: o,
801
+ syntaxHighlighter: l
802
+ }) {
803
+ const i = e.htmlPolicy !== "strip", c = Ye("markdown", t, e, o, l), s = M().use($).use(c.remarkPlugins).use(I, {
804
+ allowDangerousHtml: i,
805
+ handlers: c.handlers
806
+ });
807
+ if (e.htmlPolicy === "sanitize" && r && a && n) {
808
+ const p = Dt(n);
809
+ s.use(p.mark).use(r).use(p.protect).use(a, p.schema).use(p.restore);
810
+ } else i && r && s.use(r);
811
+ return s.use(c.rehypePlugins);
812
+ }
813
+ async function Ct(t, e, r = { warnedLanguages: /* @__PURE__ */ new Set() }) {
814
+ const a = Q(), n = Ee(e), o = ne(n.plugins, { source: t, mode: "markdown" }), l = oe(o), i = { ...n, plugins: o }, c = bt(t, l);
815
+ o.forEach((b) => a.markPluginAssets(b));
816
+ const [s, p, u] = await Promise.all([
817
+ i.htmlPolicy !== "strip" ? import("rehype-raw") : void 0,
818
+ i.htmlPolicy === "sanitize" ? import("rehype-sanitize") : void 0,
819
+ c.highlightedCode ? ut(
820
+ c.codeLanguages,
821
+ i,
822
+ r.warnedLanguages,
823
+ l
824
+ ) : void 0
825
+ ]), m = s?.default, d = p?.default, g = Lt({
826
+ assets: a,
827
+ options: i,
828
+ rehypeRaw: m,
829
+ rehypeSanitize: d,
830
+ sanitizeSchema: p?.defaultSchema,
831
+ syntax: c,
832
+ syntaxHighlighter: u
833
+ }), k = g.parse(Y(t));
834
+ return {
835
+ document: await g.run(k, {
836
+ data: { docfuseLocale: e?.locale?.trim() || void 0 }
837
+ }),
838
+ assets: a.snapshot()
839
+ };
840
+ }
841
+ const _t = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
842
+ __proto__: null,
843
+ prepareMarkdown: Ct
844
+ }, Symbol.toStringTag, { value: "Module" }));
845
+ export {
846
+ Ye as a,
847
+ _t as b,
848
+ ut as c,
849
+ bt as d,
850
+ Ee as n,
851
+ Ct as p
852
+ };