@noirmd/previewer 1.2.0 → 2.0.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 (53) hide show
  1. package/dist/NReditor.cjs +851 -895
  2. package/dist/NReditor.cjs.map +1 -1
  3. package/dist/NReditor.d.cts +1 -1
  4. package/dist/NReditor.d.ts +1 -1
  5. package/dist/NReditor.js +852 -896
  6. package/dist/NReditor.js.map +1 -1
  7. package/dist/admonition.css +55 -0
  8. package/dist/{markdown.css → base.css} +96 -126
  9. package/dist/blockquote.css +16 -0
  10. package/dist/button.css +32 -0
  11. package/dist/card.css +143 -0
  12. package/dist/codeblock.css +59 -0
  13. package/dist/core.cjs +9 -1
  14. package/dist/core.cjs.map +1 -1
  15. package/dist/core.js +9 -1
  16. package/dist/core.js.map +1 -1
  17. package/dist/details.css +45 -0
  18. package/dist/editor.css +56 -9
  19. package/dist/fonts/material-icons-round.woff2 +0 -0
  20. package/dist/index.cjs +852 -883
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +41 -70
  23. package/dist/index.d.ts +41 -70
  24. package/dist/index.js +851 -877
  25. package/dist/index.js.map +1 -1
  26. package/dist/list.css +18 -0
  27. package/dist/modal.css +82 -0
  28. package/dist/react.cjs +852 -886
  29. package/dist/react.cjs.map +1 -1
  30. package/dist/react.d.cts +44 -73
  31. package/dist/react.d.ts +44 -73
  32. package/dist/react.js +851 -880
  33. package/dist/react.js.map +1 -1
  34. package/dist/slide.css +21 -0
  35. package/dist/table.css +36 -0
  36. package/dist/toc.css +45 -0
  37. package/dist/vanilla.cjs +42 -28
  38. package/dist/vanilla.cjs.map +1 -1
  39. package/dist/vanilla.css +32 -677
  40. package/dist/vanilla.d.cts +8 -2
  41. package/dist/vanilla.d.ts +8 -2
  42. package/dist/vanilla.js +41 -28
  43. package/dist/vanilla.js.map +1 -1
  44. package/dist/variables.css +53 -0
  45. package/dist/vue.cjs +931 -1121
  46. package/dist/vue.cjs.map +1 -1
  47. package/dist/vue.d.cts +63 -214
  48. package/dist/vue.d.ts +63 -214
  49. package/dist/vue.js +930 -1120
  50. package/dist/vue.js.map +1 -1
  51. package/editor.css +56 -9
  52. package/package.json +5 -10
  53. package/markdown.css +0 -344
package/dist/react.js CHANGED
@@ -1564,7 +1564,7 @@ var require_core = __commonJS({
1564
1564
  });
1565
1565
 
1566
1566
  // react/CustomMarkdownRenderer.tsx
1567
- import React8, { useState as useState3, useEffect as useEffect4, useCallback as useCallback2, useMemo, useId as useId3, useRef as useRef5 } from "react";
1567
+ import { useEffect as useEffect2, useRef as useRef2 } from "react";
1568
1568
 
1569
1569
  // core/utils.ts
1570
1570
  function parseCssString(cssText) {
@@ -1610,9 +1610,6 @@ function extractAttributes(text) {
1610
1610
  return { text: cleanedText, classes: classList.join(" "), id };
1611
1611
  }
1612
1612
  var _scopeCounter = 0;
1613
- function resetScopeCounter() {
1614
- _scopeCounter = 0;
1615
- }
1616
1613
  function generateScopeId() {
1617
1614
  return `scope-${++_scopeCounter}`;
1618
1615
  }
@@ -1660,6 +1657,7 @@ function parseMarkdown(markdown2) {
1660
1657
  if (!markdown2) return [];
1661
1658
  const lines = markdown2.replace(/\r\n/g, "\n").replace(/\r/g, "").split("\n");
1662
1659
  const result = [];
1660
+ const usedIds = /* @__PURE__ */ new Set();
1663
1661
  let i = 0;
1664
1662
  while (i < lines.length) {
1665
1663
  const line = lines[i];
@@ -1669,7 +1667,14 @@ function parseMarkdown(markdown2) {
1669
1667
  const level = match[1].length;
1670
1668
  const rawText = match[2];
1671
1669
  const { text: text2, classes: classes2, id: customId } = extractAttributes(rawText);
1672
- const id2 = customId || generateId(text2.replace(/->|<-/g, ""));
1670
+ const baseId = customId || generateId(text2.replace(/->|<-/g, ""));
1671
+ let id2 = baseId;
1672
+ let n = 1;
1673
+ while (usedIds.has(id2)) {
1674
+ n++;
1675
+ id2 = `${baseId}-${n}`;
1676
+ }
1677
+ usedIds.add(id2);
1673
1678
  result.push({ type: "header", level, text: text2, id: id2, classes: classes2 || void 0 });
1674
1679
  i++;
1675
1680
  continue;
@@ -1984,9 +1989,6 @@ function splitSlots(rawContent) {
1984
1989
  return slots;
1985
1990
  }
1986
1991
 
1987
- // react/ui-components.tsx
1988
- import { useState, useRef } from "react";
1989
-
1990
1992
  // node_modules/highlight.js/es/core.js
1991
1993
  var import_core = __toESM(require_core(), 1);
1992
1994
  var core_default = import_core.default;
@@ -10883,7 +10885,7 @@ function shell(hljs) {
10883
10885
  };
10884
10886
  }
10885
10887
 
10886
- // react/highlightSetup.ts
10888
+ // vanilla/highlightSetup.ts
10887
10889
  core_default.registerLanguage("javascript", javascript);
10888
10890
  core_default.registerLanguage("js", javascript);
10889
10891
  core_default.registerLanguage("jsx", javascript);
@@ -10907,729 +10909,922 @@ core_default.registerLanguage("java", java);
10907
10909
  core_default.registerLanguage("csharp", csharp);
10908
10910
  core_default.registerLanguage("cs", csharp);
10909
10911
  core_default.registerLanguage("cpp", cpp);
10910
- core_default.registerLanguage("c", cpp);
10911
10912
  core_default.registerLanguage("go", go);
10912
10913
  core_default.registerLanguage("rust", rust);
10913
- core_default.registerLanguage("rs", rust);
10914
10914
  core_default.registerLanguage("php", php);
10915
10915
  core_default.registerLanguage("ruby", ruby);
10916
- core_default.registerLanguage("rb", ruby);
10917
10916
  core_default.registerLanguage("swift", swift);
10918
10917
  core_default.registerLanguage("kotlin", kotlin);
10919
- core_default.registerLanguage("kt", kotlin);
10920
10918
  core_default.registerLanguage("dart", dart);
10921
10919
  core_default.registerLanguage("yaml", yaml);
10922
- core_default.registerLanguage("yml", yaml);
10923
10920
  core_default.registerLanguage("toml", ini);
10924
- core_default.registerLanguage("ini", ini);
10925
10921
  core_default.registerLanguage("dockerfile", dockerfile);
10926
- core_default.registerLanguage("docker", dockerfile);
10927
10922
  core_default.registerLanguage("diff", diff);
10928
10923
  core_default.registerLanguage("shell", shell);
10929
10924
  var highlightSetup_default = core_default;
10930
10925
 
10931
- // react/ui-components.tsx
10932
- import { Dialog } from "@base-ui/react/dialog";
10933
- import { jsx, jsxs } from "react/jsx-runtime";
10934
- var IconRenderer = ({ iconName, extraClasses = "" }) => {
10935
- if (!iconName) return null;
10936
- const baseClass = `material-symbols-rounded !text-[1em] leading-none align-top ${extraClasses}`;
10926
+ // vanilla/components.ts
10927
+ function createIcon(iconName, extraClasses) {
10928
+ const span = document.createElement("span");
10929
+ const cls = `nr-icon material-icons-round${extraClasses ? ` ${extraClasses}` : ""}`;
10930
+ span.className = cls;
10931
+ span.setAttribute("aria-hidden", "true");
10937
10932
  const isCodepoint = /^[eE][0-9a-fA-F]{3,4}$/.test(iconName);
10938
10933
  if (isCodepoint) {
10939
- return /* @__PURE__ */ jsx(
10940
- "span",
10941
- {
10942
- className: baseClass,
10943
- dangerouslySetInnerHTML: { __html: `&#x${iconName};` },
10944
- "aria-hidden": "true"
10945
- }
10946
- );
10934
+ span.innerHTML = `&#x${iconName};`;
10935
+ } else {
10936
+ span.textContent = iconName;
10947
10937
  }
10948
- return /* @__PURE__ */ jsx("span", { className: baseClass, "aria-hidden": "true", children: iconName });
10949
- };
10950
- var CodeBlock = ({ code, language, title }) => {
10951
- const [copied, setCopied] = useState(false);
10952
- const timerRef = useRef(null);
10938
+ return span;
10939
+ }
10940
+ function createCodeBlock(code, language, title) {
10941
+ const wrapper = document.createElement("div");
10942
+ wrapper.className = "nr-codeblock";
10953
10943
  const lang = language?.split(/[\s{]/)[0]?.trim() || "";
10954
- let html;
10944
+ if (title) {
10945
+ const header = document.createElement("div");
10946
+ header.className = "nr-codeblock__header";
10947
+ header.appendChild(createIcon("description"));
10948
+ const titleSpan = document.createElement("span");
10949
+ titleSpan.textContent = title;
10950
+ header.appendChild(titleSpan);
10951
+ wrapper.appendChild(header);
10952
+ }
10953
+ const pre = document.createElement("pre");
10954
+ pre.className = "nr-codeblock__pre";
10955
+ const codeEl = document.createElement("code");
10956
+ codeEl.className = `language-${lang || "plaintext"}`;
10955
10957
  try {
10956
10958
  if (lang && highlightSetup_default.getLanguage(lang)) {
10957
- html = highlightSetup_default.highlight(code, { language: lang }).value;
10959
+ codeEl.innerHTML = highlightSetup_default.highlight(code, { language: lang }).value;
10958
10960
  } else {
10959
- html = highlightSetup_default.highlightAuto(code).value;
10961
+ codeEl.innerHTML = highlightSetup_default.highlightAuto(code).value;
10960
10962
  }
10961
10963
  } catch {
10962
- html = "";
10964
+ codeEl.textContent = code;
10963
10965
  }
10964
- const handleCopy = () => {
10966
+ pre.appendChild(codeEl);
10967
+ wrapper.appendChild(pre);
10968
+ const copyBtn = document.createElement("button");
10969
+ copyBtn.className = "nr-codeblock__copy";
10970
+ copyBtn.title = "Copy code";
10971
+ const copyIcon = createIcon("content_copy");
10972
+ copyIcon.style.fontSize = "1rem";
10973
+ copyBtn.appendChild(copyIcon);
10974
+ let timer = null;
10975
+ copyBtn.addEventListener("click", () => {
10965
10976
  navigator.clipboard.writeText(code);
10966
- setCopied(true);
10967
- if (timerRef.current) clearTimeout(timerRef.current);
10968
- timerRef.current = setTimeout(() => setCopied(false), 1800);
10969
- };
10970
- return /* @__PURE__ */ jsxs("div", { className: "not-prose my-4 rounded-2xl border border-border overflow-hidden bg-background-secondary-solid/5", children: [
10971
- title && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-4 py-2 border-b border-border bg-background-secondary-solid/10 text-xs sm:text-sm font-mono text-text-secondary", children: [
10972
- /* @__PURE__ */ jsx("span", { className: "material-symbols-rounded text-base", children: "description" }),
10973
- title
10974
- ] }),
10975
- /* @__PURE__ */ jsx("div", { className: "overflow-auto [&_pre]:m-0 [&_pre]:p-4 [&_pre]:text-xs sm:[&_pre]:text-sm", children: /* @__PURE__ */ jsx("pre", { className: "m-0", children: /* @__PURE__ */ jsx("code", { className: `language-${lang || "plaintext"}`, dangerouslySetInnerHTML: { __html: html } }) }) }),
10976
- /* @__PURE__ */ jsx("button", { className: "absolute top-2 right-2 p-1.5 rounded-lg bg-background-secondary-solid/20 hover:bg-background-secondary-solid/40 transition-colors cursor-pointer border-none text-text-secondary hover:text-text-primary", onClick: handleCopy, title: "Copy code", children: /* @__PURE__ */ jsx("span", { className: "material-symbols-rounded", style: { fontSize: "1rem" }, children: copied ? "check" : "content_copy" }) })
10977
- ] });
10978
- };
10979
- var defaultIcons = {
10977
+ copyIcon.textContent = "check";
10978
+ if (timer) clearTimeout(timer);
10979
+ timer = setTimeout(() => {
10980
+ copyIcon.textContent = "content_copy";
10981
+ }, 1800);
10982
+ });
10983
+ wrapper.appendChild(copyBtn);
10984
+ return wrapper;
10985
+ }
10986
+ var DEFAULT_ADMONITION_ICONS = {
10980
10987
  note: "info",
10981
10988
  info: "lightbulb",
10982
10989
  warning: "warning",
10983
10990
  danger: "report",
10984
- greentext: "subdirectory_play_arrow"
10985
- };
10986
- var typeClasses = {
10987
- note: "border-info/20 bg-info/5 text-info",
10988
- info: "border-info/30 bg-info/10 text-info",
10989
- warning: "border-amber-500/30 bg-amber-500/10 text-amber-500",
10990
- danger: "border-danger/30 bg-danger/10 text-danger",
10991
- greentext: "border-success/30 bg-success/10 text-success"
10991
+ greentext: "subdirectory_arrow_right"
10992
10992
  };
10993
- var Admonition = ({ type, title, icon, className = "", style, children }) => {
10994
- const iconToRender = icon || defaultIcons[type] || "info";
10995
- return /* @__PURE__ */ jsxs(
10996
- "div",
10997
- {
10998
- className: `not-prose rounded-2xl mb-6 border shadow-xs p-4 ${typeClasses[type] || typeClasses.note} ${className}`,
10999
- style,
11000
- children: [
11001
- title && /* @__PURE__ */ jsxs("h5", { className: "font-bold text-base mb-2 m-0 flex items-center gap-2", children: [
11002
- /* @__PURE__ */ jsx(IconRenderer, { iconName: iconToRender, extraClasses: "shrink-0" }),
11003
- /* @__PURE__ */ jsx("span", { children: title })
11004
- ] }),
11005
- /* @__PURE__ */ jsx("div", { className: "text-sm leading-relaxed opacity-90", children })
11006
- ]
11007
- }
11008
- );
11009
- };
11010
- var Details = ({
11011
- title,
11012
- icon,
11013
- defaultOpen = false,
11014
- className = "",
11015
- style,
11016
- children
11017
- }) => {
11018
- const [isOpen, setIsOpen] = useState(defaultOpen);
10993
+ function createAdmonition(type, title, icon) {
10994
+ const el = document.createElement("div");
10995
+ el.className = `nr-admonition nr-admonition--${type || "note"}`;
10996
+ if (title) {
10997
+ const header = document.createElement("h5");
10998
+ header.className = "nr-admonition__title";
10999
+ const iconToRender = icon || DEFAULT_ADMONITION_ICONS[type] || "info";
11000
+ header.appendChild(createIcon(iconToRender, "nr-admonition__icon"));
11001
+ const titleSpan = document.createElement("span");
11002
+ titleSpan.textContent = title;
11003
+ header.appendChild(titleSpan);
11004
+ el.appendChild(header);
11005
+ }
11006
+ const body = document.createElement("div");
11007
+ body.className = "nr-admonition__body";
11008
+ el.appendChild(body);
11009
+ return el;
11010
+ }
11011
+ function createDetails(title, icon, defaultOpen) {
11012
+ const details = document.createElement("details");
11013
+ details.className = "nr-details";
11014
+ if (defaultOpen) details.open = true;
11015
+ const summary = document.createElement("summary");
11016
+ summary.className = "nr-details__summary";
11019
11017
  const iconToRender = icon || "play_arrow";
11020
- return /* @__PURE__ */ jsxs(
11021
- "details",
11022
- {
11023
- className: `not-prose rounded-2xl border border-border mb-4 bg-background-primary/5 ${className}`,
11024
- open: isOpen,
11025
- style,
11026
- children: [
11027
- /* @__PURE__ */ jsxs(
11028
- "summary",
11029
- {
11030
- className: "cursor-pointer p-4 font-bold flex items-center gap-2 list-none [&::-webkit-details-marker]:hidden hover:text-accent-primary transition-colors",
11031
- onClick: (e) => {
11032
- e.preventDefault();
11033
- setIsOpen((prev) => !prev);
11034
- },
11035
- children: [
11036
- /* @__PURE__ */ jsx(
11037
- IconRenderer,
11038
- {
11039
- iconName: iconToRender,
11040
- extraClasses: `transition-transform ${isOpen ? "rotate-90" : ""}`
11041
- }
11042
- ),
11043
- /* @__PURE__ */ jsx("span", { children: title })
11044
- ]
11045
- }
11046
- ),
11047
- isOpen && /* @__PURE__ */ jsx("div", { className: "px-4 pb-4 border-t border-border pt-3 text-sm leading-relaxed opacity-90 overflow-hidden min-w-0", children })
11048
- ]
11049
- }
11050
- );
11051
- };
11052
- var Modal = ({ title, isOpen, onClose, children }) => {
11053
- return /* @__PURE__ */ jsx(Dialog.Root, { open: isOpen, onOpenChange: (open) => {
11054
- if (!open) onClose();
11055
- }, children: /* @__PURE__ */ jsxs(Dialog.Portal, { children: [
11056
- /* @__PURE__ */ jsx(Dialog.Backdrop, { className: "fixed inset-0 z-[9999] bg-black/60" }),
11057
- /* @__PURE__ */ jsx(Dialog.Viewport, { className: "fixed inset-0 z-[9999] flex items-center justify-center p-4", children: /* @__PURE__ */ jsxs(Dialog.Popup, { className: "bg-background-primary border border-border shadow-2xl rounded-3xl w-full max-w-3xl max-h-[85vh] flex flex-col overflow-hidden", children: [
11058
- /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center p-4 border-b border-border bg-background-secondary-solid/20", children: [
11059
- /* @__PURE__ */ jsx(Dialog.Title, { className: "text-lg font-bold !m-0", children: title }),
11060
- /* @__PURE__ */ jsx(Dialog.Close, { className: "w-8 h-8 rounded-full hover:bg-white/10 flex items-center justify-center transition-colors cursor-pointer border-none bg-transparent", children: /* @__PURE__ */ jsx("span", { className: "material-symbols-rounded text-base", children: "close" }) })
11061
- ] }),
11062
- /* @__PURE__ */ jsx("div", { className: "p-6 overflow-auto min-h-0 text-text-primary [&_h1:first-child]:mt-0 [&_h2:first-child]:mt-0 [&_h3:first-child]:mt-0 [&_h4:first-child]:mt-0 [&_h5:first-child]:mt-0 [&_h6:first-child]:mt-0", children })
11063
- ] }) })
11064
- ] }) });
11065
- };
11066
-
11067
- // react/renderers.tsx
11068
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
11069
- function renderInline(text) {
11070
- if (!text) return text;
11071
- const parsePart = (part, key) => {
11072
- let match2;
11073
- if (match2 = part.match(/^\|\[([^\]]+)\]\|$/)) {
11074
- return /* @__PURE__ */ jsx2(IconRenderer, { iconName: match2[1] }, key);
11075
- }
11076
- if (match2 = part.match(/^!~(.+?)~!$/)) {
11077
- const content = match2[1];
11078
- const parts = content.split(";");
11079
- let color = "currentColor";
11080
- let decorationStyle = "solid";
11081
- let type = "underline";
11082
- let textIndex = 0;
11083
- if (parts[textIndex]?.match(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/) || ["red", "blue", "green", "purple", "orange", "yellow", "pink"].includes(parts[textIndex])) {
11084
- color = parts[textIndex++];
11085
- }
11086
- if (["solid", "double", "dotted", "dashed", "wavy"].includes(parts[textIndex])) {
11087
- decorationStyle = parts[textIndex++];
11088
- }
11089
- if (["underline", "line-through", "overline", "both"].includes(parts[textIndex])) {
11090
- type = parts[textIndex] === "both" ? "underline line-through" : parts[textIndex++];
11091
- }
11092
- const innerText = parts.slice(textIndex).join(";");
11093
- return /* @__PURE__ */ jsx2(
11094
- "span",
11095
- {
11096
- style: {
11097
- textDecoration: `${type} ${decorationStyle} ${color}`,
11098
- textDecorationThickness: "auto"
11099
- },
11100
- children: renderInline(innerText)
11101
- },
11102
- key
11103
- );
11104
- }
11105
- if (match2 = part.match(/%([^%\s]+?)%([\s\S]+?)%%/)) {
11106
- return /* @__PURE__ */ jsx2("span", { style: { color: match2[1] }, children: renderInline(match2[2]) }, key);
11107
- }
11108
- if (match2 = part.match(/^!>([^<]+?)<!$/)) {
11109
- return /* @__PURE__ */ jsx2("span", { className: "bg-text-primary text-bg-primary px-1 rounded hover:bg-transparent transition-colors cursor-pointer", children: renderInline(match2[1]) }, key);
11110
- }
11111
- if (match2 = part.match(/^==(.+?)==$/)) {
11112
- return /* @__PURE__ */ jsx2("mark", { className: "bg-yellow-500/20 text-inherit px-0.5 rounded", children: renderInline(match2[1]) }, key);
11113
- }
11114
- if (match2 = part.match(/^\*\*\*(.+?)\*\*\*$/)) {
11115
- return /* @__PURE__ */ jsx2("strong", { children: /* @__PURE__ */ jsx2("em", { children: renderInline(match2[1]) }) }, key);
11116
- }
11117
- if (match2 = part.match(/^\*\*(.+?)\*\*$/)) {
11118
- return /* @__PURE__ */ jsx2("strong", { children: renderInline(match2[1]) }, key);
11119
- }
11120
- if (match2 = part.match(/^_(.+?)_$/)) {
11121
- return /* @__PURE__ */ jsx2("em", { children: renderInline(match2[1]) }, key);
11122
- }
11123
- if (match2 = part.match(/^~~(.+?)~~$/)) {
11124
- return /* @__PURE__ */ jsx2("del", { children: renderInline(match2[1]) }, key);
11125
- }
11126
- if (match2 = part.match(/^`([^`]+)`$/)) {
11127
- return /* @__PURE__ */ jsx2("code", { className: "text-[0.875em] font-mono bg-background-secondary/50 px-1.5 py-0.5 rounded text-text-primary", children: match2[1] }, key);
11128
- }
11129
- if (match2 = part.match(/^\[([^\]]+?)\]\(([^)]+?)\)$/)) {
11130
- return /* @__PURE__ */ jsx2(
11131
- "a",
11132
- {
11133
- href: match2[2],
11134
- className: "text-accent-primary underline decoration-accent-primary/40 hover:decoration-accent-primary transition-colors",
11135
- target: "_blank",
11136
- rel: "noopener noreferrer",
11137
- children: renderInline(match2[1])
11138
- },
11139
- key
11140
- );
11141
- }
11142
- if (part.startsWith("<") && part.endsWith(">")) {
11143
- return /* @__PURE__ */ jsx2("span", { dangerouslySetInnerHTML: { __html: part } }, key);
11144
- }
11145
- return part;
11146
- };
11147
- const regex = /(\|\[[^\]]+\]\||\*\*\*.+?\*\*\*|\*\*.+?\*\*|_.+?_|~~.+?~~|`[^`]+?`|!~.+?~!|%[^%\s]+?%[\s\S]+?%%|!>.+?<!|==.+?==|\[[^\]]+?\]\([^)]+?\)|<[^>]+>)/g;
11148
- const elements = [];
11149
- let lastIndex = 0;
11150
- let match;
11151
- let keyCounter = 0;
11152
- while ((match = regex.exec(text)) !== null) {
11153
- if (match.index > lastIndex) {
11154
- elements.push(text.slice(lastIndex, match.index));
11018
+ const iconEl = createIcon(iconToRender, "nr-details__icon");
11019
+ summary.appendChild(iconEl);
11020
+ const titleSpan = document.createElement("span");
11021
+ titleSpan.textContent = title || "Details";
11022
+ summary.appendChild(titleSpan);
11023
+ details.addEventListener("toggle", () => {
11024
+ iconEl.classList.toggle("nr-details__icon--open", details.open);
11025
+ });
11026
+ details.appendChild(summary);
11027
+ const body = document.createElement("div");
11028
+ body.className = "nr-details__body";
11029
+ details.appendChild(body);
11030
+ return details;
11031
+ }
11032
+ function createModal(title) {
11033
+ const dialog = document.createElement("dialog");
11034
+ dialog.className = "nr-modal";
11035
+ dialog.addEventListener("click", (e) => {
11036
+ if (e.target === dialog) {
11037
+ dialog.close();
11155
11038
  }
11156
- elements.push(parsePart(match[0], `inline-${keyCounter++}`));
11157
- lastIndex = regex.lastIndex;
11158
- }
11159
- if (lastIndex < text.length) {
11160
- elements.push(text.slice(lastIndex));
11161
- }
11162
- return elements;
11039
+ });
11040
+ const popup = document.createElement("div");
11041
+ popup.className = "nr-modal__popup";
11042
+ const header = document.createElement("div");
11043
+ header.className = "nr-modal__header";
11044
+ const titleEl = document.createElement("h2");
11045
+ titleEl.className = "nr-modal__title";
11046
+ titleEl.textContent = title;
11047
+ header.appendChild(titleEl);
11048
+ const closeBtn = document.createElement("button");
11049
+ closeBtn.className = "nr-modal__close";
11050
+ closeBtn.appendChild(createIcon("close"));
11051
+ closeBtn.addEventListener("click", () => dialog.close());
11052
+ header.appendChild(closeBtn);
11053
+ popup.appendChild(header);
11054
+ const body = document.createElement("div");
11055
+ body.className = "nr-modal__body";
11056
+ popup.appendChild(body);
11057
+ dialog.appendChild(popup);
11058
+ return dialog;
11163
11059
  }
11164
- function renderTable(content) {
11060
+ function createTable(content, renderInline2) {
11165
11061
  const rows = content.split("\n").filter((r) => r.trim());
11166
- if (rows.length < 2) return /* @__PURE__ */ jsx2("p", { children: content });
11062
+ if (rows.length < 2) {
11063
+ const p = document.createElement("p");
11064
+ p.textContent = content;
11065
+ return p;
11066
+ }
11167
11067
  const parseRow = (row) => row.split("|").map((c) => c.trim()).filter(Boolean);
11168
11068
  const headerCells = parseRow(rows[0]);
11169
11069
  const bodyRows = rows.slice(2).map(parseRow);
11170
- return /* @__PURE__ */ jsx2("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxs2("table", { className: "w-full text-sm sm:text-base border-collapse my-4", children: [
11171
- /* @__PURE__ */ jsx2("thead", { children: /* @__PURE__ */ jsx2("tr", { children: headerCells.map((cell, ci) => /* @__PURE__ */ jsx2("th", { className: "border border-border px-3 py-2 bg-background-secondary-solid/10 text-left font-bold", children: renderInline(cell) }, ci)) }) }),
11172
- /* @__PURE__ */ jsx2("tbody", { children: bodyRows.map((cells, ri) => /* @__PURE__ */ jsx2("tr", { children: cells.map((cell, ci) => /* @__PURE__ */ jsx2("td", { className: "border border-border px-3 py-2", children: renderInline(cell) }, ci)) }, ri)) })
11173
- ] }) });
11070
+ const wrapper = document.createElement("div");
11071
+ wrapper.className = "nr-table-wrap";
11072
+ const table = document.createElement("table");
11073
+ table.className = "nr-table";
11074
+ const thead = document.createElement("thead");
11075
+ const tr = document.createElement("tr");
11076
+ for (const cell of headerCells) {
11077
+ const th = document.createElement("th");
11078
+ th.className = "nr-table__th";
11079
+ th.appendChild(renderInline2(cell));
11080
+ tr.appendChild(th);
11081
+ }
11082
+ thead.appendChild(tr);
11083
+ table.appendChild(thead);
11084
+ const tbody = document.createElement("tbody");
11085
+ for (const cells of bodyRows) {
11086
+ const tr2 = document.createElement("tr");
11087
+ for (const cell of cells) {
11088
+ const td = document.createElement("td");
11089
+ td.className = "nr-table__td";
11090
+ td.appendChild(renderInline2(cell));
11091
+ tr2.appendChild(td);
11092
+ }
11093
+ tbody.appendChild(tr2);
11094
+ }
11095
+ table.appendChild(tbody);
11096
+ wrapper.appendChild(table);
11097
+ return wrapper;
11174
11098
  }
11175
- function renderList(content) {
11099
+ function createList(content, renderInline2) {
11176
11100
  const lines = content.split("\n");
11177
11101
  const items = [];
11178
11102
  for (const line of lines) {
11179
11103
  if (!line.trim()) continue;
11180
11104
  const match = line.match(/^(\s*)([-*+]|\d+\.)\s+(.+)$/);
11181
11105
  if (match) {
11182
- items.push({
11183
- indent: match[1].length,
11184
- marker: match[2],
11185
- text: match[3]
11186
- });
11106
+ items.push({ indent: match[1].length, marker: match[2], text: match[3] });
11187
11107
  }
11188
11108
  }
11189
- if (items.length === 0) return /* @__PURE__ */ jsx2("p", { children: content });
11109
+ if (items.length === 0) {
11110
+ const p = document.createElement("p");
11111
+ p.textContent = content;
11112
+ return p;
11113
+ }
11190
11114
  const isOrdered = /^\d+\.$/.test(items[0].marker);
11191
- const Tag = isOrdered ? "ol" : "ul";
11192
- return /* @__PURE__ */ jsx2(Tag, { className: `${isOrdered ? "list-decimal" : "list-disc"} pl-6 my-3 space-y-1 text-sm sm:text-base`, children: items.map((item, index) => /* @__PURE__ */ jsx2("li", { className: "leading-relaxed", children: renderInline(item.text) }, index)) });
11115
+ const list = document.createElement(isOrdered ? "ol" : "ul");
11116
+ list.className = "nr-list";
11117
+ for (const item of items) {
11118
+ const li = document.createElement("li");
11119
+ li.className = "nr-list__item";
11120
+ li.appendChild(renderInline2(item.text));
11121
+ list.appendChild(li);
11122
+ }
11123
+ return list;
11193
11124
  }
11194
- function extractHeaders(elements) {
11195
- return elements.filter((el) => el.type === "header");
11125
+ function createTOC(headers, renderInline2) {
11126
+ const nav = document.createElement("nav");
11127
+ nav.className = "nr-toc";
11128
+ const title = document.createElement("div");
11129
+ title.className = "nr-toc__title";
11130
+ title.textContent = "Table of Contents";
11131
+ nav.appendChild(title);
11132
+ const ul = document.createElement("ul");
11133
+ ul.className = "nr-toc__list";
11134
+ for (const h of headers) {
11135
+ const li = document.createElement("li");
11136
+ li.className = `nr-toc__item nr-toc__item--h${h.level}`;
11137
+ const a = document.createElement("a");
11138
+ a.className = "nr-toc__link";
11139
+ a.href = `#${h.id}`;
11140
+ a.appendChild(renderInline2(h.text.replace(/->|<-/g, "").trim()));
11141
+ a.addEventListener("click", (e) => {
11142
+ e.preventDefault();
11143
+ const target = document.getElementById(h.id);
11144
+ if (target) target.scrollIntoView({ behavior: "smooth", block: "start" });
11145
+ });
11146
+ li.appendChild(a);
11147
+ ul.appendChild(li);
11148
+ }
11149
+ nav.appendChild(ul);
11150
+ return nav;
11151
+ }
11152
+ function createBlockquote(content, classes, renderInline2) {
11153
+ const el = document.createElement("blockquote");
11154
+ el.className = `nr-blockquote${classes ? ` ${classes}` : ""}`;
11155
+ el.appendChild(renderInline2(content));
11156
+ return el;
11196
11157
  }
11197
11158
 
11198
- // react/directives/AdmonitionDirective.tsx
11199
- import { jsx as jsx3 } from "react/jsx-runtime";
11200
- var AdmonitionDirective = ({
11201
- directiveType,
11202
- props,
11203
- renderSlot
11204
- }) => {
11205
- return /* @__PURE__ */ jsx3(
11206
- Admonition,
11207
- {
11208
- type: directiveType,
11209
- title: props.title,
11210
- icon: props.icon,
11211
- className: props.class,
11212
- style: props.style ? parseCssString(props.style) : void 0,
11213
- children: renderSlot("default")
11159
+ // vanilla/inline.ts
11160
+ function renderInline(text) {
11161
+ const fragment = document.createDocumentFragment();
11162
+ if (!text) return fragment;
11163
+ const regex = /(\|\[[^\]]+\]\||\*\*\*.+?\*\*\*|\*\*.+?\*\*|_.+?_|~~.+?~~|`[^`]+?`|!~.+?~!|%[^%\s]+?%[\s\S]+?%%|!>.+?<!|==.+?==|\[[^\]]+?\]\([^)]+?\)|<[^>]+>)/g;
11164
+ let lastIndex = 0;
11165
+ let match;
11166
+ while ((match = regex.exec(text)) !== null) {
11167
+ if (match.index > lastIndex) {
11168
+ fragment.appendChild(document.createTextNode(text.slice(lastIndex, match.index)));
11214
11169
  }
11215
- );
11216
- };
11217
- var AdmonitionDirective_default = AdmonitionDirective;
11170
+ fragment.appendChild(parseInlinePart(match[0]));
11171
+ lastIndex = regex.lastIndex;
11172
+ }
11173
+ if (lastIndex < text.length) {
11174
+ fragment.appendChild(document.createTextNode(text.slice(lastIndex)));
11175
+ }
11176
+ return fragment;
11177
+ }
11178
+ function parseInlinePart(part) {
11179
+ let match;
11180
+ if (match = part.match(/^\|\[([^\]]+)\]\|$/)) {
11181
+ return createIcon(match[1]);
11182
+ }
11183
+ if (match = part.match(/^!~(.+?)~!$/)) {
11184
+ const content = match[1];
11185
+ const parts = content.split(";");
11186
+ let color = "currentColor";
11187
+ let decorationStyle = "solid";
11188
+ let type = "underline";
11189
+ let textIndex = 0;
11190
+ if (parts[textIndex]?.match(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/) || ["red", "blue", "green", "purple", "orange", "yellow", "pink"].includes(parts[textIndex])) {
11191
+ color = parts[textIndex++];
11192
+ }
11193
+ if (["solid", "double", "dotted", "dashed", "wavy"].includes(parts[textIndex])) {
11194
+ decorationStyle = parts[textIndex++];
11195
+ }
11196
+ if (["underline", "line-through", "overline", "both"].includes(parts[textIndex])) {
11197
+ type = parts[textIndex] === "both" ? "underline line-through" : parts[textIndex++];
11198
+ }
11199
+ const innerText = parts.slice(textIndex).join(";");
11200
+ const span = document.createElement("span");
11201
+ span.className = "nr-underline";
11202
+ span.style.textDecoration = `${type} ${decorationStyle} ${color}`;
11203
+ span.style.textDecorationThickness = "auto";
11204
+ span.appendChild(renderInline(innerText));
11205
+ return span;
11206
+ }
11207
+ if (match = part.match(/%([^%\s]+?)%([\s\S]+?)%%/)) {
11208
+ const span = document.createElement("span");
11209
+ span.style.color = match[1];
11210
+ span.appendChild(renderInline(match[2]));
11211
+ return span;
11212
+ }
11213
+ if (match = part.match(/^!>([^<]+?)<!$/)) {
11214
+ const span = document.createElement("span");
11215
+ span.className = "nr-spoiler";
11216
+ span.appendChild(renderInline(match[1]));
11217
+ return span;
11218
+ }
11219
+ if (match = part.match(/^==(.+?)==$/)) {
11220
+ const mark = document.createElement("mark");
11221
+ mark.className = "nr-highlight";
11222
+ mark.appendChild(renderInline(match[1]));
11223
+ return mark;
11224
+ }
11225
+ if (match = part.match(/^\*\*\*(.+?)\*\*\*$/)) {
11226
+ const strong = document.createElement("strong");
11227
+ const em = document.createElement("em");
11228
+ em.appendChild(renderInline(match[1]));
11229
+ strong.appendChild(em);
11230
+ return strong;
11231
+ }
11232
+ if (match = part.match(/^\*\*(.+?)\*\*$/)) {
11233
+ const strong = document.createElement("strong");
11234
+ strong.appendChild(renderInline(match[1]));
11235
+ return strong;
11236
+ }
11237
+ if (match = part.match(/^_(.+?)_$/)) {
11238
+ const em = document.createElement("em");
11239
+ em.appendChild(renderInline(match[1]));
11240
+ return em;
11241
+ }
11242
+ if (match = part.match(/^~~(.+?)~~$/)) {
11243
+ const del = document.createElement("del");
11244
+ del.appendChild(renderInline(match[1]));
11245
+ return del;
11246
+ }
11247
+ if (match = part.match(/^`([^`]+)`$/)) {
11248
+ const code = document.createElement("code");
11249
+ code.className = "nr-inline-code";
11250
+ code.textContent = match[1];
11251
+ return code;
11252
+ }
11253
+ if (match = part.match(/^\[([^\]]+?)\]\(([^)]+?)\)$/)) {
11254
+ const a = document.createElement("a");
11255
+ a.className = "nr-link";
11256
+ a.href = match[2];
11257
+ a.target = "_blank";
11258
+ a.rel = "noopener noreferrer";
11259
+ a.appendChild(renderInline(match[1]));
11260
+ return a;
11261
+ }
11262
+ if (part.startsWith("<") && part.endsWith(">")) {
11263
+ const span = document.createElement("span");
11264
+ span.innerHTML = part;
11265
+ return span;
11266
+ }
11267
+ return document.createTextNode(part);
11268
+ }
11218
11269
 
11219
- // react/directives/CardDirective.tsx
11220
- import React2, { useId } from "react";
11221
- import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
11222
- var CardDirective = ({
11223
- directiveType,
11224
- props,
11225
- slots,
11226
- renderSlot,
11227
- context,
11228
- options = {}
11229
- }) => {
11230
- const stableId = useId();
11231
- const { title, image, icon, class: customClass, url, target } = props;
11232
- const hasDescription = !!slots.description;
11233
- const { isSingleCard } = options;
11234
- const isModal = directiveType === "card-m";
11235
- const isLink = directiveType === "card-b";
11236
- const modalId = `modal-card-${props.id || stableId}`;
11237
- const wrapperClass = customClass || "";
11238
- const inlineStyles = props.style ? parseCssString(props.style) : {};
11239
- const description = hasDescription ? renderSlot("description") : null;
11240
- const content = renderSlot("content") || renderSlot("default");
11241
- return /* @__PURE__ */ jsxs3(React2.Fragment, { children: [
11242
- /* @__PURE__ */ jsxs3(
11243
- "div",
11244
- {
11245
- className: `flex flex-col h-full rounded-3xl transition-all relative overflow-hidden group border min-w-[18rem] w-[18rem] max-w-[20rem] ${isModal || isLink ? "cursor-pointer !border-accent-primary/10 hover:border-accent-primary/50" : "border-border"} ${wrapperClass}`,
11246
- style: inlineStyles,
11247
- onClick: isModal ? (e) => {
11248
- e.preventDefault();
11249
- e.stopPropagation();
11250
- context.setModals((prev) => ({ ...prev, [modalId]: true }));
11251
- } : isLink && url ? () => window.open(url, "_blank") : void 0,
11252
- role: isModal ? "button" : void 0,
11253
- tabIndex: isModal ? 0 : void 0,
11254
- onKeyDown: isModal ? (e) => {
11255
- if (e.key === "Enter" || e.key === " ") context.setModals((prev) => ({ ...prev, [modalId]: true }));
11256
- } : void 0,
11257
- children: [
11258
- image && /* @__PURE__ */ jsxs3("div", { className: `w-full ${isSingleCard ? "h-[240px]" : "h-[160px]"} overflow-hidden relative transition-all duration-500`, children: [
11259
- /* @__PURE__ */ jsx4("img", { src: image, alt: title || "", className: "w-full h-full object-cover !m-0" }),
11260
- /* @__PURE__ */ jsx4("div", { className: "absolute inset-0 bg-gradient-to-t from-background-primary/40 to-transparent" })
11261
- ] }),
11262
- /* @__PURE__ */ jsxs3("div", { className: `flex flex-col flex-1 bg-background-primary/80 rounded-t-xl p-6 relative ${image ? "-mt-10" : ""} border-t border-white/5 shadow-2xl`, children: [
11263
- /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-3 mb-3", children: [
11264
- icon && /* @__PURE__ */ jsx4("div", { className: "w-10 h-10 text-[1.6em] rounded-xl bg-accent-primary/20 flex items-center justify-center shrink-0 text-accent-primary", children: /* @__PURE__ */ jsx4(IconRenderer, { iconName: icon }) }),
11265
- /* @__PURE__ */ jsx4("h3", { className: "text-base font-black tracking-tight leading-tight !m-0", children: title })
11266
- ] }),
11267
- /* @__PURE__ */ jsxs3("div", { className: "flex-1 flex flex-col gap-2", children: [
11268
- description && /* @__PURE__ */ jsx4("div", { className: "text-sm opacity-80 leading-relaxed font-medium", children: description }),
11269
- directiveType === "card" && content && /* @__PURE__ */ jsx4("div", { className: "mt-2", children: content })
11270
- ] }),
11271
- (isModal || isLink) && /* @__PURE__ */ jsx4("div", { className: "mt-6 flex justify-end", children: isLink && url ? /* @__PURE__ */ jsxs3(
11272
- "a",
11273
- {
11274
- href: url,
11275
- target: "_blank",
11276
- rel: "noopener noreferrer",
11277
- className: "bg-accent-primary/20 hover:bg-accent-primary/30 px-4 py-2 rounded-xl flex items-center gap-1.5 text-[10px] font-black uppercase tracking-widest opacity-50 group-hover:opacity-100 group-hover:text-accent-primary transition-all no-underline",
11278
- onClick: (e) => e.stopPropagation(),
11279
- children: [
11280
- /* @__PURE__ */ jsx4(IconRenderer, { iconName: "open_in_new" }),
11281
- " Link"
11282
- ]
11283
- }
11284
- ) : isModal ? /* @__PURE__ */ jsxs3("div", { className: "bg-accent-primary/20 hover:bg-accent-primary/30 px-4 py-2 cursor-pointer rounded-xl flex items-center gap-1.5 text-[10px] font-black uppercase tracking-widest opacity-50 group-hover:opacity-100 group-hover:text-accent-primary transition-all", children: [
11285
- /* @__PURE__ */ jsx4(IconRenderer, { iconName: "arrow_forward" }),
11286
- " Abrir"
11287
- ] }) : null })
11288
- ] })
11289
- ]
11290
- }
11291
- ),
11292
- isModal && /* @__PURE__ */ jsx4(
11293
- Modal,
11294
- {
11295
- title: title || "Detalles",
11296
- isOpen: !!context.modals[modalId],
11297
- onClose: () => context.setModals((prev) => ({ ...prev, [modalId]: false })),
11298
- children: /* @__PURE__ */ jsx4("div", { className: "prose prose-sm max-w-none", children: content })
11299
- }
11300
- )
11301
- ] });
11270
+ // vanilla/directives/admonition.ts
11271
+ var admonitionDirective = ({ directiveType, props, renderSlot }) => {
11272
+ const el = createAdmonition(directiveType, props.title, props.icon);
11273
+ if (props.class) el.classList.add(...props.class.split(/\s+/).filter(Boolean));
11274
+ if (props.style) el.setAttribute("style", props.style);
11275
+ const body = el.querySelector(".nr-admonition__body");
11276
+ if (body) {
11277
+ body.appendChild(renderSlot("default"));
11278
+ }
11279
+ return el;
11302
11280
  };
11303
- var CardDirective_default = CardDirective;
11281
+ var admonition_default = admonitionDirective;
11304
11282
 
11305
- // react/directives/DetailsDirective.tsx
11306
- import { jsx as jsx5 } from "react/jsx-runtime";
11307
- var DetailsDirective = ({
11308
- props,
11309
- renderSlot
11310
- }) => {
11311
- return /* @__PURE__ */ jsx5(
11312
- Details,
11313
- {
11314
- title: props.title || "Details",
11315
- icon: props.icon,
11316
- defaultOpen: props.defaultOpen === "true",
11317
- className: props.class,
11318
- style: props.style ? parseCssString(props.style) : void 0,
11319
- children: renderSlot("default")
11320
- }
11283
+ // vanilla/directives/details.ts
11284
+ var detailsDirective = ({ props, renderSlot }) => {
11285
+ const el = createDetails(
11286
+ props.title || "Details",
11287
+ props.icon,
11288
+ props.defaultOpen === "true"
11321
11289
  );
11290
+ if (props.class) el.classList.add(...props.class.split(/\s+/).filter(Boolean));
11291
+ if (props.style) el.setAttribute("style", props.style);
11292
+ const body = el.querySelector(".nr-details__body");
11293
+ if (body) {
11294
+ body.appendChild(renderSlot("default"));
11295
+ }
11296
+ return el;
11322
11297
  };
11323
- var DetailsDirective_default = DetailsDirective;
11298
+ var details_default = detailsDirective;
11324
11299
 
11325
- // react/directives/ModalDirective.tsx
11326
- import { useId as useId2 } from "react";
11327
- import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
11328
- var ModalDirective = ({
11329
- props,
11330
- renderSlot,
11331
- context
11332
- }) => {
11333
- const stableId = useId2();
11334
- const modalId = `modal-${props.id || stableId}`;
11300
+ // vanilla/directives/modal.ts
11301
+ var modalDirective = ({ props, renderSlot }) => {
11335
11302
  const label = props.label || props.title || "Open";
11336
11303
  const modalTitle = props.title || "Modal";
11337
11304
  const customClass = props.class || "";
11338
- const hasSizeClass = /\btext-(xs|sm|base|lg|xl|[2-9]xl)\b/.test(customClass);
11339
- const sizeClass = hasSizeClass ? "" : "text-sm";
11340
- const hasDisplayClass = /\b(flex|inline-flex|block|inline-block|grid|inline-grid|hidden)\b/.test(customClass);
11341
- const displayClass = hasDisplayClass ? "" : "inline-flex";
11342
- const isInlineFlex = /\binline-flex\b/.test(customClass);
11343
- const marginClass = isInlineFlex ? "my-1 mx-1" : "my-4";
11344
- const btnBase = `${displayClass} items-center w-fit ${marginClass} ${sizeClass} px-4 py-2 rounded-xl font-bold no-underline gap-2 transition-all hover:scale-105 active:scale-95 border border-border bg-background-primary/5 hover:bg-background-primary/10 text-text-primary hover:text-text-primary`.replace(/\s+/g, " ");
11345
- const btnClass = `${btnBase} ${customClass}`.trim();
11346
- const positionMap = {
11347
- "#left": "text-left",
11348
- "#center": "text-center",
11349
- "#right": "text-right"
11350
- };
11351
- const wrapperClass = customClass.split(/\s+/).map((c) => positionMap[c] || c).join(" ");
11352
- const handleOpen = () => {
11353
- context.setModals((prev) => ({ ...prev, [modalId]: true }));
11354
- };
11355
- const handleClose = () => {
11356
- context.setModals((prev) => ({ ...prev, [modalId]: false }));
11357
- };
11358
- return /* @__PURE__ */ jsxs4("div", { className: `not-prose ${wrapperClass}`.trim(), children: [
11359
- /* @__PURE__ */ jsxs4("button", { className: btnClass, onClick: handleOpen, children: [
11360
- props.icon && /* @__PURE__ */ jsx6(IconRenderer, { iconName: props.icon }),
11361
- label
11362
- ] }),
11363
- /* @__PURE__ */ jsx6(
11364
- Modal,
11365
- {
11366
- title: modalTitle,
11367
- isOpen: !!context.modals[modalId],
11368
- onClose: handleClose,
11369
- children: renderSlot("default")
11370
- }
11371
- )
11372
- ] });
11305
+ const wrapper = document.createElement("div");
11306
+ wrapper.className = "nr-modal-trigger";
11307
+ const btn = document.createElement("button");
11308
+ btn.className = `nr-button nr-button--default`;
11309
+ if (customClass) btn.classList.add(...customClass.split(/\s+/).filter(Boolean));
11310
+ const icon = props.icon || "open_in_new";
11311
+ if (icon) btn.appendChild(createIcon(icon));
11312
+ btn.appendChild(document.createTextNode(label));
11313
+ const dialog = createModal(modalTitle);
11314
+ const body = dialog.querySelector(".nr-modal__body");
11315
+ if (body) {
11316
+ body.appendChild(renderSlot("default"));
11317
+ }
11318
+ btn.addEventListener("click", () => {
11319
+ if (!dialog.open) {
11320
+ document.body.appendChild(dialog);
11321
+ dialog.showModal();
11322
+ dialog.addEventListener("close", () => {
11323
+ dialog.remove();
11324
+ }, { once: true });
11325
+ }
11326
+ });
11327
+ wrapper.appendChild(btn);
11328
+ wrapper.appendChild(dialog);
11329
+ return wrapper;
11373
11330
  };
11374
- var ModalDirective_default = ModalDirective;
11331
+ var modal_default = modalDirective;
11375
11332
 
11376
- // react/directives/ButtonDirective.tsx
11377
- import React4 from "react";
11378
- import { Fragment, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
11379
- var ButtonDirective = ({
11380
- props,
11381
- renderSlot
11382
- }) => {
11333
+ // vanilla/directives/button.ts
11334
+ var buttonDirective = ({ props, renderSlot }) => {
11383
11335
  const url = props.url || props.href || "#";
11384
11336
  const label = props.label;
11385
11337
  const icon = props.icon || "near_me";
11386
11338
  const target = props.target || "_blank";
11387
11339
  const customClass = props.class || "";
11388
- const hasSizeClass = /\btext-(xs|sm|base|lg|xl|[2-9]xl)\b/.test(customClass);
11389
- const sizeClass = hasSizeClass ? "" : "text-sm";
11390
- const hasDisplayClass = /\b(flex|inline-flex|block|inline-block|grid|inline-grid|hidden)\b/.test(customClass);
11391
- const displayClass = hasDisplayClass ? "" : "inline-flex";
11392
- const isInline = !customClass || !/\b(flex|block|grid)\b/.test(customClass) || /\binline-flex\b/.test(customClass);
11393
- const marginClass = isInline ? "my-1 mx-1" : "my-4";
11394
- const btnBase = `${displayClass} items-center w-fit ${marginClass} ${sizeClass} px-4 py-2 rounded-xl font-bold no-underline gap-2 transition-all hover:scale-105 active:scale-95 border border-border bg-background-primary/5 hover:bg-background-primary/10 text-text-primary hover:text-text-primary`.replace(/\s+/g, " ");
11395
- const btnClass = `${btnBase} ${customClass}`.trim();
11396
- const positionMap = {
11397
- "#left": "flex justify-start",
11398
- "#center": "flex justify-center",
11399
- "#right": "flex justify-end"
11400
- };
11401
- const wrapperClass = customClass.split(/\s+/).map((c) => positionMap[c] || c).join(" ");
11340
+ const wrapper = document.createElement("div");
11341
+ wrapper.className = "nr-button-wrap";
11402
11342
  if (label) {
11403
- return /* @__PURE__ */ jsx7("div", { className: `not-prose ${wrapperClass}`.trim(), children: /* @__PURE__ */ jsxs5(
11404
- "a",
11405
- {
11406
- href: url,
11407
- target,
11408
- rel: "noopener noreferrer",
11409
- className: btnClass,
11410
- children: [
11411
- /* @__PURE__ */ jsx7(IconRenderer, { iconName: icon }),
11412
- label
11413
- ]
11414
- }
11415
- ) });
11343
+ const a = document.createElement("a");
11344
+ a.href = url;
11345
+ a.target = target;
11346
+ a.rel = "noopener noreferrer";
11347
+ a.className = "nr-button nr-button--default";
11348
+ if (customClass) a.classList.add(...customClass.split(/\s+/).filter(Boolean));
11349
+ a.appendChild(createIcon(icon));
11350
+ a.appendChild(document.createTextNode(label));
11351
+ wrapper.appendChild(a);
11352
+ return wrapper;
11416
11353
  }
11417
11354
  const slotContent = renderSlot("default");
11418
- const findLinks = (element) => {
11419
- if (!element) return [];
11420
- if (React4.isValidElement(element) && element.type === "a") {
11421
- return [element];
11422
- }
11423
- if (Array.isArray(element)) {
11424
- return element.flatMap(findLinks);
11425
- }
11426
- if (React4.isValidElement(element) && element.props.children) {
11427
- return findLinks(element.props.children);
11428
- }
11429
- return [];
11430
- };
11431
- const links = findLinks(slotContent);
11355
+ const links = slotContent.querySelectorAll("a");
11432
11356
  if (links.length > 0) {
11433
- return /* @__PURE__ */ jsx7("div", { className: `not-prose ${wrapperClass}`.trim(), children: links.map(
11434
- (link, index) => React4.cloneElement(
11435
- link,
11436
- {
11437
- key: index,
11438
- className: `${link.props.className || ""} ${btnClass}`.trim(),
11439
- target,
11440
- rel: "noopener noreferrer"
11441
- },
11442
- /* @__PURE__ */ jsxs5(Fragment, { children: [
11443
- /* @__PURE__ */ jsx7(IconRenderer, { iconName: icon }),
11444
- link.props.children
11445
- ] })
11446
- )
11447
- ) });
11357
+ links.forEach((link) => {
11358
+ link.classList.add("nr-button", "nr-button--default");
11359
+ if (customClass) link.classList.add(...customClass.split(/\s+/).filter(Boolean));
11360
+ });
11361
+ wrapper.appendChild(slotContent);
11362
+ } else {
11363
+ const a = document.createElement("a");
11364
+ a.href = url;
11365
+ a.target = target;
11366
+ a.rel = "noopener noreferrer";
11367
+ a.className = "nr-button nr-button--default";
11368
+ if (customClass) a.classList.add(...customClass.split(/\s+/).filter(Boolean));
11369
+ a.appendChild(createIcon(icon));
11370
+ a.appendChild(slotContent);
11371
+ wrapper.appendChild(a);
11448
11372
  }
11449
- return /* @__PURE__ */ jsx7("div", { className: `not-prose ${wrapperClass}`.trim(), children: /* @__PURE__ */ jsxs5("a", { href: url, target, rel: "noopener noreferrer", className: btnClass, children: [
11450
- /* @__PURE__ */ jsx7(IconRenderer, { iconName: icon }),
11451
- slotContent
11452
- ] }) });
11373
+ return wrapper;
11453
11374
  };
11454
- var ButtonDirective_default = ButtonDirective;
11375
+ var button_default = buttonDirective;
11455
11376
 
11456
- // react/directives/WrapperDirective.tsx
11457
- import { jsx as jsx8 } from "react/jsx-runtime";
11458
- var WrapperDirective = ({
11377
+ // vanilla/directives/card.ts
11378
+ var cardDirective = ({
11379
+ directiveType,
11459
11380
  props,
11460
- renderSlot
11381
+ slots,
11382
+ renderSlot,
11383
+ options
11461
11384
  }) => {
11462
- const className = props.class || "";
11463
- const id = props.id || "";
11464
- const inlineStyle = props.style ? parseCssString(props.style) : {};
11465
- const wrapperProps = {};
11466
- if (className) wrapperProps.className = className;
11467
- if (id) wrapperProps.id = id;
11468
- if (Object.keys(inlineStyle).length > 0) wrapperProps.style = inlineStyle;
11385
+ const { title, image, icon, url, target } = props;
11386
+ const customClass = props.class || "";
11387
+ const hasDescription = !!slots.description;
11388
+ const { isSingleCard } = options || {};
11389
+ const isModal = directiveType === "card-m";
11390
+ const isLink = directiveType === "card-b";
11391
+ const inlineStyles = props.style ? parseCssString(props.style) : {};
11392
+ const card = document.createElement("div");
11393
+ card.className = `nr-card${isModal || isLink ? " nr-card--interactive" : ""} ${customClass}`.trim();
11394
+ for (const [key, value] of Object.entries(inlineStyles)) {
11395
+ card.style.setProperty(key, String(value));
11396
+ }
11397
+ if (image) {
11398
+ const imgWrap = document.createElement("div");
11399
+ imgWrap.className = `nr-card__image${isSingleCard ? " nr-card__image--tall" : ""}`;
11400
+ const img = document.createElement("img");
11401
+ img.src = image;
11402
+ img.alt = title || "";
11403
+ img.className = "nr-card__img";
11404
+ imgWrap.appendChild(img);
11405
+ const gradient = document.createElement("div");
11406
+ gradient.className = "nr-card__gradient";
11407
+ imgWrap.appendChild(gradient);
11408
+ card.appendChild(imgWrap);
11409
+ }
11410
+ const body = document.createElement("div");
11411
+ body.className = `nr-card__body${image ? " nr-card__body--overlap" : ""}`;
11412
+ if (icon || title) {
11413
+ const header = document.createElement("div");
11414
+ header.className = "nr-card__header";
11415
+ if (icon) {
11416
+ const iconWrap = document.createElement("div");
11417
+ iconWrap.className = "nr-card__icon-wrap";
11418
+ iconWrap.appendChild(createIcon(icon));
11419
+ header.appendChild(iconWrap);
11420
+ }
11421
+ if (title) {
11422
+ const h3 = document.createElement("h3");
11423
+ h3.className = "nr-card__title";
11424
+ h3.textContent = title;
11425
+ header.appendChild(h3);
11426
+ }
11427
+ body.appendChild(header);
11428
+ }
11429
+ if (hasDescription) {
11430
+ const desc = document.createElement("div");
11431
+ desc.className = "nr-card__description";
11432
+ desc.appendChild(renderSlot("description"));
11433
+ body.appendChild(desc);
11434
+ }
11435
+ if (directiveType === "card") {
11436
+ const contentSlot = renderSlot("content") || renderSlot("default");
11437
+ if (contentSlot.childNodes.length > 0) {
11438
+ const contentDiv = document.createElement("div");
11439
+ contentDiv.className = "nr-card__content";
11440
+ contentDiv.appendChild(contentSlot);
11441
+ body.appendChild(contentDiv);
11442
+ }
11443
+ }
11444
+ if (isModal || isLink) {
11445
+ const action = document.createElement("div");
11446
+ action.className = "nr-card__action";
11447
+ if (isLink && url) {
11448
+ const a = document.createElement("a");
11449
+ a.href = url;
11450
+ a.target = target || "_blank";
11451
+ a.rel = "noopener noreferrer";
11452
+ a.className = "nr-card__action-link";
11453
+ a.appendChild(createIcon("open_in_new"));
11454
+ a.appendChild(document.createTextNode(" Link"));
11455
+ action.appendChild(a);
11456
+ } else if (isModal) {
11457
+ const modalBtn = document.createElement("div");
11458
+ modalBtn.className = "nr-card__action-link";
11459
+ modalBtn.appendChild(createIcon("arrow_forward"));
11460
+ modalBtn.appendChild(document.createTextNode(" Abrir"));
11461
+ action.appendChild(modalBtn);
11462
+ }
11463
+ body.appendChild(action);
11464
+ }
11465
+ card.appendChild(body);
11466
+ if (isModal) {
11467
+ const dialog = createModal(title || "Detalles");
11468
+ const modalBody = dialog.querySelector(".nr-modal__body");
11469
+ if (modalBody) {
11470
+ const contentSlot = renderSlot("content") || renderSlot("default");
11471
+ modalBody.appendChild(contentSlot);
11472
+ }
11473
+ card.addEventListener("click", () => {
11474
+ if (!dialog.open) {
11475
+ document.body.appendChild(dialog);
11476
+ dialog.showModal();
11477
+ dialog.addEventListener("close", () => dialog.remove(), { once: true });
11478
+ }
11479
+ });
11480
+ const frag = document.createDocumentFragment();
11481
+ frag.appendChild(card);
11482
+ frag.appendChild(dialog);
11483
+ return frag;
11484
+ }
11485
+ if (isLink && url) {
11486
+ card.addEventListener("click", () => window.open(url, target || "_blank"));
11487
+ }
11488
+ return card;
11489
+ };
11490
+ var card_default = cardDirective;
11491
+
11492
+ // vanilla/directives/wrapper.ts
11493
+ var wrapperDirective = ({ props, renderSlot }) => {
11494
+ const el = document.createElement("div");
11495
+ el.className = "nr-wrapper";
11496
+ if (props.class) el.classList.add(...props.class.split(/\s+/).filter(Boolean));
11497
+ if (props.id) el.id = props.id;
11498
+ if (props.style) {
11499
+ const styles = parseCssString(props.style);
11500
+ for (const [key, value] of Object.entries(styles)) {
11501
+ el.style.setProperty(key, String(value));
11502
+ }
11503
+ }
11469
11504
  for (const [key, value] of Object.entries(props)) {
11470
11505
  if (key.startsWith("data-")) {
11471
- wrapperProps[key] = value;
11506
+ el.setAttribute(key, value);
11472
11507
  }
11473
11508
  }
11474
- return /* @__PURE__ */ jsx8("div", { ...wrapperProps, children: renderSlot("default") });
11509
+ el.appendChild(renderSlot("default"));
11510
+ return el;
11475
11511
  };
11476
- var WrapperDirective_default = WrapperDirective;
11512
+ var wrapper_default = wrapperDirective;
11477
11513
 
11478
- // react/directives/SlideDirective.tsx
11479
- import { useState as useState2, useEffect, useCallback, useRef as useRef2, useLayoutEffect } from "react";
11480
- import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
11514
+ // vanilla/directives/slide.ts
11481
11515
  var slideCounter = 0;
11482
- var SlideDirective = ({
11516
+ var slideDirective = ({
11483
11517
  props,
11484
- context,
11485
- slots
11518
+ slots,
11519
+ renderInline: renderInline2,
11520
+ renderMarkdown
11486
11521
  }) => {
11487
11522
  const rawContent = slots.default || "";
11488
11523
  const lines = rawContent.split("\n").map((l) => l.trim()).filter(Boolean);
11489
- const elements = lines.map((line) => context.parseMarkdown(line));
11490
- const [current, setCurrent] = useState2(0);
11524
+ if (lines.length === 0) {
11525
+ return document.createDocumentFragment();
11526
+ }
11491
11527
  const interval = parseInt(props.interval || "3000", 10);
11492
11528
  const speed = parseInt(props.speed || "500", 10);
11493
- const elRefs = useRef2([]);
11494
- const [maxH, setMaxH] = useState2(0);
11495
- useLayoutEffect(() => {
11496
- let h = 0;
11497
- elRefs.current.forEach((el) => {
11498
- if (el) h = Math.max(h, el.offsetHeight);
11499
- });
11500
- if (h > 0) setMaxH(h);
11501
- }, [elements]);
11502
- const cycle = useCallback(() => {
11503
- if (elements.length <= 1) return;
11504
- setCurrent((prev) => (prev + 1) % elements.length);
11505
- }, [elements.length]);
11506
- useEffect(() => {
11507
- if (elements.length <= 1) return;
11508
- const id = setInterval(cycle, interval);
11509
- return () => clearInterval(id);
11510
- }, [cycle, interval, elements.length]);
11511
- if (elements.length === 0) return null;
11512
11529
  const rawClass = props.class || "";
11513
11530
  const inlineStyle = props.style ? parseCssString(props.style) : {};
11514
- const textSizeMap = {
11515
- "text-xs": "0.75rem",
11516
- "text-sm": "0.875rem",
11517
- "text-base": "1rem",
11518
- "text-lg": "1.125rem",
11519
- "text-xl": "1.25rem",
11520
- "text-2xl": "1.5rem",
11521
- "text-3xl": "1.875rem",
11522
- "text-4xl": "2.25rem",
11523
- "text-5xl": "3rem",
11524
- "text-6xl": "3.75rem",
11525
- "text-7xl": "4.5rem",
11526
- "text-8xl": "6rem",
11527
- "text-9xl": "8rem"
11528
- };
11529
- const textSizeMatch = rawClass.match(/\btext-(xs|sm|base|lg|xl|[2-9]xl)\b/);
11530
- const forcedFontSize = textSizeMatch ? textSizeMap[textSizeMatch[0]] : null;
11531
11531
  const scopeClass = `sld-${++slideCounter}`;
11532
- const className = textSizeMatch ? rawClass.replace(textSizeMatch[0], "").replace(/\s+/g, " ").trim() : rawClass;
11533
- return /* @__PURE__ */ jsxs6(
11534
- "div",
11535
- {
11536
- className: "not-prose",
11537
- style: { height: maxH || "auto", position: "relative", overflow: "hidden", ...inlineStyle },
11538
- children: [
11539
- forcedFontSize && /* @__PURE__ */ jsx9("style", { children: `.${scopeClass} * { font-size: ${forcedFontSize} !important; line-height: normal !important; }` }),
11540
- /* @__PURE__ */ jsx9(
11541
- "div",
11542
- {
11543
- style: {
11544
- position: "absolute",
11545
- left: 0,
11546
- right: 0,
11547
- top: 0,
11548
- transition: `transform ${speed}ms cubic-bezier(0.16, 1, 0.3, 1)`,
11549
- transform: `translateY(${-current * maxH}px)`
11550
- },
11551
- children: elements.map((tokens, i) => /* @__PURE__ */ jsx9(
11552
- "div",
11553
- {
11554
- ref: (el) => {
11555
- elRefs.current[i] = el;
11556
- },
11557
- style: maxH ? { height: maxH, display: "flex", alignItems: "center", overflow: "hidden" } : { display: "flex", alignItems: "center" },
11558
- children: /* @__PURE__ */ jsx9("div", { className: `${scopeClass} ${className}`, style: { width: "100%" }, children: context.processAndRenderElements(tokens) })
11559
- },
11560
- i
11561
- ))
11562
- }
11563
- )
11564
- ]
11532
+ const container = document.createElement("div");
11533
+ container.className = "nr-slide";
11534
+ Object.assign(container.style, {
11535
+ position: "relative",
11536
+ overflow: "hidden",
11537
+ ...inlineStyle
11538
+ });
11539
+ const track = document.createElement("div");
11540
+ track.className = "nr-slide__track";
11541
+ track.style.transition = `transform ${speed}ms cubic-bezier(0.16, 1, 0.3, 1)`;
11542
+ const slideEls = [];
11543
+ for (const line of lines) {
11544
+ const slideEl = document.createElement("div");
11545
+ slideEl.className = `nr-slide__item ${scopeClass} ${rawClass}`.trim();
11546
+ slideEl.style.display = "flex";
11547
+ slideEl.style.alignItems = "center";
11548
+ if (renderMarkdown) {
11549
+ const tokens = renderMarkdown(line);
11550
+ slideEl.appendChild(tokens);
11551
+ } else if (renderInline2) {
11552
+ slideEl.appendChild(renderInline2(line));
11565
11553
  }
11566
- );
11554
+ track.appendChild(slideEl);
11555
+ slideEls.push(slideEl);
11556
+ }
11557
+ container.appendChild(track);
11558
+ let current = 0;
11559
+ let maxH = 0;
11560
+ const measureAndSetHeight = () => {
11561
+ maxH = 0;
11562
+ for (const el of slideEls) {
11563
+ maxH = Math.max(maxH, el.offsetHeight);
11564
+ }
11565
+ if (maxH > 0) {
11566
+ container.style.height = `${maxH}px`;
11567
+ for (const el of slideEls) {
11568
+ el.style.height = `${maxH}px`;
11569
+ }
11570
+ }
11571
+ };
11572
+ requestAnimationFrame(() => {
11573
+ measureAndSetHeight();
11574
+ if (document.fonts?.ready) {
11575
+ document.fonts.ready.then(measureAndSetHeight);
11576
+ }
11577
+ });
11578
+ if (lines.length > 1) {
11579
+ setInterval(() => {
11580
+ current = (current + 1) % lines.length;
11581
+ track.style.transform = `translateY(${-current * maxH}px)`;
11582
+ }, interval);
11583
+ }
11584
+ return container;
11567
11585
  };
11568
- var SlideDirective_default = SlideDirective;
11586
+ var slide_default = slideDirective;
11569
11587
 
11570
- // react/directives/index.ts
11588
+ // vanilla/directives/index.ts
11571
11589
  var directiveRegistry = {
11572
11590
  // Admonitions
11573
- note: AdmonitionDirective_default,
11574
- info: AdmonitionDirective_default,
11575
- warning: AdmonitionDirective_default,
11576
- danger: AdmonitionDirective_default,
11577
- greentext: AdmonitionDirective_default,
11591
+ note: admonition_default,
11592
+ info: admonition_default,
11593
+ warning: admonition_default,
11594
+ danger: admonition_default,
11595
+ greentext: admonition_default,
11578
11596
  // Cards
11579
- card: CardDirective_default,
11580
- "card-m": CardDirective_default,
11581
- "card-b": CardDirective_default,
11597
+ card: card_default,
11598
+ "card-m": card_default,
11599
+ "card-b": card_default,
11582
11600
  // Interactive
11583
- details: DetailsDirective_default,
11584
- modal: ModalDirective_default,
11585
- button: ButtonDirective_default,
11601
+ details: details_default,
11602
+ modal: modal_default,
11603
+ button: button_default,
11586
11604
  // Layout / generic wrappers
11587
- div: WrapperDirective_default,
11588
- style: WrapperDirective_default,
11589
- custom: WrapperDirective_default,
11590
- raw: WrapperDirective_default,
11605
+ div: wrapper_default,
11606
+ style: wrapper_default,
11607
+ custom: wrapper_default,
11608
+ raw: wrapper_default,
11591
11609
  // Animation
11592
- slide: SlideDirective_default
11610
+ slide: slide_default
11593
11611
  };
11594
11612
  var directives_default = directiveRegistry;
11595
11613
 
11596
- // react/DirectiveRenderer.tsx
11597
- import { jsx as jsx10 } from "react/jsx-runtime";
11598
- var DirectiveRenderer = ({
11599
- element,
11600
- context,
11601
- index,
11602
- allElements
11603
- }) => {
11614
+ // vanilla/renderer.ts
11615
+ function renderTokens(tokens) {
11616
+ const article = document.createElement("article");
11617
+ article.className = "nr-prose";
11618
+ const ctx = {
11619
+ parseMarkdown,
11620
+ renderElements: (tks) => renderTokensInner(tks, ctx),
11621
+ renderInline,
11622
+ renderMarkdown: (md) => renderTokensInner(parseMarkdown(md), ctx)
11623
+ };
11624
+ article.appendChild(processElements(tokens, ctx, tokens));
11625
+ return article;
11626
+ }
11627
+ function renderMarkdownString(markdown2) {
11628
+ const tokens = parseMarkdown(markdown2);
11629
+ return renderTokens(tokens);
11630
+ }
11631
+ function renderHtmlString(html) {
11632
+ let processedContent = html;
11633
+ processedContent = processedContent.replace(
11634
+ /<style(?:\s+[^>]*)?>([\s\S]*?)<\/style>/gi,
11635
+ (_match, cssContent) => {
11636
+ const styleEl = document.createElement("style");
11637
+ styleEl.setAttribute("data-nr-global", "");
11638
+ styleEl.textContent = cssContent;
11639
+ document.head.appendChild(styleEl);
11640
+ return "";
11641
+ }
11642
+ );
11643
+ const wrapper = document.createElement("div");
11644
+ wrapper.className = "nr-raw-html";
11645
+ wrapper.innerHTML = processedContent;
11646
+ const scripts = wrapper.querySelectorAll("script");
11647
+ scripts.forEach((oldScript) => {
11648
+ const newScript = document.createElement("script");
11649
+ Array.from(oldScript.attributes).forEach(
11650
+ (attr) => newScript.setAttribute(attr.name, attr.value)
11651
+ );
11652
+ newScript.textContent = oldScript.textContent;
11653
+ oldScript.parentNode?.replaceChild(newScript, oldScript);
11654
+ });
11655
+ return wrapper;
11656
+ }
11657
+ function renderTokensInner(tokens, ctx) {
11658
+ const container = document.createElement("div");
11659
+ container.appendChild(processElements(tokens, ctx, tokens));
11660
+ return container;
11661
+ }
11662
+ function processElements(elements, ctx, allElements) {
11663
+ const fragment = document.createDocumentFragment();
11664
+ let i = 0;
11665
+ while (i < elements.length) {
11666
+ const el = elements[i];
11667
+ if (el.type === "directive" && ["card", "card-m", "card-b"].includes(el.directiveType)) {
11668
+ const cards = [];
11669
+ while (i < elements.length && elements[i].type === "directive" && ["card", "card-m", "card-b"].includes(elements[i].directiveType)) {
11670
+ cards.push(elements[i]);
11671
+ i++;
11672
+ }
11673
+ if (cards.length === 1 || cards[0].props?.batch === "off") {
11674
+ for (const card of cards) {
11675
+ const rendered = renderElement(card, ctx, allElements);
11676
+ if (rendered) fragment.appendChild(rendered);
11677
+ }
11678
+ } else {
11679
+ const grid = document.createElement("div");
11680
+ grid.className = "nr-card-grid";
11681
+ for (const card of cards) {
11682
+ const rendered = renderElement(card, ctx, allElements);
11683
+ if (rendered) grid.appendChild(rendered);
11684
+ }
11685
+ fragment.appendChild(grid);
11686
+ }
11687
+ } else {
11688
+ const rendered = renderElement(el, ctx, allElements);
11689
+ if (rendered) fragment.appendChild(rendered);
11690
+ i++;
11691
+ }
11692
+ }
11693
+ return fragment;
11694
+ }
11695
+ function renderElement(element, ctx, allElements) {
11696
+ switch (element.type) {
11697
+ case "header": {
11698
+ const tag = `h${element.level}`;
11699
+ let text = element.text;
11700
+ const alignCenter = text.match(/^->\s*(.+?)\s*<-\s*$/);
11701
+ const alignRight = text.match(/^->\s*(.+?)\s*->\s*$/);
11702
+ if (alignCenter) text = alignCenter[1];
11703
+ else if (alignRight) text = alignRight[1];
11704
+ const h = document.createElement(tag);
11705
+ h.id = element.id;
11706
+ let cls = `md-h${element.level}`;
11707
+ if (alignCenter) cls += " text-center";
11708
+ if (alignRight) cls += " text-right";
11709
+ if (element.classes) cls += ` ${element.classes}`;
11710
+ h.className = cls;
11711
+ h.appendChild(renderInline(text));
11712
+ return h;
11713
+ }
11714
+ case "paragraph": {
11715
+ const p = document.createElement("p");
11716
+ let cls = "md-p";
11717
+ if (element.classes) cls += ` ${element.classes}`;
11718
+ if (element.align) cls += ` text-${element.align}`;
11719
+ p.className = cls;
11720
+ if (element.id) p.id = element.id;
11721
+ const lines = element.content.split("\n");
11722
+ for (let li = 0; li < lines.length; li++) {
11723
+ const line = lines[li];
11724
+ const hardBreakMatch = line.match(/^(.*?)(\s{2,})$/);
11725
+ if (hardBreakMatch) {
11726
+ p.appendChild(renderInline(hardBreakMatch[1]));
11727
+ p.appendChild(document.createElement("br"));
11728
+ } else {
11729
+ p.appendChild(renderInline(line));
11730
+ if (li < lines.length - 1) {
11731
+ p.appendChild(document.createTextNode(" "));
11732
+ }
11733
+ }
11734
+ }
11735
+ return p;
11736
+ }
11737
+ case "codeblock":
11738
+ return createCodeBlock(element.content, element.language, element.title);
11739
+ case "directive":
11740
+ return renderDirective(element, ctx, allElements);
11741
+ case "html": {
11742
+ const el = element;
11743
+ return renderHtmlString(el.content);
11744
+ }
11745
+ case "html-block": {
11746
+ const htmlBlock = element;
11747
+ const rawProps = parseHtmlAttrs(htmlBlock.attrs);
11748
+ const el = document.createElement(htmlBlock.tag);
11749
+ for (const [key, value] of Object.entries(rawProps)) {
11750
+ if (key === "style" && typeof value === "object") {
11751
+ for (const [prop, val] of Object.entries(value)) {
11752
+ el.style.setProperty(prop, String(val));
11753
+ }
11754
+ } else if (value === true) {
11755
+ el.setAttribute(key, "");
11756
+ } else {
11757
+ el.setAttribute(key, String(value));
11758
+ }
11759
+ }
11760
+ const childFrag = processElements(htmlBlock.children, ctx, allElements);
11761
+ el.appendChild(childFrag);
11762
+ return el;
11763
+ }
11764
+ case "image": {
11765
+ const img = document.createElement("img");
11766
+ img.src = element.src;
11767
+ img.alt = element.alt;
11768
+ img.className = "nr-image";
11769
+ if (element.style) {
11770
+ for (const [key, value] of Object.entries(element.style)) {
11771
+ img.style.setProperty(key, String(value));
11772
+ }
11773
+ }
11774
+ return img;
11775
+ }
11776
+ case "table":
11777
+ return createTable(element.content, renderInline);
11778
+ case "list":
11779
+ return createList(element.content, renderInline);
11780
+ case "blockquote":
11781
+ return createBlockquote(element.content, element.classes, renderInline);
11782
+ case "hr": {
11783
+ const hr = document.createElement("hr");
11784
+ hr.className = "nr-hr";
11785
+ return hr;
11786
+ }
11787
+ case "toc": {
11788
+ const headers = allElements.filter((e) => e.type === "header");
11789
+ return createTOC(headers.map((h) => ({ level: h.level, text: h.text, id: h.id })), renderInline);
11790
+ }
11791
+ default:
11792
+ return null;
11793
+ }
11794
+ }
11795
+ function renderDirective(element, ctx, allElements) {
11604
11796
  const { directiveType, props, slots, scopeId } = element;
11605
- const Component = directives_default[directiveType];
11797
+ const renderer = directives_default[directiveType];
11606
11798
  const renderSlot = (name) => {
11799
+ const frag = document.createDocumentFragment();
11607
11800
  const slotContent = slots[name];
11608
- if (!slotContent) return null;
11609
- const parsed = context.parseMarkdown(slotContent);
11610
- return context.processAndRenderElements(parsed);
11801
+ if (!slotContent) return frag;
11802
+ const tokens = ctx.parseMarkdown(slotContent);
11803
+ frag.appendChild(ctx.renderElements(tokens));
11804
+ return frag;
11611
11805
  };
11612
11806
  const directiveProps = {
11613
11807
  directiveType,
11614
11808
  props,
11615
11809
  slots,
11616
11810
  renderSlot,
11617
- context,
11618
- index,
11619
- allElements
11811
+ context: ctx,
11812
+ index: 0,
11813
+ allElements,
11814
+ renderInline,
11815
+ renderMarkdown: ctx.renderMarkdown
11620
11816
  };
11621
- if (Component) {
11622
- return /* @__PURE__ */ jsx10(Component, { ...directiveProps }, index);
11817
+ if (renderer) {
11818
+ return renderer(directiveProps);
11623
11819
  }
11624
- return /* @__PURE__ */ jsx10("div", { className: `my-4 p-4 rounded-2xl border border-border bg-background-primary/5`, children: renderSlot("default") }, index);
11625
- };
11626
- var DirectiveRenderer_default = DirectiveRenderer;
11627
-
11628
- // react/RawHtmlRenderer.tsx
11629
- import { useRef as useRef4, useEffect as useEffect3 } from "react";
11820
+ const fallback = document.createElement("div");
11821
+ fallback.className = "nr-unknown-directive";
11822
+ fallback.appendChild(renderSlot("default"));
11823
+ return fallback;
11824
+ }
11630
11825
 
11631
11826
  // react/useTailwindCDN.ts
11632
- import { useEffect as useEffect2, useRef as useRef3 } from "react";
11827
+ import { useEffect, useRef } from "react";
11633
11828
  var CDN_URL = "https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4";
11634
11829
  var SCRIPT_ID = "tailwind-cdn-v4-runtime";
11635
11830
  var CONFIG_ID = "tailwind-cdn-v4-config";
@@ -11642,8 +11837,8 @@ window.tailwind.config = {
11642
11837
  };
11643
11838
  `;
11644
11839
  function useLazyTailwindCDN(enabled) {
11645
- const loadedRef = useRef3(false);
11646
- useEffect2(() => {
11840
+ const loadedRef = useRef(false);
11841
+ useEffect(() => {
11647
11842
  if (!enabled) {
11648
11843
  window.__twCDNRefs = (window.__twCDNRefs ?? 1) - 1;
11649
11844
  if ((window.__twCDNRefs ?? 0) <= 0) {
@@ -11706,272 +11901,52 @@ function preloadTailwindCDN() {
11706
11901
  }
11707
11902
  }
11708
11903
 
11709
- // react/RawHtmlRenderer.tsx
11710
- import { jsx as jsx11 } from "react/jsx-runtime";
11711
- var RawHtmlRenderer = ({
11712
- content,
11713
- globalStyles,
11714
- wrapperClassName
11715
- }) => {
11716
- const containerRef = useRef4(null);
11717
- useEffect3(() => {
11718
- if (!containerRef.current) return;
11719
- const scripts = containerRef.current.querySelectorAll("script");
11720
- scripts.forEach((oldScript) => {
11721
- const newScript = document.createElement("script");
11722
- Array.from(oldScript.attributes).forEach(
11723
- (attr) => newScript.setAttribute(attr.name, attr.value)
11724
- );
11725
- newScript.textContent = oldScript.textContent;
11726
- oldScript.parentNode?.replaceChild(newScript, oldScript);
11727
- });
11728
- scanTailwindCDN();
11729
- }, [content]);
11730
- useEffect3(() => {
11731
- if (!globalStyles) return;
11732
- const styleEl = document.createElement("style");
11733
- styleEl.setAttribute("data-global", "");
11734
- styleEl.textContent = globalStyles;
11735
- document.head.appendChild(styleEl);
11736
- return () => {
11737
- if (styleEl.parentNode) document.head.removeChild(styleEl);
11738
- };
11739
- }, [globalStyles]);
11740
- return /* @__PURE__ */ jsx11("div", { className: wrapperClassName, ref: containerRef, children: /* @__PURE__ */ jsx11("div", { dangerouslySetInnerHTML: { __html: content } }) });
11741
- };
11742
- var RawHtmlRenderer_default = RawHtmlRenderer;
11743
-
11744
- // react/context.tsx
11745
- import { createContext, useContext } from "react";
11746
- var RenderCtx = createContext(null);
11747
- var RenderContextProvider = RenderCtx.Provider;
11748
-
11749
11904
  // react/CustomMarkdownRenderer.tsx
11750
- import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
11751
- var CustomMarkdownRenderer = ({ content: initialContent }) => {
11752
- const [modals, setModals] = useState3({});
11753
- const baseId = useId3().replace(/:/g, "");
11754
- const articleClass = `scope-${baseId}`;
11755
- const contextRef = useRef5(null);
11756
- resetScopeCounter();
11757
- const allElements = useMemo(() => parseMarkdown(initialContent), [initialContent]);
11758
- useEffect4(() => {
11905
+ import { jsx } from "react/jsx-runtime";
11906
+ var CustomMarkdownRenderer = ({ content }) => {
11907
+ const containerRef = useRef2(null);
11908
+ useEffect2(() => {
11909
+ const container = containerRef.current;
11910
+ if (!container) return;
11911
+ container.replaceChildren();
11912
+ container.appendChild(renderMarkdownString(content));
11913
+ scanTailwindCDN();
11759
11914
  const handleHashChange = () => {
11760
11915
  const hash = window.location.hash;
11761
11916
  if (hash) {
11762
11917
  const parts = hash.split("#");
11763
- const id = parts[parts.length - 1];
11764
- scrollToId(id);
11918
+ scrollToId(parts[parts.length - 1]);
11765
11919
  }
11766
11920
  };
11767
11921
  handleHashChange();
11768
11922
  window.addEventListener("hashchange", handleHashChange);
11769
11923
  return () => window.removeEventListener("hashchange", handleHashChange);
11770
- }, [initialContent]);
11771
- const renderElement = useCallback2(
11772
- (element, index, _depth = 0) => {
11773
- switch (element.type) {
11774
- case "header": {
11775
- const HeaderTag = `h${element.level}`;
11776
- let text = element.text;
11777
- const alignCenter = text.match(/^->\s*(.+?)\s*<-\s*$/);
11778
- const alignRight = text.match(/^->\s*(.+?)\s*->\s*$/);
11779
- if (alignCenter) {
11780
- text = alignCenter[1];
11781
- } else if (alignRight) {
11782
- text = alignRight[1];
11783
- }
11784
- const userClasses = element.classes || "";
11785
- let headerClasses = `md-h${element.level}`;
11786
- if (alignCenter) headerClasses += " text-center";
11787
- if (alignRight) headerClasses += " text-right";
11788
- if (userClasses) headerClasses += ` ${userClasses}`;
11789
- return React8.createElement(
11790
- HeaderTag,
11791
- { key: index, id: element.id, className: headerClasses },
11792
- renderInline(text)
11793
- );
11794
- }
11795
- case "paragraph": {
11796
- const lines = element.content.split("\n");
11797
- const processedContent = lines.map((line, lineIndex) => {
11798
- const hardBreakMatch = line.match(/^(.*?)(\s{2,})$/);
11799
- if (hardBreakMatch) {
11800
- return /* @__PURE__ */ jsxs7(React8.Fragment, { children: [
11801
- renderInline(hardBreakMatch[1]),
11802
- /* @__PURE__ */ jsx12("br", {})
11803
- ] }, lineIndex);
11804
- }
11805
- const isLastLine = lineIndex === lines.length - 1;
11806
- return /* @__PURE__ */ jsxs7(React8.Fragment, { children: [
11807
- renderInline(line),
11808
- !isLastLine && " "
11809
- ] }, lineIndex);
11810
- });
11811
- const pUserClasses = element.classes || "";
11812
- let pClasses = "md-p";
11813
- if (pUserClasses) pClasses += ` ${pUserClasses}`;
11814
- if (element.align) pClasses += ` text-${element.align}`;
11815
- return /* @__PURE__ */ jsx12("p", { id: element.id, className: pClasses, children: processedContent }, index);
11816
- }
11817
- case "codeblock":
11818
- return /* @__PURE__ */ jsx12(
11819
- CodeBlock,
11820
- {
11821
- code: element.content,
11822
- language: element.language,
11823
- title: element.title
11824
- },
11825
- index
11826
- );
11827
- case "directive":
11828
- return /* @__PURE__ */ jsx12(
11829
- DirectiveRenderer_default,
11830
- {
11831
- element,
11832
- context: contextRef.current,
11833
- index,
11834
- allElements
11835
- },
11836
- index
11837
- );
11838
- case "html": {
11839
- let processedContent = element.content;
11840
- let globalStyles = "";
11841
- processedContent = processedContent.replace(
11842
- /<style(?:\s+[^>]*)?>([\s\S]*?)<\/style>/gi,
11843
- (_match, cssContent) => {
11844
- globalStyles += cssContent + "\n";
11845
- return "";
11846
- }
11847
- );
11848
- const wrapperClassName = "w-full my-4";
11849
- return /* @__PURE__ */ jsx12(
11850
- RawHtmlRenderer_default,
11851
- {
11852
- content: processedContent,
11853
- globalStyles: globalStyles || void 0,
11854
- wrapperClassName
11855
- },
11856
- index
11857
- );
11858
- }
11859
- case "html-block": {
11860
- const htmlBlock = element;
11861
- const rawProps = parseHtmlAttrs(htmlBlock.attrs);
11862
- const props = {};
11863
- for (const [key, value] of Object.entries(rawProps)) {
11864
- if (key === "class") props["className"] = value;
11865
- else if (key === "for") props["htmlFor"] = value;
11866
- else if (key === "tabindex") props["tabIndex"] = value;
11867
- else props[key] = value;
11868
- }
11869
- return React8.createElement(
11870
- htmlBlock.tag,
11871
- { key: index, ...props },
11872
- ...processAndRenderElements(htmlBlock.children, _depth + 1)
11873
- );
11874
- }
11875
- case "image":
11876
- return /* @__PURE__ */ jsx12(
11877
- "img",
11878
- {
11879
- alt: element.alt,
11880
- src: element.src,
11881
- style: element.style,
11882
- className: "max-w-full h-auto"
11883
- },
11884
- index
11885
- );
11886
- case "table":
11887
- return /* @__PURE__ */ jsx12("div", { children: renderTable(element.content) }, index);
11888
- case "list":
11889
- return /* @__PURE__ */ jsx12("div", { children: renderList(element.content) }, index);
11890
- case "blockquote":
11891
- return /* @__PURE__ */ jsx12("blockquote", { className: `border-l-4 border-accent-primary/30 pl-4 italic text-text-secondary my-4 text-sm sm:text-base${element.classes ? ` ${element.classes}` : ""}`, children: renderInline(element.content) }, index);
11892
- case "hr":
11893
- return /* @__PURE__ */ jsx12("hr", { className: "my-8 border-border" }, index);
11894
- case "toc":
11895
- return /* @__PURE__ */ jsx12("div", { children: generateToc(allElements) }, index);
11896
- default:
11897
- return null;
11898
- }
11899
- },
11900
- [allElements]
11901
- );
11902
- const processAndRenderElements = useCallback2(
11903
- (elements, depth = 0) => {
11904
- const result = [];
11905
- let i = 0;
11906
- while (i < elements.length) {
11907
- const el = elements[i];
11908
- if (el.type === "directive" && ["card", "card-m", "card-b"].includes(el.directiveType)) {
11909
- const cards = [];
11910
- while (i < elements.length && elements[i].type === "directive" && ["card", "card-m", "card-b"].includes(elements[i].directiveType)) {
11911
- cards.push(elements[i]);
11912
- i++;
11913
- }
11914
- if (cards.length === 1 || cards[0].props?.batch === "off") {
11915
- for (let c = 0; c < cards.length; c++) {
11916
- result.push(renderElement(cards[c], result.length, depth));
11917
- }
11918
- } else {
11919
- const firstCardClass = cards[0].props?.["class"] || "";
11920
- const justifyClasses = firstCardClass.match(/\bjustify-\S+/g) || [];
11921
- const wrapperJustify = justifyClasses.length > 0 ? justifyClasses.join(" ") : "";
11922
- result.push(
11923
- /* @__PURE__ */ jsx12("div", { className: `not-prose flex flex-wrap gap-6 my-6 ${wrapperJustify}`, children: cards.map((card, ci) => /* @__PURE__ */ jsx12(React8.Fragment, { children: renderElement(card, ci, depth) }, ci)) }, `card-grid-${result.length}`)
11924
- );
11925
- }
11926
- } else {
11927
- result.push(renderElement(el, result.length, depth));
11928
- i++;
11929
- }
11930
- }
11931
- return result;
11932
- },
11933
- [renderElement]
11934
- );
11935
- const generateToc = (elements) => {
11936
- const headers = extractHeaders(elements);
11937
- if (headers.length === 0) return null;
11938
- return /* @__PURE__ */ jsxs7("nav", { className: "not-prose my-6 p-4 rounded-2xl border border-border bg-background-primary/5", children: [
11939
- /* @__PURE__ */ jsx12("div", { className: "text-base font-bold mb-3", children: "Table of Contents" }),
11940
- /* @__PURE__ */ jsx12("ul", { className: "space-y-1 list-none p-0 m-0", children: headers.map((h, i) => {
11941
- if (h.type !== "header") return null;
11942
- const indentClass = h.level <= 2 ? "pl-0" : h.level === 3 ? "pl-4" : h.level === 4 ? "pl-8" : "pl-12";
11943
- return /* @__PURE__ */ jsx12("li", { className: `${indentClass} text-sm sm:text-base`, children: /* @__PURE__ */ jsx12(
11944
- "a",
11945
- {
11946
- href: `#${h.id}`,
11947
- className: "text-accent-primary hover:text-accent-primary/80 no-underline hover:underline transition-colors",
11948
- onClick: (e) => {
11949
- e.preventDefault();
11950
- scrollToId(h.id);
11951
- },
11952
- children: renderInline(h.text.replace(/->|<-/g, "").trim())
11953
- }
11954
- ) }, i);
11955
- }) })
11956
- ] });
11957
- };
11958
- const contextForDirectives = {
11959
- modals,
11960
- setModals,
11961
- articleClass,
11962
- allElements,
11963
- parseMarkdown,
11964
- renderElement,
11965
- renderInline,
11966
- processAndRenderElements
11967
- };
11968
- contextRef.current = contextForDirectives;
11969
- return /* @__PURE__ */ jsx12(RenderContextProvider, { value: contextForDirectives, children: processAndRenderElements(allElements) });
11924
+ }, [content]);
11925
+ return /* @__PURE__ */ jsx("div", { ref: containerRef });
11970
11926
  };
11971
11927
  var CustomMarkdownRenderer_default = CustomMarkdownRenderer;
11972
11928
 
11929
+ // react/RawHtmlRenderer.tsx
11930
+ import { useEffect as useEffect3, useRef as useRef3 } from "react";
11931
+ import { jsx as jsx2 } from "react/jsx-runtime";
11932
+ var RawHtmlRenderer = ({
11933
+ content,
11934
+ wrapperClassName = "nr-raw-html"
11935
+ }) => {
11936
+ const containerRef = useRef3(null);
11937
+ useEffect3(() => {
11938
+ const container = containerRef.current;
11939
+ if (!container) return;
11940
+ container.replaceChildren();
11941
+ container.appendChild(renderHtmlString(content));
11942
+ scanTailwindCDN();
11943
+ }, [content]);
11944
+ return /* @__PURE__ */ jsx2("div", { ref: containerRef, className: wrapperClassName });
11945
+ };
11946
+ var RawHtmlRenderer_default = RawHtmlRenderer;
11947
+
11973
11948
  // react/NRpreviewer.tsx
11974
- import { jsx as jsx13 } from "react/jsx-runtime";
11949
+ import { jsx as jsx3 } from "react/jsx-runtime";
11975
11950
  var NRpreviewer = ({
11976
11951
  content,
11977
11952
  html,
@@ -11980,35 +11955,31 @@ var NRpreviewer = ({
11980
11955
  style
11981
11956
  }) => {
11982
11957
  useLazyTailwindCDN(tailwindCDN);
11958
+ const wrapperClass = `nr-prose${className ? ` ${className}` : ""}`;
11983
11959
  if (content) {
11984
- return /* @__PURE__ */ jsx13("div", { className: `nr-prose${className ? ` ${className}` : ""}`, style, children: /* @__PURE__ */ jsx13(CustomMarkdownRenderer_default, { content }) });
11960
+ return /* @__PURE__ */ jsx3("div", { className: wrapperClass, style, children: /* @__PURE__ */ jsx3(CustomMarkdownRenderer_default, { content }) });
11985
11961
  }
11986
11962
  if (html) {
11987
- return /* @__PURE__ */ jsx13("div", { className: `nr-prose${className ? ` ${className}` : ""}`, style, children: /* @__PURE__ */ jsx13(RawHtmlRenderer_default, { content: html, wrapperClassName: "nr-preview-html" }) });
11963
+ return /* @__PURE__ */ jsx3("div", { className: wrapperClass, style, children: /* @__PURE__ */ jsx3(RawHtmlRenderer_default, { content: html }) });
11988
11964
  }
11989
11965
  return null;
11990
11966
  };
11991
11967
  var NRpreviewer_default = NRpreviewer;
11992
11968
 
11993
11969
  // react/useDebounce.ts
11994
- import { useState as useState4, useEffect as useEffect5 } from "react";
11970
+ import { useState, useEffect as useEffect4 } from "react";
11995
11971
  function useDebounce(value, delay) {
11996
- const [debouncedValue, setDebouncedValue] = useState4(value);
11997
- useEffect5(() => {
11972
+ const [debouncedValue, setDebouncedValue] = useState(value);
11973
+ useEffect4(() => {
11998
11974
  const timer = setTimeout(() => setDebouncedValue(value), delay);
11999
11975
  return () => clearTimeout(timer);
12000
11976
  }, [value, delay]);
12001
11977
  return debouncedValue;
12002
11978
  }
12003
11979
  export {
12004
- Admonition,
12005
- CodeBlock,
12006
11980
  CustomMarkdownRenderer_default as CustomMarkdownRenderer,
12007
- Details,
12008
- IconRenderer,
12009
- Modal,
12010
11981
  NRpreviewer_default as NRpreviewer,
12011
- extractHeaders,
11982
+ RawHtmlRenderer_default as RawHtmlRenderer,
12012
11983
  parseMarkdown,
12013
11984
  preloadTailwindCDN,
12014
11985
  scanTailwindCDN,