@pixerate/editor 0.51.0 → 0.53.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/dist/agent/index.cjs +23 -23
- package/dist/agent/index.js +4 -4
- package/dist/chart/index.cjs +475 -124
- package/dist/chart/index.cjs.map +1 -1
- package/dist/chart/index.d.cts +174 -25
- package/dist/chart/index.d.ts +174 -25
- package/dist/chart/index.js +375 -24
- package/dist/chart/index.js.map +1 -1
- package/dist/{chunk-GJBIVWB2.js → chunk-3S72F46R.js} +387 -9
- package/dist/chunk-3S72F46R.js.map +1 -0
- package/dist/{chunk-5TWIN7ZJ.js → chunk-47WWV3LI.js} +34 -4
- package/dist/chunk-47WWV3LI.js.map +1 -0
- package/dist/{chunk-OV7UAKIY.js → chunk-633QC34G.js} +172 -1
- package/dist/chunk-633QC34G.js.map +1 -0
- package/dist/{chunk-MR2764X2.js → chunk-AGGUNWT6.js} +2 -322
- package/dist/chunk-AGGUNWT6.js.map +1 -0
- package/dist/{chunk-T6XU4B54.js → chunk-BQQZ6MOI.js} +7 -7
- package/dist/{chunk-LNKZPIQD.cjs → chunk-C3JHII3M.cjs} +67 -67
- package/dist/{chunk-LNKZPIQD.cjs.map → chunk-C3JHII3M.cjs.map} +1 -1
- package/dist/{chunk-JOX6MJW4.cjs → chunk-CKRNELPO.cjs} +176 -5
- package/dist/chunk-CKRNELPO.cjs.map +1 -0
- package/dist/{chunk-TGBCBQFV.cjs → chunk-DK6QBGCS.cjs} +45 -15
- package/dist/chunk-DK6QBGCS.cjs.map +1 -0
- package/dist/{chunk-GTZXF4BI.cjs → chunk-NK3WL5TJ.cjs} +298 -133
- package/dist/chunk-NK3WL5TJ.cjs.map +1 -0
- package/dist/{chunk-3JNRQVTS.cjs → chunk-NN3JGUSX.cjs} +402 -24
- package/dist/chunk-NN3JGUSX.cjs.map +1 -0
- package/dist/{chunk-3CC7OPUQ.cjs → chunk-O6FO6VI3.cjs} +3 -323
- package/dist/chunk-O6FO6VI3.cjs.map +1 -0
- package/dist/{chunk-DQPBQXKG.js → chunk-OIKYP7XC.js} +8 -8
- package/dist/{chunk-FEMIVHN3.cjs → chunk-P43HUQRX.cjs} +16 -16
- package/dist/{chunk-FEMIVHN3.cjs.map → chunk-P43HUQRX.cjs.map} +1 -1
- package/dist/{chunk-QFTVLEVN.js → chunk-RIXTW3C4.js} +3 -3
- package/dist/{chunk-WBOAXDKD.js → chunk-VODBAO32.js} +222 -57
- package/dist/chunk-VODBAO32.js.map +1 -0
- package/dist/{chunk-2Q46FKZK.cjs → chunk-YZZMX6V7.cjs} +25 -25
- package/dist/{chunk-2Q46FKZK.cjs.map → chunk-YZZMX6V7.cjs.map} +1 -1
- package/dist/{controller-DS3drIvy.d.cts → controller-CX0QfSv0.d.cts} +53 -2
- package/dist/{controller-BdKzaxs2.d.ts → controller-DscWQbjO.d.ts} +53 -2
- package/dist/export/index.cjs +5 -5
- package/dist/export/index.js +4 -4
- package/dist/extensions/index.cjs +7 -7
- package/dist/extensions/index.d.cts +2 -2
- package/dist/extensions/index.d.ts +2 -2
- package/dist/extensions/index.js +6 -6
- package/dist/{index-Dt9lzydb.d.ts → index-CALDD35B.d.ts} +1 -1
- package/dist/{index-DOy9HzfC.d.cts → index-DIWB6xMf.d.cts} +1 -1
- package/dist/index.cjs +15 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -113
- package/dist/index.d.ts +6 -113
- package/dist/index.js +13 -12
- package/dist/index.js.map +1 -1
- package/dist/zip-4nG0YAH7.d.cts +110 -0
- package/dist/zip-4nG0YAH7.d.ts +110 -0
- package/package.json +1 -1
- package/dist/chunk-3CC7OPUQ.cjs.map +0 -1
- package/dist/chunk-3JNRQVTS.cjs.map +0 -1
- package/dist/chunk-5TWIN7ZJ.js.map +0 -1
- package/dist/chunk-GJBIVWB2.js.map +0 -1
- package/dist/chunk-GTZXF4BI.cjs.map +0 -1
- package/dist/chunk-JOX6MJW4.cjs.map +0 -1
- package/dist/chunk-MR2764X2.js.map +0 -1
- package/dist/chunk-OV7UAKIY.js.map +0 -1
- package/dist/chunk-TGBCBQFV.cjs.map +0 -1
- package/dist/chunk-WBOAXDKD.js.map +0 -1
- /package/dist/{chunk-T6XU4B54.js.map → chunk-BQQZ6MOI.js.map} +0 -0
- /package/dist/{chunk-DQPBQXKG.js.map → chunk-OIKYP7XC.js.map} +0 -0
- /package/dist/{chunk-QFTVLEVN.js.map → chunk-RIXTW3C4.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/chart/color.ts","../src/chart/errorbars.ts","../src/chart/spec.ts"],"sourcesContent":["// Portions ported from gridcraft-main/crates/chart/src/resolve.rs (palette tint cycle) and\n// crates/chart/src/render.rs (`on`: label colour from the fill), and designcraft-main/crates/color/src/cms/mod.rs\n// (`simulate_cvd`, Machado–Oliveira–Fernandes 2009 matrices) (MIT OR Apache-2.0, © ArtCraft Team and contributors).\n// See THIRD_PARTY_NOTICES.md.\n\n/** An sRGB colour with channels from 0 to 1. */\nexport type ChartRgb = [number, number, number];\n\nconst NAMED: Record<string, string> = {\n\tblack: '#000000',\n\twhite: '#ffffff',\n\tred: '#ff0000',\n\tgreen: '#008000',\n\tblue: '#0000ff',\n\tyellow: '#ffff00',\n\torange: '#ffa500',\n\tpurple: '#800080',\n\tgray: '#808080',\n\tgrey: '#808080',\n\tteal: '#008080',\n\tnavy: '#000080',\n\tmaroon: '#800000',\n\tolive: '#808000',\n\tsilver: '#c0c0c0',\n\tlime: '#00ff00',\n\taqua: '#00ffff',\n\tcyan: '#00ffff',\n\tfuchsia: '#ff00ff',\n\tmagenta: '#ff00ff',\n\tpink: '#ffc0cb',\n\tbrown: '#a52a2a'\n};\n\n/**\n * Reads `#rgb`, `#rrggbb`, `#rrggbbaa`, `rgb()` / `rgba()` and a few colour names. Returns\n * `null` for anything else (CSS variables, `hsl()`, …), so callers can leave such colours alone.\n */\nexport function parseChartColor(color: string): ChartRgb | null {\n\tconst text = color.trim().toLowerCase();\n\tconst hex = NAMED[text] ?? text;\n\tlet m = /^#([0-9a-f]{3})$/.exec(hex);\n\tif (m) return [...m[1]].map((c) => parseInt(c + c, 16) / 255) as ChartRgb;\n\tm = /^#([0-9a-f]{6})([0-9a-f]{2})?$/.exec(hex);\n\tif (m) return [0, 2, 4].map((i) => parseInt(m![1].slice(i, i + 2), 16) / 255) as ChartRgb;\n\tm = /^rgba?\\(\\s*([\\d.]+)%?[\\s,]+([\\d.]+)%?[\\s,]+([\\d.]+)%?(?:[\\s,/]+[\\d.]+%?)?\\s*\\)$/.exec(text);\n\tif (m) {\n\t\tconst pct = text.includes('%');\n\t\treturn [m[1], m[2], m[3]].map((v) => Math.max(0, Math.min(1, Number(v) / (pct ? 100 : 255)))) as ChartRgb;\n\t}\n\treturn null;\n}\n\nexport function chartRgbToHex(rgb: ChartRgb): string {\n\treturn `#${rgb.map((c) => Math.round(Math.max(0, Math.min(1, c)) * 255).toString(16).padStart(2, '0')).join('')}`;\n}\n\n/**\n * A lighter (`amount` > 0, towards white) or darker (`amount` < 0, towards black) shade of\n * `color`. Colours it cannot read (CSS variables) come back unchanged.\n */\nexport function shadeChartColor(color: string, amount: number): string {\n\tconst rgb = parseChartColor(color);\n\tif (!rgb || !amount) return color;\n\tconst t = Math.max(-1, Math.min(1, amount));\n\treturn chartRgbToHex(rgb.map((c) => (t > 0 ? c + (1 - c) * t : c * (1 + t))) as ChartRgb);\n}\n\n/** Shades used once a palette is used up: the same hues, lighter then darker (GridCraft's cycle). */\nexport const CHART_PALETTE_SHADES: readonly number[] = [0, 0.4, -0.25, 0.6, -0.5, 0.2];\n\n/** The palette colour for the `index`-th item: the palette in order, then lighter and darker rounds of it. */\nexport function cyclePaletteColor(palette: readonly string[], index: number): string {\n\tconst base = palette[index % palette.length];\n\tconst round = Math.floor(index / palette.length) % CHART_PALETTE_SHADES.length;\n\treturn shadeChartColor(base, CHART_PALETTE_SHADES[round]);\n}\n\nconst toLinear = (c: number) => (c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4));\nconst fromLinear = (c: number) => (c <= 0.0031308 ? c * 12.92 : 1.055 * Math.pow(c, 1 / 2.4) - 0.055);\n\n/** WCAG relative luminance (0 black – 1 white). */\nexport function chartLuminance(rgb: ChartRgb): number {\n\tconst [r, g, b] = rgb.map(toLinear);\n\treturn 0.2126 * r + 0.7152 * g + 0.0722 * b;\n}\n\n/** WCAG contrast ratio (1–21) between two colours, or `null` when either cannot be read. */\nexport function chartContrastRatio(a: string, b: string): number | null {\n\tconst ra = parseChartColor(a);\n\tconst rb = parseChartColor(b);\n\tif (!ra || !rb) return null;\n\tconst la = chartLuminance(ra);\n\tconst lb = chartLuminance(rb);\n\treturn (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05);\n}\n\n/**\n * Dark or white text, whichever reads better on `fill`; `fallback` when the fill cannot be\n * read (a CSS variable).\n */\nexport function chartTextOn(fill: string, fallback: string, dark = '#0f172a', light = '#ffffff'): string {\n\tconst rgb = parseChartColor(fill);\n\tif (!rgb) return fallback;\n\tconst darkRatio = chartContrastRatio(fill, dark)!;\n\tconst lightRatio = chartContrastRatio(fill, light)!;\n\treturn darkRatio >= lightRatio ? dark : light;\n}\n\n/** OKLab (Ottosson) from sRGB. */\nexport function chartRgbToOklab(rgb: ChartRgb): [number, number, number] {\n\tconst [r, g, b] = rgb.map(toLinear);\n\tconst l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);\n\tconst m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);\n\tconst s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);\n\treturn [\n\t\t0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,\n\t\t1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,\n\t\t0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s\n\t];\n}\n\n/** Perceptual distance between two colours (Euclidean in OKLab; ≈0.02 is just noticeable). */\nexport function chartColorDistance(a: ChartRgb, b: ChartRgb): number {\n\tconst p = chartRgbToOklab(a);\n\tconst q = chartRgbToOklab(b);\n\treturn Math.hypot(p[0] - q[0], p[1] - q[1], p[2] - q[2]);\n}\n\nexport type ChartVision = 'normal' | 'protanopia' | 'deuteranopia' | 'tritanopia';\n\n// Machado, Oliveira & Fernandes (2009), severity 1.0, applied in linear RGB.\nconst CVD: Record<Exclude<ChartVision, 'normal'>, number[][]> = {\n\tprotanopia: [\n\t\t[0.152286, 1.052583, -0.204868],\n\t\t[0.114503, 0.786281, 0.099216],\n\t\t[-0.003882, -0.048116, 1.051998]\n\t],\n\tdeuteranopia: [\n\t\t[0.367322, 0.860646, -0.227968],\n\t\t[0.280085, 0.672501, 0.047413],\n\t\t[-0.01182, 0.04294, 0.968881]\n\t],\n\ttritanopia: [\n\t\t[1.255528, -0.076749, -0.178779],\n\t\t[-0.078411, 0.930809, 0.147602],\n\t\t[0.004733, 0.691367, 0.3039]\n\t]\n};\n\n/** How a colour looks with a colour-vision deficiency (Machado et al. 2009, full severity). */\nexport function simulateChartVision(rgb: ChartRgb, vision: ChartVision): ChartRgb {\n\tif (vision === 'normal') return rgb;\n\tconst lin = rgb.map(toLinear);\n\tconst m = CVD[vision];\n\treturn m.map((row) => fromLinear(Math.max(0, Math.min(1, row[0] * lin[0] + row[1] * lin[1] + row[2] * lin[2])))) as ChartRgb;\n}\n\nexport interface ChartColorPair {\n\ta: number;\n\tb: number;\n\tcolors: [string, string];\n\tdistance: number;\n}\n\nexport interface ChartColorCheck {\n\t/** No problems found. */\n\tok: boolean;\n\t/** Per vision: the closest pair of colours and their OKLab distance. */\n\tclosest: Partial<Record<ChartVision, ChartColorPair>>;\n\t/** Contrast ratio of each colour against the surface (null when unreadable). */\n\tcontrast: (number | null)[];\n\t/** Problems, as sentences. */\n\tissues: string[];\n\t/** Colours that could not be read (CSS variables, `hsl()`); they are skipped. */\n\tskipped: string[];\n}\n\nexport interface ChartColorCheckOptions {\n\t/** The page colour behind the marks (default white). */\n\tsurface?: string;\n\t/** Smallest OKLab distance two series may have (default 0.08). */\n\tminDistance?: number;\n\t/** Smallest contrast ratio against the surface (default 1.5; WCAG asks 3 for graphics). */\n\tminContrast?: number;\n\t/** Visions to check (default all four). */\n\tvisions?: readonly ChartVision[];\n}\n\n/**\n * Checks that series colours can be told apart, with normal vision and the three\n * colour-vision deficiencies, and stand out from the surface. Returns the closest pair per\n * vision and problems as sentences.\n */\nexport function checkChartColors(colors: readonly string[], options: ChartColorCheckOptions = {}): ChartColorCheck {\n\tconst surface = options.surface ?? '#ffffff';\n\tconst minDistance = options.minDistance ?? 0.08;\n\tconst minContrast = options.minContrast ?? 1.5;\n\tconst visions = options.visions ?? (['normal', 'protanopia', 'deuteranopia', 'tritanopia'] as const);\n\tconst parsed = colors.map(parseChartColor);\n\tconst skipped = colors.filter((_, i) => !parsed[i]);\n\tconst issues: string[] = [];\n\tconst closest: ChartColorCheck['closest'] = {};\n\tfor (const vision of visions) {\n\t\tconst seen = parsed.map((c) => (c ? simulateChartVision(c, vision) : null));\n\t\tlet best: ChartColorPair | undefined;\n\t\tfor (let a = 0; a < seen.length; a++) {\n\t\t\tfor (let b = a + 1; b < seen.length; b++) {\n\t\t\t\tif (!seen[a] || !seen[b]) continue;\n\t\t\t\tconst distance = chartColorDistance(seen[a]!, seen[b]!);\n\t\t\t\tif (!best || distance < best.distance) best = { a, b, colors: [colors[a], colors[b]], distance: Math.round(distance * 1000) / 1000 };\n\t\t\t}\n\t\t}\n\t\tif (best) {\n\t\t\tclosest[vision] = best;\n\t\t\tif (best.distance < minDistance) {\n\t\t\t\tconst who = vision === 'normal' ? '' : ` with ${vision}`;\n\t\t\t\tissues.push(`Colours ${best.a + 1} (${best.colors[0]}) and ${best.b + 1} (${best.colors[1]}) are hard to tell apart${who} (distance ${best.distance}, want at least ${minDistance}).`);\n\t\t\t}\n\t\t}\n\t}\n\tconst contrast = colors.map((c) => {\n\t\tconst ratio = chartContrastRatio(c, surface);\n\t\treturn ratio === null ? null : Math.round(ratio * 100) / 100;\n\t});\n\tcontrast.forEach((ratio, i) => {\n\t\tif (ratio !== null && ratio < minContrast) issues.push(`Colour ${i + 1} (${colors[i]}) barely stands out from the background ${surface} (contrast ${ratio}:1, want at least ${minContrast}:1).`);\n\t});\n\treturn { ok: issues.length === 0, closest, contrast, issues, skipped };\n}\n","import type { ChartErrorBars, ChartErrorBarType, ChartValue } from './types.js';\n\nexport const CHART_ERROR_BAR_TYPES: readonly ChartErrorBarType[] = ['fixed', 'percent', 'stddev', 'stderr', 'custom'];\nexport const CHART_ERROR_BAR_DIRECTIONS: readonly NonNullable<ChartErrorBars['direction']>[] = ['both', 'plus', 'minus'];\n\n/** Labels for pickers, shared by the React and Svelte components. */\nexport const CHART_ERROR_BAR_LABELS: Readonly<Record<ChartErrorBarType, string>> = {\n\tfixed: 'Fixed amount',\n\tpercent: 'Percentage',\n\tstddev: 'Standard deviation',\n\tstderr: 'Standard error',\n\tcustom: 'Custom'\n};\n\n/** The default `value` per type (`fixed` 1, `percent` 5, `stddev` 1). */\nexport function defaultChartErrorBarValue(type: ChartErrorBarType): number | undefined {\n\treturn type === 'fixed' ? 1 : type === 'percent' ? 5 : type === 'stddev' ? 1 : undefined;\n}\n\n/** One point's error bar: where it is centred and how far it reaches each way (both 0 or more). */\nexport interface ChartErrorAmount {\n\t/** The point's value, or the series mean for `stddev` (as Excel draws it). */\n\tcenter: number;\n\tplus: number;\n\tminus: number;\n}\n\n/** Mean and sample standard deviation of the finite values (sd 0 with fewer than 2). */\nfunction meanAndSd(values: readonly ChartValue[]): { mean: number; sd: number; n: number } {\n\tconst xs = values.filter((v): v is number => v !== null && Number.isFinite(v));\n\tconst n = xs.length;\n\tif (!n) return { mean: 0, sd: 0, n };\n\tconst mean = xs.reduce((t, v) => t + v, 0) / n;\n\tconst sd = n > 1 ? Math.sqrt(xs.reduce((t, v) => t + (v - mean) ** 2, 0) / (n - 1)) : 0;\n\treturn { mean, sd, n };\n}\n\n/**\n * The error bar at each point of `values` (a series' values, or its x values for x error\n * bars), following Excel's error amount types: `fixed` and `percent` from `value`, `stddev`\n * around the series mean, `stderr` (sample standard deviation / √n) and `custom` amounts from\n * `plus` / `minus`. Gaps (and custom points without an amount) give `null`.\n */\nexport function chartErrorAmounts(bars: ChartErrorBars, values: readonly ChartValue[]): (ChartErrorAmount | null)[] {\n\tconst direction = bars.direction ?? 'both';\n\tconst up = direction !== 'minus';\n\tconst down = direction !== 'plus';\n\tconst stats = bars.type === 'stddev' || bars.type === 'stderr' ? meanAndSd(values) : null;\n\tconst amount = bars.value ?? defaultChartErrorBarValue(bars.type) ?? 0;\n\treturn values.map((v, i) => {\n\t\tif (v === null || !Number.isFinite(v)) return null;\n\t\tlet plus: number;\n\t\tlet minus: number;\n\t\tlet center = v;\n\t\tswitch (bars.type) {\n\t\t\tcase 'fixed':\n\t\t\t\tplus = minus = Math.abs(amount);\n\t\t\t\tbreak;\n\t\t\tcase 'percent':\n\t\t\t\tplus = minus = Math.abs((v * amount) / 100);\n\t\t\t\tbreak;\n\t\t\tcase 'stddev':\n\t\t\t\tcenter = stats!.mean;\n\t\t\t\tplus = minus = Math.abs(amount) * stats!.sd;\n\t\t\t\tbreak;\n\t\t\tcase 'stderr':\n\t\t\t\tplus = minus = stats!.n ? stats!.sd / Math.sqrt(stats!.n) : 0;\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tconst p = bars.plus?.[i] ?? null;\n\t\t\t\tconst m = bars.minus?.[i] ?? (bars.minus ? null : p);\n\t\t\t\tif ((p === null || !Number.isFinite(p)) && (m === null || !Number.isFinite(m))) return null;\n\t\t\t\tplus = p !== null && Number.isFinite(p) ? Math.abs(p) : 0;\n\t\t\t\tminus = m !== null && Number.isFinite(m) ? Math.abs(m) : 0;\n\t\t\t}\n\t\t}\n\t\treturn { center, plus: up ? plus : 0, minus: down ? minus : 0 };\n\t});\n}\n\n/** A one-line description of error bars (\"±5% error bars\", \"±1 standard deviation error bars\"). */\nexport function describeChartErrorBars(bars: ChartErrorBars): string {\n\tconst sign = bars.direction === 'plus' ? '+' : bars.direction === 'minus' ? '−' : '±';\n\tconst value = bars.value ?? defaultChartErrorBarValue(bars.type);\n\tswitch (bars.type) {\n\t\tcase 'fixed':\n\t\t\treturn `${sign}${value} error bars`;\n\t\tcase 'percent':\n\t\t\treturn `${sign}${value}% error bars`;\n\t\tcase 'stddev':\n\t\t\treturn `${sign}${value} standard deviation${value === 1 ? '' : 's'} error bars`;\n\t\tcase 'stderr':\n\t\t\treturn `${sign}standard error bars`;\n\t\tdefault:\n\t\t\treturn 'custom error bars';\n\t}\n}\n\n/**\n * Error bars for a picker change: `null` for none, else bars of `type` that keep the current\n * direction and caps. Switching to `custom` starts from the amounts the current bars (or ±1)\n * draw, so the picture does not jump. Shared by the React and Svelte inspectors.\n */\nexport function chartErrorBarsOfType(type: ChartErrorBarType | '' | null, current: ChartErrorBars | undefined, values: readonly ChartValue[]): ChartErrorBars | null {\n\tif (!type) return null;\n\tconst keep: Partial<ChartErrorBars> = { ...(current?.direction ? { direction: current.direction } : {}), ...(current?.cap === false ? { cap: false } : {}) };\n\tif (type !== 'custom') return { type, ...keep, ...(current?.type === type && current.value !== undefined ? { value: current.value } : {}) };\n\tif (current?.type === 'custom') return current;\n\tconst amounts = chartErrorAmounts({ ...(current ?? { type: 'fixed' }), direction: 'both' }, values);\n\tconst round = (n: number) => Number(n.toPrecision(4));\n\tconst plus = amounts.map((a) => (a ? round(a.plus) : null));\n\tconst minus = amounts.map((a) => (a ? round(a.minus) : null));\n\treturn { type, plus, ...(JSON.stringify(minus) !== JSON.stringify(plus) ? { minus } : {}), ...keep };\n}\n\n/** Custom amounts as text for an input: \"1, 2, -, 0.5\" (`-` is a point without a bar). */\nexport function formatChartAmountList(values: readonly ChartValue[] | undefined): string {\n\treturn (values ?? []).map((v) => (v === null ? '-' : String(v))).join(', ');\n}\n\n/** Reads amounts typed as \"1, 2, -, 0.5\" (commas, semicolons or spaces; `-` or blank for none). */\nexport function parseChartAmountList(text: string): (string | null)[] {\n\treturn text\n\t\t.split(/[;,\\s]+/)\n\t\t.filter((t) => t !== '')\n\t\t.map((t) => (t === '-' ? null : t));\n}\n","import { cyclePaletteColor } from './color.js';\nimport { CHART_ERROR_BAR_DIRECTIONS, CHART_ERROR_BAR_TYPES } from './errorbars.js';\nimport type {\n\tChartAxis,\n\tChartCurve,\n\tChartErrorBars,\n\tChartIssue,\n\tChartLabelPosition,\n\tChartLegend,\n\tChartLegendPosition,\n\tChartMarker,\n\tChartNumberFormat,\n\tChartOrientation,\n\tChartSeries,\n\tChartSeriesType,\n\tChartSpec,\n\tChartStacking,\n\tChartTheme,\n\tChartTrendline,\n\tChartTrendlineType,\n\tChartType,\n\tChartValue\n} from './types.js';\n\nexport const CHART_TYPES: readonly ChartType[] = ['bar', 'line', 'area', 'scatter', 'bubble', 'pie', 'donut', 'radar', 'waterfall', 'histogram', 'box', 'funnel', 'treemap'];\nexport const CHART_MARKERS: readonly ChartMarker[] = ['circle', 'square', 'diamond', 'triangle', 'cross', 'none'];\nexport const CHART_TRENDLINE_TYPES: readonly ChartTrendlineType[] = ['linear', 'exponential', 'logarithmic', 'power', 'polynomial', 'moving-average'];\nexport const CHART_LABEL_POSITIONS: readonly ChartLabelPosition[] = ['auto', 'inside', 'outside', 'center'];\nexport const CHART_AXIS_KINDS: readonly NonNullable<ChartAxis['kind']>[] = ['category', 'date'];\nexport const CHART_AXIS_SCALES: readonly NonNullable<ChartAxis['scale']>[] = ['linear', 'log'];\nexport const CHART_SERIES_TYPES: readonly ChartSeriesType[] = ['bar', 'line', 'area', 'scatter'];\nexport const CHART_STACKINGS: readonly ChartStacking[] = ['none', 'stacked', 'percent'];\nexport const CHART_CURVES: readonly ChartCurve[] = ['linear', 'smooth', 'step'];\nexport const CHART_ORIENTATIONS: readonly ChartOrientation[] = ['vertical', 'horizontal'];\nexport const CHART_LEGEND_POSITIONS: readonly ChartLegendPosition[] = ['top', 'bottom', 'left', 'right'];\nexport const CHART_NUMBER_STYLES: readonly NonNullable<ChartNumberFormat['style']>[] = ['number', 'percent', 'currency', 'compact'];\n\n/** Labels for pickers, shared by the React and Svelte components. */\nexport const CHART_TYPE_LABELS: Readonly<Record<ChartType, string>> = {\n\tbar: 'Bar',\n\tline: 'Line',\n\tarea: 'Area',\n\tscatter: 'Scatter',\n\tbubble: 'Bubble',\n\tpie: 'Pie',\n\tdonut: 'Donut',\n\tradar: 'Radar',\n\twaterfall: 'Waterfall',\n\thistogram: 'Histogram',\n\tbox: 'Box plot',\n\tfunnel: 'Funnel',\n\ttreemap: 'Treemap'\n};\n\n/** How a chart type is laid out. */\nexport type ChartFamily = 'cartesian' | 'xy' | 'pie' | 'radar' | 'waterfall' | 'histogram' | 'box' | 'funnel' | 'treemap';\n\n/** A colour-blind-friendly categorical palette (Okabe–Ito order, tuned for light and dark backgrounds). */\nexport const DEFAULT_CHART_PALETTE: readonly string[] = ['#4269d0', '#efb118', '#ff725c', '#6cc5b0', '#3ca951', '#ff8ab7', '#a463f2', '#97bbf5', '#9c6b4e', '#9498a0'];\n\nexport const DEFAULT_CHART_THEME: ChartTheme = {\n\tbackground: '#ffffff',\n\tsurface: '#ffffff',\n\ttext: '#0f172a',\n\tmutedText: '#64748b',\n\tgrid: '#e2e8f0',\n\taxis: '#94a3b8',\n\tselection: '#2563eb',\n\tpositive: '#3ca951',\n\tnegative: '#e5484d',\n\tfontFamily: 'system-ui, -apple-system, \"Segoe UI\", sans-serif',\n\tfontSize: 11,\n\ttitleSize: 15\n};\n\n/**\n * A theme that reads the page's `--background`, `--foreground`, `--muted-foreground`,\n * `--border` and `--primary` colour variables (full colours, as the other components'\n * inline styles use them), with light fallbacks. The React and Svelte canvases use it.\n */\nexport const CSS_VARIABLE_CHART_THEME: ChartTheme = {\n\t...DEFAULT_CHART_THEME,\n\tbackground: 'transparent',\n\tsurface: 'var(--background, #ffffff)',\n\ttext: 'var(--foreground, #0f172a)',\n\tmutedText: 'var(--muted-foreground, #64748b)',\n\tgrid: 'var(--border, #e2e8f0)',\n\taxis: 'var(--muted-foreground, #94a3b8)',\n\tselection: 'var(--primary, #2563eb)',\n\tfontFamily: 'inherit'\n};\n\n/** Bar, line, area and scatter: categories (or numeric x) against values, series may mix. */\nexport function isCartesianChart(type: ChartType): boolean {\n\treturn type === 'bar' || type === 'line' || type === 'area' || type === 'scatter';\n}\n\n/** Whether the chart plots series against a numeric x axis (bubble charts, and scatter charts with x values). */\nexport function isXyChart(spec: Pick<ChartSpec, 'type' | 'series'>): boolean {\n\tif (spec.type === 'bubble') return true;\n\treturn spec.type === 'scatter' && spec.series.some((s) => !s.hidden && Array.isArray(s.x) && s.x.some((v) => v !== null));\n}\n\n/** How a chart is laid out (see `ChartType`). */\nexport function chartFamily(spec: Pick<ChartSpec, 'type' | 'series'>): ChartFamily {\n\tif (isXyChart(spec)) return 'xy';\n\tswitch (spec.type) {\n\t\tcase 'pie':\n\t\tcase 'donut':\n\t\t\treturn 'pie';\n\t\tcase 'radar':\n\t\tcase 'waterfall':\n\t\tcase 'histogram':\n\t\tcase 'box':\n\t\tcase 'funnel':\n\t\tcase 'treemap':\n\t\t\treturn spec.type;\n\t\tcase 'bubble':\n\t\t\treturn 'xy';\n\t\tdefault:\n\t\t\treturn 'cartesian';\n\t}\n}\n\n/** Chart types whose legend lists categories (one colour per category) rather than series. */\nexport function chartColorsByCategory(type: ChartType): boolean {\n\treturn type === 'pie' || type === 'donut' || type === 'funnel' || type === 'treemap';\n}\n\nexport function defaultChartAxis(value: boolean): ChartAxis {\n\treturn { show: true, title: '', min: null, max: null, step: null, gridlines: value, format: {} };\n}\n\n/** A complete spec with every default filled in. */\nexport function createChartSpec(partial: Partial<ChartSpec> = {}): ChartSpec {\n\treturn normalizeChartSpec(partial).spec;\n}\n\n/** The colour a series is drawn with. */\nexport function chartSeriesColor(spec: Pick<ChartSpec, 'palette' | 'series'>, seriesIndex: number): string {\n\tconst series = spec.series[seriesIndex];\n\tif (series?.color) return series.color;\n\treturn cyclePaletteColor(spec.palette.length ? spec.palette : DEFAULT_CHART_PALETTE, seriesIndex);\n}\n\n/** The colour a pie slice is drawn with (by category). */\nexport function chartSliceColor(spec: Pick<ChartSpec, 'palette'>, index: number): string {\n\treturn cyclePaletteColor(spec.palette.length ? spec.palette : DEFAULT_CHART_PALETTE, index);\n}\n\n/** The colour of one bar or point: its override, else the series colour. */\nexport function chartPointColor(spec: Pick<ChartSpec, 'palette' | 'series'>, seriesIndex: number, index: number): string {\n\treturn spec.series[seriesIndex]?.pointColors?.[index] || chartSeriesColor(spec, seriesIndex);\n}\n\n/** How a series is drawn in a cartesian chart. */\nexport function chartSeriesType(spec: Pick<ChartSpec, 'type'>, series: ChartSeries): ChartSeriesType {\n\tif (series.type) return series.type;\n\tif (spec.type === 'bubble') return 'scatter';\n\treturn isCartesianChart(spec.type) ? (spec.type as ChartSeriesType) : 'bar';\n}\n\n/** An id not used by any series (`series-1`, `series-2`, …). */\nexport function uniqueChartSeriesId(series: readonly Pick<ChartSeries, 'id'>[], base = 'series'): string {\n\tconst used = new Set(series.map((s) => s.id));\n\tfor (let i = series.length + 1; ; i++) {\n\t\tconst id = `${base}-${i}`;\n\t\tif (!used.has(id)) return id;\n\t}\n}\n\n/**\n * Reads a number the way people type it in a data grid: `1,234.5`, `12%` (→ 0.12),\n * `$40`, `(3)` (→ -3). Blank → `null`. Returns `undefined` when it is not a number.\n */\nexport function parseChartValue(input: unknown): ChartValue | undefined {\n\tif (input === null || input === undefined) return null;\n\tif (typeof input === 'number') return Number.isFinite(input) ? input : undefined;\n\tif (typeof input !== 'string') return undefined;\n\tlet text = input.trim();\n\tif (!text || text === '-' || text === '—') return null;\n\tlet negative = false;\n\tif (/^\\(.*\\)$/.test(text)) {\n\t\tnegative = true;\n\t\ttext = text.slice(1, -1).trim();\n\t}\n\tconst percent = text.endsWith('%');\n\tif (percent) text = text.slice(0, -1).trim();\n\ttext = text.replace(/^[$€£¥]/, '').replace(/,/g, '').replace(/\\s+/g, '');\n\tif (!/^[-+]?(\\d+\\.?\\d*|\\.\\d+)(e[-+]?\\d+)?$/i.test(text)) return undefined;\n\tlet value = Number(text);\n\tif (percent) value /= 100;\n\tif (negative) value = -value;\n\treturn Number.isFinite(value) ? value : undefined;\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => typeof value === 'object' && value !== null && !Array.isArray(value);\n\nfunction pick<T extends string>(value: unknown, options: readonly T[], fallback: T, path: string, issues: ChartIssue[]): T {\n\tif (value === undefined) return fallback;\n\tif (typeof value === 'string' && (options as readonly string[]).includes(value)) return value as T;\n\tissues.push({ path, message: `${path} must be one of ${options.map((o) => `\"${o}\"`).join(', ')}; got ${JSON.stringify(value)}.` });\n\treturn fallback;\n}\n\nfunction text(value: unknown, fallback: string, path: string, issues: ChartIssue[]): string {\n\tif (value === undefined || value === null) return fallback;\n\tif (typeof value === 'string') return value;\n\tif (typeof value === 'number' || typeof value === 'boolean') return String(value);\n\tissues.push({ path, message: `${path} must be text.` });\n\treturn fallback;\n}\n\nfunction flag(value: unknown, fallback: boolean, path: string, issues: ChartIssue[]): boolean {\n\tif (value === undefined) return fallback;\n\tif (typeof value === 'boolean') return value;\n\tissues.push({ path, message: `${path} must be true or false.` });\n\treturn fallback;\n}\n\nfunction bound(value: unknown, path: string, issues: ChartIssue[]): number | null {\n\tif (value === undefined || value === null || value === '') return null;\n\tconst n = typeof value === 'string' ? Number(value) : value;\n\tif (typeof n === 'number' && Number.isFinite(n)) return n;\n\tissues.push({ path, message: `${path} must be a number or null.` });\n\treturn null;\n}\n\nfunction normalizeFormat(value: unknown, path: string, issues: ChartIssue[]): ChartNumberFormat {\n\tif (value === undefined || value === null) return {};\n\tif (!isRecord(value)) {\n\t\tissues.push({ path, message: `${path} must be an object.` });\n\t\treturn {};\n\t}\n\tconst out: ChartNumberFormat = {};\n\tif (value.style !== undefined) out.style = pick(value.style, CHART_NUMBER_STYLES, 'number', `${path}.style`, issues);\n\tif (value.decimals !== undefined) {\n\t\tconst d = Number(value.decimals);\n\t\tif (Number.isInteger(d) && d >= 0 && d <= 10) out.decimals = d;\n\t\telse issues.push({ path: `${path}.decimals`, message: `${path}.decimals must be a whole number from 0 to 10.` });\n\t}\n\tfor (const key of ['currency', 'prefix', 'suffix', 'code'] as const) {\n\t\tif (value[key] !== undefined) out[key] = text(value[key], '', `${path}.${key}`, issues);\n\t}\n\treturn out;\n}\n\nexport function normalizeChartAxis(value: unknown, fallback: ChartAxis, path: string, issues: ChartIssue[] = []): ChartAxis {\n\tif (value === undefined) return { ...fallback, format: { ...fallback.format } };\n\tif (!isRecord(value)) {\n\t\tissues.push({ path, message: `${path} must be an object.` });\n\t\treturn { ...fallback, format: { ...fallback.format } };\n\t}\n\tlet min = 'min' in value ? bound(value.min, `${path}.min`, issues) : fallback.min;\n\tlet max = 'max' in value ? bound(value.max, `${path}.max`, issues) : fallback.max;\n\tif (min !== null && max !== null && min >= max) {\n\t\tissues.push({ path: `${path}.max`, message: `${path}.max (${max}) must be greater than ${path}.min (${min}).` });\n\t\tmin = fallback.min;\n\t\tmax = fallback.max;\n\t}\n\tlet step = 'step' in value ? bound(value.step, `${path}.step`, issues) : fallback.step;\n\tif (step !== null && !(step > 0)) {\n\t\tissues.push({ path: `${path}.step`, message: `${path}.step must be greater than 0 (or null for automatic).` });\n\t\tstep = fallback.step;\n\t}\n\tconst axis: ChartAxis = {\n\t\tshow: flag(value.show, fallback.show, `${path}.show`, issues),\n\t\ttitle: text(value.title, fallback.title, `${path}.title`, issues),\n\t\tmin,\n\t\tmax,\n\t\tstep,\n\t\tgridlines: flag(value.gridlines, fallback.gridlines, `${path}.gridlines`, issues),\n\t\tformat: 'format' in value ? normalizeFormat(value.format, `${path}.format`, issues) : { ...fallback.format }\n\t};\n\tconst kind = 'kind' in value ? (value.kind === null ? undefined : pick(value.kind, CHART_AXIS_KINDS, 'category', `${path}.kind`, issues)) : fallback.kind;\n\tif (kind && kind !== 'category') axis.kind = kind;\n\tconst scale = 'scale' in value ? (value.scale === null ? 'linear' : pick(value.scale, CHART_AXIS_SCALES, 'linear', `${path}.scale`, issues)) : (fallback.scale ?? 'linear');\n\tif (scale === 'log') {\n\t\taxis.scale = 'log';\n\t\tconst base = 'logBase' in value ? value.logBase : fallback.logBase;\n\t\tif (base !== undefined && base !== null) {\n\t\t\tconst b = Number(base);\n\t\t\tif (Number.isFinite(b) && b >= 2 && b <= 1000) {\n\t\t\t\tif (b !== 10) axis.logBase = b;\n\t\t\t} else issues.push({ path: `${path}.logBase`, message: `${path}.logBase must be a number from 2 to 1000 (default 10).` });\n\t\t}\n\t\tfor (const end of ['min', 'max'] as const) {\n\t\t\tif (axis[end] !== null && !(axis[end]! > 0)) {\n\t\t\t\tissues.push({ path: `${path}.${end}`, message: `${path}.${end} must be greater than 0 on a logarithmic axis (or null for automatic); got ${axis[end]}.` });\n\t\t\t\taxis[end] = null;\n\t\t\t}\n\t\t}\n\t}\n\tif ('reverse' in value ? value.reverse !== null && flag(value.reverse, false, `${path}.reverse`, issues) : fallback.reverse) axis.reverse = true;\n\treturn axis;\n}\n\nfunction normalizeLegend(value: unknown, issues: ChartIssue[]): ChartLegend {\n\tconst fallback: ChartLegend = { show: true, position: 'bottom' };\n\tif (value === undefined) return fallback;\n\tif (!isRecord(value)) {\n\t\tissues.push({ path: 'legend', message: 'legend must be an object.' });\n\t\treturn fallback;\n\t}\n\treturn {\n\t\tshow: flag(value.show, fallback.show, 'legend.show', issues),\n\t\tposition: pick(value.position, CHART_LEGEND_POSITIONS, fallback.position, 'legend.position', issues)\n\t};\n}\n\n/** Values as numbers or nulls; bad entries become null and are reported. */\nexport function normalizeChartValues(value: unknown, length: number | undefined, path: string, issues: ChartIssue[] = []): ChartValue[] {\n\tif (value === undefined) return length ? Array(length).fill(null) : [];\n\tif (!Array.isArray(value)) {\n\t\tissues.push({ path, message: `${path} must be an array of numbers.` });\n\t\treturn length ? Array(length).fill(null) : [];\n\t}\n\tconst out = value.map((v, i) => {\n\t\tconst parsed = parseChartValue(v);\n\t\tif (parsed === undefined) {\n\t\t\tissues.push({ path: `${path}[${i}]`, message: `${path}[${i}] is not a number: ${JSON.stringify(v)}.` });\n\t\t\treturn null;\n\t\t}\n\t\treturn parsed;\n\t});\n\tif (length === undefined) return out;\n\tif (out.length > length) return out.slice(0, length);\n\twhile (out.length < length) out.push(null);\n\treturn out;\n}\n\nfunction normalizeSeries(value: unknown, length: number, used: Set<string>, index: number, issues: ChartIssue[]): ChartSeries | null {\n\tconst path = `series[${index}]`;\n\tif (!isRecord(value)) {\n\t\tissues.push({ path, message: `${path} must be an object with a name and values.` });\n\t\treturn null;\n\t}\n\tlet id = typeof value.id === 'string' && value.id.trim() ? value.id.trim() : '';\n\tif (!id || used.has(id)) {\n\t\tif (id) issues.push({ path: `${path}.id`, message: `Series id \"${id}\" is used twice; the second was renamed.` });\n\t\tfor (let n = index + 1; ; n++) {\n\t\t\tid = `series-${n}`;\n\t\t\tif (!used.has(id)) break;\n\t\t}\n\t}\n\tused.add(id);\n\tconst series: ChartSeries = {\n\t\tid,\n\t\tname: text(value.name, `Series ${index + 1}`, `${path}.name`, issues),\n\t\tvalues: normalizeChartValues(value.values, length, `${path}.values`, issues)\n\t};\n\tif (typeof value.color === 'string' && value.color.trim()) series.color = value.color.trim();\n\tif (value.type !== undefined && value.type !== null) series.type = pick(value.type, CHART_SERIES_TYPES, 'bar', `${path}.type`, issues);\n\tif (value.hidden === true) series.hidden = true;\n\tif (value.axis !== undefined && value.axis !== null && pick(value.axis, ['primary', 'secondary'] as const, 'primary', `${path}.axis`, issues) === 'secondary') series.axis = 'secondary';\n\tfor (const key of ['x', 'sizes'] as const) {\n\t\tif (value[key] === undefined || value[key] === null) continue;\n\t\tconst list = normalizeChartValues(value[key], length, `${path}.${key}`, issues);\n\t\tif (list.some((v) => v !== null)) series[key] = list;\n\t}\n\tif (key(value, 'sizes') && series.sizes?.some((v) => v !== null && v < 0)) {\n\t\tissues.push({ path: `${path}.sizes`, message: `${path}.sizes must not be negative.` });\n\t\tseries.sizes = series.sizes.map((v) => (v !== null && v < 0 ? null : v));\n\t}\n\tif (value.pointColors !== undefined && value.pointColors !== null) {\n\t\tif (!Array.isArray(value.pointColors)) issues.push({ path: `${path}.pointColors`, message: `${path}.pointColors must be an array of colours or nulls.` });\n\t\telse {\n\t\t\tconst colors = Array.from({ length }, (_, i) => {\n\t\t\t\tconst c = (value.pointColors as unknown[])[i];\n\t\t\t\treturn typeof c === 'string' && c.trim() ? c.trim() : null;\n\t\t\t});\n\t\t\tif (colors.some((c) => c !== null)) series.pointColors = colors;\n\t\t}\n\t}\n\tif (value.marker !== undefined && value.marker !== null) series.marker = pick(value.marker, CHART_MARKERS, 'circle', `${path}.marker`, issues);\n\tif (value.curve !== undefined && value.curve !== null) series.curve = pick(value.curve, CHART_CURVES, 'linear', `${path}.curve`, issues);\n\tif (value.dataLabels !== undefined && value.dataLabels !== null) series.dataLabels = flag(value.dataLabels, false, `${path}.dataLabels`, issues);\n\tif (value.format !== undefined && value.format !== null) {\n\t\tconst format = normalizeFormat(value.format, `${path}.format`, issues);\n\t\tif (Object.keys(format).length) series.format = format;\n\t}\n\tfor (const name of ['errorBars', 'xErrorBars'] as const) {\n\t\tif (!key(value, name)) continue;\n\t\tconst bars = normalizeChartErrorBars(value[name], length, `${path}.${name}`, issues);\n\t\tif (bars) series[name] = bars;\n\t}\n\tif (value.trendlines !== undefined && value.trendlines !== null) {\n\t\tif (!Array.isArray(value.trendlines)) issues.push({ path: `${path}.trendlines`, message: `${path}.trendlines must be an array.` });\n\t\telse {\n\t\t\tconst lines = value.trendlines.map((t, i) => normalizeChartTrendline(t, `${path}.trendlines[${i}]`, issues)).filter((t): t is ChartTrendline => t !== null);\n\t\t\tif (lines.length) series.trendlines = lines;\n\t\t}\n\t}\n\treturn series;\n}\n\nconst key = (value: Record<string, unknown>, name: string) => value[name] !== undefined && value[name] !== null;\n\n/** Checks one set of error bars; `null` (reported) when it is unusable. Custom amounts are padded to `length`. */\nexport function normalizeChartErrorBars(value: unknown, length: number, path: string, issues: ChartIssue[] = []): ChartErrorBars | null {\n\tif (!isRecord(value)) {\n\t\tissues.push({ path, message: `${path} must be an object with a type (${CHART_ERROR_BAR_TYPES.join(', ')}), or null for none.` });\n\t\treturn null;\n\t}\n\tconst before = issues.length;\n\tconst type = pick(value.type, CHART_ERROR_BAR_TYPES, 'fixed', `${path}.type`, issues);\n\tif (value.type === undefined) issues.push({ path: `${path}.type`, message: `${path}.type is required: one of ${CHART_ERROR_BAR_TYPES.map((t) => `\"${t}\"`).join(', ')}.` });\n\tconst bars: ChartErrorBars = { type };\n\tif (key(value, 'value')) {\n\t\tconst n = Number(value.value);\n\t\tif (type === 'stderr' || type === 'custom') issues.push({ path: `${path}.value`, message: `${type} error bars take no value; ${type === 'custom' ? 'pass plus and minus amounts instead' : 'the amount comes from the data'}.` });\n\t\telse if (Number.isFinite(n) && n >= 0) bars.value = n;\n\t\telse issues.push({ path: `${path}.value`, message: `${path}.value must be a number, 0 or more${type === 'percent' ? ' (a percentage, e.g. 5 for 5%)' : ''}.` });\n\t}\n\tfor (const name of ['plus', 'minus'] as const) {\n\t\tif (!key(value, name)) continue;\n\t\tif (type !== 'custom') {\n\t\t\tissues.push({ path: `${path}.${name}`, message: `${path}.${name} only applies to custom error bars; set type to \"custom\".` });\n\t\t\tcontinue;\n\t\t}\n\t\tconst list = normalizeChartValues(value[name], length, `${path}.${name}`, issues);\n\t\tif (list.some((v) => v !== null && v < 0)) issues.push({ path: `${path}.${name}`, message: `${path}.${name} amounts must be 0 or more (distances from the point).` });\n\t\telse bars[name] = list;\n\t}\n\tif (type === 'custom' && !bars.plus && !bars.minus && issues.length === before) issues.push({ path: `${path}.plus`, message: `Custom error bars need plus and / or minus amounts, one per category.` });\n\tif (key(value, 'direction')) {\n\t\tconst direction = pick(value.direction, CHART_ERROR_BAR_DIRECTIONS, 'both', `${path}.direction`, issues);\n\t\tif (direction !== 'both') bars.direction = direction;\n\t}\n\tif (key(value, 'cap') && !flag(value.cap, true, `${path}.cap`, issues)) bars.cap = false;\n\treturn issues.length > before ? null : bars;\n}\n\n/** Checks one trendline; `null` (reported) when it is unusable. */\nexport function normalizeChartTrendline(value: unknown, path: string, issues: ChartIssue[] = []): ChartTrendline | null {\n\tif (!isRecord(value)) {\n\t\tissues.push({ path, message: `${path} must be an object with a type.` });\n\t\treturn null;\n\t}\n\tconst type = pick(value.type, CHART_TRENDLINE_TYPES, 'linear', `${path}.type`, issues);\n\tconst line: ChartTrendline = { type };\n\tconst whole = (name: 'order' | 'period', min: number, max: number) => {\n\t\tif (!key(value, name)) return;\n\t\tconst n = Number(value[name]);\n\t\tif (Number.isInteger(n) && n >= min && n <= max) line[name] = n;\n\t\telse issues.push({ path: `${path}.${name}`, message: `${path}.${name} must be a whole number from ${min} to ${max}.` });\n\t};\n\tif (type === 'polynomial') whole('order', 2, 6);\n\tif (type === 'moving-average') whole('period', 2, 1000);\n\tfor (const name of ['forward', 'backward'] as const) {\n\t\tif (!key(value, name)) continue;\n\t\tconst n = Number(value[name]);\n\t\tif (Number.isFinite(n) && n >= 0) {\n\t\t\tif (n > 0) line[name] = n;\n\t\t} else issues.push({ path: `${path}.${name}`, message: `${path}.${name} must be a number of x units, 0 or more.` });\n\t}\n\tif (key(value, 'intercept')) {\n\t\tconst n = Number(value.intercept);\n\t\tif (!Number.isFinite(n)) issues.push({ path: `${path}.intercept`, message: `${path}.intercept must be a number or null.` });\n\t\telse if (type === 'linear' || type === 'polynomial' || type === 'exponential') {\n\t\t\tif (type === 'exponential' && n <= 0) issues.push({ path: `${path}.intercept`, message: `${path}.intercept must be greater than 0 for an exponential trendline.` });\n\t\t\telse line.intercept = n;\n\t\t} else issues.push({ path: `${path}.intercept`, message: `A ${type} trendline cannot have a fixed intercept; use linear, polynomial or exponential.` });\n\t}\n\tfor (const name of ['showEquation', 'showR2'] as const) if (key(value, name) && flag(value[name], false, `${path}.${name}`, issues)) line[name] = true;\n\tfor (const name of ['name', 'color'] as const) {\n\t\tif (!key(value, name)) continue;\n\t\tconst t = text(value[name], '', `${path}.${name}`, issues).trim();\n\t\tif (t) line[name] = t;\n\t}\n\treturn line;\n}\n\n/**\n * Turns any input (a partial spec, saved JSON, an agent's arguments) into a complete,\n * valid `ChartSpec`. Every value is checked; problems are reported as sentences in\n * `issues` and replaced by defaults, so the result is always drawable. Series values are\n * padded or trimmed to the number of categories.\n */\nexport function normalizeChartSpec(input: unknown): { spec: ChartSpec; issues: ChartIssue[] } {\n\tconst issues: ChartIssue[] = [];\n\tconst value = isRecord(input) ? input : {};\n\tif (input !== undefined && !isRecord(input)) issues.push({ path: '', message: 'A chart must be an object.' });\n\tconst type = pick(value.type, CHART_TYPES, 'bar', 'type', issues);\n\tconst rawSeries = Array.isArray(value.series) ? value.series : [];\n\tif (value.series !== undefined && !Array.isArray(value.series)) issues.push({ path: 'series', message: 'series must be an array.' });\n\n\tlet categories: string[];\n\tif (Array.isArray(value.categories)) categories = value.categories.map((c, i) => text(c, '', `categories[${i}]`, issues));\n\telse {\n\t\tif (value.categories !== undefined) issues.push({ path: 'categories', message: 'categories must be an array of labels.' });\n\t\tconst longest = rawSeries.reduce<number>((n, s) => Math.max(n, isRecord(s) && Array.isArray(s.values) ? s.values.length : 0), 0);\n\t\tcategories = Array.from({ length: longest }, (_, i) => `${i + 1}`);\n\t}\n\n\tconst used = new Set<string>();\n\tconst series = rawSeries.map((s, i) => normalizeSeries(s, categories.length, used, i, issues)).filter((s): s is ChartSeries => s !== null);\n\n\tlet palette = [...DEFAULT_CHART_PALETTE];\n\tif (Array.isArray(value.palette)) {\n\t\tconst colors = value.palette.filter((c): c is string => typeof c === 'string' && c.trim() !== '');\n\t\tif (colors.length) palette = colors;\n\t\telse issues.push({ path: 'palette', message: 'palette must list at least one colour.' });\n\t} else if (value.palette !== undefined) issues.push({ path: 'palette', message: 'palette must be an array of colours.' });\n\n\tconst fraction = (name: string, fallback: number, min: number, max: number) => {\n\t\tif (value[name] === undefined) return fallback;\n\t\tconst r = Number(value[name]);\n\t\tif (value[name] !== null && Number.isFinite(r) && r >= min && r <= max) return r;\n\t\tissues.push({ path: name, message: `${name} must be a number from ${min} to ${max}.` });\n\t\treturn fallback;\n\t};\n\tconst innerRadius = fraction('innerRadius', 0.55, 0, 0.9);\n\tconst gapWidth = fraction('gapWidth', 0.28, 0, 0.9);\n\tconst overlap = fraction('overlap', -0.12, -1, 1);\n\tlet bins: number | null = null;\n\tif (value.bins !== undefined && value.bins !== null) {\n\t\tconst b = Number(value.bins);\n\t\tif (Number.isInteger(b) && b >= 1 && b <= 500) bins = b;\n\t\telse issues.push({ path: 'bins', message: 'bins must be a whole number from 1 to 500, or null for automatic.' });\n\t}\n\n\tconst spec: ChartSpec = {\n\t\tversion: 1,\n\t\ttype,\n\t\ttitle: text(value.title, '', 'title', issues),\n\t\tsubtitle: text(value.subtitle, '', 'subtitle', issues),\n\t\tcategories,\n\t\tseries,\n\t\txAxis: normalizeChartAxis(value.xAxis, defaultChartAxis(false), 'xAxis', issues),\n\t\tyAxis: normalizeChartAxis(value.yAxis, defaultChartAxis(true), 'yAxis', issues),\n\t\tyAxis2: normalizeChartAxis(value.yAxis2, defaultChartAxis(false), 'yAxis2', issues),\n\t\tlegend: normalizeLegend(value.legend, issues),\n\t\tstacking: pick(value.stacking, CHART_STACKINGS, 'none', 'stacking', issues),\n\t\torientation: pick(value.orientation, CHART_ORIENTATIONS, 'vertical', 'orientation', issues),\n\t\tcurve: pick(value.curve, CHART_CURVES, 'linear', 'curve', issues),\n\t\tpoints: flag(value.points, true, 'points', issues),\n\t\tdataLabels: flag(value.dataLabels, false, 'dataLabels', issues),\n\t\tlabelPosition: pick(value.labelPosition, CHART_LABEL_POSITIONS, 'auto', 'labelPosition', issues),\n\t\tpalette,\n\t\tinnerRadius,\n\t\tgapWidth,\n\t\toverlap,\n\t\tbins,\n\t\tshowTotal: flag(value.showTotal, true, 'showTotal', issues)\n\t};\n\tif (spec.stacking === 'percent')\n\t\tfor (const name of ['yAxis', 'yAxis2'] as const) {\n\t\t\tif (spec[name].scale !== 'log') continue;\n\t\t\tissues.push({ path: `${name}.scale`, message: `A logarithmic ${name} cannot show percent stacking (shares from 0% to 100% include 0); use stacking \"stacked\" or \"none\", or a linear axis.` });\n\t\t\tdelete spec[name].scale;\n\t\t\tdelete spec[name].logBase;\n\t\t}\n\treturn { spec, issues };\n}\n\n/** A deep copy (specs are plain JSON). */\nexport function cloneChartSpec(spec: ChartSpec): ChartSpec {\n\treturn {\n\t\t...spec,\n\t\tcategories: [...spec.categories],\n\t\tseries: spec.series.map(cloneChartSeries),\n\t\txAxis: { ...spec.xAxis, format: { ...spec.xAxis.format } },\n\t\tyAxis: { ...spec.yAxis, format: { ...spec.yAxis.format } },\n\t\tyAxis2: { ...spec.yAxis2, format: { ...spec.yAxis2.format } },\n\t\tlegend: { ...spec.legend },\n\t\tpalette: [...spec.palette]\n\t};\n}\n\nexport function cloneChartSeries(series: ChartSeries): ChartSeries {\n\tconst copy: ChartSeries = { ...series, values: [...series.values] };\n\tif (series.x) copy.x = [...series.x];\n\tif (series.sizes) copy.sizes = [...series.sizes];\n\tif (series.pointColors) copy.pointColors = [...series.pointColors];\n\tif (series.format) copy.format = { ...series.format };\n\tif (series.trendlines) copy.trendlines = series.trendlines.map((t) => ({ ...t }));\n\tfor (const name of ['errorBars', 'xErrorBars'] as const) {\n\t\tconst bars = series[name];\n\t\tif (!bars) continue;\n\t\tcopy[name] = { ...bars, ...(bars.plus ? { plus: [...bars.plus] } : {}), ...(bars.minus ? { minus: [...bars.minus] } : {}) };\n\t}\n\treturn copy;\n}\n\nexport interface ChartTableOptions {\n\t/**\n\t * `columns` (default): the first column holds categories and each other column is a\n\t * series. `rows`: the first row holds categories and each other row is a series.\n\t */\n\tseriesIn?: 'columns' | 'rows';\n\t/**\n\t * The first row (or column for `rows`) holds series names (default `true`). `auto`: only\n\t * when one of its value cells is not a number.\n\t */\n\theader?: boolean | 'auto';\n\t/**\n\t * Read the first column as numeric x values (scatter and bubble charts): every series gets\n\t * them as `x`, and the categories are their labels.\n\t */\n\txFromFirstColumn?: boolean;\n}\n\nexport interface ChartTableData {\n\tcategories: string[];\n\tseries: ChartSeries[];\n\tissues: ChartIssue[];\n}\n\n/**\n * Reads a grid of cells (from CSV, a spreadsheet range or the clipboard) as categories and\n * series. Cells that are not numbers become gaps and are reported.\n */\nexport function chartDataFromTable(rows: ReadonlyArray<ReadonlyArray<unknown>>, options: ChartTableOptions = {}): ChartTableData {\n\tlet grid = rows.map((r) => [...r]).filter((r) => r.some((c) => c !== null && c !== undefined && String(c).trim() !== ''));\n\tif (options.seriesIn === 'rows') {\n\t\tconst width = Math.max(0, ...grid.map((r) => r.length));\n\t\tgrid = Array.from({ length: width }, (_, c) => grid.map((r) => r[c]));\n\t}\n\tconst issues: ChartIssue[] = [];\n\tif (!grid.length) return { categories: [], series: [], issues };\n\tconst width = Math.max(...grid.map((r) => r.length));\n\tconst header = options.header === 'auto' ? grid[0].slice(1).some((c) => c !== null && c !== undefined && String(c).trim() !== '' && parseChartValue(c) === undefined) : (options.header ?? true);\n\tconst names = header ? grid[0] : [];\n\tconst body = header ? grid.slice(1) : grid;\n\tconst categories = body.map((r, i) => {\n\t\tconst c = r[0];\n\t\treturn c === null || c === undefined || String(c).trim() === '' ? `${i + 1}` : String(c).trim();\n\t});\n\tconst series: ChartSeries[] = [];\n\tfor (let col = 1; col < width; col++) {\n\t\tconst name = names[col] !== undefined && String(names[col]).trim() ? String(names[col]).trim() : `Series ${col}`;\n\t\tconst values = body.map((r, i) => {\n\t\t\tconst parsed = parseChartValue(r[col] ?? null);\n\t\t\tif (parsed === undefined) {\n\t\t\t\tissues.push({ path: `${name}[${i}]`, message: `\"${String(r[col])}\" in ${name} (${categories[i]}) is not a number; it was left blank.` });\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn parsed;\n\t\t});\n\t\tseries.push({ id: `series-${col}`, name, values });\n\t}\n\tif (options.xFromFirstColumn) {\n\t\tconst x = body.map((r, i) => {\n\t\t\tconst parsed = parseChartValue(r[0] ?? null);\n\t\t\tif (parsed === undefined) issues.push({ path: `x[${i}]`, message: `\"${String(r[0])}\" in the first column is not a number; that point has no x.` });\n\t\t\treturn parsed ?? null;\n\t\t});\n\t\tfor (const s of series) s.x = [...x];\n\t}\n\treturn { categories, series, issues };\n}\n\n/** The chart's data as a grid: a header row of series names, then one row per category. */\nexport function chartDataToTable(spec: Pick<ChartSpec, 'categories' | 'series'>, options: { categoryHeader?: string } = {}): (string | number | null)[][] {\n\treturn [\n\t\t[options.categoryHeader ?? '', ...spec.series.map((s) => s.name)],\n\t\t...spec.categories.map((category, i) => [category, ...spec.series.map((s) => s.values[i] ?? null)])\n\t];\n}\n\n/** A colour input value (`#rrggbb`) for a CSS colour: `#abc` expands, non-hex colours show as black. */\nexport function chartColorInputValue(color: string): string {\n\tif (/^#[0-9a-f]{6}$/i.test(color)) return color.toLowerCase();\n\tif (/^#[0-9a-f]{3}$/i.test(color)) return `#${[...color.slice(1)].map((c) => c + c).join('')}`.toLowerCase();\n\treturn '#000000';\n}\n"],"mappings":";AAQA,IAAM,QAAgC;AAAA,EACrC,OAAO;AAAA,EACP,OAAO;AAAA,EACP,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,MAAM;AAAA,EACN,OAAO;AACR;AAMO,SAAS,gBAAgB,OAAgC;AAC/D,QAAMA,QAAO,MAAM,KAAK,EAAE,YAAY;AACtC,QAAM,MAAM,MAAMA,KAAI,KAAKA;AAC3B,MAAI,IAAI,mBAA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M,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,YAAY;AAC3G,SAAO;AACR;","names":["text","text","text","key","width"]}
|
|
@@ -500,332 +500,12 @@ function createStyleRegistry(options = {}) {
|
|
|
500
500
|
return new StyleRegistry(options);
|
|
501
501
|
}
|
|
502
502
|
|
|
503
|
-
// src/import/zip.ts
|
|
504
|
-
var ZipError = class extends Error {
|
|
505
|
-
code;
|
|
506
|
-
entryName;
|
|
507
|
-
constructor(code, message, details = {}) {
|
|
508
|
-
super(message, details.cause !== void 0 ? { cause: details.cause } : void 0);
|
|
509
|
-
this.name = "ZipError";
|
|
510
|
-
this.code = code;
|
|
511
|
-
this.entryName = details.entryName;
|
|
512
|
-
}
|
|
513
|
-
};
|
|
514
|
-
var DEFAULT_ZIP_MAX_ENTRIES = 1e4;
|
|
515
|
-
var DEFAULT_ZIP_MAX_TOTAL_SIZE = 256 * 1024 * 1024;
|
|
516
|
-
var SIG_EOCD = 101010256;
|
|
517
|
-
var SIG_ZIP64_EOCD = 101075792;
|
|
518
|
-
var SIG_ZIP64_LOCATOR = 117853008;
|
|
519
|
-
var SIG_CENTRAL = 33639248;
|
|
520
|
-
var SIG_LOCAL = 67324752;
|
|
521
|
-
var EOCD_SIZE = 22;
|
|
522
|
-
var MAX_COMMENT = 65535;
|
|
523
|
-
var crcTable = null;
|
|
524
|
-
function zipCrc32(data) {
|
|
525
|
-
if (!crcTable) {
|
|
526
|
-
crcTable = new Uint32Array(256);
|
|
527
|
-
for (let n = 0; n < 256; n++) {
|
|
528
|
-
let c = n;
|
|
529
|
-
for (let k = 0; k < 8; k++) c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
|
|
530
|
-
crcTable[n] = c >>> 0;
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
let crc = 4294967295;
|
|
534
|
-
for (let i = 0; i < data.length; i++) crc = crcTable[(crc ^ data[i]) & 255] ^ crc >>> 8;
|
|
535
|
-
return (crc ^ 4294967295) >>> 0;
|
|
536
|
-
}
|
|
537
|
-
function toBytes(data) {
|
|
538
|
-
if (ArrayBuffer.isView(data)) return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
539
|
-
return new Uint8Array(data);
|
|
540
|
-
}
|
|
541
|
-
function isUnsafeZipPath(name) {
|
|
542
|
-
if (!name || name.includes("\0")) return true;
|
|
543
|
-
const normalized = name.replace(/\\/g, "/");
|
|
544
|
-
if (normalized.startsWith("/") || /^[a-zA-Z]:/.test(normalized)) return true;
|
|
545
|
-
return normalized.split("/").some((segment) => segment === "..");
|
|
546
|
-
}
|
|
547
|
-
var utf8 = new TextDecoder("utf-8");
|
|
548
|
-
var CP437_HIGH = "\xC7\xFC\xE9\xE2\xE4\xE0\xE5\xE7\xEA\xEB\xE8\xEF\xEE\xEC\xC4\xC5\xC9\xE6\xC6\xF4\xF6\xF2\xFB\xF9\xFF\xD6\xDC\xA2\xA3\xA5\u20A7\u0192\xE1\xED\xF3\xFA\xF1\xD1\xAA\xBA\xBF\u2310\xAC\xBD\xBC\xA1\xAB\xBB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\xDF\u0393\u03C0\u03A3\u03C3\xB5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\xB1\u2265\u2264\u2320\u2321\xF7\u2248\xB0\u2219\xB7\u221A\u207F\xB2\u25A0\xA0";
|
|
549
|
-
function decodeName(bytes, isUtf8) {
|
|
550
|
-
if (isUtf8 || bytes.every((b) => b < 128)) return utf8.decode(bytes);
|
|
551
|
-
let out = "";
|
|
552
|
-
for (const b of bytes) out += b < 128 ? String.fromCharCode(b) : CP437_HIGH[b - 128];
|
|
553
|
-
return out;
|
|
554
|
-
}
|
|
555
|
-
var ZipArchive = class {
|
|
556
|
-
constructor(bytes, entries, maxTotalSize) {
|
|
557
|
-
this.bytes = bytes;
|
|
558
|
-
this.maxTotalSize = maxTotalSize;
|
|
559
|
-
this.entries = entries;
|
|
560
|
-
entries.forEach((entry) => {
|
|
561
|
-
if (!this.byName.has(entry.name)) this.byName.set(entry.name, entry);
|
|
562
|
-
});
|
|
563
|
-
}
|
|
564
|
-
bytes;
|
|
565
|
-
maxTotalSize;
|
|
566
|
-
/** Entries in central-directory order. */
|
|
567
|
-
entries;
|
|
568
|
-
byName = /* @__PURE__ */ new Map();
|
|
569
|
-
extracted = 0;
|
|
570
|
-
/** Looks up an entry by exact name (a leading `/` is ignored). */
|
|
571
|
-
get(name) {
|
|
572
|
-
return this.byName.get(name.replace(/^\/+/, ""));
|
|
573
|
-
}
|
|
574
|
-
has(name) {
|
|
575
|
-
return !!this.get(name);
|
|
576
|
-
}
|
|
577
|
-
/** Uncompressed bytes extracted so far (counted against `maxTotalSize`). */
|
|
578
|
-
get extractedSize() {
|
|
579
|
-
return this.extracted;
|
|
580
|
-
}
|
|
581
|
-
/** Extracts an entry's data, verifying its size and CRC-32. */
|
|
582
|
-
async read(entryOrName) {
|
|
583
|
-
const entry = typeof entryOrName === "string" ? this.get(entryOrName) : entryOrName;
|
|
584
|
-
if (!entry) {
|
|
585
|
-
throw new ZipError("entry_not_found", `ZIP entry "${String(entryOrName)}" not found.`, {
|
|
586
|
-
entryName: String(entryOrName)
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
|
-
const name = entry.name;
|
|
590
|
-
if (entry.encrypted) {
|
|
591
|
-
throw new ZipError("encrypted", `ZIP entry "${name}" is encrypted; encrypted archives are not supported.`, {
|
|
592
|
-
entryName: name
|
|
593
|
-
});
|
|
594
|
-
}
|
|
595
|
-
if (entry.isDirectory) return new Uint8Array(0);
|
|
596
|
-
const remaining = this.maxTotalSize - this.extracted;
|
|
597
|
-
if (entry.size > remaining) {
|
|
598
|
-
throw new ZipError(
|
|
599
|
-
"too_large",
|
|
600
|
-
`Extracting "${name}" (${entry.size} bytes) would exceed the ${this.maxTotalSize}-byte limit.`,
|
|
601
|
-
{ entryName: name }
|
|
602
|
-
);
|
|
603
|
-
}
|
|
604
|
-
const { bytes } = this;
|
|
605
|
-
const offset = entry.localHeaderOffset;
|
|
606
|
-
if (offset + 30 > bytes.length || readU32(bytes, offset) !== SIG_LOCAL) {
|
|
607
|
-
throw new ZipError("corrupt_entry", `ZIP entry "${name}" has no valid local header.`, { entryName: name });
|
|
608
|
-
}
|
|
609
|
-
const dataStart = offset + 30 + readU16(bytes, offset + 26) + readU16(bytes, offset + 28);
|
|
610
|
-
const dataEnd = dataStart + entry.compressedSize;
|
|
611
|
-
if (dataEnd > bytes.length) {
|
|
612
|
-
throw new ZipError("corrupt_entry", `ZIP entry "${name}" is truncated.`, { entryName: name });
|
|
613
|
-
}
|
|
614
|
-
const raw = bytes.subarray(dataStart, dataEnd);
|
|
615
|
-
let data;
|
|
616
|
-
if (entry.method === 0) {
|
|
617
|
-
if (entry.compressedSize !== entry.size) {
|
|
618
|
-
throw new ZipError("corrupt_entry", `Stored ZIP entry "${name}" has inconsistent sizes.`, { entryName: name });
|
|
619
|
-
}
|
|
620
|
-
data = raw.slice();
|
|
621
|
-
} else if (entry.method === 8) {
|
|
622
|
-
data = await inflateRaw(raw, entry.size, name);
|
|
623
|
-
} else {
|
|
624
|
-
throw new ZipError(
|
|
625
|
-
"unsupported_feature",
|
|
626
|
-
`ZIP entry "${name}" uses unsupported compression method ${entry.method}; only stored and deflate are supported.`,
|
|
627
|
-
{ entryName: name }
|
|
628
|
-
);
|
|
629
|
-
}
|
|
630
|
-
if (data.length !== entry.size) {
|
|
631
|
-
throw new ZipError("corrupt_entry", `ZIP entry "${name}" size does not match the directory.`, { entryName: name });
|
|
632
|
-
}
|
|
633
|
-
this.extracted += data.length;
|
|
634
|
-
if (zipCrc32(data) !== entry.crc32) {
|
|
635
|
-
throw new ZipError("corrupt_entry", `ZIP entry "${name}" failed its CRC-32 check.`, { entryName: name });
|
|
636
|
-
}
|
|
637
|
-
return data;
|
|
638
|
-
}
|
|
639
|
-
/** Extracts an entry and decodes it as UTF-8 (a leading BOM is removed). */
|
|
640
|
-
async readText(entryOrName) {
|
|
641
|
-
const text = utf8.decode(await this.read(entryOrName));
|
|
642
|
-
return text.charCodeAt(0) === 65279 ? text.slice(1) : text;
|
|
643
|
-
}
|
|
644
|
-
};
|
|
645
|
-
function readU16(bytes, offset) {
|
|
646
|
-
return bytes[offset] | bytes[offset + 1] << 8;
|
|
647
|
-
}
|
|
648
|
-
function readU32(bytes, offset) {
|
|
649
|
-
return (bytes[offset] | bytes[offset + 1] << 8 | bytes[offset + 2] << 16 | bytes[offset + 3] << 24) >>> 0;
|
|
650
|
-
}
|
|
651
|
-
function readU64(bytes, offset) {
|
|
652
|
-
const value = readU32(bytes, offset) + readU32(bytes, offset + 4) * 4294967296;
|
|
653
|
-
if (!Number.isSafeInteger(value)) {
|
|
654
|
-
throw new ZipError("unsupported_feature", "ZIP64 value exceeds the supported range.");
|
|
655
|
-
}
|
|
656
|
-
return value;
|
|
657
|
-
}
|
|
658
|
-
async function inflateRaw(raw, limit, entryName) {
|
|
659
|
-
const Stream = globalThis.DecompressionStream;
|
|
660
|
-
if (typeof Stream !== "function") {
|
|
661
|
-
throw new ZipError(
|
|
662
|
-
"unsupported_environment",
|
|
663
|
-
"Inflating ZIP entries needs DecompressionStream (modern browsers, Node 18+).",
|
|
664
|
-
{ entryName }
|
|
665
|
-
);
|
|
666
|
-
}
|
|
667
|
-
const stream = new Stream("deflate-raw");
|
|
668
|
-
const writer = stream.writable.getWriter();
|
|
669
|
-
const reader = stream.readable.getReader();
|
|
670
|
-
const CHUNK = 64 * 1024;
|
|
671
|
-
const feeding = (async () => {
|
|
672
|
-
for (let i = 0; i < raw.length; i += CHUNK) await writer.write(raw.subarray(i, i + CHUNK));
|
|
673
|
-
await writer.close();
|
|
674
|
-
})();
|
|
675
|
-
feeding.catch(() => {
|
|
676
|
-
});
|
|
677
|
-
const chunks = [];
|
|
678
|
-
let total = 0;
|
|
679
|
-
try {
|
|
680
|
-
for (; ; ) {
|
|
681
|
-
const { done, value } = await reader.read();
|
|
682
|
-
if (done) break;
|
|
683
|
-
total += value.length;
|
|
684
|
-
if (total > limit) {
|
|
685
|
-
throw new ZipError(
|
|
686
|
-
"corrupt_entry",
|
|
687
|
-
`ZIP entry "${entryName}" inflates beyond its declared size of ${limit} bytes.`,
|
|
688
|
-
{ entryName }
|
|
689
|
-
);
|
|
690
|
-
}
|
|
691
|
-
chunks.push(value);
|
|
692
|
-
}
|
|
693
|
-
} catch (error) {
|
|
694
|
-
reader.cancel().catch(() => {
|
|
695
|
-
});
|
|
696
|
-
writer.abort().catch(() => {
|
|
697
|
-
});
|
|
698
|
-
if (error instanceof ZipError) throw error;
|
|
699
|
-
throw new ZipError("corrupt_entry", `ZIP entry "${entryName}" has an invalid deflate stream.`, {
|
|
700
|
-
entryName,
|
|
701
|
-
cause: error
|
|
702
|
-
});
|
|
703
|
-
}
|
|
704
|
-
await feeding.catch(() => {
|
|
705
|
-
});
|
|
706
|
-
const out = new Uint8Array(total);
|
|
707
|
-
let pos = 0;
|
|
708
|
-
for (const chunk of chunks) {
|
|
709
|
-
out.set(chunk, pos);
|
|
710
|
-
pos += chunk.length;
|
|
711
|
-
}
|
|
712
|
-
return out;
|
|
713
|
-
}
|
|
714
|
-
function findEndOfCentralDirectory(bytes) {
|
|
715
|
-
const min = Math.max(0, bytes.length - EOCD_SIZE - MAX_COMMENT);
|
|
716
|
-
for (let i = bytes.length - EOCD_SIZE; i >= min; i--) {
|
|
717
|
-
if (readU32(bytes, i) === SIG_EOCD && i + EOCD_SIZE + readU16(bytes, i + 20) <= bytes.length) return i;
|
|
718
|
-
}
|
|
719
|
-
return -1;
|
|
720
|
-
}
|
|
721
|
-
async function readZip(data, options = {}) {
|
|
722
|
-
const bytes = toBytes(data);
|
|
723
|
-
const maxEntries = options.maxEntries ?? DEFAULT_ZIP_MAX_ENTRIES;
|
|
724
|
-
const maxTotalSize = options.maxTotalSize ?? DEFAULT_ZIP_MAX_TOTAL_SIZE;
|
|
725
|
-
const eocd = findEndOfCentralDirectory(bytes);
|
|
726
|
-
if (eocd < 0) throw new ZipError("invalid_archive", "Not a ZIP archive (no end of central directory record).");
|
|
727
|
-
let diskNumber = readU16(bytes, eocd + 4);
|
|
728
|
-
let cdDisk = readU16(bytes, eocd + 6);
|
|
729
|
-
let count = readU16(bytes, eocd + 10);
|
|
730
|
-
let cdSize = readU32(bytes, eocd + 12);
|
|
731
|
-
let cdOffset = readU32(bytes, eocd + 16);
|
|
732
|
-
if (count === 65535 || cdSize === 4294967295 || cdOffset === 4294967295) {
|
|
733
|
-
const locator = eocd - 20;
|
|
734
|
-
if (locator < 0 || readU32(bytes, locator) !== SIG_ZIP64_LOCATOR) {
|
|
735
|
-
throw new ZipError("invalid_archive", "ZIP64 archive is missing its end of central directory locator.");
|
|
736
|
-
}
|
|
737
|
-
const record = readU64(bytes, locator + 8);
|
|
738
|
-
if (record + 56 > bytes.length || readU32(bytes, record) !== SIG_ZIP64_EOCD) {
|
|
739
|
-
throw new ZipError("invalid_archive", "ZIP64 end of central directory record not found.");
|
|
740
|
-
}
|
|
741
|
-
diskNumber = readU32(bytes, record + 16);
|
|
742
|
-
cdDisk = readU32(bytes, record + 20);
|
|
743
|
-
count = readU64(bytes, record + 32);
|
|
744
|
-
cdSize = readU64(bytes, record + 40);
|
|
745
|
-
cdOffset = readU64(bytes, record + 48);
|
|
746
|
-
}
|
|
747
|
-
if (diskNumber !== 0 || cdDisk !== 0) {
|
|
748
|
-
throw new ZipError("unsupported_feature", "Multi-disk (spanned) ZIP archives are not supported.");
|
|
749
|
-
}
|
|
750
|
-
if (count > maxEntries) {
|
|
751
|
-
throw new ZipError("too_many_entries", `ZIP archive has ${count} entries; the limit is ${maxEntries}.`);
|
|
752
|
-
}
|
|
753
|
-
if (cdOffset + cdSize > bytes.length) {
|
|
754
|
-
throw new ZipError("invalid_archive", "ZIP central directory lies outside the file.");
|
|
755
|
-
}
|
|
756
|
-
const entries = [];
|
|
757
|
-
let p = cdOffset;
|
|
758
|
-
for (let i = 0; i < count; i++) {
|
|
759
|
-
if (p + 46 > bytes.length || readU32(bytes, p) !== SIG_CENTRAL) {
|
|
760
|
-
throw new ZipError("invalid_archive", "ZIP central directory is corrupt.");
|
|
761
|
-
}
|
|
762
|
-
const flags = readU16(bytes, p + 8);
|
|
763
|
-
const method = readU16(bytes, p + 10);
|
|
764
|
-
const crc32 = readU32(bytes, p + 16);
|
|
765
|
-
let compressedSize = readU32(bytes, p + 20);
|
|
766
|
-
let size = readU32(bytes, p + 24);
|
|
767
|
-
const nameLength = readU16(bytes, p + 28);
|
|
768
|
-
const extraLength = readU16(bytes, p + 30);
|
|
769
|
-
const commentLength = readU16(bytes, p + 32);
|
|
770
|
-
let localHeaderOffset = readU32(bytes, p + 42);
|
|
771
|
-
const nameStart = p + 46;
|
|
772
|
-
const extraStart = nameStart + nameLength;
|
|
773
|
-
const next = extraStart + extraLength + commentLength;
|
|
774
|
-
if (next > bytes.length) throw new ZipError("invalid_archive", "ZIP central directory is truncated.");
|
|
775
|
-
for (let e = extraStart; e + 4 <= extraStart + extraLength; ) {
|
|
776
|
-
const id = readU16(bytes, e);
|
|
777
|
-
const len = readU16(bytes, e + 2);
|
|
778
|
-
if (id === 1) {
|
|
779
|
-
let f = e + 4;
|
|
780
|
-
const end = f + len;
|
|
781
|
-
if (size === 4294967295 && f + 8 <= end) {
|
|
782
|
-
size = readU64(bytes, f);
|
|
783
|
-
f += 8;
|
|
784
|
-
}
|
|
785
|
-
if (compressedSize === 4294967295 && f + 8 <= end) {
|
|
786
|
-
compressedSize = readU64(bytes, f);
|
|
787
|
-
f += 8;
|
|
788
|
-
}
|
|
789
|
-
if (localHeaderOffset === 4294967295 && f + 8 <= end) localHeaderOffset = readU64(bytes, f);
|
|
790
|
-
}
|
|
791
|
-
e += 4 + len;
|
|
792
|
-
}
|
|
793
|
-
const rawName = decodeName(bytes.subarray(nameStart, extraStart), (flags & 2048) !== 0);
|
|
794
|
-
const name = rawName.replace(/\\/g, "/");
|
|
795
|
-
p = next;
|
|
796
|
-
if (isUnsafeZipPath(rawName)) {
|
|
797
|
-
if (options.unsafePaths === "skip") continue;
|
|
798
|
-
throw new ZipError("unsafe_path", `ZIP entry name "${rawName}" is absolute or escapes the archive root.`, {
|
|
799
|
-
entryName: rawName
|
|
800
|
-
});
|
|
801
|
-
}
|
|
802
|
-
entries.push({
|
|
803
|
-
name,
|
|
804
|
-
isDirectory: name.endsWith("/"),
|
|
805
|
-
encrypted: (flags & 1) !== 0,
|
|
806
|
-
method,
|
|
807
|
-
compressedSize,
|
|
808
|
-
size,
|
|
809
|
-
crc32,
|
|
810
|
-
localHeaderOffset
|
|
811
|
-
});
|
|
812
|
-
}
|
|
813
|
-
return new ZipArchive(bytes, entries, maxTotalSize);
|
|
814
|
-
}
|
|
815
|
-
|
|
816
503
|
export {
|
|
817
504
|
NORMAL_STYLE_ID,
|
|
818
505
|
isValidStyleId,
|
|
819
506
|
DEFAULT_STYLES,
|
|
820
507
|
StyleRegistry,
|
|
821
508
|
safeCSSValue,
|
|
822
|
-
createStyleRegistry
|
|
823
|
-
ZipError,
|
|
824
|
-
DEFAULT_ZIP_MAX_ENTRIES,
|
|
825
|
-
DEFAULT_ZIP_MAX_TOTAL_SIZE,
|
|
826
|
-
zipCrc32,
|
|
827
|
-
isUnsafeZipPath,
|
|
828
|
-
ZipArchive,
|
|
829
|
-
readZip
|
|
509
|
+
createStyleRegistry
|
|
830
510
|
};
|
|
831
|
-
//# sourceMappingURL=chunk-
|
|
511
|
+
//# sourceMappingURL=chunk-AGGUNWT6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/extensions/paragraph-styles/registry.ts"],"sourcesContent":["// Portions ported from wordcraft/crates/doc/src/styles.rs and wordcraft/crates/doc/src/resolve.rs (MIT OR Apache-2.0, © ArtCraft Team and contributors). See THIRD_PARTY_NOTICES.md.\n\n/** Paragraph styles format whole blocks; character styles format runs of text. */\nexport type StyleKind = \"paragraph\" | \"character\";\n\n/** Character formatting of a style (CSS values). */\nexport interface CharacterFormat {\n fontFamily?: string;\n /** CSS length, e.g. `\"1.5em\"` or `\"18px\"`. */\n fontSize?: string;\n bold?: boolean;\n italic?: boolean;\n underline?: boolean;\n strike?: boolean;\n color?: string;\n backgroundColor?: string;\n letterSpacing?: string;\n textTransform?: \"none\" | \"uppercase\" | \"lowercase\" | \"capitalize\";\n smallCaps?: boolean;\n}\n\n/** Paragraph formatting of a style (CSS values). */\nexport interface ParagraphFormat {\n textAlign?: \"left\" | \"center\" | \"right\" | \"justify\";\n lineHeight?: string;\n spaceBefore?: string;\n spaceAfter?: string;\n indentLeft?: string;\n indentRight?: string;\n indentFirstLine?: string;\n /** CSS border shorthand, e.g. `\"3px solid currentColor\"`. */\n borderLeft?: string;\n paddingLeft?: string;\n backgroundColor?: string;\n}\n\n/** The block node a paragraph style uses (`heading` with `level` for Heading N). */\nexport interface StyleBlock {\n type: string;\n attrs?: Record<string, any>;\n}\n\nexport interface StyleDefinition {\n /** Stable id (`Heading1`): letters, digits, `_` and `-`, starting with a letter. */\n id: string;\n /** Display name (`Heading 1`). */\n name: string;\n kind: StyleKind;\n /** Style this one inherits from; what it sets wins over its base. */\n basedOn?: string | null;\n /** Style of the paragraph after this one when Enter is pressed at its end (paragraph styles). */\n next?: string | null;\n /** Linked style: a paragraph style's character style, or a character style's paragraph style. */\n linked?: string | null;\n paragraph?: ParagraphFormat;\n character?: CharacterFormat;\n /** Block node of a paragraph style. Inherited along `basedOn`; `paragraph` by default. */\n block?: StyleBlock | null;\n /** Gallery order (lower first). */\n priority?: number;\n /** Shown in the styles gallery. */\n quick?: boolean;\n hidden?: boolean;\n /** Built in (cannot be removed). */\n builtin?: boolean;\n}\n\n/** A style with its `basedOn` chain and the defaults merged. */\nexport interface ResolvedStyle {\n id: string;\n paragraph: ParagraphFormat;\n character: CharacterFormat;\n block: StyleBlock;\n /** Id of the style after Enter at the end of a paragraph. */\n next: string;\n}\n\nexport interface StyleDefaults {\n paragraph?: ParagraphFormat;\n character?: CharacterFormat;\n}\n\nexport interface StyleRegistryOptions {\n /** Styles added to (or replacing) the built-in ones. */\n styles?: readonly StyleDefinition[];\n /** Include the built-in styles. Default `true`. */\n builtins?: boolean;\n /** Document defaults, applied below every style. */\n defaults?: StyleDefaults;\n}\n\nexport interface StyleRegistrySnapshot {\n styles: readonly StyleDefinition[];\n defaults: StyleDefaults;\n /** Increases on every change. */\n version: number;\n}\n\n/** Serializable registry content (`registry.toJSON()`). */\nexport interface StyleRegistryJSON {\n styles: StyleDefinition[];\n defaults: StyleDefaults;\n}\n\nexport interface StyleCSSOptions {\n /** Selector the rules are scoped to. Default `.ProseMirror`. */\n scope?: string;\n /**\n * Element selector of blocks that use a style without naming it\n * (`data-style` absent), e.g. `h2` for Heading 2. Return `null` for none.\n */\n tagFor?: (block: StyleBlock) => string | null;\n}\n\n/** Longest `basedOn` chain followed (cycle and depth guard). */\nconst MAX_CHAIN = 32;\nconst STYLE_ID = /^[A-Za-z][A-Za-z0-9_-]{0,63}$/;\n/** CSS values that could escape a declaration or load resources are dropped. */\nconst UNSAFE_CSS = /[;{}<>\\\\]|\\/\\*|url\\s*\\(|expression\\s*\\(|@import|javascript:/i;\n\nexport const NORMAL_STYLE_ID = \"Normal\";\n\nconst PREVIEW_PROPERTIES = new Set([\n \"font-family\",\n \"font-weight\",\n \"font-style\",\n \"color\",\n \"text-decoration-line\",\n \"text-transform\",\n \"letter-spacing\",\n \"font-variant-caps\",\n]);\n\n/** Whether `id` is a valid style id. */\nexport function isValidStyleId(id: unknown): id is string {\n return typeof id === \"string\" && STYLE_ID.test(id);\n}\n\nconst MUTED = \"var(--pixerate-style-muted, #6b7280)\";\nconst HEADING_SIZES = [\"2em\", \"1.5em\", \"1.25em\", \"1.1em\", \"1em\", \"0.9em\"];\n\nfunction builtinStyles(): StyleDefinition[] {\n const styles: StyleDefinition[] = [\n {\n id: NORMAL_STYLE_ID,\n name: \"Normal\",\n kind: \"paragraph\",\n block: { type: \"paragraph\" },\n priority: 0,\n quick: true,\n builtin: true,\n },\n {\n id: \"Title\",\n name: \"Title\",\n kind: \"paragraph\",\n basedOn: NORMAL_STYLE_ID,\n next: NORMAL_STYLE_ID,\n linked: \"TitleChar\",\n paragraph: { spaceAfter: \"0.25em\", lineHeight: \"1.15\" },\n character: { fontSize: \"2.5em\", bold: true, letterSpacing: \"-0.01em\" },\n priority: 10,\n quick: true,\n builtin: true,\n },\n {\n id: \"Subtitle\",\n name: \"Subtitle\",\n kind: \"paragraph\",\n basedOn: NORMAL_STYLE_ID,\n next: NORMAL_STYLE_ID,\n linked: \"SubtitleChar\",\n paragraph: { spaceAfter: \"0.75em\" },\n character: { fontSize: \"1.25em\", color: MUTED },\n priority: 11,\n quick: true,\n builtin: true,\n },\n ];\n HEADING_SIZES.forEach((fontSize, i) => {\n const level = i + 1;\n styles.push({\n id: `Heading${level}`,\n name: `Heading ${level}`,\n kind: \"paragraph\",\n basedOn: NORMAL_STYLE_ID,\n next: NORMAL_STYLE_ID,\n linked: `Heading${level}Char`,\n block: { type: \"heading\", attrs: { level } },\n paragraph: { spaceBefore: level <= 2 ? \"1em\" : \"0.75em\", spaceAfter: \"0.25em\" },\n character: { fontSize, bold: true },\n priority: 11 + level,\n quick: level <= 3,\n builtin: true,\n });\n });\n styles.push(\n {\n id: \"Quote\",\n name: \"Quote\",\n kind: \"paragraph\",\n basedOn: NORMAL_STYLE_ID,\n next: NORMAL_STYLE_ID,\n linked: \"QuoteChar\",\n paragraph: { indentLeft: \"1em\", paddingLeft: \"0.75em\", borderLeft: \"3px solid currentColor\" },\n character: { italic: true, color: MUTED },\n priority: 29,\n quick: true,\n builtin: true,\n },\n {\n id: \"Code\",\n name: \"Code\",\n kind: \"paragraph\",\n basedOn: NORMAL_STYLE_ID,\n next: NORMAL_STYLE_ID,\n block: { type: \"codeBlock\" },\n character: {\n fontFamily: \"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace\",\n fontSize: \"0.9em\",\n },\n priority: 30,\n quick: true,\n builtin: true,\n },\n {\n id: \"ListParagraph\",\n name: \"List Paragraph\",\n kind: \"paragraph\",\n basedOn: NORMAL_STYLE_ID,\n paragraph: { indentLeft: \"2em\" },\n priority: 34,\n quick: true,\n builtin: true,\n },\n );\n // Linked character styles: their formatting is the paragraph style's.\n const linked = [\"Title\", \"Subtitle\", \"Quote\", ...HEADING_SIZES.map((_, i) => `Heading${i + 1}`)];\n linked.forEach((paragraphId) => {\n const name = styles.find((s) => s.id === paragraphId)!.name;\n styles.push({\n id: `${paragraphId}Char`,\n name: `${name} Char`,\n kind: \"character\",\n linked: paragraphId,\n priority: 99,\n hidden: true,\n builtin: true,\n });\n });\n styles.push(\n {\n id: \"Emphasis\",\n name: \"Emphasis\",\n kind: \"character\",\n character: { italic: true },\n priority: 20,\n quick: true,\n builtin: true,\n },\n {\n id: \"Strong\",\n name: \"Strong\",\n kind: \"character\",\n character: { bold: true },\n priority: 22,\n quick: true,\n builtin: true,\n },\n );\n return styles;\n}\n\n/** The built-in styles: Normal, Title, Subtitle, Heading 1–6, Quote, Code, List Paragraph and character styles. */\nexport const DEFAULT_STYLES: readonly StyleDefinition[] = Object.freeze(builtinStyles());\n\nconst clone = <T>(value: T): T => (value === undefined ? value : JSON.parse(JSON.stringify(value)));\n\n/** Copies only defined values of `patch` over `base`. */\nfunction overlay<T extends object>(base: T, patch: T | undefined | null): T {\n if (!patch) return base;\n const out: Record<string, unknown> = { ...(base as Record<string, unknown>) };\n Object.entries(patch).forEach(([key, value]) => {\n if (value !== undefined && value !== null) out[key] = value;\n });\n return out as T;\n}\n\nfunction sameBlock(a: StyleBlock, type: string, attrs: Record<string, any>): boolean {\n if (a.type !== type) return false;\n return Object.entries(a.attrs ?? {}).every(([key, value]) => attrs[key] === value);\n}\n\n/**\n * Style definitions with `basedOn` inheritance, next-style and linked\n * character/paragraph styles, resolved in cascade order: document defaults →\n * style chain (base first) → direct formatting. Chains are cycle-safe.\n *\n * `subscribe` calls the listener immediately and on every change (Svelte\n * store contract); `getSnapshot` is stable between changes.\n */\nexport class StyleRegistry {\n private styles = new Map<string, StyleDefinition>();\n private defaults: StyleDefaults;\n private version = 0;\n private snapshot: StyleRegistrySnapshot | null = null;\n private listeners = new Set<(snapshot: StyleRegistrySnapshot) => void>();\n\n constructor(options: StyleRegistryOptions = {}) {\n this.defaults = clone(options.defaults ?? {});\n if (options.builtins !== false) DEFAULT_STYLES.forEach((style) => this.styles.set(style.id, clone(style)));\n (options.styles ?? []).forEach((style) => this.put(style));\n }\n\n // -- Reading --------------------------------------------------------------\n\n get(id: string | null | undefined): StyleDefinition | undefined {\n return id ? this.styles.get(id) : undefined;\n }\n\n /** Finds a style by id or display name (case-insensitive). */\n find(nameOrId: string): StyleDefinition | undefined {\n const direct = this.styles.get(nameOrId);\n if (direct) return direct;\n const lower = nameOrId.toLowerCase();\n return this.list().find((style) => style.name.toLowerCase() === lower);\n }\n\n /** All styles (optionally of one kind) in gallery order. */\n list(kind?: StyleKind): StyleDefinition[] {\n return Array.from(this.styles.values())\n .filter((style) => !kind || style.kind === kind)\n .sort((a, b) => (a.priority ?? 99) - (b.priority ?? 99) || a.name.localeCompare(b.name));\n }\n\n /** Styles shown in the gallery (`quick`, not hidden), paragraph styles by default. */\n gallery(kind: StyleKind = \"paragraph\"): StyleDefinition[] {\n return this.list(kind).filter((style) => style.quick && !style.hidden);\n }\n\n /** The `basedOn` chain from the root style down to `id` (cycle-safe, bounded). */\n chain(id: string): StyleDefinition[] {\n const out: StyleDefinition[] = [];\n let current = this.styles.get(id);\n while (current && out.length < MAX_CHAIN && !out.includes(current)) {\n out.push(current);\n current = current.basedOn ? this.styles.get(current.basedOn) : undefined;\n }\n return out.reverse();\n }\n\n /**\n * Resolves a paragraph style: defaults, then each style of the chain (base\n * first). Unknown ids resolve to the defaults in a `paragraph` block.\n */\n resolve(id: string): ResolvedStyle {\n let paragraph = overlay<ParagraphFormat>({}, this.defaults.paragraph);\n let character = overlay<CharacterFormat>({}, this.defaults.character);\n let block: StyleBlock = { type: \"paragraph\" };\n this.chain(id).forEach((style) => {\n if (style.kind !== \"paragraph\") return;\n paragraph = overlay(paragraph, style.paragraph);\n character = overlay(character, style.character);\n if (style.block) block = clone(style.block);\n });\n return { id, paragraph, character, block, next: this.nextStyleId(id) };\n }\n\n /** Character formatting a paragraph style's chain sets (without defaults). */\n private paragraphCharacter(id: string): CharacterFormat {\n let character: CharacterFormat = {};\n this.chain(id).forEach((style) => {\n if (style.kind === \"paragraph\") character = overlay(character, style.character);\n });\n return character;\n }\n\n /**\n * Character formatting of a character style's chain. A style linked to a\n * paragraph style takes that style's character formatting first.\n */\n resolveCharacterStyle(id: string): CharacterFormat {\n let character: CharacterFormat = {};\n this.chain(id).forEach((style) => {\n if (style.kind === \"character\" && style.linked && this.get(style.linked)?.kind === \"paragraph\") {\n character = overlay(character, this.paragraphCharacter(style.linked));\n }\n character = overlay(character, style.character);\n });\n return character;\n }\n\n /**\n * Character formatting of text: defaults → paragraph style chain →\n * character style chain → direct formatting.\n */\n resolveText(input: {\n paragraphStyle?: string | null;\n characterStyle?: string | null;\n direct?: CharacterFormat;\n }): CharacterFormat {\n let character = this.resolve(input.paragraphStyle || NORMAL_STYLE_ID).character;\n if (input.characterStyle) character = overlay(character, this.resolveCharacterStyle(input.characterStyle));\n return overlay(character, input.direct);\n }\n\n /** The style after Enter at the end of a paragraph of `id` (itself when unset or unknown). */\n nextStyleId(id: string): string {\n const next = this.styles.get(id)?.next;\n return next && this.styles.get(next)?.kind === \"paragraph\" ? next : id;\n }\n\n /** The linked character style of a paragraph style, if any. */\n linkedCharacterStyle(id: string): StyleDefinition | undefined {\n const style = this.styles.get(id);\n const linked = style?.linked ? this.styles.get(style.linked) : undefined;\n return style?.kind === \"paragraph\" && linked?.kind === \"character\" ? linked : undefined;\n }\n\n /**\n * The style a block uses when it names none: Normal for paragraphs,\n * Heading N for headings of level N, Code for code blocks (the built-in\n * style whose own `block` matches).\n */\n defaultStyleFor(type: string, attrs: Record<string, any> = {}): string | null {\n if (type === \"paragraph\" && this.styles.get(NORMAL_STYLE_ID)) return NORMAL_STYLE_ID;\n const candidates = this.list(\"paragraph\").filter(\n (style) => style.block && sameBlock(style.block, type, attrs),\n );\n return (candidates.find((s) => s.builtin) ?? candidates[0])?.id ?? null;\n }\n\n /** The style of a block: its `styleId` when known, otherwise the block's default style. */\n styleOfBlock(type: string, attrs: Record<string, any> = {}): string | null {\n const id = attrs.styleId;\n if (id && this.styles.get(id)?.kind === \"paragraph\") return id;\n return this.defaultStyleFor(type, attrs);\n }\n\n getSnapshot = (): StyleRegistrySnapshot => {\n if (!this.snapshot) {\n this.snapshot = Object.freeze({\n styles: Object.freeze(this.list()),\n defaults: this.defaults,\n version: this.version,\n });\n }\n return this.snapshot;\n };\n\n subscribe = (listener: (snapshot: StyleRegistrySnapshot) => void): (() => void) => {\n this.listeners.add(listener);\n listener(this.getSnapshot());\n return () => {\n this.listeners.delete(listener);\n };\n };\n\n toJSON(): StyleRegistryJSON {\n return { styles: clone(Array.from(this.styles.values())), defaults: clone(this.defaults) };\n }\n\n // -- Writing --------------------------------------------------------------\n\n /** Adds or replaces a style. Throws on an invalid id. */\n upsert(style: StyleDefinition): StyleDefinition {\n const stored = this.put(style);\n this.changed();\n return stored;\n }\n\n /** Merges `patch` into a style (formats are merged key by key). Returns `undefined` for unknown ids. */\n update(id: string, patch: Partial<Omit<StyleDefinition, \"id\">>): StyleDefinition | undefined {\n const current = this.styles.get(id);\n if (!current) return undefined;\n const next: StyleDefinition = {\n ...current,\n ...patch,\n id,\n paragraph: patch.paragraph ? { ...current.paragraph, ...patch.paragraph } : current.paragraph,\n character: patch.character ? { ...current.character, ...patch.character } : current.character,\n };\n return this.upsert(next);\n }\n\n /**\n * Removes a style and returns it. Built-in styles cannot be removed. Styles\n * based on it are rebased onto its own base, and `next`/`linked`\n * references to it are dropped.\n */\n remove(id: string): StyleDefinition | undefined {\n const gone = this.styles.get(id);\n if (!gone || gone.builtin) return undefined;\n this.styles.delete(id);\n this.styles.forEach((style, key) => {\n let changed = style;\n if (style.basedOn === id) {\n changed = { ...changed, basedOn: gone.basedOn && gone.basedOn !== key ? gone.basedOn : null };\n }\n if (style.next === id) changed = { ...changed, next: null };\n if (style.linked === id) changed = { ...changed, linked: null };\n if (changed !== style) this.styles.set(key, changed);\n });\n this.changed();\n return gone;\n }\n\n /** Replaces the document defaults. */\n setDefaults(defaults: StyleDefaults): void {\n this.defaults = clone(defaults);\n this.changed();\n }\n\n /** An unused id derived from a display name (`My Style` → `MyStyle`, then `MyStyle1`, …). */\n newId(name: string): string {\n let base = name.replace(/[^A-Za-z0-9_-]+/g, \"\").replace(/^[^A-Za-z]+/, \"\").slice(0, 56);\n if (!base) base = \"Style\";\n if (!this.styles.has(base)) return base;\n for (let i = 1; i < 100000; i++) {\n const id = `${base}${i}`;\n if (!this.styles.has(id)) return id;\n }\n return `${base}${Date.now()}`;\n }\n\n // -- CSS --------------------------------------------------------------------\n\n /** CSS declarations (`property: value`) of a resolved paragraph or character style. */\n cssDeclarations(id: string): Record<string, string> {\n const style = this.styles.get(id);\n if (style?.kind === \"character\") return characterCSS(this.resolveCharacterStyle(id));\n const resolved = this.resolve(id);\n return { ...paragraphCSS(resolved.paragraph), ...characterCSS(resolved.character) };\n }\n\n /**\n * Declarations for previewing a style in a menu or gallery: font family,\n * weight, style, color, decoration, case and letter spacing (no sizes,\n * margins or borders).\n */\n previewDeclarations(id: string): Record<string, string> {\n return Object.fromEntries(\n Object.entries(this.cssDeclarations(id)).filter(([property]) => PREVIEW_PROPERTIES.has(property)),\n );\n }\n\n /**\n * A stylesheet for the styles: `[data-style=\"Id\"]` rules for paragraph\n * styles (plus the plain element of blocks that use their default style,\n * e.g. `h2:not([data-style])`), `[data-char-style=\"Id\"]` for character\n * styles and the defaults on the scope element.\n */\n toCSS(options: StyleCSSOptions = {}): string {\n const scope = options.scope ?? \".ProseMirror\";\n const tagFor = options.tagFor ?? defaultTagFor;\n const rules: string[] = [];\n const rule = (selectors: string[], declarations: Record<string, string>) => {\n const body = Object.entries(declarations)\n .map(([property, value]) => `${property}: ${value};`)\n .join(\" \");\n if (body) rules.push(`${selectors.join(\", \")} { ${body} }`);\n };\n rule([scope], {\n ...paragraphCSS(this.defaults.paragraph ?? {}),\n ...characterCSS(this.defaults.character ?? {}),\n });\n this.list().forEach((style) => {\n if (style.kind === \"character\") {\n rule([`${scope} [data-char-style=\"${style.id}\"]`], this.cssDeclarations(style.id));\n return;\n }\n const selectors = [`${scope} [data-style=\"${style.id}\"]`];\n const block = this.resolve(style.id).block;\n if (this.defaultStyleFor(block.type, block.attrs ?? {}) === style.id) {\n const tag = tagFor(block);\n if (tag) selectors.push(`${scope} ${tag}:not([data-style])`);\n }\n // Defaults already apply to the scope; repeat only what the chain sets.\n const resolved = this.resolve(style.id);\n const own = {\n ...paragraphCSS(withoutDefaults(resolved.paragraph, this.defaults.paragraph)),\n ...characterCSS(withoutDefaults(resolved.character, this.defaults.character)),\n };\n rule(selectors, own);\n });\n return rules.join(\"\\n\");\n }\n\n // -- Internals --------------------------------------------------------------\n\n private put(style: StyleDefinition): StyleDefinition {\n if (!isValidStyleId(style.id)) throw new Error(`Invalid style id: ${String(style.id)}`);\n if (style.kind !== \"paragraph\" && style.kind !== \"character\") {\n throw new Error(`Invalid style kind: ${String(style.kind)}`);\n }\n const stored = clone({ ...style, name: style.name || style.id });\n this.styles.set(style.id, stored);\n return stored;\n }\n\n private changed(): void {\n this.version++;\n this.snapshot = null;\n const snapshot = this.getSnapshot();\n this.listeners.forEach((listener) => {\n try {\n listener(snapshot);\n } catch (err) {\n console.error(\"[StyleRegistry] Error in listener:\", err);\n }\n });\n }\n}\n\nfunction withoutDefaults<T extends object>(format: T, defaults: T | undefined): T {\n if (!defaults) return format;\n const out: Record<string, unknown> = {};\n Object.entries(format).forEach(([key, value]) => {\n if ((defaults as Record<string, unknown>)[key] !== value) out[key] = value;\n });\n return out as T;\n}\n\nfunction defaultTagFor(block: StyleBlock): string | null {\n if (block.type === \"paragraph\") return \"p\";\n if (block.type === \"heading\") {\n const level = Number(block.attrs?.level);\n return level >= 1 && level <= 6 ? `h${level}` : null;\n }\n if (block.type === \"codeBlock\") return \"pre\";\n return null;\n}\n\n/** A CSS value, or `undefined` when it is unsafe or empty. */\nexport function safeCSSValue(value: unknown): string | undefined {\n if (typeof value !== \"string\") return undefined;\n const trimmed = value.trim();\n if (!trimmed || trimmed.length > 200 || UNSAFE_CSS.test(trimmed)) return undefined;\n return trimmed;\n}\n\nfunction paragraphCSS(format: ParagraphFormat): Record<string, string> {\n const out: Record<string, string> = {};\n const set = (property: string, value: unknown) => {\n const safe = safeCSSValue(value);\n if (safe) out[property] = safe;\n };\n set(\"text-align\", format.textAlign);\n set(\"line-height\", format.lineHeight);\n set(\"margin-top\", format.spaceBefore);\n set(\"margin-bottom\", format.spaceAfter);\n set(\"margin-left\", format.indentLeft);\n set(\"margin-right\", format.indentRight);\n set(\"text-indent\", format.indentFirstLine);\n set(\"border-left\", format.borderLeft);\n set(\"padding-left\", format.paddingLeft);\n set(\"background-color\", format.backgroundColor);\n return out;\n}\n\nfunction characterCSS(format: CharacterFormat): Record<string, string> {\n const out: Record<string, string> = {};\n const set = (property: string, value: unknown) => {\n const safe = safeCSSValue(value);\n if (safe) out[property] = safe;\n };\n set(\"font-family\", format.fontFamily);\n set(\"font-size\", format.fontSize);\n if (format.bold !== undefined) out[\"font-weight\"] = format.bold ? \"700\" : \"400\";\n if (format.italic !== undefined) out[\"font-style\"] = format.italic ? \"italic\" : \"normal\";\n const lines = [format.underline && \"underline\", format.strike && \"line-through\"].filter(Boolean);\n if (format.underline !== undefined || format.strike !== undefined) {\n out[\"text-decoration-line\"] = lines.length ? lines.join(\" \") : \"none\";\n }\n set(\"color\", format.color);\n set(\"background-color\", format.backgroundColor);\n set(\"letter-spacing\", format.letterSpacing);\n set(\"text-transform\", format.textTransform);\n if (format.smallCaps !== undefined) out[\"font-variant-caps\"] = format.smallCaps ? \"small-caps\" : \"normal\";\n return out;\n}\n\n/** Creates a style registry with the built-in styles (unless `builtins: false`) and `styles`. */\nexport function createStyleRegistry(options: StyleRegistryOptions | StyleRegistryJSON = {}): StyleRegistry {\n return new StyleRegistry(options as StyleRegistryOptions);\n}\n"],"mappings":";AAmHA,IAAM,YAAY;AAClB,IAAM,WAAW;AAEjB,IAAM,aAAa;AAEZ,IAAM,kBAAkB;AAE/B,IAAM,qBAAqB,oBAAI,IAAI;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGM,SAAS,eAAe,IAA2B;AACxD,SAAO,OAAO,OAAO,YAAY,SAAS,KAAK,EAAE;AACnD;AAEA,IAAM,QAAQ;AACd,IAAM,gBAAgB,CAAC,OAAO,SAAS,UAAU,SAAS,OAAO,OAAO;AAExE,SAAS,gBAAmC;AAC1C,QAAM,SAA4B;AAAA,IAChC;AAAA,MACE,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,EAAE,MAAM,YAAY;AAAA,MAC3B,UAAU;AAAA,MACV,OAAO;AAAA,MACP,SAAS;AAAA,IACX;AAAA,IACA;AAAA,MACE,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,MAAM;AAAA,MACN,SAAS;AAAA,MACT,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,WAAW,EAAE,YAAY,UAAU,YAAY,OAAO;AAAA,MACtD,WAAW,EAAE,UAAU,SAAS,MAAM,MAAM,eAAe,UAAU;AAAA,MACrE,UAAU;AAAA,MACV,OAAO;AAAA,MACP,SAAS;AAAA,IACX;AAAA,IACA;AAA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