nish-ui 1.9.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +218 -58
- package/dist/base-tailwind.css +1757 -0
- package/dist/base.css +1590 -1445
- package/dist/chart.d.ts +4 -1
- package/dist/chart.js +122 -49
- package/dist/elements-all.d.ts +8 -0
- package/dist/elements-all.js +178 -0
- package/dist/elements-charts.d.ts +71 -0
- package/dist/elements-charts.js +56 -57
- package/dist/elements-data.d.ts +71 -0
- package/dist/elements-data.js +5 -6
- package/dist/elements-forms.d.ts +71 -0
- package/dist/elements-forms.js +24 -25
- package/dist/elements.d.ts +71 -0
- package/dist/elements.js +4 -5
- package/dist/esm/chart-values.js +58 -0
- package/dist/esm/chart.js +10 -0
- package/dist/esm/cn.js +19 -0
- package/dist/esm/combobox-filter.js +13 -0
- package/dist/esm/components/accordion.js +166 -0
- package/dist/esm/components/app-shell.js +198 -0
- package/dist/esm/components/avatar-classes.js +28 -0
- package/dist/esm/components/avatar.js +113 -0
- package/dist/esm/components/breadcrumbs.js +154 -0
- package/dist/esm/components/canvas/follow-caption.js +32 -0
- package/dist/esm/components/canvas/follow.js +119 -0
- package/dist/esm/components/canvas/icons.js +70 -0
- package/dist/esm/components/canvas/index.js +10 -0
- package/dist/esm/components/canvas/layout.js +258 -0
- package/dist/esm/components/canvas/legend.js +93 -0
- package/dist/esm/components/canvas/minimap.js +127 -0
- package/dist/esm/components/canvas/node.js +87 -0
- package/dist/esm/components/canvas/route.js +262 -0
- package/dist/esm/components/canvas/system-canvas.js +837 -0
- package/dist/esm/components/canvas/types.js +10 -0
- package/dist/esm/components/canvas/view.js +47 -0
- package/dist/esm/components/chart-hooks.js +19 -0
- package/dist/esm/components/charts.js +467 -0
- package/dist/esm/components/client.js +24 -0
- package/dist/esm/components/combobox.js +343 -0
- package/dist/esm/components/command.js +403 -0
- package/dist/esm/components/data-classes.js +159 -0
- package/dist/esm/components/data.js +517 -0
- package/dist/esm/components/display-classes.js +130 -0
- package/dist/esm/components/display.js +755 -0
- package/dist/esm/components/error-boundary.js +64 -0
- package/dist/esm/components/feedback.js +136 -0
- package/dist/esm/components/file-dropzone.js +184 -0
- package/dist/esm/components/filters.js +108 -0
- package/dist/esm/components/flow.js +746 -0
- package/dist/esm/components/forms-classes.js +43 -0
- package/dist/esm/components/forms.js +581 -0
- package/dist/esm/components/hooks-classes.js +9 -0
- package/dist/esm/components/hooks.js +236 -0
- package/dist/esm/components/icons.js +96 -0
- package/dist/esm/components/inbox-classes.js +29 -0
- package/dist/esm/components/inbox.js +257 -0
- package/dist/esm/components/latest.js +13 -0
- package/dist/esm/components/layout-vars.js +96 -0
- package/dist/esm/components/layout.js +272 -0
- package/dist/esm/components/media.js +143 -0
- package/dist/esm/components/nav.js +614 -0
- package/dist/esm/components/overlay-classes.js +66 -0
- package/dist/esm/components/overlay.js +1447 -0
- package/dist/esm/components/pagination-classes.js +29 -0
- package/dist/esm/components/pagination.js +154 -0
- package/dist/esm/components/portal.js +16 -0
- package/dist/esm/components/primitives-classes.js +198 -0
- package/dist/esm/components/primitives.js +268 -0
- package/dist/esm/components/progress.js +77 -0
- package/dist/esm/components/provider.js +32 -0
- package/dist/esm/components/radio-group.js +186 -0
- package/dist/esm/components/resource-classes.js +133 -0
- package/dist/esm/components/resource.js +209 -0
- package/dist/esm/components/segmented.js +178 -0
- package/dist/esm/components/separator.js +38 -0
- package/dist/esm/components/service-tokens.js +221 -0
- package/dist/esm/components/settings.js +301 -0
- package/dist/esm/components/slider.js +262 -0
- package/dist/esm/components/split-classes.js +8 -0
- package/dist/esm/components/split.js +411 -0
- package/dist/esm/components/strings.js +119 -0
- package/dist/esm/components/table.js +144 -0
- package/dist/esm/components/tabs-classes.js +21 -0
- package/dist/esm/components/tabs.js +201 -0
- package/dist/esm/components/tag-input.js +257 -0
- package/dist/esm/components/theme-toggle.js +177 -0
- package/dist/esm/components/toast.js +361 -0
- package/dist/esm/components/url-state.js +118 -0
- package/dist/esm/components/visually-hidden.js +20 -0
- package/dist/esm/format.js +320 -0
- package/dist/esm/inbox-client.js +2 -0
- package/dist/esm/inbox-types.js +2 -0
- package/dist/esm/index.js +320 -0
- package/dist/esm/runtime.js +37 -0
- package/dist/esm/server/inbox/client.js +297 -0
- package/dist/esm/server/inbox/types.js +24 -0
- package/dist/esm/sparkline-path.js +59 -0
- package/dist/esm/split-layout.js +419 -0
- package/dist/esm/system-canvas.js +2 -0
- package/dist/esm/theme.js +804 -0
- package/dist/esm/tokens.mjs +425 -0
- package/dist/esm/url.js +20 -0
- package/dist/files.json +5 -1
- package/dist/fonts/LICENSE-Inter.txt +93 -0
- package/dist/format.d.ts +32 -18
- package/dist/format.js +227 -82
- package/dist/inbox-client.js +3 -1
- package/dist/index.d.ts +1686 -667
- package/dist/nish-components.css +4649 -4506
- package/dist/nish-components.min.css +1 -0
- package/dist/nish.css +1603 -1450
- package/dist/nish.min.css +1 -0
- package/dist/node/eslint.js +29 -14
- package/dist/node/th-check.js +29 -14
- package/dist/node/vite.d.ts +12 -0
- package/dist/node/vite.js +12 -2
- package/dist/server/hono.d.ts +15 -6
- package/dist/server/hono.js +30 -25
- package/dist/server/index.d.ts +3 -10
- package/dist/server/index.js +71 -38
- package/dist/{spa-DuVB5O7S.d.ts → spa-BLlMc0eI.d.ts} +38 -5
- package/dist/system-canvas-BLuWd69H.d.ts +183 -0
- package/dist/system-canvas.d.ts +2 -168
- package/dist/tailwind-core.css +114 -0
- package/dist/tailwind.css +3 -7
- package/dist/theme-init.js +23 -9
- package/dist/theme-init.sha256 +1 -0
- package/dist/theme.d.ts +243 -4
- package/dist/theme.global.js +356 -89
- package/dist/theme.js +337 -67
- package/dist/tokens.css +14 -6
- package/dist/tokens.dtcg.json +1513 -0
- package/dist/tokens.js +29 -14
- package/dist/tokens.json +512 -0
- package/package.json +51 -13
- package/dist/chart.js.map +0 -1
- package/dist/elements-charts.js.map +0 -1
- package/dist/elements-data.js.map +0 -1
- package/dist/elements-forms.js.map +0 -1
- package/dist/elements.js.map +0 -1
- package/dist/format.js.map +0 -1
- package/dist/inbox-client.js.map +0 -1
- package/dist/index.js +0 -10260
- package/dist/index.js.map +0 -1
- package/dist/server/hono.js.map +0 -1
- package/dist/server/index.js.map +0 -1
- package/dist/split-layout.js.map +0 -1
- package/dist/system-canvas.js +0 -2204
- package/dist/system-canvas.js.map +0 -1
- package/dist/theme.global.js.map +0 -1
- package/dist/theme.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nish-ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Design tokens, seven themes, flash-free theme switching and accessible React 19 components for Tailwind 4, plain CSS and static HTML. Live docs: https://design.nish.software",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Nishant Arora",
|
|
@@ -40,12 +40,32 @@
|
|
|
40
40
|
],
|
|
41
41
|
"files": [
|
|
42
42
|
"dist",
|
|
43
|
+
"!dist/esm/**/*.map",
|
|
44
|
+
"!dist/**/*.map",
|
|
43
45
|
"tsconfig"
|
|
44
46
|
],
|
|
45
|
-
"main": "./dist/index.js",
|
|
47
|
+
"main": "./dist/esm/index.js",
|
|
46
48
|
"types": "./dist/index.d.ts",
|
|
47
49
|
"typesVersions": {
|
|
48
50
|
"*": {
|
|
51
|
+
"theme": [
|
|
52
|
+
"./dist/theme.d.ts"
|
|
53
|
+
],
|
|
54
|
+
"tokens": [
|
|
55
|
+
"./dist/tokens.d.ts"
|
|
56
|
+
],
|
|
57
|
+
"system-canvas": [
|
|
58
|
+
"./dist/system-canvas.d.ts"
|
|
59
|
+
],
|
|
60
|
+
"chart": [
|
|
61
|
+
"./dist/chart.d.ts"
|
|
62
|
+
],
|
|
63
|
+
"format": [
|
|
64
|
+
"./dist/format.d.ts"
|
|
65
|
+
],
|
|
66
|
+
"split-layout": [
|
|
67
|
+
"./dist/split-layout.d.ts"
|
|
68
|
+
],
|
|
49
69
|
"inbox-client": [
|
|
50
70
|
"./dist/inbox-client.d.ts"
|
|
51
71
|
],
|
|
@@ -61,6 +81,9 @@
|
|
|
61
81
|
"elements/charts": [
|
|
62
82
|
"./dist/elements-charts.d.ts"
|
|
63
83
|
],
|
|
84
|
+
"elements/all": [
|
|
85
|
+
"./dist/elements-all.d.ts"
|
|
86
|
+
],
|
|
64
87
|
"vite": [
|
|
65
88
|
"./dist/node/vite.d.ts"
|
|
66
89
|
],
|
|
@@ -81,37 +104,43 @@
|
|
|
81
104
|
"exports": {
|
|
82
105
|
".": {
|
|
83
106
|
"types": "./dist/index.d.ts",
|
|
84
|
-
"import": "./dist/index.js"
|
|
107
|
+
"import": "./dist/esm/index.js",
|
|
108
|
+
"default": "./dist/esm/index.js"
|
|
85
109
|
},
|
|
86
110
|
"./theme": {
|
|
87
111
|
"types": "./dist/theme.d.ts",
|
|
88
|
-
"import": "./dist/theme.js"
|
|
112
|
+
"import": "./dist/esm/theme.js",
|
|
113
|
+
"default": "./dist/esm/theme.js"
|
|
89
114
|
},
|
|
90
115
|
"./tokens": {
|
|
91
116
|
"types": "./dist/tokens.d.ts",
|
|
92
|
-
"import": "./dist/tokens.
|
|
117
|
+
"import": "./dist/esm/tokens.mjs",
|
|
118
|
+
"default": "./dist/esm/tokens.mjs"
|
|
93
119
|
},
|
|
94
120
|
"./system-canvas": {
|
|
95
121
|
"types": "./dist/system-canvas.d.ts",
|
|
96
|
-
"import": "./dist/system-canvas.js"
|
|
122
|
+
"import": "./dist/esm/system-canvas.js",
|
|
123
|
+
"default": "./dist/esm/system-canvas.js"
|
|
97
124
|
},
|
|
98
125
|
"./chart": {
|
|
99
126
|
"types": "./dist/chart.d.ts",
|
|
100
|
-
"import": "./dist/chart.js"
|
|
127
|
+
"import": "./dist/esm/chart.js",
|
|
128
|
+
"default": "./dist/esm/chart.js"
|
|
101
129
|
},
|
|
102
130
|
"./format": {
|
|
103
131
|
"types": "./dist/format.d.ts",
|
|
104
|
-
"import": "./dist/format.js"
|
|
132
|
+
"import": "./dist/esm/format.js",
|
|
133
|
+
"default": "./dist/esm/format.js"
|
|
105
134
|
},
|
|
106
135
|
"./split-layout": {
|
|
107
136
|
"types": "./dist/split-layout.d.ts",
|
|
108
|
-
"import": "./dist/split-layout.js",
|
|
109
|
-
"default": "./dist/split-layout.js"
|
|
137
|
+
"import": "./dist/esm/split-layout.js",
|
|
138
|
+
"default": "./dist/esm/split-layout.js"
|
|
110
139
|
},
|
|
111
140
|
"./inbox-client": {
|
|
112
141
|
"types": "./dist/inbox-client.d.ts",
|
|
113
|
-
"import": "./dist/inbox-client.js",
|
|
114
|
-
"default": "./dist/inbox-client.js"
|
|
142
|
+
"import": "./dist/esm/inbox-client.js",
|
|
143
|
+
"default": "./dist/esm/inbox-client.js"
|
|
115
144
|
},
|
|
116
145
|
"./elements": {
|
|
117
146
|
"types": "./dist/elements.d.ts",
|
|
@@ -133,6 +162,11 @@
|
|
|
133
162
|
"import": "./dist/elements-charts.js",
|
|
134
163
|
"default": "./dist/elements-charts.js"
|
|
135
164
|
},
|
|
165
|
+
"./elements/all": {
|
|
166
|
+
"types": "./dist/elements-all.d.ts",
|
|
167
|
+
"import": "./dist/elements-all.js",
|
|
168
|
+
"default": "./dist/elements-all.js"
|
|
169
|
+
},
|
|
136
170
|
"./vite": {
|
|
137
171
|
"types": "./dist/node/vite.d.ts",
|
|
138
172
|
"import": "./dist/node/vite.js",
|
|
@@ -155,19 +189,23 @@
|
|
|
155
189
|
"default": "./dist/server/hono.js"
|
|
156
190
|
},
|
|
157
191
|
"./theme-init.js": "./dist/theme-init.js",
|
|
192
|
+
"./theme-init.sha256": "./dist/theme-init.sha256",
|
|
158
193
|
"./theme.global.js": "./dist/theme.global.js",
|
|
159
194
|
"./tailwind.css": "./dist/tailwind.css",
|
|
195
|
+
"./tailwind-core.css": "./dist/tailwind-core.css",
|
|
160
196
|
"./nish.css": "./dist/nish.css",
|
|
161
197
|
"./tokens.css": "./dist/tokens.css",
|
|
162
198
|
"./fonts.css": "./dist/fonts.css",
|
|
163
199
|
"./base.css": "./dist/base.css",
|
|
164
200
|
"./nish-components.css": "./dist/nish-components.css",
|
|
201
|
+
"./tokens.json": "./dist/tokens.json",
|
|
202
|
+
"./tokens.dtcg.json": "./dist/tokens.dtcg.json",
|
|
165
203
|
"./fonts/*": "./dist/fonts/*",
|
|
166
204
|
"./files.json": "./dist/files.json",
|
|
167
205
|
"./package.json": "./package.json"
|
|
168
206
|
},
|
|
169
207
|
"engines": {
|
|
170
|
-
"node": ">=20"
|
|
208
|
+
"node": ">=20.19"
|
|
171
209
|
},
|
|
172
210
|
"peerDependencies": {
|
|
173
211
|
"hono": ">=4",
|
package/dist/chart.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/chart.ts","../src/tokens.mjs","../src/theme.ts"],"sourcesContent":["// @nish/ui/chart: theme colors for charts, with no chart library. SVG and CSS charts\n// (Recharts, hand-drawn SVG) take the var() strings and follow theme changes on their\n// own; canvas charts (uPlot, Chart.js) take chartTheme()'s resolved values and redraw\n// when useChartTheme() (or onThemeChange) reports a change.\nimport { useEffect, useState, type CSSProperties } from 'react';\nimport { onThemeChange, readToken } from './theme';\n\n/** The categorical series color for index i (0-based), cycling through chart-1…chart-8. */\nexport function seriesColor(i: number): string {\n const n = ((Math.trunc(i) % 8) + 8) % 8;\n return `var(--nish-chart-${n + 1})`;\n}\n\n/** Chart chrome as var() strings: gridlines, axis lines, the zero line and tick text. */\nexport const CHART = {\n grid: 'var(--nish-line)',\n axis: 'var(--nish-line-strong)',\n zero: 'var(--nish-hi3)',\n text: 'var(--nish-hi3)',\n} as const;\n\n/** Inline style for a chart tooltip box (Recharts contentStyle and similar). */\nexport const tooltipStyle: CSSProperties = {\n background: 'var(--nish-elevated)',\n border: '1px solid var(--nish-line-strong)',\n borderRadius: 'var(--nish-radius-sm)',\n boxShadow: 'var(--nish-shadow-pop)',\n color: 'var(--nish-hi)',\n fontSize: 12,\n};\n\n/** Resolved chart colors for canvas libraries, which cannot read var(). */\nexport interface ChartTheme {\n /** Gridlines. */\n grid: string;\n /** Axis lines. */\n axis: string;\n /** The zero line. */\n zero: string;\n /** Tick and legend text. */\n text: string;\n /** The page and panel backgrounds, for clearing or filling the canvas. */\n bg: string;\n surface: string;\n /** chart-1 … chart-8. */\n series: string[];\n /** Status fills for up/down bars and alert bands. */\n ok: string;\n loss: string;\n warn: string;\n info: string;\n accent: string;\n}\n\n/** Reads the current theme's chart colors from <html>. Call it again after a theme\n * change (see useChartTheme or onThemeChange). Returns empty strings during SSR. */\nexport function chartTheme(): ChartTheme {\n const t = (name: string) => (typeof document === 'undefined' ? '' : readToken(name));\n return {\n grid: t('line'),\n axis: t('line-strong'),\n zero: t('hi3'),\n text: t('hi3'),\n bg: t('bg'),\n surface: t('surface'),\n series: Array.from({ length: 8 }, (_, i) => t(`chart-${i + 1}`)),\n ok: t('ok-fill'),\n loss: t('loss-fill'),\n warn: t('warn-fill'),\n info: t('info-fill'),\n accent: t('accent'),\n };\n}\n\n/** chartTheme() as React state: re-renders the component when the theme changes, so a\n * canvas chart can redraw with the new colors. */\nexport function useChartTheme(): ChartTheme {\n const [theme, setTheme] = useState<ChartTheme>(chartTheme);\n useEffect(() => {\n setTheme(chartTheme());\n // Watch <html>'s data-theme rather than only onThemeChange: this entry is bundled on\n // its own, so its copy of the theme module's listener list may not be the one the\n // app's applyTheme() calls.\n const update = () => setTheme(chartTheme());\n const obs = new MutationObserver(update);\n obs.observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme', 'style', 'class'] });\n const off = onThemeChange(update);\n return () => {\n obs.disconnect();\n off();\n };\n }, []);\n return theme;\n}\n","// The one source of truth for every design token. scripts/build.mjs turns this into\n// dist/tokens.css (--nish-* custom properties), tools/contrast.mjs checks it, and\n// src/theme.ts reads PRESETS from it. Edit values here, never in generated CSS.\n//\n// Colors are plain hex so static pages can use them as-is; Tailwind opacity\n// modifiers (bg-th-surface/50) work through color-mix in Tailwind 4.\n\n/** Roles every theme must define. Soft tints are derived, not listed here. */\nexport const COLOR_ROLES = [\n 'bg', // page background\n 'surface', // cards, panels, table bodies\n 'elevated', // popovers, hovered rows, inputs, raised things inside cards\n 'overlay', // the deepest inner layer: chips inside raised things, skeleton sheen\n 'line', // borders and dividers\n 'line-strong', // input borders, focused outlines that are not the accent\n 'hi', // primary text\n 'hi2', // secondary text\n 'hi3', // tertiary text, labels\n 'ghost', // placeholders, disabled, decorative icons (not for body text)\n 'accent', // links, primary buttons, active nav, focus ring\n 'accent2', // a second accent for paired highlights and the 2nd chart series\n 'on-accent', // text and icons on an accent fill\n 'on-accent2', // text and icons on an accent2 fill\n 'on-ok', // text and icons on a solid ok-fill\n 'on-loss', // ... on loss-fill and loss (danger buttons)\n 'on-warn', // ... on warn-fill\n 'on-info', // ... on info-fill\n 'ok', // success, gains\n 'loss', // errors, losses, destructive\n 'warn', // warnings, pending\n 'info', // neutral notices\n 'ok-fill', // status colors for bars, meters and chart lines: brighter than the\n 'loss-fill', // text versions in light themes, where text-safe colors look muddy as fills\n 'warn-fill',\n 'info-fill',\n 'scrim', // modal and drawer backdrop tone\n 'invert-bg', // inverted pill (today marker, active segmented control)\n 'invert-text',\n 'chart-1',\n 'chart-2',\n 'chart-3',\n 'chart-4',\n 'chart-5',\n 'chart-6',\n 'chart-7',\n 'chart-8',\n 'emerald',\n 'indigo',\n 'amber',\n 'lime',\n 'rose',\n 'sky',\n 'violet',\n 'teal',\n];\n\n/** Color roles with no meaning: tags, tiles, stores, calendar dots. */\nexport const HUE_ROLES = ['emerald', 'indigo', 'amber', 'lime', 'rose', 'sky', 'violet', 'teal'];\n\n/** Tints mixed from a role over transparent (14%), for badges, banners and soft fills:\n * --nish-<role>-soft and Tailwind th-<role>-soft. The status roles first, then the hues. */\nexport const SOFT_ROLES = ['accent', 'ok', 'loss', 'warn', 'info', ...HUE_ROLES];\n\nconst DARK_HUES = {\n emerald: '#34d399',\n indigo: '#8b93ff',\n amber: '#fbbf24',\n lime: '#a3e635',\n rose: '#fb7185',\n sky: '#38bdf8',\n violet: '#c084fc',\n teal: '#2dd4bf',\n};\n\nconst LIGHT_HUES = {\n emerald: '#046d4f',\n indigo: '#4e45e3',\n amber: '#9b4708',\n lime: '#41690d',\n rose: '#b8113a',\n sky: '#036499',\n violet: '#7e22ce',\n teal: '#0e6b64',\n};\n\n// Categorical series ordered so neighbors never share a hue family.\nconst DARK_CHART = ['#8b93ff', '#34d399', '#fbbf24', '#fb7185', '#38bdf8', '#c084fc', '#fb923c', '#a3e635'];\n// Light series are the most vivid shades that still clear 3:1 (chart marks, not text)\n// on bg, surface and elevated; darker text-safe shades read as muddy lines.\nconst LIGHT_CHART = ['#6366f1', '#059669', '#c96d06', '#f43f5e', '#0284c7', '#a855f7', '#ea580c', '#5a910c'];\n\nconst chart = (list) => Object.fromEntries(list.map((c, i) => [`chart-${i + 1}`, c]));\n\n/**\n * Every theme. `scheme` is what a page that only knows light/dark falls back to.\n * The first entry is the default.\n */\nexport const THEMES = {\n dark: {\n label: 'Dark',\n scheme: 'dark',\n colors: {\n bg: '#0a0b0f',\n surface: '#111218',\n elevated: '#191b23',\n overlay: '#22252f',\n line: '#262935',\n 'line-strong': '#3a3e4d',\n hi: '#ececf1',\n hi2: '#a8aab7',\n hi3: '#8a8d9b',\n ghost: '#6b6e7c',\n accent: '#8b93ff',\n accent2: '#c084fc',\n 'on-accent': '#0a0b0f',\n ok: '#34d399',\n loss: '#f87171',\n warn: '#fbbf24',\n info: '#38bdf8',\n scrim: '#000000',\n 'invert-bg': '#ececf1',\n 'invert-text': '#111218',\n ...chart(DARK_CHART),\n ...DARK_HUES,\n },\n },\n light: {\n label: 'Light',\n scheme: 'light',\n colors: {\n bg: '#f7f6f3',\n surface: '#ffffff',\n elevated: '#f1f0ec',\n overlay: '#e6e4de',\n line: '#e2e0da',\n 'line-strong': '#c9c6bd',\n hi: '#17171c',\n hi2: '#4f515c',\n hi3: '#666874',\n ghost: '#8a8c98',\n accent: '#4338ca',\n accent2: '#7e22ce',\n 'on-accent': '#ffffff',\n // Light fills are mid-tones: white only clears 4.5:1 on loss and accent2.\n 'on-accent2': '#ffffff',\n 'on-ok': '#0a0a0c',\n 'on-loss': '#ffffff',\n 'on-warn': '#0a0a0c',\n 'on-info': '#0a0a0c',\n ok: '#065f46',\n 'ok-fill': '#059669',\n 'loss-fill': '#dc2626',\n 'warn-fill': '#c96d06',\n 'info-fill': '#0284c7',\n loss: '#a91b1b',\n warn: '#92400e',\n info: '#075985',\n scrim: '#17171c',\n 'invert-bg': '#17171c',\n 'invert-text': '#f7f6f3',\n ...chart(LIGHT_CHART),\n ...LIGHT_HUES,\n },\n },\n slate: {\n label: 'Slate',\n scheme: 'dark',\n colors: {\n bg: '#18181b',\n surface: '#202024',\n elevated: '#2c2c32',\n overlay: '#36363d',\n line: '#3a3a42',\n 'line-strong': '#52525b',\n hi: '#f4f4f5',\n hi2: '#a1a1aa',\n hi3: '#8f8f99',\n ghost: '#71717a',\n accent: '#a5b4fc',\n accent2: '#c084fc',\n 'on-accent': '#18181b',\n ok: '#4ade80',\n loss: '#fda4af',\n warn: '#facc15',\n info: '#38bdf8',\n scrim: '#000000',\n 'invert-bg': '#f4f4f5',\n 'invert-text': '#202024',\n ...chart(['#818cf8', '#4ade80', '#facc15', '#fb7185', '#38bdf8', '#c084fc', '#fb923c', '#a3e635']),\n ...DARK_HUES,\n // Lifted so tinted chips stay readable on this theme's lighter cards.\n indigo: '#9aa1ff', rose: '#fc8395', violet: '#c792fc',\n },\n },\n terminal: {\n label: 'Terminal',\n scheme: 'dark',\n colors: {\n bg: '#050807',\n surface: '#0c110e',\n elevated: '#141c17',\n overlay: '#1c2820',\n line: '#233028',\n 'line-strong': '#34483b',\n hi: '#d1fae5',\n hi2: '#8fc4a8',\n hi3: '#74a68b',\n ghost: '#4f7a62',\n accent: '#34d399',\n accent2: '#2dd4bf',\n 'on-accent': '#050807',\n ok: '#4ade80',\n loss: '#f87171',\n warn: '#fbbf24',\n info: '#67e8f9',\n scrim: '#000000',\n 'invert-bg': '#d1fae5',\n 'invert-text': '#0c110e',\n ...chart(['#34d399', '#67e8f9', '#fbbf24', '#f87171', '#a3e635', '#c084fc', '#fb923c', '#2dd4bf']),\n ...DARK_HUES,\n },\n },\n mocha: {\n label: 'Mocha',\n scheme: 'dark',\n colors: {\n bg: '#1c1917',\n surface: '#292524',\n elevated: '#393432',\n overlay: '#44403c',\n line: '#44403c',\n 'line-strong': '#57534e',\n hi: '#f5f0eb',\n hi2: '#b3ada8',\n hi3: '#a39d98',\n ghost: '#78716c',\n accent: '#fdba74',\n accent2: '#f472b6',\n 'on-accent': '#1c1917',\n ok: '#4ade80',\n loss: '#fca5a5',\n warn: '#facc15',\n info: '#7dd3fc',\n scrim: '#000000',\n 'invert-bg': '#f5f0eb',\n 'invert-text': '#292524',\n ...chart(['#fb923c', '#4ade80', '#facc15', '#f472b6', '#7dd3fc', '#c4b5fd', '#f87171', '#bef264']),\n ...DARK_HUES,\n // Lifted so tinted chips stay readable on this theme's lighter cards.\n indigo: '#a9afff', rose: '#fc99a7', sky: '#3ebff8', violet: '#cfa2fd',\n },\n },\n ocean: {\n label: 'Ocean',\n scheme: 'dark',\n colors: {\n bg: '#020c18',\n surface: '#061528',\n elevated: '#0a243e',\n overlay: '#103658',\n line: '#123050',\n 'line-strong': '#1f4a72',\n hi: '#e0f2fe',\n hi2: '#9ccde6',\n hi3: '#6fa9c6',\n ghost: '#3f7392',\n accent: '#38bdf8',\n accent2: '#a78bfa',\n 'on-accent': '#020c18',\n ok: '#34d399',\n loss: '#fb7185',\n warn: '#fbbf24',\n info: '#7dd3fc',\n scrim: '#000000',\n 'invert-bg': '#38bdf8',\n 'invert-text': '#020c18',\n ...chart(['#38bdf8', '#34d399', '#fbbf24', '#fb7185', '#a78bfa', '#2dd4bf', '#fb923c', '#a3e635']),\n ...DARK_HUES,\n },\n },\n contrast: {\n label: 'High contrast',\n scheme: 'dark',\n colors: {\n bg: '#000000',\n surface: '#080808',\n elevated: '#141414',\n overlay: '#222222',\n line: '#4a4a4a',\n 'line-strong': '#8a8a8a',\n hi: '#ffffff',\n hi2: '#d4d4d4',\n hi3: '#bdbdbd',\n ghost: '#8f8f8f',\n accent: '#ffd60a',\n accent2: '#7dd3fc',\n 'on-accent': '#000000',\n ok: '#4ade80',\n loss: '#ff6b6b',\n warn: '#ffd60a',\n info: '#7dd3fc',\n scrim: '#000000',\n 'invert-bg': '#ffffff',\n 'invert-text': '#000000',\n ...chart(['#ffd60a', '#4ade80', '#7dd3fc', '#ff6b6b', '#c4b5fd', '#fb923c', '#f9a8d4', '#bef264']),\n ...DARK_HUES,\n },\n },\n};\n\n// Dark themes use their status colors as fills too, with the same dark ink on every\n// fill; only light themes override them. tools/contrast.mjs checks each on-* color on\n// its fill (4.5:1).\nfor (const t of Object.values(THEMES)) {\n for (const r of ['ok', 'loss', 'warn', 'info']) {\n t.colors[`${r}-fill`] ??= t.colors[r];\n t.colors[`on-${r}`] ??= t.colors['on-accent'];\n }\n t.colors['on-accent2'] ??= t.colors['on-accent'];\n}\n\nexport const DEFAULT_THEME = 'dark';\n\n/** Everything that is not a color. Same in every theme. */\nexport const SCALE = {\n // Inter Variable is self-hosted (fonts.css). Sites with their own display face\n // (mc's pixel font, trips' serif) set it locally and keep these for UI text.\n 'font-sans': \"'Inter Variable', 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif\",\n 'font-mono': \"ui-monospace, 'Cascadia Code', 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace\",\n\n // Dense UI only (widget chrome, table meta, keyboard hints): never body text.\n 'text-3xs': '0.625rem',\n 'text-3xs-lh': '0.875rem',\n 'text-2xs': '0.6875rem',\n 'text-2xs-lh': '1rem',\n 'text-xs': '0.75rem',\n 'text-xs-lh': '1.1rem',\n 'text-sm': '0.875rem',\n 'text-sm-lh': '1.35rem',\n 'text-base': '1rem',\n 'text-base-lh': '1.55rem',\n 'text-lg': '1.125rem',\n 'text-lg-lh': '1.65rem',\n 'text-xl': '1.25rem',\n 'text-xl-lh': '1.75rem',\n 'text-2xl': '1.5rem',\n 'text-2xl-lh': '2rem',\n 'text-3xl': '1.875rem',\n 'text-3xl-lh': '2.3rem',\n 'text-4xl': '2.25rem',\n 'text-4xl-lh': '2.6rem',\n 'weight-normal': '400',\n 'weight-medium': '500',\n 'weight-semibold': '600',\n 'weight-bold': '700',\n 'tracking-tight': '-0.015em',\n 'tracking-caps': '0.08em',\n\n // 4px grid\n 'space-1': '4px',\n 'space-2': '8px',\n 'space-3': '12px',\n 'space-4': '16px',\n 'space-5': '20px',\n 'space-6': '24px',\n 'space-8': '32px',\n 'space-10': '40px',\n 'space-12': '48px',\n 'space-16': '64px',\n\n 'radius-xs': '4px',\n 'radius-sm': '8px',\n // Card is 12px (Tailwind rounded-xl). Controls use radius-sm (rounded-lg), dialogs\n // 16px (rounded-2xl), pills radius-pill (rounded-full).\n 'radius-card': '12px',\n 'radius-md': '14px',\n 'radius-lg': '20px',\n 'radius-pill': '999px',\n\n 'ease-out': 'cubic-bezier(0.22, 1, 0.36, 1)',\n 'ease-in-out': 'cubic-bezier(0.65, 0, 0.35, 1)',\n 'dur-fast': '160ms',\n 'dur-med': '320ms',\n\n 'z-base': '0',\n 'z-sticky': '20',\n 'z-dropdown': '40',\n 'z-modal': '50',\n 'z-toast': '60',\n 'z-tooltip': '100',\n\n 'page-max': '1120px',\n gutter: '16px',\n 'tap-min': '44px',\n 'focus-width': '2px',\n 'focus-offset': '2px',\n\n // Breakpoints for reference in JS and media queries (CSS vars cannot drive @media).\n 'bp-sm': '640px',\n 'bp-md': '768px',\n 'bp-lg': '1024px',\n 'bp-xl': '1280px',\n};\n\n/** Shadows reference --nish-scrim so the same recipe is faint on dark and soft on light. */\nexport const SHADOWS = {\n card: '0 1px 2px color-mix(in srgb, var(--nish-scrim) 10%, transparent), 0 6px 20px -8px color-mix(in srgb, var(--nish-scrim) 22%, transparent)',\n pop: '0 4px 12px -2px color-mix(in srgb, var(--nish-scrim) 24%, transparent), 0 12px 32px -8px color-mix(in srgb, var(--nish-scrim) 30%, transparent)',\n modal: '0 24px 64px -16px color-mix(in srgb, var(--nish-scrim) 45%, transparent)',\n};\n","/** Theme switching shared by every nish.software page.\n *\n * The choice ('system' or a theme name) lives in a `nish-theme` cookie on\n * `.nish.software`, so picking dark on one subdomain applies on all of them. Another\n * site shares it across its own subdomains with <html data-nish-domain=\"example.com\">.\n * Anywhere else (localhost, Electron, a host outside that domain) it falls back to\n * localStorage. theme-init.js applies the same rules before first paint; this\n * module takes over for runtime switching and keeps tabs and subdomains in sync.\n */\nimport { DEFAULT_THEME, THEMES, type Scheme } from './tokens.mjs';\n\n/** A shared theme, or an app's own one added with registerThemes(). */\nexport type ThemeName = keyof typeof THEMES | (string & {});\nexport type ThemeChoice = ThemeName | 'system';\n\nexport interface ThemePreset {\n id: ThemeName;\n label: string;\n scheme: Scheme;\n colors: Record<string, string>;\n}\n\nexport const PRESETS: ThemePreset[] = (Object.keys(THEMES) as (keyof typeof THEMES)[]).map((id) => ({\n id,\n label: THEMES[id].label,\n scheme: THEMES[id].scheme,\n colors: THEMES[id].colors,\n}));\n\nconst KEY = 'nish-theme';\nconst SHARED_DOMAIN = 'nish.software';\nconst ONE_YEAR = 60 * 60 * 24 * 365;\n\n// App-defined themes ({ id: 'dark' | 'light' }). The app styles them itself with\n// [data-theme='<id>'] blocks that set --nish-* variables; this only teaches the theme\n// logic that the names are valid and which scheme each one is.\nconst extra: Record<string, Scheme> = {};\n\n/** Let an app offer its own themes next to the shared ones. Call it before\n * initTheme(), and set the same map on window.__nishExtraThemes before theme-init.js\n * runs, so the first paint knows them too. */\nexport function registerThemes(themes: Record<string, Scheme>): void {\n Object.assign(extra, themes);\n}\n\nconst has = (o: object, k: string) => Object.prototype.hasOwnProperty.call(o, k);\n\nexport function isThemeName(v: unknown): v is ThemeName {\n return typeof v === 'string' && (has(THEMES, v) || has(extra, v));\n}\n\nfunction readCookie(): string | null {\n if (typeof document === 'undefined') return null;\n const m = document.cookie.match(/(?:^|;\\s*)nish-theme=([a-z0-9-]+)/);\n return m ? m[1] : null;\n}\n\nconst covers = (domain: string, host: string) => host === domain || host.endsWith('.' + domain);\n\n/** The domain the cookie is shared on, or null for localStorage only. A page sets its own\n * with <html data-nish-domain=\"example.com\">; it counts only when this host is that\n * domain or one of its subdomains, so a stray attribute cannot write a cookie the\n * browser would refuse. Without it, nish.software hosts share on `.nish.software`. */\nfunction cookieDomain(host: string, attr: string | null): string | null {\n const h = host.toLowerCase();\n const own = (attr ?? '').trim().toLowerCase().replace(/^\\./, '');\n if (own) return covers(own, h) ? own : null;\n return covers(SHARED_DOMAIN, h) ? SHARED_DOMAIN : null;\n}\n\nfunction sharedDomain(): string | null {\n if (typeof location === 'undefined' || typeof document === 'undefined') return null;\n return cookieDomain(location.hostname, document.documentElement.getAttribute('data-nish-domain'));\n}\n\n/** The saved choice; 'system' when nothing (valid) is saved. */\nexport function getThemeChoice(): ThemeChoice {\n let v: string | null = null;\n try {\n v = readCookie() ?? localStorage.getItem(KEY);\n } catch {\n // storage blocked: fall through to system\n }\n return v === 'system' || isThemeName(v) ? v : 'system';\n}\n\nfunction systemTheme(): ThemeName {\n const light = typeof matchMedia !== 'undefined' && matchMedia('(prefers-color-scheme: light)').matches;\n return light ? 'light' : DEFAULT_THEME;\n}\n\n/** Pages may limit themselves with <html data-nish-themes=\"dark light\">. */\nfunction allowedThemes(): ThemeName[] | null {\n const attr = document.documentElement.getAttribute('data-nish-themes');\n return attr ? (attr.split(/\\s+/).filter(isThemeName) as ThemeName[]) : null;\n}\n\n/** What a choice renders as on this page. */\nexport function resolveTheme(choice: ThemeChoice = getThemeChoice()): ThemeName {\n let theme: ThemeName = choice === 'system' ? systemTheme() : choice;\n const allowed = typeof document === 'undefined' ? null : allowedThemes();\n if (allowed && !allowed.includes(theme)) theme = schemeOf(theme);\n return theme;\n}\n\nexport function schemeOf(theme: ThemeName): Scheme {\n return has(THEMES, theme) ? THEMES[theme as keyof typeof THEMES].scheme : (extra[theme] ?? 'dark');\n}\n\n/** Paint a choice onto <html> without saving it. */\nexport function applyTheme(choice: ThemeChoice = getThemeChoice()): ThemeName {\n const theme = resolveTheme(choice);\n const root = document.documentElement;\n root.setAttribute('data-theme', theme);\n root.setAttribute('data-scheme', schemeOf(theme));\n root.setAttribute('data-theme-choice', choice);\n root.style.colorScheme = schemeOf(theme);\n syncChromeColor();\n listeners.forEach((fn) => fn(choice, theme));\n return theme;\n}\n\n/** Save a choice everywhere it can be read back, then apply it. */\nexport function setThemeChoice(choice: ThemeChoice): ThemeName {\n try {\n localStorage.setItem(KEY, choice);\n } catch {\n // private mode: the cookie (or nothing) still carries it for this page view\n }\n const domain = sharedDomain();\n if (domain) {\n const secure = location.protocol === 'https:' ? '; Secure' : '';\n document.cookie = `${KEY}=${choice}; Domain=.${domain}; Path=/; Max-Age=${ONE_YEAR}; SameSite=Lax${secure}`;\n }\n return applyTheme(choice);\n}\n\n/** Current value of a token on <html>, e.g. readToken('chart-1') for canvas charts. */\nexport function readToken(name: string): string {\n return getComputedStyle(document.documentElement).getPropertyValue(`--nish-${name}`).trim();\n}\n\n/** Keep the browser/PWA chrome and the root background in step with the theme, so\n * the old color never peeks through on overscroll. */\nfunction syncChromeColor(): void {\n const bg = readToken('bg');\n if (!bg) return;\n let meta = document.querySelector<HTMLMetaElement>('meta[name=\"theme-color\"]');\n if (!meta) {\n meta = document.createElement('meta');\n meta.name = 'theme-color';\n document.head.appendChild(meta);\n }\n meta.content = bg;\n}\n\ntype Listener = (choice: ThemeChoice, theme: ThemeName) => void;\nconst listeners = new Set<Listener>();\nlet watching = false;\n\n/** Re-apply when the OS scheme flips (for 'system'), another tab saves a choice, or\n * the page comes back into view after another subdomain changed the cookie. */\nfunction watch(): void {\n if (watching || typeof window === 'undefined') return;\n watching = true;\n const reapply = () => {\n const choice = getThemeChoice();\n if (choice !== document.documentElement.getAttribute('data-theme-choice') || choice === 'system') applyTheme(choice);\n };\n matchMedia('(prefers-color-scheme: light)').addEventListener('change', reapply);\n window.addEventListener('storage', (e) => {\n if (e.key === KEY) reapply();\n });\n document.addEventListener('visibilitychange', () => {\n if (document.visibilityState === 'visible') reapply();\n });\n}\n\n/** Subscribe to theme changes; returns an unsubscribe function. */\nexport function onThemeChange(fn: Listener): () => void {\n watch();\n listeners.add(fn);\n return () => listeners.delete(fn);\n}\n\n/** The order a one-button toggle steps through. */\nexport const TOGGLE_ORDER: ThemeChoice[] = ['system', 'light', 'dark'];\n\n/** One-button toggle for static pages: system → light → dark → system. A preset\n * chosen elsewhere steps to 'system'. */\nexport function cycleTheme(): ThemeChoice {\n const next = nextChoice(getThemeChoice());\n setThemeChoice(next);\n return next;\n}\n\n/** Words mountThemeToggle uses for the three one-button choices. */\nexport type ThemeToggleLabels = Partial<Record<'system' | 'light' | 'dark', string>>;\n\nexport interface MountThemeToggleOptions {\n /** Replace the words \"System\", \"Light\" and \"Dark\" in the button's label, e.g. for\n * another language. The label reads \"Theme: Light. Switch to Dark\". */\n labels?: ThemeToggleLabels;\n /** Also show the current choice as a word after the icon (System, Light, Dark, or a\n * preset's name such as \"Mocha\" when one was saved on another site): a\n * <span data-theme-word aria-hidden=\"true\">, kept in sync on click and on theme\n * changes. aria-label and title stay as they are. Style the button with\n * .nish-theme-btn--labelled. */\n showLabel?: boolean;\n}\n\n// Same geometry as ThemeToggle's MonitorIcon, SunIcon and MoonIcon (lucide, 24px grid).\nconst TOGGLE_ICONS: Record<'system' | 'light' | 'dark', string> = {\n system: '<rect width=\"20\" height=\"14\" x=\"2\" y=\"3\" rx=\"2\"/><path d=\"M8 21h8M12 17v4\"/>',\n light:\n '<circle cx=\"12\" cy=\"12\" r=\"4\"/><path d=\"M12 2v2M12 20v2m-7.07-2.93 1.41-1.41M17.66 6.34l1.41-1.41M2 12h2m16 0h2M4.93 4.93l1.41 1.41m11.32 11.32 1.41 1.41\"/>',\n dark: '<path d=\"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9\"/>',\n};\n\nconst DEFAULT_TOGGLE_LABELS = { system: 'System', light: 'Light', dark: 'Dark' };\n\n/** What a one-button toggle steps to from a choice: the same rule as cycleTheme(). */\nfunction nextChoice(choice: ThemeChoice): ThemeChoice {\n const i = TOGGLE_ORDER.indexOf(choice);\n return TOGGLE_ORDER[(i + 1) % TOGGLE_ORDER.length];\n}\n\nfunction themeLabel(choice: ThemeChoice, words: Record<'system' | 'light' | 'dark', string>): string {\n if (choice === 'system' || choice === 'light' || choice === 'dark') return words[choice as 'system' | 'light' | 'dark'];\n if (has(THEMES, choice)) return THEMES[choice as keyof typeof THEMES].label;\n return choice.charAt(0).toUpperCase() + choice.slice(1);\n}\n\n/** Turn any button on a static page into the one-button theme toggle (system → light\n * → dark → system). It fills the button with the three icons (only the current one\n * shows), sets `data-choice`, keeps `aria-label` and `title` saying what is on and\n * what a click does (\"Theme: Light. Switch to Dark\"; a preset saved on another site\n * reads \"Theme: Mocha (set on another site). Switch to System\"), cycles on click and\n * follows changes from other tabs and subdomains. Returns a cleanup function.\n *\n * ```html\n * <button class=\"nish-theme-btn\" id=\"theme\"></button>\n * <script type=\"module\">\n * import { initTheme, mountThemeToggle } from './nish/theme.js';\n * initTheme();\n * mountThemeToggle(document.getElementById('theme'));\n * </script>\n * ```\n */\nexport function mountThemeToggle(button: HTMLElement, opts: MountThemeToggleOptions = {}): () => void {\n const words = { ...DEFAULT_TOGGLE_LABELS, ...opts.labels };\n if (button.tagName === 'BUTTON' && !button.getAttribute('type')) button.setAttribute('type', 'button');\n button.innerHTML =\n (Object.keys(TOGGLE_ICONS) as (keyof typeof TOGGLE_ICONS)[])\n .map(\n (id) =>\n `<svg data-icon=\"${id}\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\">${TOGGLE_ICONS[id]}</svg>`,\n )\n .join('') + (opts.showLabel ? '<span data-theme-word aria-hidden=\"true\"></span>' : '');\n const word = button.querySelector<HTMLElement>('[data-theme-word]');\n\n const render = (choice: ThemeChoice) => {\n // A preset shows the icon of the scheme it is built on.\n const icon = choice === 'system' || choice === 'light' || choice === 'dark' ? choice : schemeOf(choice);\n button.setAttribute('data-choice', choice);\n button.querySelectorAll<SVGElement>('svg[data-icon]').forEach((svg) => {\n if (svg.getAttribute('data-icon') === icon) svg.removeAttribute('display');\n else svg.setAttribute('display', 'none');\n });\n const elsewhere = TOGGLE_ORDER.includes(choice) ? '' : ' (set on another site)';\n const label = `Theme: ${themeLabel(choice, words)}${elsewhere}. Switch to ${themeLabel(nextChoice(choice), words)}`;\n button.setAttribute('aria-label', label);\n button.setAttribute('title', label);\n if (word) word.textContent = themeLabel(choice, words);\n };\n\n const onClick = () => {\n cycleTheme();\n };\n button.addEventListener('click', onClick);\n const off = onThemeChange((choice) => render(choice));\n render(getThemeChoice());\n return () => {\n button.removeEventListener('click', onClick);\n off();\n };\n}\n\n// --- showToast (static pages) ------------------------------------------------------\n\nexport type StaticToastTone = 'neutral' | 'ok' | 'warn' | 'loss' | 'info';\n\n// The React toast's tone icons (CheckCircle, AlertTriangle, Info), 15px: static markup, no user text.\nconst TOAST_ICON_PATHS: Record<StaticToastTone, string> = {\n neutral: '<circle cx=\"12\" cy=\"12\" r=\"10\"/><path d=\"M12 16v-4M12 8h.01\"/>',\n info: '<circle cx=\"12\" cy=\"12\" r=\"10\"/><path d=\"M12 16v-4M12 8h.01\"/>',\n ok: '<circle cx=\"12\" cy=\"12\" r=\"10\"/><path d=\"m9 12 2 2 4-4\"/>',\n warn: '<path d=\"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3\"/><path d=\"M12 9v4M12 17h.01\"/>',\n loss: '<path d=\"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3\"/><path d=\"M12 9v4M12 17h.01\"/>',\n};\n\nexport interface ShowToastOptions {\n /** Border tint: ok, warn, loss or info (the /30 tint border). Default neutral. */\n tone?: StaticToastTone;\n /** Milliseconds before it hides itself, or 'sticky' to stay until dismissed. Default\n * 6000. The timer pauses while the toast is hovered or holds focus, so a keyboard\n * user can reach a link inside it. */\n duration?: number | 'sticky';\n /** One text action after the message: a link (href) or a button (onClick). Clicking\n * it hides the toast. */\n action?: { label: string; href?: string; onClick?: () => void };\n /** Accessible name of the dismiss button. Default \"Dismiss\". */\n dismissLabel?: string;\n}\n\nconst TOAST_MS = 6_000;\nlet toastRegion: HTMLElement | null = null;\nlet hideCurrent: (() => void) | null = null;\n\n/** Show one toast on a static page: a .nish-toast inside a single role=\"status\"\n * aria-live=\"polite\" region (created on first use). A new toast replaces the one on\n * screen. content is text, or a Node for markup (a <strong>, a link): text is never\n * parsed as HTML. Same policy as the React toast: the timer pauses on hover and on\n * focus. Returns a function that hides it now. Needs nish-components.css. */\nexport function showToast(content: string | Node, opts: ShowToastOptions = {}): () => void {\n hideCurrent?.();\n if (!toastRegion || !toastRegion.isConnected) {\n toastRegion = document.createElement('div');\n toastRegion.setAttribute('role', 'status');\n toastRegion.setAttribute('aria-live', 'polite');\n toastRegion.className = 'nish-toast-region';\n document.body.appendChild(toastRegion);\n }\n const region = toastRegion;\n const box = document.createElement('div');\n box.className = 'nish-toast' + (opts.tone && opts.tone !== 'neutral' ? ` nish-toast--${opts.tone}` : '');\n const icon = document.createElement('span');\n icon.className = 'nish-toast-icon';\n icon.setAttribute('aria-hidden', 'true');\n icon.innerHTML = `<svg width=\"15\" height=\"15\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" focusable=\"false\">${TOAST_ICON_PATHS[opts.tone ?? 'neutral']}</svg>`;\n box.append(icon);\n const body = document.createElement('p');\n body.className = 'nish-toast-body';\n body.append(typeof content === 'string' ? document.createTextNode(content) : content);\n box.append(body);\n\n let timer: ReturnType<typeof setTimeout> | null = null;\n let remaining = opts.duration === 'sticky' ? Infinity : (opts.duration ?? TOAST_MS);\n let started = 0;\n let holds = 0;\n const hide = () => {\n if (timer != null) clearTimeout(timer);\n timer = null;\n box.remove();\n if (hideCurrent === hide) hideCurrent = null;\n };\n const run = (ms: number) => {\n if (!Number.isFinite(ms)) return;\n started = Date.now();\n timer = setTimeout(hide, ms);\n };\n const pause = () => {\n holds += 1;\n if (holds > 1 || timer == null) return;\n clearTimeout(timer);\n timer = null;\n remaining = Math.max(0, remaining - (Date.now() - started));\n };\n const resume = () => {\n if (holds === 0) return;\n holds -= 1;\n // Give the reader a moment after they move away, even if the time had nearly run out.\n if (holds === 0) run(Math.max(remaining, 1_000));\n };\n\n if (opts.action) {\n const a = opts.action;\n const el = document.createElement(a.href ? 'a' : 'button');\n el.className = 'nish-toast-action';\n el.textContent = a.label;\n if (a.href) (el as HTMLAnchorElement).href = a.href;\n else (el as HTMLButtonElement).type = 'button';\n el.addEventListener('click', () => {\n a.onClick?.();\n hide();\n });\n box.append(el);\n }\n const close = document.createElement('button');\n close.type = 'button';\n close.className = 'nish-toast-close';\n close.setAttribute('aria-label', opts.dismissLabel ?? 'Dismiss');\n close.innerHTML =\n '<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M18 6 6 18M6 6l12 12\"/></svg>';\n close.addEventListener('click', hide);\n box.append(close);\n\n // Mouse only: a tap fires enter with no leave, which would pin the toast forever.\n box.addEventListener('pointerenter', (e) => e.pointerType === 'mouse' && pause());\n box.addEventListener('pointerleave', (e) => e.pointerType === 'mouse' && resume());\n box.addEventListener('focusin', (e) => !box.contains(e.relatedTarget as Node | null) && pause());\n box.addEventListener('focusout', (e) => !box.contains(e.relatedTarget as Node | null) && resume());\n box.addEventListener('keydown', (e) => {\n if (e.key === 'Escape') hide();\n });\n\n // Insert after the region is in the DOM, so screen readers announce the change.\n setTimeout(() => {\n if (hideCurrent !== hide) return;\n region.append(box);\n run(remaining);\n }, 50);\n hideCurrent = hide;\n return hide;\n}\n\n// --- confirmDialog (static pages) --------------------------------------------------\n\nexport interface ConfirmDialogOptions {\n /** The question, e.g. \"Save before closing?\". Also the dialog's name. */\n title: string;\n /** What happens if they confirm: text, or a Node for markup (never parsed as HTML). */\n body?: string | Node;\n /** The confirm button's label: a verb that names the action. Default \"Confirm\". */\n confirmLabel?: string;\n /** The cancel button's label. Default \"Cancel\". */\n cancelLabel?: string;\n /** danger: a red confirm button, and focus starts on Cancel (as in the React\n * ConfirmDialog). Without it: an accent confirm button that takes the first focus. */\n tone?: 'danger' | 'primary';\n}\n\nlet dialogSeq = 0;\n\n/** A yes-or-no question in place of `window.confirm`, for pages without React: a\n * native <dialog class=\"nish-dialog\"> opened with showModal(), so the browser traps\n * focus and makes the page inert. Resolves true on the confirm button, false on Cancel,\n * Escape or a backdrop click; then the dialog is removed and focus returns to the\n * element that had it. Escape does not reach the page's own key handlers. Needs\n * nish-components.css. */\nexport function confirmDialog(opts: ConfirmDialogOptions): Promise<boolean> {\n if (typeof document === 'undefined') return Promise.resolve(false);\n const opener = document.activeElement instanceof HTMLElement ? document.activeElement : null;\n const id = `nish-dialog-${++dialogSeq}`;\n const danger = opts.tone === 'danger';\n\n const dialog = document.createElement('dialog');\n dialog.className = 'nish-dialog';\n dialog.setAttribute('aria-labelledby', `${id}-title`);\n const title = document.createElement('h2');\n title.className = 'nish-dialog-title';\n title.id = `${id}-title`;\n title.textContent = opts.title;\n dialog.append(title);\n if (opts.body != null && opts.body !== '') {\n const body = document.createElement('div');\n body.className = 'nish-dialog-body';\n body.id = `${id}-body`;\n body.append(typeof opts.body === 'string' ? document.createTextNode(opts.body) : opts.body);\n dialog.setAttribute('aria-describedby', body.id);\n dialog.append(body);\n }\n const actions = document.createElement('div');\n actions.className = 'nish-dialog-actions';\n const button = (label: string, cls: string) => {\n const b = document.createElement('button');\n b.type = 'button';\n b.className = cls;\n b.textContent = label;\n return b;\n };\n const cancelBtn = button(opts.cancelLabel ?? 'Cancel', 'nish-btn');\n const confirmBtn = button(opts.confirmLabel ?? 'Confirm', `nish-btn ${danger ? 'nish-btn--danger' : 'nish-btn--primary'}`);\n (danger ? cancelBtn : confirmBtn).autofocus = true;\n actions.append(cancelBtn, confirmBtn);\n dialog.append(actions);\n\n return new Promise<boolean>((resolve) => {\n let done = false;\n const finish = (ok: boolean) => {\n if (done) return;\n done = true;\n if (dialog.open) dialog.close();\n dialog.remove();\n if (opener?.isConnected) opener.focus();\n resolve(ok);\n };\n cancelBtn.addEventListener('click', () => finish(false));\n confirmBtn.addEventListener('click', () => finish(true));\n // Escape: the browser fires cancel; keep the key from the page's own listeners\n // (an outer framework dialog would close too).\n dialog.addEventListener('keydown', (e) => {\n if (e.key === 'Escape') e.stopPropagation();\n });\n dialog.addEventListener('cancel', (e) => {\n e.preventDefault();\n finish(false);\n });\n dialog.addEventListener('close', () => finish(false));\n // A press on the backdrop targets the dialog itself, outside its box.\n dialog.addEventListener('click', (e) => {\n if (e.target !== dialog) return;\n const r = dialog.getBoundingClientRect();\n const inside = e.clientX >= r.left && e.clientX <= r.right && e.clientY >= r.top && e.clientY <= r.bottom;\n if (!inside) finish(false);\n });\n document.body.append(dialog);\n dialog.showModal();\n });\n}\n\n// --- mountTooltips (static pages) --------------------------------------------------\n\n/** Escape for .nish-tooltip triggers under root (default document): pressing it hides\n * the open tip until the pointer leaves or focus moves away, as the React Tooltip does.\n * Also links a .nish-tooltip-content without an id to its trigger by aria-describedby.\n * The tips show and hide on hover and focus with CSS alone; this only adds Escape.\n * Returns a function that removes the listeners. */\nexport function mountTooltips(root: Document | HTMLElement = document): () => void {\n if (typeof document === 'undefined') return () => undefined;\n root.querySelectorAll<HTMLElement>('.nish-tooltip').forEach((t) => {\n const tip = t.querySelector<HTMLElement>(':scope > .nish-tooltip-content');\n if (!tip) return;\n if (!tip.getAttribute('role')) tip.setAttribute('role', 'tooltip');\n if (!tip.id) tip.id = `nish-tip-${++dialogSeq}`;\n const ids = (t.getAttribute('aria-describedby') ?? '').split(/\\s+/).filter(Boolean);\n if (!ids.includes(tip.id)) t.setAttribute('aria-describedby', [...ids, tip.id].join(' '));\n });\n const trigger = (e: Event) => (e.target instanceof Element ? e.target.closest<HTMLElement>('.nish-tooltip') : null);\n const onKey = (e: Event) => {\n if ((e as KeyboardEvent).key !== 'Escape') return;\n const open = root.querySelectorAll<HTMLElement>('.nish-tooltip:hover, .nish-tooltip:focus-within');\n open.forEach((t) => t.setAttribute('data-tooltip-hidden', ''));\n };\n const reset = (e: Event) => {\n const t = trigger(e);\n if (!t) return;\n const to = (e as MouseEvent | FocusEvent).relatedTarget as Node | null;\n if (to && t.contains(to)) return;\n t.removeAttribute('data-tooltip-hidden');\n };\n root.addEventListener('keydown', onKey);\n root.addEventListener('mouseout', reset);\n root.addEventListener('focusout', reset);\n return () => {\n root.removeEventListener('keydown', onKey);\n root.removeEventListener('mouseout', reset);\n root.removeEventListener('focusout', reset);\n };\n}\n\n// --- Static layout helpers (sheets, scrollspy, stuck, checklists, height vars) -------\n\nconst reducedMotion = () => typeof matchMedia !== 'undefined' && matchMedia('(prefers-reduced-motion: reduce)').matches;\n\n/** Open a <dialog class=\"nish-sheet\"> as a modal bottom sheet (a centered panel from\n * 640px): showModal, Escape and a backdrop click close it, a downward swipe on the handle\n * or header closes it on touch, `[data-sheet-close]` elements inside close it, and focus\n * returns to the element that opened it. The exit animation plays before the dialog\n * closes (none under reduced motion). The dialog's own `close` event still fires. Returns\n * a function that closes the sheet. Needs nish-components.css. */\nexport function openSheet(dialog: HTMLDialogElement): () => void {\n if (typeof document === 'undefined') return () => undefined;\n if (dialog.open) return () => closeNow();\n const opener = document.activeElement instanceof HTMLElement ? document.activeElement : null;\n let closing = false;\n let dragging = false;\n\n function closeNow(): void {\n if (closing || !dialog.open) return;\n closing = true;\n // eslint-disable-next-line prefer-const -- assigned after `finish`, which the reduced-motion path calls first (a const would hit its TDZ)\n let timer: ReturnType<typeof setTimeout> | undefined;\n const finish = () => {\n dialog.removeEventListener('animationend', onEnd);\n if (timer !== undefined) clearTimeout(timer);\n dialog.removeAttribute('data-closing');\n dialog.style.transform = '';\n dialog.style.transition = '';\n closing = false;\n if (dialog.open) dialog.close();\n };\n const onEnd = (e: AnimationEvent) => {\n if (e.target === dialog) finish();\n };\n if (reducedMotion()) {\n finish();\n return;\n }\n dialog.style.transform = '';\n dialog.setAttribute('data-closing', '');\n dialog.addEventListener('animationend', onEnd);\n timer = setTimeout(finish, 260);\n }\n\n const onCancel = (e: Event) => {\n e.preventDefault();\n closeNow();\n };\n const onKey = (e: KeyboardEvent) => {\n // Keep Escape from an outer framework dialog; the cancel event does the closing.\n if (e.key === 'Escape') e.stopPropagation();\n };\n const onClick = (e: MouseEvent) => {\n if (e.target === dialog) {\n const r = dialog.getBoundingClientRect();\n const inside = e.clientX >= r.left && e.clientX <= r.right && e.clientY >= r.top && e.clientY <= r.bottom;\n if (!inside) closeNow();\n return;\n }\n if (e.target instanceof Element && e.target.closest('[data-sheet-close]')) closeNow();\n };\n\n // Swipe down on the handle or header (touch and pen, phone layout only).\n let startY = 0;\n let lastY = 0;\n let lastT = 0;\n let velocity = 0;\n let height = 1;\n const onDown = (e: PointerEvent) => {\n if (e.pointerType === 'mouse' || closing || !e.isPrimary) return;\n if (typeof matchMedia !== 'undefined' && matchMedia('(min-width: 640px)').matches) return;\n const r = dialog.getBoundingClientRect();\n const onHeader = e.target instanceof Element && e.target.closest('.nish-sheet-header') != null;\n if (!onHeader && e.clientY - r.top > 28) return;\n dragging = true;\n startY = lastY = e.clientY;\n lastT = e.timeStamp;\n velocity = 0;\n height = r.height || 1;\n dialog.style.transition = 'none';\n dialog.setPointerCapture?.(e.pointerId);\n };\n const onMove = (e: PointerEvent) => {\n if (!dragging) return;\n const dy = e.clientY - startY;\n const dt = e.timeStamp - lastT;\n if (dt > 0) velocity = (e.clientY - lastY) / dt;\n lastY = e.clientY;\n lastT = e.timeStamp;\n dialog.style.transform = `translateY(${dy >= 0 ? dy : dy * 0.3}px)`;\n };\n const onUp = (e: PointerEvent) => {\n if (!dragging) return;\n dragging = false;\n dialog.releasePointerCapture?.(e.pointerId);\n const dy = e.clientY - startY;\n if (e.type !== 'pointercancel' && (dy > height * 0.3 || velocity > 0.5)) {\n closeNow();\n return;\n }\n dialog.style.transition = 'transform 180ms var(--nish-ease-out, ease-out)';\n dialog.style.transform = '';\n setTimeout(() => {\n if (!closing) dialog.style.transition = '';\n }, 200);\n };\n\n const onClose = () => {\n dialog.removeEventListener('cancel', onCancel);\n dialog.removeEventListener('keydown', onKey);\n dialog.removeEventListener('click', onClick);\n dialog.removeEventListener('pointerdown', onDown);\n dialog.removeEventListener('pointermove', onMove);\n dialog.removeEventListener('pointerup', onUp);\n dialog.removeEventListener('pointercancel', onUp);\n dialog.removeEventListener('close', onClose);\n if (opener?.isConnected) opener.focus();\n };\n dialog.addEventListener('cancel', onCancel);\n dialog.addEventListener('keydown', onKey);\n dialog.addEventListener('click', onClick);\n dialog.addEventListener('pointerdown', onDown);\n dialog.addEventListener('pointermove', onMove);\n dialog.addEventListener('pointerup', onUp);\n dialog.addEventListener('pointercancel', onUp);\n dialog.addEventListener('close', onClose);\n dialog.showModal();\n return closeNow;\n}\n\n/** Publish an element's height as a CSS variable on <html> (the static twin of\n * useHeightVar): `mountHeightVar(nav, '--nish-bottom-nav-h')`. Written now and on every\n * resize; removed when the element is hidden (height 0) and by the returned cleanup. */\nexport function mountHeightVar(el: HTMLElement, name: string): () => void {\n if (typeof document === 'undefined') return () => undefined;\n const root = document.documentElement;\n const write = () => {\n const h = el.offsetHeight;\n if (h > 0) root.style.setProperty(name, `${h}px`);\n else root.style.removeProperty(name);\n };\n write();\n let ro: ResizeObserver | undefined;\n if (typeof ResizeObserver !== 'undefined') {\n ro = new ResizeObserver(write);\n ro.observe(el);\n } else {\n window.addEventListener('resize', write);\n }\n return () => {\n ro?.disconnect();\n window.removeEventListener('resize', write);\n root.style.removeProperty(name);\n };\n}\n\n/** Toggle `data-stuck` on a position:sticky element while it is stuck to its `top`: the page\n * (or a scrolling ancestor) has scrolled and the element rests at its sticky `top`. Not\n * stuck at scroll 0, when the element is not position:sticky, or once its container has\n * carried it past the top. Nothing is inserted into the DOM, so flex and grid parents are\n * unaffected. An IntersectionObserver (its root margin cut 1px below the sticky `top`)\n * and scroll events trigger the check; the `top` is re-read on resize and `<html>` style\n * changes. Style `.nish-sticky[data-stuck]` or your own. `onChange` is called with every\n * change. Returns a function that stops watching. */\nexport function mountStuck(el: HTMLElement, onChange?: (stuck: boolean) => void): () => void {\n if (typeof document === 'undefined' || typeof IntersectionObserver === 'undefined') return () => undefined;\n let io: IntersectionObserver | undefined;\n let builtTop = Number.NaN;\n let current = false;\n const scrolled = () => {\n if ((window.scrollY || document.documentElement.scrollTop || 0) > 0) return true;\n for (let p = el.parentElement; p && p !== document.body && p !== document.documentElement; p = p.parentElement) {\n if (p.scrollTop > 0) return true;\n }\n return false;\n };\n const evaluate = () => {\n const style = getComputedStyle(el);\n const next =\n style.position === 'sticky' &&\n Math.abs(el.getBoundingClientRect().top - (parseFloat(style.top) || 0)) < 1 &&\n scrolled();\n if (next === current) return;\n current = next;\n if (next) el.setAttribute('data-stuck', '');\n else el.removeAttribute('data-stuck');\n onChange?.(next);\n };\n const build = () => {\n const top = Math.round(parseFloat(getComputedStyle(el).top) || 0);\n if (top !== builtTop) {\n builtTop = top;\n io?.disconnect();\n io = new IntersectionObserver(evaluate, {\n threshold: [0, 0.25, 0.5, 0.75, 0.9, 0.99, 1],\n rootMargin: `${-top - 1}px 0px 0px 0px`,\n });\n io.observe(el);\n }\n evaluate();\n };\n // Capture: scroll does not bubble, and a scrolling ancestor may be the sticky root.\n window.addEventListener('scroll', evaluate, { passive: true, capture: true });\n build();\n let ro: ResizeObserver | undefined;\n if (typeof ResizeObserver !== 'undefined') {\n ro = new ResizeObserver(build);\n ro.observe(el);\n }\n let mo: MutationObserver | undefined;\n if (typeof MutationObserver !== 'undefined') {\n mo = new MutationObserver(build);\n mo.observe(document.documentElement, { attributes: true, attributeFilter: ['style'] });\n }\n return () => {\n window.removeEventListener('scroll', evaluate, { capture: true });\n io?.disconnect();\n ro?.disconnect();\n mo?.disconnect();\n el.removeAttribute('data-stuck');\n };\n}\n\nexport interface MountScrollspyOptions {\n /** Pixels from the top of the viewport where a section counts as current. Default: the\n * `--nish-header-h` variable plus the nav's own height plus 8. */\n offset?: number;\n /** Publish the nav's height as `--nish-sticky-extra`. Default true; a non-sticky nav passes\n * false so it does not touch a value another sticky nav publishes. */\n height?: boolean;\n}\n\n/** Scrollspy for a `.nish-subnav`: each `a[href^=\"#\"]` maps to the element with that id.\n * The link whose section is current gets `aria-current=\"true\"` (the last section whose top\n * has passed the offset, the first one at the top of the page), is scrolled into view\n * inside the nav, and the nav gets `data-at-start` / `data-at-end` for its edge fades.\n * Publishes the nav's height as `--nish-sticky-extra` so `.nish-scroll-target` clears it.\n * Returns a function that removes everything. */\nexport function mountScrollspy(nav: HTMLElement, o: MountScrollspyOptions = {}): () => void {\n if (typeof document === 'undefined') return () => undefined;\n const links = Array.from(nav.querySelectorAll<HTMLAnchorElement>('a[href^=\"#\"]')).filter((a) => a.hash.length > 1);\n const target = (a: HTMLAnchorElement) => {\n try {\n return document.getElementById(decodeURIComponent(a.hash.slice(1)));\n } catch {\n return null;\n }\n };\n const unheight = o.height === false ? () => undefined : mountHeightVar(nav, '--nish-sticky-extra');\n let current: HTMLAnchorElement | null = null;\n\n const edges = () => {\n const max = nav.scrollWidth - nav.clientWidth;\n nav.dataset.atStart = String(nav.scrollLeft <= 1);\n nav.dataset.atEnd = String(max <= 1 || nav.scrollLeft >= max - 1);\n };\n const reveal = (a: HTMLAnchorElement) => {\n const left = a.offsetLeft - nav.offsetLeft;\n const view = nav.clientWidth;\n if (left < nav.scrollLeft + 24) nav.scrollLeft = Math.max(0, left - 24);\n else if (left + a.offsetWidth > nav.scrollLeft + view - 24) nav.scrollLeft = left + a.offsetWidth - view + 24;\n };\n const activate = (a: HTMLAnchorElement | null) => {\n if (a === current) return;\n current?.removeAttribute('aria-current');\n current = a;\n if (a) {\n a.setAttribute('aria-current', 'true');\n reveal(a);\n }\n };\n const update = () => {\n const header = parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--nish-header-h')) || 0;\n const line = o.offset ?? header + nav.offsetHeight + 8;\n let found: HTMLAnchorElement | null = links[0] ?? null;\n for (const a of links) {\n const t = target(a);\n if (t && t.getBoundingClientRect().top <= line + 1) found = a;\n }\n const de = document.documentElement;\n if (window.innerHeight + window.scrollY >= de.scrollHeight - 2) {\n for (const a of links) if (target(a)) found = a;\n }\n activate(found);\n };\n let frame = 0;\n const schedule = () => {\n if (frame) return;\n frame = requestAnimationFrame(() => {\n frame = 0;\n update();\n });\n };\n const onClick = (e: MouseEvent) => {\n const a = e.target instanceof Element ? e.target.closest<HTMLAnchorElement>('a[href^=\"#\"]') : null;\n if (a && links.includes(a)) activate(a);\n };\n edges();\n update();\n window.addEventListener('scroll', schedule, { passive: true });\n window.addEventListener('resize', schedule);\n nav.addEventListener('scroll', edges, { passive: true });\n nav.addEventListener('click', onClick);\n let ro: ResizeObserver | undefined;\n if (typeof ResizeObserver !== 'undefined') {\n ro = new ResizeObserver(() => {\n edges();\n schedule();\n });\n ro.observe(nav);\n }\n return () => {\n if (frame) cancelAnimationFrame(frame);\n window.removeEventListener('scroll', schedule);\n window.removeEventListener('resize', schedule);\n nav.removeEventListener('scroll', edges);\n nav.removeEventListener('click', onClick);\n ro?.disconnect();\n unheight();\n current?.removeAttribute('aria-current');\n delete nav.dataset.atStart;\n delete nav.dataset.atEnd;\n };\n}\n\n/** Persist a checklist: the `input[type=checkbox]` inside each `li[data-id]` of `list` is\n * saved to localStorage under `list.dataset.store` (a JSON array of checked ids) and\n * restored now. Updates the `.nish-checklist-progress` element before the list (or the\n * first one in its parent) to \"{done} of {total}\" and its `--p` meter. Without\n * `data-store` it still counts. Storage failures are ignored. Returns a function that\n * removes the listener. */\nexport function mountChecklist(list: HTMLElement): () => void {\n if (typeof document === 'undefined') return () => undefined;\n const key = list.dataset.store || null;\n const boxes = () => Array.from(list.querySelectorAll<HTMLInputElement>('li[data-id] input[type=\"checkbox\"]'));\n const idOf = (b: HTMLInputElement) => b.closest<HTMLElement>('li[data-id]')?.dataset.id ?? '';\n let progress: Element | null = null;\n for (let sib = list.previousElementSibling; sib; sib = sib.previousElementSibling) {\n if (sib.classList.contains('nish-checklist-progress')) {\n progress = sib;\n break;\n }\n }\n progress ??= list.parentElement?.querySelector('.nish-checklist-progress') ?? null;\n\n if (key) {\n try {\n const saved: unknown = JSON.parse(localStorage.getItem(key) ?? '[]');\n if (Array.isArray(saved)) for (const b of boxes()) b.checked = saved.includes(idOf(b));\n } catch {\n /* storage blocked or corrupt: start unchecked */\n }\n }\n const render = () => {\n const all = boxes();\n const done = all.filter((b) => b.checked).length;\n if (progress) {\n progress.textContent = `${done} of ${all.length}`;\n (progress as HTMLElement).style.setProperty('--p', `${all.length ? (done / all.length) * 100 : 0}%`);\n }\n };\n const onChange = (e: Event) => {\n if (!(e.target instanceof HTMLInputElement) || e.target.type !== 'checkbox') return;\n if (key) {\n try {\n localStorage.setItem(key, JSON.stringify(boxes().filter((b) => b.checked).map(idOf)));\n } catch {\n /* storage blocked: the state lasts for this page view */\n }\n }\n render();\n };\n render();\n list.addEventListener('change', onChange);\n return () => list.removeEventListener('change', onChange);\n}\n\n/** For pages without a framework: apply now and start syncing. */\nexport function initTheme(): ThemeName {\n watch();\n return applyTheme();\n}\n"],"mappings":";AAIA,SAAS,WAAW,gBAAoC;;;ACqDjD,IAAM,YAAY,CAAC,WAAW,UAAU,SAAS,QAAQ,QAAQ,OAAO,UAAU,MAAM;AAIxF,IAAM,aAAa,CAAC,UAAU,MAAM,QAAQ,QAAQ,QAAQ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