@clarify-labs/renderer 0.6.4 → 0.6.6

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 (64) hide show
  1. package/output/{OpenApiOperation-DcK7Ekkx.js → OpenApiOperation-CI_PeMSy.js} +768 -74
  2. package/output/OpenApiOperation-CI_PeMSy.js.map +1 -0
  3. package/output/{OpenApiOperation-BI41nyGy.cjs → OpenApiOperation-CxQQyEHK.cjs} +865 -81
  4. package/output/OpenApiOperation-CxQQyEHK.cjs.map +1 -0
  5. package/output/ThemeRoot-BhP5M3Hd.cjs +1800 -0
  6. package/output/ThemeRoot-BhP5M3Hd.cjs.map +1 -0
  7. package/output/ThemeRoot-DErmHskn.js +1757 -0
  8. package/output/ThemeRoot-DErmHskn.js.map +1 -0
  9. package/output/app/ErrorBoundary.d.ts +29 -0
  10. package/output/client.cjs +5 -1
  11. package/output/client.d.ts +2 -0
  12. package/output/client.js +3 -2
  13. package/output/core/i18n.d.ts +1 -1
  14. package/output/core/types.d.ts +30 -9
  15. package/output/index.cjs +42 -32
  16. package/output/index.cjs.map +1 -1
  17. package/output/index.d.ts +3 -1
  18. package/output/index.js +19 -12
  19. package/output/index.js.map +1 -1
  20. package/output/markdown.cjs +1 -1
  21. package/output/markdown.js +1 -1
  22. package/output/mdx/remark.d.ts +11 -1
  23. package/output/openapi/entry.d.ts +1 -0
  24. package/output/preview.cjs +4 -3
  25. package/output/preview.cjs.map +1 -1
  26. package/output/preview.js +4 -3
  27. package/output/preview.js.map +1 -1
  28. package/output/remark-Dd2WU50s.js +35 -0
  29. package/output/remark-Dd2WU50s.js.map +1 -0
  30. package/output/remark-Dv3owbSH.cjs +42 -0
  31. package/output/remark-Dv3owbSH.cjs.map +1 -0
  32. package/output/{render-CjZt3edL.cjs → render-C_NHO3rz.cjs} +12 -8
  33. package/output/render-C_NHO3rz.cjs.map +1 -0
  34. package/output/{render-BpavVnAe.js → render-HeCAMIGm.js} +12 -8
  35. package/output/render-HeCAMIGm.js.map +1 -0
  36. package/output/renderer.css +457 -597
  37. package/output/server.cjs +11 -7
  38. package/output/server.cjs.map +1 -1
  39. package/output/server.js +11 -7
  40. package/output/server.js.map +1 -1
  41. package/output/{shell-_MyLsMUI.cjs → shell-D4tS8Jts.cjs} +112 -1016
  42. package/output/shell-D4tS8Jts.cjs.map +1 -0
  43. package/output/{shell-BlMMdTpZ.js → shell-DvTfFx6M.js} +107 -933
  44. package/output/shell-DvTfFx6M.js.map +1 -0
  45. package/output/theme/ThemeEditor.d.ts +67 -0
  46. package/output/theme/ThemeProvider.d.ts +1 -1
  47. package/output/theme/ThemeRoot.d.ts +9 -0
  48. package/output/theme/randomTheme.d.ts +2 -0
  49. package/output/theme/variables.d.ts +62 -0
  50. package/package.json +1 -1
  51. package/output/AppShell-D3FsVHQK.js +0 -390
  52. package/output/AppShell-D3FsVHQK.js.map +0 -1
  53. package/output/AppShell-DeaJ-rgo.cjs +0 -409
  54. package/output/AppShell-DeaJ-rgo.cjs.map +0 -1
  55. package/output/OpenApiOperation-BI41nyGy.cjs.map +0 -1
  56. package/output/OpenApiOperation-DcK7Ekkx.js.map +0 -1
  57. package/output/remark-DNOdJz5i.cjs +0 -14
  58. package/output/remark-DNOdJz5i.cjs.map +0 -1
  59. package/output/remark-o5sg9Ilv.js +0 -7
  60. package/output/remark-o5sg9Ilv.js.map +0 -1
  61. package/output/render-BpavVnAe.js.map +0 -1
  62. package/output/render-CjZt3edL.cjs.map +0 -1
  63. package/output/shell-BlMMdTpZ.js.map +0 -1
  64. package/output/shell-_MyLsMUI.cjs.map +0 -1
@@ -0,0 +1,1800 @@
1
+ const require_chunk = require("./chunk-DakpK96I.cjs");
2
+ const require_shell = require("./shell-D4tS8Jts.cjs");
3
+ let clsx = require("clsx");
4
+ clsx = require_chunk.__toESM(clsx, 1);
5
+ let react = require("react");
6
+ let react_router_dom = require("react-router-dom");
7
+ let lucide_react = require("lucide-react");
8
+ let react_jsx_runtime = require("react/jsx-runtime");
9
+ //#region source/app/ErrorBoundary.tsx
10
+ function PageErrorPanel(props) {
11
+ const { title, description, reloadLabel, detailsLabel, pathLabel, typeLabel, messageLabel, stackLabel, componentStackLabel, timestampLabel, copyLabel, copiedLabel, path, error, errorInfo, occurredAt } = props;
12
+ const [copiedStack, setCopiedStack] = (0, react.useState)(false);
13
+ const stack = error.stack ?? error.message;
14
+ const componentStack = errorInfo?.componentStack?.trim();
15
+ const stackText = componentStack ? `${stack}\n\n${componentStackLabel}\n${componentStack}` : stack;
16
+ const capturedAt = occurredAt ?? (/* @__PURE__ */ new Date()).toISOString();
17
+ async function copyStack() {
18
+ if (!await require_shell.copyTextToClipboard(stackText)) return;
19
+ setCopiedStack(true);
20
+ window.setTimeout(() => setCopiedStack(false), 1600);
21
+ }
22
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
23
+ className: "mx-auto flex min-h-(--clarify-error-page-min-height) w-full max-w-4xl flex-col justify-center py-16 text-(--clarify-theme-tokens-colors-foreground)",
24
+ "aria-labelledby": "clarify-render-error-title",
25
+ role: "alert",
26
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
27
+ className: "border-t-2 border-(--clarify-error-accent-text) pt-8",
28
+ children: [
29
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
30
+ className: "flex flex-col gap-6 sm:flex-row sm:items-start sm:justify-between",
31
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
32
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
33
+ className: "font-mono text-xs/5 font-semibold uppercase tracking-wide text-(--clarify-error-accent-text)",
34
+ children: "Render error"
35
+ }),
36
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {
37
+ id: "clarify-render-error-title",
38
+ className: "mt-3 text-3xl/9 font-semibold tracking-tight text-(--clarify-theme-tokens-colors-foreground)",
39
+ children: title
40
+ }),
41
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
42
+ className: "mt-4 max-w-2xl text-sm/6 text-(--clarify-theme-tokens-colors-muted)",
43
+ children: description
44
+ })
45
+ ] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
46
+ type: "button",
47
+ className: "inline-flex shrink-0 items-center rounded-(--clarify-theme-tokens-radius-md) bg-(--clarify-theme-tokens-colors-primary) px-4 py-2 text-sm/5 font-semibold text-white shadow-xs transition hover:opacity-90",
48
+ onClick: () => window.location.reload(),
49
+ children: reloadLabel
50
+ })]
51
+ }),
52
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dl", {
53
+ className: "mt-8 grid gap-px overflow-hidden rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-border) sm:grid-cols-3",
54
+ children: [
55
+ [pathLabel, path],
56
+ [typeLabel, error.name],
57
+ [timestampLabel, capturedAt]
58
+ ].map(([label, value]) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
59
+ className: "min-w-0 bg-(--clarify-theme-tokens-colors-surface) px-4 py-3",
60
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", {
61
+ className: "text-xs/5 font-semibold uppercase tracking-wide text-(--clarify-ui-text-faint)",
62
+ children: label
63
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", {
64
+ className: "mt-1 truncate font-mono text-sm/6 text-(--clarify-ui-text-strong)",
65
+ title: value,
66
+ children: value
67
+ })]
68
+ }, label))
69
+ }),
70
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
71
+ className: "mt-6 overflow-hidden rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-code-background)",
72
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
73
+ className: "flex items-center justify-between gap-3 border-b border-(--clarify-theme-tokens-colors-border) px-4 py-3",
74
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
75
+ className: "text-sm/6 font-semibold text-(--clarify-ui-text-strong)",
76
+ children: detailsLabel
77
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
78
+ type: "button",
79
+ className: "rounded-(--clarify-theme-tokens-radius-sm) px-2 py-1 text-xs/5 font-semibold text-(--clarify-ui-text-soft) ring-1 ring-(--clarify-theme-tokens-colors-border) transition hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-ui-text-strong)",
80
+ onClick: copyStack,
81
+ children: copiedStack ? copiedLabel : copyLabel
82
+ })]
83
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
84
+ className: "px-4 py-4 text-xs/5 text-(--clarify-ui-text)",
85
+ children: [
86
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
87
+ className: "font-semibold uppercase tracking-wide text-(--clarify-ui-text-faint)",
88
+ children: messageLabel
89
+ }),
90
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
91
+ className: "mt-2 break-words font-mono text-sm/6 font-semibold text-(--clarify-theme-tokens-colors-foreground)",
92
+ children: error.message
93
+ }),
94
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
95
+ className: "mt-6 font-semibold uppercase tracking-wide text-(--clarify-ui-text-faint)",
96
+ children: stackLabel
97
+ }),
98
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
99
+ className: "mt-2 max-h-(--clarify-error-details-max-height) overflow-auto whitespace-pre-wrap break-words font-mono",
100
+ children: stack
101
+ }),
102
+ componentStack ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
103
+ className: "mt-6 font-semibold uppercase tracking-wide text-(--clarify-ui-text-faint)",
104
+ children: componentStackLabel
105
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
106
+ className: "mt-2 max-h-(--clarify-error-component-stack-max-height) overflow-auto whitespace-pre-wrap break-words font-mono",
107
+ children: componentStack
108
+ })] }) : null
109
+ ]
110
+ })]
111
+ })
112
+ ]
113
+ })
114
+ });
115
+ }
116
+ var PageErrorBoundary = class extends react.Component {
117
+ state = {};
118
+ static getDerivedStateFromError(error) {
119
+ return {
120
+ error,
121
+ occurredAt: (/* @__PURE__ */ new Date()).toISOString()
122
+ };
123
+ }
124
+ componentDidCatch(error, errorInfo) {
125
+ console.error("[clarify] Failed to render page:", error, errorInfo);
126
+ this.setState({ errorInfo });
127
+ }
128
+ render() {
129
+ const { error, errorInfo, occurredAt } = this.state;
130
+ if (!error) return this.props.children;
131
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PageErrorPanel, {
132
+ title: this.props.title,
133
+ description: this.props.description,
134
+ reloadLabel: this.props.reloadLabel,
135
+ detailsLabel: this.props.detailsLabel,
136
+ pathLabel: this.props.pathLabel,
137
+ typeLabel: this.props.typeLabel,
138
+ messageLabel: this.props.messageLabel,
139
+ stackLabel: this.props.stackLabel,
140
+ componentStackLabel: this.props.componentStackLabel,
141
+ timestampLabel: this.props.timestampLabel,
142
+ copyLabel: this.props.copyLabel,
143
+ copiedLabel: this.props.copiedLabel,
144
+ path: this.props.path,
145
+ error,
146
+ errorInfo,
147
+ occurredAt
148
+ });
149
+ }
150
+ };
151
+ //#endregion
152
+ //#region source/assets/clarify.svg?url
153
+ var clarify_default = "data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20width='279px'%20height='200px'%20viewBox='0%200%20279%20200'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3ctitle%3eclarify%3c/title%3e%3cg%20id='页面-1'%20stroke='none'%20stroke-width='1'%20fill='none'%20fill-rule='evenodd'%3e%3cg%20id='clarify'%20transform='translate(-0,%200.0054)'%3e%3cpath%20d='M44.867217,0.0054376148%20C130.715579,1.00591567%20200,70.9091172%20200,156.994562%20L199.986321,155.127494%20C199.384888,180.009127%20179.026368,199.994562%20154,199.994562%20L46,199.994562%20C20.5949015,199.994562%200,179.399661%200,153.994562%20L0,45.9945624%20C0,21.0975659%2019.7793434,0.820282524%2044.4815926,0.0191499894%20Z'%20fill='%2300D492'%3e%3c/path%3e%3cpath%20d='M123.867217,0.0054376148%20C209.715579,1.00591567%20279,70.9091172%20279,156.994562%20L278.986321,155.127494%20C278.384888,180.009127%20258.026368,199.994562%20233,199.994562%20L125,199.994562%20C99.5949015,199.994562%2079,179.399661%2079,153.994562%20L79,45.9945624%20C79,21.0975659%2098.7793434,0.820282524%20123.481593,0.0191499894%20Z'%20id='clarify-right'%20fill-opacity='0.6'%20fill='%2300F6C9'%20transform='translate(179,%20100)%20rotate(-90)%20translate(-179,%20-100)'%3e%3c/path%3e%3cpath%20d='M199.979267,154.416906%20L199.984438,155.157125%20L199.962366,155.872459%20C198.977251,180.406837%20178.776104,199.994562%20154,199.994562%20L124.372438,199.994125%20L124.249053,199.994081%20C99.6939678,199.603921%2079.8122712,179.973634%2079.01915,155.518407%20L79.0054376,155.132783%20C79.5830823,105.566626%20103.129768,61.5221348%20139.498462,33.1463428%20C175.69419,61.3871018%20199.186123,105.143863%20199.979267,154.416906%20Z'%20id='形状结合'%20fill='%2300F692'%3e%3c/path%3e%3c/g%3e%3c/g%3e%3c/svg%3e";
154
+ //#endregion
155
+ //#region source/app/BuiltWithClarify.tsx
156
+ function BuiltWithClarify() {
157
+ const t = require_shell.useBuiltInText();
158
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
159
+ href: "https://clarify.pub",
160
+ target: "_blank",
161
+ rel: "noreferrer",
162
+ "aria-label": t("builtWith.label"),
163
+ className: "clarify-built-with inline-flex items-center gap-1.5 rounded-full px-2 py-1 font-medium no-underline transition",
164
+ children: [
165
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("builtWith.prefix") }),
166
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
167
+ src: clarify_default,
168
+ alt: "",
169
+ className: "clarify-built-with-logo h-3.5 w-5 flex-none"
170
+ }),
171
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
172
+ className: "clarify-built-with-brand font-semibold",
173
+ children: "Clarify"
174
+ })
175
+ ]
176
+ });
177
+ }
178
+ //#endregion
179
+ //#region source/app/PageFooter.tsx
180
+ function resolveLocalizedText(text, locale, fallbackLocale) {
181
+ if (typeof text === "string") return text;
182
+ return (locale ? text[locale] : void 0) ?? (fallbackLocale ? text[fallbackLocale] : void 0) ?? Object.values(text)[0] ?? "";
183
+ }
184
+ function localeForPath$1(config, pathname) {
185
+ const i18n = config.i18n;
186
+ if (!i18n) return void 0;
187
+ const firstSegment = pathname.split("/").filter(Boolean)[0];
188
+ return i18n.locales.find((locale) => locale.code === firstSegment)?.code ?? i18n.defaultLocale;
189
+ }
190
+ function FooterLink(arg0) {
191
+ const { link, locale, config } = arg0;
192
+ const external = link.external ?? require_shell.isExternalHref(link.href);
193
+ const href = external ? link.href : require_shell.localizeHref(link.href, config, locale);
194
+ const className = "clarify-footer-link no-underline transition";
195
+ const label = resolveLocalizedText(link.label, locale, config.i18n?.defaultLocale);
196
+ if (external) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
197
+ href,
198
+ target: "_blank",
199
+ rel: "noreferrer",
200
+ className,
201
+ children: label
202
+ });
203
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_router_dom.Link, {
204
+ to: href,
205
+ className,
206
+ children: label
207
+ });
208
+ }
209
+ function SocialLink(arg0) {
210
+ const { name, href } = arg0;
211
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
212
+ href,
213
+ target: "_blank",
214
+ rel: "noreferrer",
215
+ className: "clarify-footer-social capitalize no-underline transition",
216
+ children: name
217
+ });
218
+ }
219
+ function PageFooter() {
220
+ const config = require_shell.useClarifyConfig();
221
+ const locale = localeForPath$1(config, (0, react_router_dom.useLocation)().pathname);
222
+ const footer = config.footer;
223
+ const links = footer?.links ?? [];
224
+ const socials = Object.entries(footer?.socials ?? {});
225
+ const copyright = footer?.copyright ? resolveLocalizedText(footer.copyright, locale, config.i18n?.defaultLocale) : void 0;
226
+ const hasCustomFooter = Boolean(copyright || links.length > 0 || socials.length > 0);
227
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("footer", {
228
+ className: (0, clsx.default)("clarify-page-footer mx-auto flex w-full max-w-(--clarify-theme-layout-max-width) flex-col items-end gap-4 border-t border-(--clarify-theme-tokens-colors-border) px-4 py-8 sm:px-6 lg:mt-24 lg:px-5", hasCustomFooter && "sm:flex-row sm:items-center sm:justify-between"),
229
+ children: [hasCustomFooter ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
230
+ className: "clarify-footer-content flex flex-col gap-3 text-right sm:text-left",
231
+ children: [copyright ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
232
+ className: "clarify-footer-copyright m-0",
233
+ children: copyright
234
+ }) : null, links.length > 0 || socials.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
235
+ className: "clarify-footer-links flex flex-wrap justify-end gap-x-4 gap-y-2 sm:justify-start",
236
+ children: [links.map((link) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FooterLink, {
237
+ link,
238
+ locale,
239
+ config
240
+ }, `${link.href}-${resolveLocalizedText(link.label, locale, config.i18n?.defaultLocale)}`)), socials.map(([name, href]) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SocialLink, {
241
+ name,
242
+ href
243
+ }, name))]
244
+ }) : null]
245
+ }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
246
+ className: "clarify-footer-brand flex justify-end",
247
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BuiltWithClarify, {})
248
+ })]
249
+ });
250
+ }
251
+ //#endregion
252
+ //#region source/app/PageNavigation.tsx
253
+ function flattenNavigation(nodes) {
254
+ return nodes.flatMap((node) => node.children?.length ? flattenNavigation(node.children) : [node]);
255
+ }
256
+ function PageNavigation(arg0) {
257
+ const { navigation, currentRoute } = arg0;
258
+ const t = require_shell.useBuiltInText();
259
+ if (!currentRoute) return null;
260
+ const pageRoutes = flattenNavigation(navigation);
261
+ const currentIndex = pageRoutes.findIndex((route) => require_shell.isSameRoutePath(route.path, currentRoute.path));
262
+ if (currentIndex === -1) return null;
263
+ const previous = pageRoutes[currentIndex - 1];
264
+ const next = pageRoutes[currentIndex + 1];
265
+ if (!previous && !next) return null;
266
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("nav", {
267
+ className: "clarify-page-navigation mt-6 grid gap-3 @3xl:grid-cols-2",
268
+ "aria-label": t("navigation.previousNext"),
269
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(PageNavigationLink, {
270
+ direction: "previous",
271
+ route: previous
272
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PageNavigationLink, {
273
+ direction: "next",
274
+ route: next
275
+ })]
276
+ });
277
+ }
278
+ function PageNavigationLink(arg0) {
279
+ const { direction, route } = arg0;
280
+ const t = require_shell.useBuiltInText();
281
+ if (!route) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "hidden @3xl:block" });
282
+ const isNext = direction === "next";
283
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_router_dom.Link, {
284
+ to: require_shell.normalizeRoutePath(route.path),
285
+ className: (0, clsx.default)("group flex min-w-0 items-center gap-3 rounded-lg border border-(--clarify-theme-tokens-colors-border) px-4 py-3 no-underline transition hover:border-(--clarify-theme-tokens-colors-primary) hover:bg-(--clarify-ui-hover-background)", isNext && "@3xl:justify-end @3xl:text-right"),
286
+ children: [
287
+ !isNext ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronLeft, { className: "h-3.5 w-3.5 shrink-0 text-(--clarify-theme-tokens-colors-muted) transition group-hover:text-(--clarify-theme-tokens-colors-primary)" }) : null,
288
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
289
+ className: "min-w-0 flex-1",
290
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
291
+ className: "clarify-page-navigation-label block font-medium uppercase tracking-wide text-(--clarify-theme-tokens-colors-muted)",
292
+ children: isNext ? t("navigation.next") : t("navigation.previous")
293
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
294
+ className: "clarify-page-navigation-title mt-0.5 block truncate font-semibold text-(--clarify-theme-tokens-colors-foreground)",
295
+ children: route.title
296
+ })]
297
+ }),
298
+ isNext ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRight, { className: "h-3.5 w-3.5 shrink-0 text-(--clarify-theme-tokens-colors-muted) transition group-hover:text-(--clarify-theme-tokens-colors-primary)" }) : null
299
+ ]
300
+ });
301
+ }
302
+ //#endregion
303
+ //#region source/app/PageSkeleton.tsx
304
+ var paragraphLines = [
305
+ "w-full",
306
+ "w-11/12",
307
+ "w-4/5"
308
+ ];
309
+ var codeLines = [
310
+ "w-5/6",
311
+ "w-2/3",
312
+ "w-3/4",
313
+ "w-1/2"
314
+ ];
315
+ function SkeletonBlock(props) {
316
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
317
+ "aria-hidden": "true",
318
+ className: (0, clsx.default)("rounded-(--clarify-skeleton-radius) bg-(--clarify-skeleton-background)", props.className)
319
+ });
320
+ }
321
+ function SkeletonParagraph() {
322
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
323
+ className: "space-y-3",
324
+ children: paragraphLines.map((width) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SkeletonBlock, { className: (0, clsx.default)("h-3", width) }, width))
325
+ });
326
+ }
327
+ function PageSkeleton() {
328
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
329
+ className: "clarify-page-skeleton animate-pulse space-y-10 py-8",
330
+ "aria-label": "Loading page",
331
+ children: [
332
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
333
+ className: "space-y-5",
334
+ children: [
335
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SkeletonBlock, { className: "h-3 w-24 rounded-full bg-(--clarify-skeleton-accent-background)" }),
336
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SkeletonBlock, { className: "h-11 w-full max-w-(--clarify-skeleton-title-width) rounded-3xl" }),
337
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
338
+ className: "max-w-3xl space-y-3",
339
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SkeletonBlock, { className: "h-4 w-full" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SkeletonBlock, { className: "h-4 w-5/6" })]
340
+ })
341
+ ]
342
+ }),
343
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
344
+ className: "grid gap-4 xl:grid-cols-2",
345
+ children: [0, 1].map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
346
+ className: "rounded-(--clarify-skeleton-card-radius) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) p-5 shadow-sm shadow-zinc-900/5",
347
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
348
+ className: "flex items-start gap-4",
349
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SkeletonBlock, { className: "h-10 w-10 shrink-0 bg-(--clarify-skeleton-accent-background)" }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
350
+ className: "min-w-0 flex-1 space-y-4",
351
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SkeletonBlock, { className: "h-5 w-2/3" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SkeletonParagraph, {})]
352
+ })]
353
+ })
354
+ }, item))
355
+ }),
356
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
357
+ className: "space-y-8",
358
+ children: [
359
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("article", {
360
+ className: "space-y-5",
361
+ children: [
362
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SkeletonBlock, { className: "h-7 w-full max-w-(--clarify-skeleton-heading-width) rounded-2xl" }),
363
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SkeletonParagraph, {}),
364
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
365
+ className: "rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-ui-accent-border) bg-(--clarify-ui-accent-background) p-4",
366
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SkeletonBlock, { className: "h-4 w-full max-w-(--clarify-skeleton-line-width) bg-(--clarify-skeleton-accent-background)" })
367
+ })
368
+ ]
369
+ }),
370
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
371
+ className: "overflow-hidden rounded-(--clarify-skeleton-block-radius) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-code-background)",
372
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
373
+ className: "flex items-center gap-2 border-b border-(--clarify-theme-tokens-colors-border) px-4 py-3",
374
+ children: [
375
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SkeletonBlock, { className: "h-3 w-3 rounded-full" }),
376
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SkeletonBlock, { className: "h-3 w-3 rounded-full" }),
377
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SkeletonBlock, { className: "h-3 w-3 rounded-full" }),
378
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SkeletonBlock, { className: "ml-3 h-3 w-32" })
379
+ ]
380
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
381
+ className: "space-y-3 p-4",
382
+ children: codeLines.map((width) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SkeletonBlock, { className: (0, clsx.default)("h-3", width) }, width))
383
+ })]
384
+ }),
385
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("article", {
386
+ className: "space-y-5",
387
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SkeletonBlock, { className: "h-7 w-full max-w-(--clarify-skeleton-heading-short-width) rounded-2xl" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
388
+ className: "grid gap-3 sm:grid-cols-2",
389
+ children: [
390
+ 0,
391
+ 1,
392
+ 2,
393
+ 3
394
+ ].map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
395
+ className: "rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-theme-tokens-colors-border) p-4",
396
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SkeletonBlock, { className: "mb-3 h-4 w-1/2" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SkeletonBlock, { className: "h-3 w-4/5" })]
397
+ }, item))
398
+ })]
399
+ })
400
+ ]
401
+ })
402
+ ]
403
+ });
404
+ }
405
+ //#endregion
406
+ //#region source/app/AppShell.tsx
407
+ function routeForPath(routes, pathname) {
408
+ return routes.find((route) => require_shell.isSameRoutePath(route.path, pathname));
409
+ }
410
+ function notFoundRouteForPath(routes, pathname, currentLocale) {
411
+ const localePrefix = currentLocale ? `/${currentLocale}` : void 0;
412
+ if (localePrefix && pathname.startsWith(`${localePrefix}/`)) return routeForPath(routes, `${localePrefix}/404`);
413
+ return routeForPath(routes, "/404") ?? routes.find((route) => require_shell.isSameRoutePath(route.basePath, "/404"));
414
+ }
415
+ function sectionsForRoute(route) {
416
+ return route?.sections?.map((section) => ({
417
+ id: section.id,
418
+ title: section.title,
419
+ badge: section.badge,
420
+ tags: section.tags
421
+ })) ?? [];
422
+ }
423
+ function resolveRouteComponent(route) {
424
+ if (route.lazy) return (0, react.lazy)(route.component);
425
+ return route.component;
426
+ }
427
+ function scrollToHash(hash) {
428
+ if (!hash) return;
429
+ const targetId = require_shell.safeDecodeURIComponent(hash.slice(1));
430
+ window.requestAnimationFrame(() => {
431
+ document.getElementById(targetId)?.scrollIntoView();
432
+ window.requestAnimationFrame(() => {
433
+ window.dispatchEvent(new Event("scroll"));
434
+ });
435
+ });
436
+ }
437
+ function localeForPath(config, pathname, route) {
438
+ if (route?.locale) return route.locale;
439
+ const i18n = config.i18n;
440
+ if (!i18n) return void 0;
441
+ const firstSegment = pathname.split("/").filter(Boolean)[0];
442
+ return i18n.locales.find((locale) => locale.code === firstSegment)?.code ?? i18n.defaultLocale;
443
+ }
444
+ function isTabbedNavigation(navigation) {
445
+ return !Array.isArray(navigation) && "tabs" in navigation;
446
+ }
447
+ function hasPath(nodes, pathname) {
448
+ return nodes.some((node) => require_shell.isSameRoutePath(node.path, pathname) || hasPath(node.children ?? [], pathname));
449
+ }
450
+ function navigationFromTabs(navigation, pathname) {
451
+ return {
452
+ items: navigation.tabs.find((tab) => require_shell.isSameRoutePath(tab.path, pathname) || hasPath(tab.children, pathname))?.children ?? navigation.tabs[0]?.children ?? [],
453
+ tabs: navigation.tabs
454
+ };
455
+ }
456
+ function navigationForLocale(navigation, locale, pathname) {
457
+ if (Array.isArray(navigation)) return { items: navigation };
458
+ if (isTabbedNavigation(navigation)) return navigationFromTabs(navigation, pathname);
459
+ if (!locale) return { items: [] };
460
+ const localizedNavigation = navigation[locale];
461
+ if (!localizedNavigation) return { items: [] };
462
+ return Array.isArray(localizedNavigation) ? { items: localizedNavigation } : navigationFromTabs(localizedNavigation, pathname);
463
+ }
464
+ function pageTitle(config, route) {
465
+ const routeTitle = route?.title?.trim();
466
+ if (!routeTitle || routeTitle === config.title) return config.title;
467
+ return `${routeTitle} - ${config.title}`;
468
+ }
469
+ function setNamedMeta(name, content) {
470
+ const existing = document.head.querySelector(`meta[name="${name}"]`);
471
+ if (!content) {
472
+ existing?.remove();
473
+ return;
474
+ }
475
+ const meta = existing ?? document.createElement("meta");
476
+ meta.name = name;
477
+ meta.content = content;
478
+ if (!existing) document.head.appendChild(meta);
479
+ }
480
+ function applyDocumentMetadata(config, route) {
481
+ document.title = pageTitle(config, route);
482
+ setNamedMeta("description", route?.description ?? config.description);
483
+ setNamedMeta("keywords", route?.keywords?.join(", "));
484
+ }
485
+ function BuiltInNotFoundPage() {
486
+ const text = require_shell.useBuiltInText();
487
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
488
+ className: "mx-auto flex min-h-(--clarify-error-page-min-height) max-w-2xl flex-col justify-center py-16 text-(--clarify-theme-tokens-colors-foreground)",
489
+ "aria-labelledby": "clarify-not-found-title",
490
+ children: [
491
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
492
+ className: "text-sm/6 font-semibold text-(--clarify-theme-tokens-colors-primary)",
493
+ children: text("notFound.label")
494
+ }),
495
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {
496
+ id: "clarify-not-found-title",
497
+ className: "mt-3 text-3xl/9 font-semibold tracking-tight text-(--clarify-theme-tokens-colors-foreground)",
498
+ children: text("notFound.title")
499
+ }),
500
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
501
+ className: "mt-4 text-sm/6 text-(--clarify-theme-tokens-colors-muted)",
502
+ children: text("notFound.description")
503
+ }),
504
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
505
+ className: "mt-8",
506
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_router_dom.Link, {
507
+ className: "inline-flex items-center rounded-(--clarify-theme-tokens-radius-md) bg-(--clarify-theme-tokens-colors-primary) px-3 py-2 text-sm/5 font-semibold text-white shadow-xs transition hover:opacity-90",
508
+ to: "/",
509
+ children: text("notFound.home")
510
+ })
511
+ })
512
+ ]
513
+ });
514
+ }
515
+ function NotFoundRouteElement(props) {
516
+ const { component: RouteComponent } = props;
517
+ if (!RouteComponent) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BuiltInNotFoundPage, {});
518
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteComponent, {});
519
+ }
520
+ function AppShell(arg0) {
521
+ const { config, routes, navigation } = arg0;
522
+ const location = (0, react_router_dom.useLocation)();
523
+ const pathname = require_shell.normalizeRoutePath(location.pathname);
524
+ const currentRoute = routeForPath(routes, pathname);
525
+ const currentLocale = localeForPath(config, pathname, currentRoute);
526
+ const currentLocaleConfig = config.i18n?.locales.find((locale) => locale.code === currentLocale);
527
+ const notFoundRoute = currentRoute ? void 0 : notFoundRouteForPath(routes, pathname, currentLocale);
528
+ const text = require_shell.useBuiltInText(currentLocale);
529
+ const currentNavigation = navigationForLocale(navigation, currentLocale, pathname);
530
+ const sections = sectionsForRoute(currentRoute);
531
+ const hasTabs = Boolean(currentNavigation.tabs?.length);
532
+ const renderRoutes = (0, react.useMemo)(() => routes.map((route) => ({
533
+ ...route,
534
+ component: resolveRouteComponent(route)
535
+ })), [routes]);
536
+ const NotFoundRouteComponent = notFoundRoute ? renderRoutes.find((route) => require_shell.isSameRoutePath(route.path, notFoundRoute.path))?.component : void 0;
537
+ (0, react.useEffect)(() => {
538
+ if (location.hash) {
539
+ scrollToHash(location.hash);
540
+ return;
541
+ }
542
+ window.scrollTo({
543
+ top: 0,
544
+ left: 0
545
+ });
546
+ window.requestAnimationFrame(() => {
547
+ window.dispatchEvent(new Event("scroll"));
548
+ });
549
+ }, [location.hash, location.pathname]);
550
+ (0, react.useEffect)(() => {
551
+ if (!currentLocale) return;
552
+ document.documentElement.lang = currentLocale;
553
+ if (currentLocaleConfig?.dir) document.documentElement.dir = currentLocaleConfig.dir;
554
+ else document.documentElement.removeAttribute("dir");
555
+ }, [currentLocale, currentLocaleConfig?.dir]);
556
+ (0, react.useEffect)(() => {
557
+ applyDocumentMetadata(config, currentRoute ?? notFoundRoute);
558
+ }, [
559
+ config,
560
+ currentRoute,
561
+ notFoundRoute
562
+ ]);
563
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_shell.ClarifyLocaleContext.Provider, {
564
+ value: currentLocale,
565
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_shell.SectionProvider, {
566
+ sections,
567
+ children: [
568
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_shell.Header, {
569
+ config,
570
+ navigation: currentNavigation.items,
571
+ tabs: currentNavigation.tabs,
572
+ routes,
573
+ currentLocale,
574
+ currentRoute
575
+ }),
576
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
577
+ className: "clarify-layout pb-12 mx-auto grid w-full max-w-(--clarify-theme-layout-max-width) grid-cols-1 lg:grid-cols-(--clarify-layout-sidebar-grid) xl:grid-cols-(--clarify-layout-sidebar-grid-wide)",
578
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("aside", {
579
+ className: (0, clsx.default)("clarify-sidebar hidden lg:sticky lg:z-30 lg:block lg:h-(--clarify-sidebar-height) lg:self-start lg:overflow-y-auto lg:bg-(--clarify-theme-tokens-colors-background) lg:px-5 lg:pb-8 xl:px-6", hasTabs ? "lg:top-28 lg:h-(--clarify-sidebar-height-with-tabs) lg:pt-6" : "lg:top-14 lg:pt-6"),
580
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_shell.Navigation, { navigation: currentNavigation.items })
581
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
582
+ className: (0, clsx.default)("clarify-content @container relative flex min-h-screen min-w-0 flex-col px-4 sm:px-6 lg:px-8 xl:px-10", hasTabs ? "pt-14 lg:pt-28" : "pt-14"),
583
+ children: [
584
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_shell.ContentActions, {
585
+ hasTabs,
586
+ route: currentRoute,
587
+ routePrefix: config.routePrefix
588
+ }),
589
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("main", {
590
+ className: "clarify-main min-w-0 flex-auto",
591
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PageErrorBoundary, {
592
+ title: text("renderError.title"),
593
+ description: text("renderError.description"),
594
+ reloadLabel: text("renderError.reload"),
595
+ detailsLabel: text("renderError.details"),
596
+ pathLabel: text("renderError.path"),
597
+ typeLabel: text("renderError.type"),
598
+ messageLabel: text("renderError.message"),
599
+ stackLabel: text("renderError.stack"),
600
+ componentStackLabel: text("renderError.componentStack"),
601
+ timestampLabel: text("renderError.timestamp"),
602
+ copyLabel: text("actions.copy"),
603
+ copiedLabel: text("actions.copied"),
604
+ path: pathname,
605
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Suspense, {
606
+ fallback: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PageSkeleton, {}),
607
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_router_dom.Routes, { children: [renderRoutes.map((route) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_router_dom.Route, {
608
+ path: route.path,
609
+ element: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(route.component, {})
610
+ }, route.path)), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_router_dom.Route, {
611
+ path: "*",
612
+ element: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NotFoundRouteElement, { component: NotFoundRouteComponent })
613
+ })] })
614
+ })
615
+ }, pathname)
616
+ }),
617
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PageNavigation, {
618
+ navigation: currentNavigation.items,
619
+ currentRoute
620
+ })
621
+ ]
622
+ })]
623
+ }),
624
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PageFooter, {})
625
+ ]
626
+ })
627
+ });
628
+ }
629
+ //#endregion
630
+ //#region source/theme/randomTheme.ts
631
+ var randomThemePalettes = [
632
+ {
633
+ primary: "#047857",
634
+ accent: "#0D9488",
635
+ background: "#ffffff",
636
+ foreground: "#111827",
637
+ surface: "#ffffff",
638
+ muted: "#64748b",
639
+ borderMix: .12,
640
+ codeMix: .04
641
+ },
642
+ {
643
+ primary: "#2563eb",
644
+ accent: "#7c3aed",
645
+ background: "#f8fafc",
646
+ foreground: "#0f172a",
647
+ surface: "#ffffff",
648
+ muted: "#64748b",
649
+ borderMix: .12,
650
+ codeMix: .05
651
+ },
652
+ {
653
+ primary: "#9333ea",
654
+ accent: "#db2777",
655
+ background: "#fdf4ff",
656
+ foreground: "#2e1065",
657
+ surface: "#ffffff",
658
+ muted: "#7e22ce",
659
+ borderMix: .14,
660
+ codeMix: .06
661
+ },
662
+ {
663
+ primary: "#ea580c",
664
+ accent: "#ca8a04",
665
+ background: "#fff7ed",
666
+ foreground: "#431407",
667
+ surface: "#fffbeb",
668
+ muted: "#9a3412",
669
+ borderMix: .14,
670
+ codeMix: .06
671
+ },
672
+ {
673
+ primary: "#0f766e",
674
+ accent: "#0891b2",
675
+ background: "#f0fdfa",
676
+ foreground: "#042f2e",
677
+ surface: "#ffffff",
678
+ muted: "#0f766e",
679
+ borderMix: .13,
680
+ codeMix: .05
681
+ },
682
+ {
683
+ primary: "#be123c",
684
+ accent: "#f97316",
685
+ background: "#fff1f2",
686
+ foreground: "#4c0519",
687
+ surface: "#ffffff",
688
+ muted: "#9f1239",
689
+ borderMix: .13,
690
+ codeMix: .06
691
+ },
692
+ {
693
+ primary: "#4f46e5",
694
+ accent: "#06b6d4",
695
+ background: "#eef2ff",
696
+ foreground: "#1e1b4b",
697
+ surface: "#ffffff",
698
+ muted: "#4338ca",
699
+ borderMix: .12,
700
+ codeMix: .05
701
+ },
702
+ {
703
+ primary: "#0e7490",
704
+ accent: "#22c55e",
705
+ background: "#ecfeff",
706
+ foreground: "#083344",
707
+ surface: "#ffffff",
708
+ muted: "#155e75",
709
+ borderMix: .13,
710
+ codeMix: .05
711
+ },
712
+ {
713
+ primary: "#7c2d12",
714
+ accent: "#dc2626",
715
+ background: "#fef2f2",
716
+ foreground: "#450a0a",
717
+ surface: "#fff7ed",
718
+ muted: "#991b1b",
719
+ borderMix: .14,
720
+ codeMix: .06
721
+ },
722
+ {
723
+ primary: "#365314",
724
+ accent: "#84cc16",
725
+ background: "#f7fee7",
726
+ foreground: "#1a2e05",
727
+ surface: "#ffffff",
728
+ muted: "#4d7c0f",
729
+ borderMix: .13,
730
+ codeMix: .05
731
+ },
732
+ {
733
+ primary: "#0369a1",
734
+ accent: "#14b8a6",
735
+ background: "#f0f9ff",
736
+ foreground: "#082f49",
737
+ surface: "#ffffff",
738
+ muted: "#075985",
739
+ borderMix: .12,
740
+ codeMix: .05
741
+ },
742
+ {
743
+ primary: "#a21caf",
744
+ accent: "#e879f9",
745
+ background: "#fdf4ff",
746
+ foreground: "#4a044e",
747
+ surface: "#ffffff",
748
+ muted: "#86198f",
749
+ borderMix: .14,
750
+ codeMix: .06
751
+ },
752
+ {
753
+ primary: "#c2410c",
754
+ accent: "#fb7185",
755
+ background: "#fff7ed",
756
+ foreground: "#431407",
757
+ surface: "#ffffff",
758
+ muted: "#9a3412",
759
+ borderMix: .13,
760
+ codeMix: .05
761
+ },
762
+ {
763
+ primary: "#1d4ed8",
764
+ accent: "#f59e0b",
765
+ background: "#eff6ff",
766
+ foreground: "#172554",
767
+ surface: "#ffffff",
768
+ muted: "#1e40af",
769
+ borderMix: .12,
770
+ codeMix: .05
771
+ },
772
+ {
773
+ primary: "#6d28d9",
774
+ accent: "#10b981",
775
+ background: "#faf5ff",
776
+ foreground: "#2e1065",
777
+ surface: "#ffffff",
778
+ muted: "#6b21a8",
779
+ borderMix: .13,
780
+ codeMix: .05
781
+ },
782
+ {
783
+ primary: "#0f172a",
784
+ accent: "#64748b",
785
+ background: "#f8fafc",
786
+ foreground: "#0f172a",
787
+ surface: "#ffffff",
788
+ muted: "#475569",
789
+ borderMix: .12,
790
+ codeMix: .04
791
+ },
792
+ {
793
+ primary: "#18181b",
794
+ accent: "#71717a",
795
+ background: "#fafafa",
796
+ foreground: "#18181b",
797
+ surface: "#ffffff",
798
+ muted: "#52525b",
799
+ borderMix: .12,
800
+ codeMix: .04
801
+ },
802
+ {
803
+ primary: "#166534",
804
+ accent: "#06b6d4",
805
+ background: "#f0fdf4",
806
+ foreground: "#052e16",
807
+ surface: "#ffffff",
808
+ muted: "#15803d",
809
+ borderMix: .13,
810
+ codeMix: .05
811
+ },
812
+ {
813
+ primary: "#9d174d",
814
+ accent: "#8b5cf6",
815
+ background: "#fdf2f8",
816
+ foreground: "#500724",
817
+ surface: "#ffffff",
818
+ muted: "#be185d",
819
+ borderMix: .14,
820
+ codeMix: .06
821
+ },
822
+ {
823
+ primary: "#4338ca",
824
+ accent: "#ec4899",
825
+ background: "#f5f3ff",
826
+ foreground: "#312e81",
827
+ surface: "#ffffff",
828
+ muted: "#4f46e5",
829
+ borderMix: .13,
830
+ codeMix: .05
831
+ },
832
+ {
833
+ primary: "#92400e",
834
+ accent: "#65a30d",
835
+ background: "#fffbeb",
836
+ foreground: "#451a03",
837
+ surface: "#ffffff",
838
+ muted: "#a16207",
839
+ borderMix: .13,
840
+ codeMix: .05
841
+ },
842
+ {
843
+ primary: "#0f766e",
844
+ accent: "#f43f5e",
845
+ background: "#f8fafc",
846
+ foreground: "#134e4a",
847
+ surface: "#ffffff",
848
+ muted: "#0f766e",
849
+ borderMix: .12,
850
+ codeMix: .05
851
+ },
852
+ {
853
+ primary: "#1e3a8a",
854
+ accent: "#0ea5e9",
855
+ background: "#f8fafc",
856
+ foreground: "#0f172a",
857
+ surface: "#ffffff",
858
+ muted: "#475569",
859
+ borderMix: .12,
860
+ codeMix: .04
861
+ },
862
+ {
863
+ primary: "#581c87",
864
+ accent: "#f97316",
865
+ background: "#faf5ff",
866
+ foreground: "#3b0764",
867
+ surface: "#ffffff",
868
+ muted: "#7e22ce",
869
+ borderMix: .14,
870
+ codeMix: .06
871
+ },
872
+ {
873
+ primary: "#991b1b",
874
+ accent: "#facc15",
875
+ background: "#fef2f2",
876
+ foreground: "#450a0a",
877
+ surface: "#ffffff",
878
+ muted: "#b91c1c",
879
+ borderMix: .14,
880
+ codeMix: .06
881
+ },
882
+ {
883
+ primary: "#115e59",
884
+ accent: "#a3e635",
885
+ background: "#f0fdfa",
886
+ foreground: "#042f2e",
887
+ surface: "#ffffff",
888
+ muted: "#0f766e",
889
+ borderMix: .13,
890
+ codeMix: .05
891
+ },
892
+ {
893
+ primary: "#075985",
894
+ accent: "#38bdf8",
895
+ background: "#f0f9ff",
896
+ foreground: "#082f49",
897
+ surface: "#ffffff",
898
+ muted: "#0369a1",
899
+ borderMix: .12,
900
+ codeMix: .05
901
+ },
902
+ {
903
+ primary: "#7e22ce",
904
+ accent: "#f472b6",
905
+ background: "#faf5ff",
906
+ foreground: "#3b0764",
907
+ surface: "#ffffff",
908
+ muted: "#9333ea",
909
+ borderMix: .14,
910
+ codeMix: .06
911
+ },
912
+ {
913
+ primary: "#b45309",
914
+ accent: "#ef4444",
915
+ background: "#fffbeb",
916
+ foreground: "#451a03",
917
+ surface: "#ffffff",
918
+ muted: "#92400e",
919
+ borderMix: .13,
920
+ codeMix: .05
921
+ },
922
+ {
923
+ primary: "#065f46",
924
+ accent: "#2dd4bf",
925
+ background: "#ecfdf5",
926
+ foreground: "#022c22",
927
+ surface: "#ffffff",
928
+ muted: "#047857",
929
+ borderMix: .13,
930
+ codeMix: .05
931
+ },
932
+ {
933
+ primary: "#312e81",
934
+ accent: "#22d3ee",
935
+ background: "#eef2ff",
936
+ foreground: "#1e1b4b",
937
+ surface: "#ffffff",
938
+ muted: "#4338ca",
939
+ borderMix: .13,
940
+ codeMix: .05
941
+ },
942
+ {
943
+ primary: "#831843",
944
+ accent: "#fb923c",
945
+ background: "#fdf2f8",
946
+ foreground: "#500724",
947
+ surface: "#ffffff",
948
+ muted: "#be185d",
949
+ borderMix: .14,
950
+ codeMix: .06
951
+ },
952
+ {
953
+ primary: "#164e63",
954
+ accent: "#818cf8",
955
+ background: "#ecfeff",
956
+ foreground: "#083344",
957
+ surface: "#ffffff",
958
+ muted: "#155e75",
959
+ borderMix: .13,
960
+ codeMix: .05
961
+ },
962
+ {
963
+ primary: "#3f6212",
964
+ accent: "#f97316",
965
+ background: "#f7fee7",
966
+ foreground: "#1a2e05",
967
+ surface: "#ffffff",
968
+ muted: "#4d7c0f",
969
+ borderMix: .13,
970
+ codeMix: .05
971
+ },
972
+ {
973
+ primary: "#1e40af",
974
+ accent: "#fb7185",
975
+ background: "#eff6ff",
976
+ foreground: "#172554",
977
+ surface: "#ffffff",
978
+ muted: "#2563eb",
979
+ borderMix: .12,
980
+ codeMix: .05
981
+ },
982
+ {
983
+ primary: "#701a75",
984
+ accent: "#14b8a6",
985
+ background: "#fdf4ff",
986
+ foreground: "#4a044e",
987
+ surface: "#ffffff",
988
+ muted: "#a21caf",
989
+ borderMix: .14,
990
+ codeMix: .06
991
+ },
992
+ {
993
+ primary: "#713f12",
994
+ accent: "#eab308",
995
+ background: "#fefce8",
996
+ foreground: "#422006",
997
+ surface: "#ffffff",
998
+ muted: "#a16207",
999
+ borderMix: .13,
1000
+ codeMix: .05
1001
+ },
1002
+ {
1003
+ primary: "#1f2937",
1004
+ accent: "#0ea5e9",
1005
+ background: "#f9fafb",
1006
+ foreground: "#111827",
1007
+ surface: "#ffffff",
1008
+ muted: "#4b5563",
1009
+ borderMix: .12,
1010
+ codeMix: .04
1011
+ },
1012
+ {
1013
+ primary: "#27272a",
1014
+ accent: "#a855f7",
1015
+ background: "#fafafa",
1016
+ foreground: "#18181b",
1017
+ surface: "#ffffff",
1018
+ muted: "#52525b",
1019
+ borderMix: .12,
1020
+ codeMix: .04
1021
+ },
1022
+ {
1023
+ primary: "#374151",
1024
+ accent: "#10b981",
1025
+ background: "#f3f4f6",
1026
+ foreground: "#111827",
1027
+ surface: "#ffffff",
1028
+ muted: "#4b5563",
1029
+ borderMix: .12,
1030
+ codeMix: .04
1031
+ },
1032
+ {
1033
+ primary: "#064e3b",
1034
+ accent: "#f59e0b",
1035
+ background: "#f8fafc",
1036
+ foreground: "#022c22",
1037
+ surface: "#ffffff",
1038
+ muted: "#047857",
1039
+ borderMix: .12,
1040
+ codeMix: .05
1041
+ },
1042
+ {
1043
+ primary: "#7f1d1d",
1044
+ accent: "#60a5fa",
1045
+ background: "#fff7ed",
1046
+ foreground: "#450a0a",
1047
+ surface: "#ffffff",
1048
+ muted: "#991b1b",
1049
+ borderMix: .14,
1050
+ codeMix: .06
1051
+ },
1052
+ {
1053
+ primary: "#3730a3",
1054
+ accent: "#34d399",
1055
+ background: "#f8fafc",
1056
+ foreground: "#1e1b4b",
1057
+ surface: "#ffffff",
1058
+ muted: "#4f46e5",
1059
+ borderMix: .12,
1060
+ codeMix: .05
1061
+ },
1062
+ {
1063
+ primary: "#9f1239",
1064
+ accent: "#22c55e",
1065
+ background: "#fff1f2",
1066
+ foreground: "#4c0519",
1067
+ surface: "#ffffff",
1068
+ muted: "#be123c",
1069
+ borderMix: .14,
1070
+ codeMix: .06
1071
+ },
1072
+ {
1073
+ primary: "#134e4a",
1074
+ accent: "#8b5cf6",
1075
+ background: "#f0fdfa",
1076
+ foreground: "#042f2e",
1077
+ surface: "#ffffff",
1078
+ muted: "#0f766e",
1079
+ borderMix: .13,
1080
+ codeMix: .05
1081
+ },
1082
+ {
1083
+ primary: "#1d4ed8",
1084
+ accent: "#dc2626",
1085
+ background: "#f8fafc",
1086
+ foreground: "#0f172a",
1087
+ surface: "#ffffff",
1088
+ muted: "#475569",
1089
+ borderMix: .12,
1090
+ codeMix: .05
1091
+ },
1092
+ {
1093
+ primary: "#6b21a8",
1094
+ accent: "#fbbf24",
1095
+ background: "#faf5ff",
1096
+ foreground: "#2e1065",
1097
+ surface: "#ffffff",
1098
+ muted: "#7e22ce",
1099
+ borderMix: .14,
1100
+ codeMix: .06
1101
+ },
1102
+ {
1103
+ primary: "#155e75",
1104
+ accent: "#84cc16",
1105
+ background: "#f0f9ff",
1106
+ foreground: "#083344",
1107
+ surface: "#ffffff",
1108
+ muted: "#0369a1",
1109
+ borderMix: .13,
1110
+ codeMix: .05
1111
+ },
1112
+ {
1113
+ primary: "#854d0e",
1114
+ accent: "#06b6d4",
1115
+ background: "#fefce8",
1116
+ foreground: "#422006",
1117
+ surface: "#ffffff",
1118
+ muted: "#a16207",
1119
+ borderMix: .13,
1120
+ codeMix: .05
1121
+ },
1122
+ {
1123
+ primary: "#14532d",
1124
+ accent: "#f43f5e",
1125
+ background: "#f0fdf4",
1126
+ foreground: "#052e16",
1127
+ surface: "#ffffff",
1128
+ muted: "#166534",
1129
+ borderMix: .13,
1130
+ codeMix: .05
1131
+ },
1132
+ {
1133
+ primary: "#4c1d95",
1134
+ accent: "#2dd4bf",
1135
+ background: "#f5f3ff",
1136
+ foreground: "#2e1065",
1137
+ surface: "#ffffff",
1138
+ muted: "#6d28d9",
1139
+ borderMix: .14,
1140
+ codeMix: .06
1141
+ },
1142
+ {
1143
+ primary: "#9a3412",
1144
+ accent: "#c084fc",
1145
+ background: "#fff7ed",
1146
+ foreground: "#431407",
1147
+ surface: "#ffffff",
1148
+ muted: "#c2410c",
1149
+ borderMix: .13,
1150
+ codeMix: .05
1151
+ },
1152
+ {
1153
+ primary: "#0c4a6e",
1154
+ accent: "#f472b6",
1155
+ background: "#f0f9ff",
1156
+ foreground: "#082f49",
1157
+ surface: "#ffffff",
1158
+ muted: "#075985",
1159
+ borderMix: .13,
1160
+ codeMix: .05
1161
+ },
1162
+ {
1163
+ primary: "#166534",
1164
+ accent: "#facc15",
1165
+ background: "#f7fee7",
1166
+ foreground: "#052e16",
1167
+ surface: "#ffffff",
1168
+ muted: "#15803d",
1169
+ borderMix: .13,
1170
+ codeMix: .05
1171
+ },
1172
+ {
1173
+ primary: "#be185d",
1174
+ accent: "#38bdf8",
1175
+ background: "#fdf2f8",
1176
+ foreground: "#500724",
1177
+ surface: "#ffffff",
1178
+ muted: "#9d174d",
1179
+ borderMix: .14,
1180
+ codeMix: .06
1181
+ },
1182
+ {
1183
+ primary: "#5b21b6",
1184
+ accent: "#ef4444",
1185
+ background: "#f5f3ff",
1186
+ foreground: "#2e1065",
1187
+ surface: "#ffffff",
1188
+ muted: "#6d28d9",
1189
+ borderMix: .14,
1190
+ codeMix: .06
1191
+ }
1192
+ ];
1193
+ var randomRadiusSets = [
1194
+ {
1195
+ sm: "2px",
1196
+ md: "6px",
1197
+ lg: "10px",
1198
+ xl: "14px"
1199
+ },
1200
+ {
1201
+ sm: "4px",
1202
+ md: "8px",
1203
+ lg: "12px",
1204
+ xl: "16px"
1205
+ },
1206
+ {
1207
+ sm: "6px",
1208
+ md: "10px",
1209
+ lg: "14px",
1210
+ xl: "18px"
1211
+ },
1212
+ {
1213
+ sm: "8px",
1214
+ md: "12px",
1215
+ lg: "18px",
1216
+ xl: "24px"
1217
+ },
1218
+ {
1219
+ sm: "10px",
1220
+ md: "14px",
1221
+ lg: "20px",
1222
+ xl: "28px"
1223
+ },
1224
+ {
1225
+ sm: "12px",
1226
+ md: "16px",
1227
+ lg: "24px",
1228
+ xl: "32px"
1229
+ }
1230
+ ];
1231
+ var randomLayoutWidths = [
1232
+ "72rem",
1233
+ "76rem",
1234
+ "78rem",
1235
+ "80rem",
1236
+ "82rem",
1237
+ "86rem",
1238
+ "90rem",
1239
+ "96rem",
1240
+ "104rem",
1241
+ "112rem",
1242
+ "120rem",
1243
+ "128rem",
1244
+ "144rem"
1245
+ ];
1246
+ function randomItem(items) {
1247
+ return items[Math.floor(Math.random() * items.length)];
1248
+ }
1249
+ function randomRgbMix(color, alpha) {
1250
+ return `color-mix(in srgb, ${color} ${Math.round(alpha * 100)}%, transparent)`;
1251
+ }
1252
+ function modeColor(light, dark) {
1253
+ return {
1254
+ light,
1255
+ dark
1256
+ };
1257
+ }
1258
+ function createRandomTheme() {
1259
+ const palette = randomItem(randomThemePalettes);
1260
+ const radius = randomItem(randomRadiusSets);
1261
+ const maxWidth = randomItem(randomLayoutWidths);
1262
+ return {
1263
+ preset: "default",
1264
+ tokens: {
1265
+ colors: {
1266
+ primary: modeColor(palette.primary, palette.accent),
1267
+ accent: modeColor(palette.accent, palette.primary),
1268
+ background: modeColor(palette.background, "#09090b"),
1269
+ foreground: modeColor(palette.foreground, "#f8fafc"),
1270
+ surface: modeColor(palette.surface, "#18181b"),
1271
+ muted: modeColor(palette.muted, "#a1a1aa"),
1272
+ border: modeColor(randomRgbMix(palette.foreground, palette.borderMix), "rgb(255 255 255 / 0.1)"),
1273
+ codeBackground: modeColor(randomRgbMix(palette.primary, palette.codeMix), "#18181b")
1274
+ },
1275
+ radius: { ...radius }
1276
+ },
1277
+ layout: { maxWidth },
1278
+ editor: false
1279
+ };
1280
+ }
1281
+ //#endregion
1282
+ //#region source/theme/variables.ts
1283
+ var clarifyThemePresets = {
1284
+ default: {
1285
+ preset: "default",
1286
+ tokens: {
1287
+ colors: {
1288
+ primary: "#047857",
1289
+ accent: "#0D9488",
1290
+ background: "#ffffff",
1291
+ foreground: "#111827",
1292
+ surface: "#ffffff",
1293
+ muted: "#64748b",
1294
+ border: "rgb(15 23 42 / 0.12)",
1295
+ codeBackground: "#f6fbf8"
1296
+ },
1297
+ radius: {
1298
+ sm: "6px",
1299
+ md: "10px",
1300
+ lg: "14px",
1301
+ xl: "18px"
1302
+ }
1303
+ },
1304
+ layout: { maxWidth: "82rem" },
1305
+ editor: false
1306
+ },
1307
+ base: {
1308
+ preset: "base",
1309
+ tokens: {
1310
+ colors: {
1311
+ primary: "#18181b",
1312
+ accent: "#52525b",
1313
+ background: "#ffffff",
1314
+ foreground: "#18181b",
1315
+ surface: "#ffffff",
1316
+ muted: "#71717a",
1317
+ border: "rgb(24 24 27 / 0.12)",
1318
+ codeBackground: "#f4f4f5"
1319
+ },
1320
+ radius: {
1321
+ sm: "6px",
1322
+ md: "8px",
1323
+ lg: "12px",
1324
+ xl: "16px"
1325
+ }
1326
+ },
1327
+ layout: { maxWidth: "80rem" },
1328
+ editor: false
1329
+ }
1330
+ };
1331
+ function cloneThemeColorValue(value) {
1332
+ return typeof value === "string" ? value : { ...value };
1333
+ }
1334
+ function cloneTheme(theme) {
1335
+ return {
1336
+ preset: theme.preset,
1337
+ tokens: {
1338
+ colors: {
1339
+ primary: cloneThemeColorValue(theme.tokens.colors.primary),
1340
+ accent: cloneThemeColorValue(theme.tokens.colors.accent),
1341
+ background: cloneThemeColorValue(theme.tokens.colors.background),
1342
+ foreground: cloneThemeColorValue(theme.tokens.colors.foreground),
1343
+ surface: cloneThemeColorValue(theme.tokens.colors.surface),
1344
+ muted: cloneThemeColorValue(theme.tokens.colors.muted),
1345
+ border: cloneThemeColorValue(theme.tokens.colors.border),
1346
+ codeBackground: cloneThemeColorValue(theme.tokens.colors.codeBackground)
1347
+ },
1348
+ radius: { ...theme.tokens.radius }
1349
+ },
1350
+ layout: { ...theme.layout },
1351
+ editor: theme.editor
1352
+ };
1353
+ }
1354
+ function isModeColorValue(value) {
1355
+ return typeof value === "object" && value !== null;
1356
+ }
1357
+ function resolveThemeColorValue(value, resolvedTheme = "light") {
1358
+ if (!isModeColorValue(value)) return value;
1359
+ return value[resolvedTheme] ?? value.light ?? value.dark ?? "";
1360
+ }
1361
+ function resolveThemeColors(colors, resolvedTheme = "light") {
1362
+ return {
1363
+ primary: resolveThemeColorValue(colors.primary, resolvedTheme),
1364
+ accent: resolveThemeColorValue(colors.accent, resolvedTheme),
1365
+ background: resolveThemeColorValue(colors.background, resolvedTheme),
1366
+ foreground: resolveThemeColorValue(colors.foreground, resolvedTheme),
1367
+ surface: resolveThemeColorValue(colors.surface, resolvedTheme),
1368
+ muted: resolveThemeColorValue(colors.muted, resolvedTheme),
1369
+ border: resolveThemeColorValue(colors.border, resolvedTheme),
1370
+ codeBackground: resolveThemeColorValue(colors.codeBackground, resolvedTheme)
1371
+ };
1372
+ }
1373
+ function matchesPresetTheme(theme) {
1374
+ const preset = clarifyThemePresets[theme.preset];
1375
+ return JSON.stringify({
1376
+ tokens: theme.tokens,
1377
+ layout: theme.layout
1378
+ }) === JSON.stringify({
1379
+ tokens: preset.tokens,
1380
+ layout: preset.layout
1381
+ });
1382
+ }
1383
+ function effectiveTheme(theme, resolvedTheme) {
1384
+ if (resolvedTheme !== "dark" || !matchesPresetTheme(theme)) return theme;
1385
+ return {
1386
+ ...theme,
1387
+ tokens: {
1388
+ ...theme.tokens,
1389
+ colors: {
1390
+ ...theme.tokens.colors,
1391
+ background: "#09090b",
1392
+ foreground: "#ffffff",
1393
+ surface: "#18181b",
1394
+ muted: "#a1a1aa",
1395
+ border: "rgb(255 255 255 / 0.1)",
1396
+ codeBackground: "#18181b"
1397
+ }
1398
+ }
1399
+ };
1400
+ }
1401
+ function themeToCssVariables(theme, resolvedTheme) {
1402
+ const resolved = effectiveTheme(theme, resolvedTheme);
1403
+ const colors = resolveThemeColors(resolved.tokens.colors, resolvedTheme);
1404
+ const { radius } = resolved.tokens;
1405
+ return {
1406
+ "--clarify-theme-tokens-colors-primary": colors.primary,
1407
+ "--clarify-theme-tokens-colors-accent": colors.accent,
1408
+ "--clarify-theme-tokens-colors-background": colors.background,
1409
+ "--clarify-theme-tokens-colors-foreground": colors.foreground,
1410
+ "--clarify-theme-tokens-colors-surface": colors.surface,
1411
+ "--clarify-theme-tokens-colors-muted": colors.muted,
1412
+ "--clarify-theme-tokens-colors-border": colors.border,
1413
+ "--clarify-theme-tokens-colors-code-background": colors.codeBackground,
1414
+ "--clarify-theme-tokens-radius-sm": radius.sm,
1415
+ "--clarify-theme-tokens-radius-md": radius.md,
1416
+ "--clarify-theme-tokens-radius-lg": radius.lg,
1417
+ "--clarify-theme-tokens-radius-xl": radius.xl,
1418
+ "--clarify-theme-layout-max-width": resolved.layout.maxWidth
1419
+ };
1420
+ }
1421
+ function uniqueElements(elements) {
1422
+ return Array.from(new Set(elements));
1423
+ }
1424
+ function resolveThemeVariableTargets(target) {
1425
+ if (typeof document === "undefined") return [];
1426
+ if (target instanceof HTMLElement) return [target];
1427
+ if (typeof target === "string") return Array.from(document.querySelectorAll(target));
1428
+ return uniqueElements([document.documentElement, ...Array.from(document.querySelectorAll(".clarify-app"))]);
1429
+ }
1430
+ function applyThemeCssVariables(variables, targets) {
1431
+ const previousValues = /* @__PURE__ */ new Map();
1432
+ for (const element of targets) {
1433
+ const elementPreviousValues = /* @__PURE__ */ new Map();
1434
+ for (const [property, value] of Object.entries(variables)) {
1435
+ elementPreviousValues.set(property, element.style.getPropertyValue(property));
1436
+ element.style.setProperty(property, value);
1437
+ }
1438
+ previousValues.set(element, elementPreviousValues);
1439
+ }
1440
+ return () => {
1441
+ for (const [element, elementPreviousValues] of previousValues) for (const [property, previousValue] of elementPreviousValues) if (previousValue) element.style.setProperty(property, previousValue);
1442
+ else element.style.removeProperty(property);
1443
+ };
1444
+ }
1445
+ //#endregion
1446
+ //#region source/theme/ThemeEditor.tsx
1447
+ var colorTokenFields = [
1448
+ {
1449
+ key: "primary",
1450
+ label: "Primary"
1451
+ },
1452
+ {
1453
+ key: "accent",
1454
+ label: "Accent"
1455
+ },
1456
+ {
1457
+ key: "background",
1458
+ label: "Background"
1459
+ },
1460
+ {
1461
+ key: "foreground",
1462
+ label: "Foreground"
1463
+ },
1464
+ {
1465
+ key: "surface",
1466
+ label: "Surface"
1467
+ },
1468
+ {
1469
+ key: "muted",
1470
+ label: "Muted"
1471
+ },
1472
+ {
1473
+ key: "border",
1474
+ label: "Border"
1475
+ },
1476
+ {
1477
+ key: "codeBackground",
1478
+ label: "Code background"
1479
+ }
1480
+ ];
1481
+ var radiusTokenFields = [
1482
+ {
1483
+ key: "sm",
1484
+ label: "Small"
1485
+ },
1486
+ {
1487
+ key: "md",
1488
+ label: "Medium"
1489
+ },
1490
+ {
1491
+ key: "lg",
1492
+ label: "Large"
1493
+ },
1494
+ {
1495
+ key: "xl",
1496
+ label: "Extra large"
1497
+ }
1498
+ ];
1499
+ var layoutFields = [{
1500
+ key: "maxWidth",
1501
+ label: "Max width"
1502
+ }];
1503
+ var clarifyThemeEditorPresets = clarifyThemePresets;
1504
+ function applyClarifyThemeVariables(theme, target) {
1505
+ return applyThemeCssVariables(themeToCssVariables(theme), resolveThemeVariableTargets(target));
1506
+ }
1507
+ function isHexColor(value) {
1508
+ return /^#[0-9a-f]{6}$/i.test(value);
1509
+ }
1510
+ function updateThemeModeColorValue(value, resolvedTheme, nextValue) {
1511
+ if (typeof value === "string") return nextValue;
1512
+ return {
1513
+ ...value,
1514
+ [resolvedTheme]: nextValue
1515
+ };
1516
+ }
1517
+ function TextField(props) {
1518
+ const { id, label, value, onChange, withColorInput = false } = props;
1519
+ const canUseColorInput = withColorInput && isHexColor(value);
1520
+ function handleTextChange(event) {
1521
+ onChange(event.target.value);
1522
+ }
1523
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
1524
+ htmlFor: id,
1525
+ className: "grid min-w-0 gap-1.5 text-xs/5 font-medium text-(--clarify-ui-text)",
1526
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1527
+ className: "flex min-w-0 items-center justify-between gap-3",
1528
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1529
+ className: "truncate",
1530
+ children: label
1531
+ }), canUseColorInput ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1532
+ type: "color",
1533
+ value,
1534
+ "aria-label": `${label} color`,
1535
+ className: "h-5 w-8 shrink-0 cursor-pointer rounded border border-(--clarify-theme-tokens-colors-border) bg-transparent p-0",
1536
+ onChange: handleTextChange
1537
+ }) : null]
1538
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1539
+ id,
1540
+ value,
1541
+ spellCheck: false,
1542
+ className: "h-9 w-full min-w-0 rounded-(--clarify-theme-tokens-radius-md) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-background) px-2.5 font-mono text-xs text-(--clarify-theme-tokens-colors-foreground) shadow-xs outline-none transition focus:border-(--clarify-theme-tokens-colors-primary) focus:ring-2 focus:ring-(--clarify-ui-accent-border)",
1543
+ onChange: handleTextChange
1544
+ })]
1545
+ });
1546
+ }
1547
+ function themeToConfigSource(theme) {
1548
+ return JSON.stringify({ theme: {
1549
+ preset: theme.preset,
1550
+ tokens: theme.tokens,
1551
+ layout: theme.layout
1552
+ } }, null, 2);
1553
+ }
1554
+ function ThemeEditor(props) {
1555
+ const { initialTheme, onChange, target, defaultOpen = false, className } = props;
1556
+ const { resolvedTheme } = require_shell.useTheme();
1557
+ const [isOpen, setIsOpen] = (0, react.useState)(defaultOpen);
1558
+ const [theme, setTheme] = (0, react.useState)(() => cloneTheme(initialTheme ?? clarifyThemeEditorPresets.default));
1559
+ const [copyState, setCopyState] = (0, react.useState)("idle");
1560
+ const configSource = (0, react.useMemo)(() => themeToConfigSource(theme), [theme]);
1561
+ (0, react.useEffect)(() => applyThemeCssVariables(themeToCssVariables(theme, resolvedTheme), resolveThemeVariableTargets(target)), [
1562
+ resolvedTheme,
1563
+ target,
1564
+ theme
1565
+ ]);
1566
+ function commit(nextTheme) {
1567
+ setTheme(nextTheme);
1568
+ onChange?.(nextTheme);
1569
+ }
1570
+ function updatePreset(nextPreset) {
1571
+ commit(cloneTheme(clarifyThemeEditorPresets[nextPreset]));
1572
+ }
1573
+ function updateColorToken(key, value) {
1574
+ commit({
1575
+ ...theme,
1576
+ tokens: {
1577
+ ...theme.tokens,
1578
+ colors: {
1579
+ ...theme.tokens.colors,
1580
+ [key]: updateThemeModeColorValue(theme.tokens.colors[key], resolvedTheme, value)
1581
+ }
1582
+ }
1583
+ });
1584
+ }
1585
+ function updateRadiusToken(key, value) {
1586
+ commit({
1587
+ ...theme,
1588
+ tokens: {
1589
+ ...theme.tokens,
1590
+ radius: {
1591
+ ...theme.tokens.radius,
1592
+ [key]: value
1593
+ }
1594
+ }
1595
+ });
1596
+ }
1597
+ function updateLayoutToken(key, value) {
1598
+ commit({
1599
+ ...theme,
1600
+ layout: {
1601
+ ...theme.layout,
1602
+ [key]: value
1603
+ }
1604
+ });
1605
+ }
1606
+ async function copyConfig() {
1607
+ try {
1608
+ await navigator.clipboard.writeText(configSource);
1609
+ setCopyState("copied");
1610
+ window.setTimeout(() => setCopyState("idle"), 1400);
1611
+ } catch {
1612
+ setCopyState("failed");
1613
+ window.setTimeout(() => setCopyState("idle"), 1400);
1614
+ }
1615
+ }
1616
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1617
+ className: (0, clsx.default)("clarify-theme-editor fixed right-4 bottom-4 z-50 text-(--clarify-theme-tokens-colors-foreground)", className),
1618
+ children: [isOpen ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
1619
+ className: "mb-3 flex max-h-(--clarify-theme-editor-panel-max-height) w-(--clarify-theme-editor-width) flex-col overflow-hidden rounded-md border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface)/95 shadow-2xl shadow-zinc-900/15 backdrop-blur",
1620
+ "aria-label": "Clarify theme editor",
1621
+ children: [
1622
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", {
1623
+ className: "shrink-0 flex items-start justify-between gap-4 border-b border-(--clarify-theme-tokens-colors-border) px-4 py-3",
1624
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
1625
+ className: "text-sm/6 font-semibold text-(--clarify-theme-tokens-colors-foreground)",
1626
+ children: "Theme editor"
1627
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1628
+ className: "mt-0.5 text-xs/5 text-(--clarify-ui-text-soft)",
1629
+ children: "Live CSS variable preview for Clarify theme tokens."
1630
+ })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1631
+ type: "button",
1632
+ className: "-mr-1 flex size-8 items-center justify-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-ui-text-soft) transition hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-ui-text-strong)",
1633
+ "aria-label": "Close theme editor",
1634
+ onClick: () => setIsOpen(false),
1635
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, { className: "size-4 stroke-current stroke-2" })
1636
+ })]
1637
+ }),
1638
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1639
+ className: "min-h-0 flex-1 overflow-y-auto px-4 py-4",
1640
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1641
+ className: "grid gap-5",
1642
+ children: [
1643
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
1644
+ htmlFor: "clarify-theme-editor-preset",
1645
+ className: "grid gap-1.5 text-xs/5 font-medium text-(--clarify-ui-text)",
1646
+ children: ["Preset", /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1647
+ className: "relative block",
1648
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
1649
+ id: "clarify-theme-editor-preset",
1650
+ value: theme.preset,
1651
+ className: "h-9 w-full appearance-none rounded-(--clarify-theme-tokens-radius-md) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-background) px-2.5 pr-9 text-sm text-(--clarify-theme-tokens-colors-foreground) shadow-xs outline-none transition focus:border-(--clarify-theme-tokens-colors-primary) focus:ring-2 focus:ring-(--clarify-ui-accent-border)",
1652
+ onChange: (event) => updatePreset(event.target.value),
1653
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
1654
+ value: "default",
1655
+ children: "default"
1656
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
1657
+ value: "base",
1658
+ children: "base"
1659
+ })]
1660
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, { className: "pointer-events-none absolute top-1/2 right-3 size-4 -translate-y-1/2 stroke-current stroke-2 text-(--clarify-ui-text-faint)" })]
1661
+ })]
1662
+ }),
1663
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("fieldset", {
1664
+ className: "grid gap-3",
1665
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("legend", {
1666
+ className: "mb-2 text-xs/5 font-semibold uppercase tracking-wide text-(--clarify-ui-text-faint)",
1667
+ children: "Colors"
1668
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1669
+ className: "grid grid-cols-1 gap-3",
1670
+ children: colorTokenFields.map((field) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextField, {
1671
+ id: `clarify-theme-editor-color-${field.key}`,
1672
+ label: field.label,
1673
+ value: resolveThemeColorValue(theme.tokens.colors[field.key], resolvedTheme),
1674
+ withColorInput: true,
1675
+ onChange: (value) => updateColorToken(field.key, value)
1676
+ }, field.key))
1677
+ })]
1678
+ }),
1679
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("fieldset", {
1680
+ className: "grid gap-3",
1681
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("legend", {
1682
+ className: "mb-2 text-xs/5 font-semibold uppercase tracking-wide text-(--clarify-ui-text-faint)",
1683
+ children: "Radius"
1684
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1685
+ className: "grid grid-cols-2 gap-3",
1686
+ children: radiusTokenFields.map((field) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextField, {
1687
+ id: `clarify-theme-editor-radius-${field.key}`,
1688
+ label: field.label,
1689
+ value: theme.tokens.radius[field.key],
1690
+ onChange: (value) => updateRadiusToken(field.key, value)
1691
+ }, field.key))
1692
+ })]
1693
+ }),
1694
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("fieldset", {
1695
+ className: "grid gap-3",
1696
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("legend", {
1697
+ className: "mb-2 text-xs/5 font-semibold uppercase tracking-wide text-(--clarify-ui-text-faint)",
1698
+ children: "Layout"
1699
+ }), layoutFields.map((field) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextField, {
1700
+ id: `clarify-theme-editor-layout-${field.key}`,
1701
+ label: field.label,
1702
+ value: theme.layout[field.key],
1703
+ onChange: (value) => updateLayoutToken(field.key, value)
1704
+ }, field.key))]
1705
+ })
1706
+ ]
1707
+ })
1708
+ }),
1709
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("footer", {
1710
+ className: "shrink-0 flex items-center justify-between gap-3 border-t border-(--clarify-theme-tokens-colors-border) bg-(--clarify-ui-subtle-background) px-4 py-3",
1711
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1712
+ className: "flex items-center gap-1.5",
1713
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1714
+ type: "button",
1715
+ className: "rounded-(--clarify-theme-tokens-radius-md) px-2.5 py-1.5 text-xs/5 font-semibold text-(--clarify-ui-text) transition hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-ui-text-strong)",
1716
+ onClick: () => updatePreset(theme.preset),
1717
+ children: "Reset preset"
1718
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1719
+ type: "button",
1720
+ className: "inline-flex items-center gap-1.5 rounded-(--clarify-theme-tokens-radius-md) px-2.5 py-1.5 text-xs/5 font-semibold text-(--clarify-ui-text) transition hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-ui-text-strong)",
1721
+ onClick: () => commit(createRandomTheme()),
1722
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.WandSparkles, { className: "size-3.5 stroke-current stroke-2" }), "Random"]
1723
+ })]
1724
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1725
+ type: "button",
1726
+ className: "rounded-(--clarify-theme-tokens-radius-md) bg-(--clarify-theme-tokens-colors-primary) px-3 py-1.5 text-xs/5 font-semibold text-white shadow-xs transition hover:opacity-90",
1727
+ onClick: copyConfig,
1728
+ children: copyState === "copied" ? "Copied" : copyState === "failed" ? "Copy failed" : "Copy config"
1729
+ })]
1730
+ })
1731
+ ]
1732
+ }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1733
+ type: "button",
1734
+ className: "ml-auto flex size-12 items-center justify-center rounded-full border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface)/95 text-(--clarify-theme-tokens-colors-primary) shadow-xl shadow-zinc-900/15 backdrop-blur transition hover:scale-105 hover:bg-(--clarify-ui-accent-background) focus:outline-none focus:ring-2 focus:ring-(--clarify-ui-accent-border)",
1735
+ "aria-label": isOpen ? "Close Clarify theme editor" : "Open Clarify theme editor",
1736
+ "aria-expanded": isOpen,
1737
+ onClick: () => setIsOpen((value) => !value),
1738
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Settings, { className: "size-5 stroke-current stroke-2" })
1739
+ })]
1740
+ });
1741
+ }
1742
+ //#endregion
1743
+ //#region source/theme/ThemeRoot.tsx
1744
+ function ThemeRoot(props) {
1745
+ const { children, theme, themeEditor = false } = props;
1746
+ const { resolvedTheme } = require_shell.useTheme();
1747
+ const themeVariables = (0, react.useMemo)(() => themeToCssVariables(theme, resolvedTheme), [resolvedTheme, theme]);
1748
+ (0, react.useEffect)(() => applyThemeCssVariables(themeVariables, resolveThemeVariableTargets(":root")), [themeVariables]);
1749
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1750
+ className: "clarify-app h-full min-h-screen bg-(--clarify-theme-tokens-colors-background) text-(--clarify-theme-tokens-colors-foreground)",
1751
+ "data-theme-preset": theme.preset,
1752
+ style: themeVariables,
1753
+ children: [children, themeEditor ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThemeEditor, { initialTheme: theme }) : null]
1754
+ });
1755
+ }
1756
+ //#endregion
1757
+ Object.defineProperty(exports, "AppShell", {
1758
+ enumerable: true,
1759
+ get: function() {
1760
+ return AppShell;
1761
+ }
1762
+ });
1763
+ Object.defineProperty(exports, "BuiltWithClarify", {
1764
+ enumerable: true,
1765
+ get: function() {
1766
+ return BuiltWithClarify;
1767
+ }
1768
+ });
1769
+ Object.defineProperty(exports, "PageFooter", {
1770
+ enumerable: true,
1771
+ get: function() {
1772
+ return PageFooter;
1773
+ }
1774
+ });
1775
+ Object.defineProperty(exports, "ThemeEditor", {
1776
+ enumerable: true,
1777
+ get: function() {
1778
+ return ThemeEditor;
1779
+ }
1780
+ });
1781
+ Object.defineProperty(exports, "ThemeRoot", {
1782
+ enumerable: true,
1783
+ get: function() {
1784
+ return ThemeRoot;
1785
+ }
1786
+ });
1787
+ Object.defineProperty(exports, "applyClarifyThemeVariables", {
1788
+ enumerable: true,
1789
+ get: function() {
1790
+ return applyClarifyThemeVariables;
1791
+ }
1792
+ });
1793
+ Object.defineProperty(exports, "clarifyThemeEditorPresets", {
1794
+ enumerable: true,
1795
+ get: function() {
1796
+ return clarifyThemeEditorPresets;
1797
+ }
1798
+ });
1799
+
1800
+ //# sourceMappingURL=ThemeRoot-BhP5M3Hd.cjs.map