@clarify-labs/renderer 0.6.3 → 0.6.5

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