react-smart-copy 1.15.0 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +140 -1
- package/dist/color.cjs +927 -0
- package/dist/color.cjs.map +1 -0
- package/dist/color.d.cts +198 -0
- package/dist/color.d.ts +198 -0
- package/dist/color.js +916 -0
- package/dist/color.js.map +1 -0
- package/dist/markdown.cjs.map +1 -1
- package/dist/markdown.js.map +1 -1
- package/dist/rich.cjs +1883 -0
- package/dist/rich.cjs.map +1 -0
- package/dist/rich.d.cts +212 -0
- package/dist/rich.d.ts +212 -0
- package/dist/rich.js +1879 -0
- package/dist/rich.js.map +1 -0
- package/package.json +74 -4
package/dist/rich.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rich.js","names":["WHITE","rgb"],"sources":["../src/core/errors.ts","../src/link/url.ts","../src/rich/policy.ts","../src/color/convert.ts","../src/color/names.ts","../src/color/parse.ts","../src/color/format.ts","../src/color/contrast.ts","../src/rich/style.ts","../src/rich/text.ts","../src/rich/walk.ts","../src/rich/payload.ts"],"sourcesContent":["import type { PasteSource } from './paste-reader';\n\n/**\n * Every way a clipboard operation can fail, as a closed union.\n *\n * `CopyError.message` is developer-facing (logs, telemetry). For user-facing\n * text use {@link describeCopyError} / {@link describePasteError}, or map\n * `type` through your own i18n layer.\n */\nexport type CopyErrorType =\n /** No Clipboard API (old browser, server, locked-down webview). Not retryable. */\n | 'unsupported'\n /** Page is not served over HTTPS/localhost. Not retryable. */\n | 'insecure-context'\n /** Browser or user blocked the operation. Also what Safari reports for a missing user gesture. */\n | 'permission-denied'\n /** The document lost focus mid-operation (Chromium). Retrying after refocus usually works. */\n | 'not-focused'\n /** Empty or malformed payload, or a lazy source that threw. Caught before touching the clipboard. */\n | 'invalid-payload'\n /** The browser cannot handle this MIME type (e.g. non-PNG image, HTML without ClipboardItem). */\n | 'unsupported-format'\n /** A lazy image source (or capture) threw, rejected or did not produce a Blob. */\n | 'blob-generation-failed'\n /** `retry()` was called after `maxRetries` was reached. Terminal. */\n | 'max-retries-exceeded'\n /** Paste: the clipboard held nothing matching `accept`. */\n | 'no-content'\n /** Content exceeded a configured safety limit (bytes, items or pixels). Not retryable. */\n | 'too-large'\n /** An operation did not settle within its deadline. Retryable. */\n | 'timeout'\n /** The caller aborted the operation through an `AbortSignal`. Not retryable. */\n | 'aborted'\n /** Anything the platform threw that we could not classify. */\n | 'unknown';\n\n/** Which clipboard direction failed; only changes developer-facing messages. */\nexport type ClipboardOperation = 'write' | 'read';\n\nexport interface CopyError {\n readonly type: CopyErrorType;\n readonly message: string;\n readonly cause?: unknown;\n}\n\nexport function createCopyError(type: CopyErrorType, message: string, cause?: unknown): CopyError {\n return cause === undefined ? { type, message } : { type, message, cause };\n}\n\nconst RETRYABLE_ERRORS: ReadonlySet<CopyErrorType> = /* @__PURE__ */ new Set<CopyErrorType>([\n 'permission-denied',\n 'not-focused',\n 'blob-generation-failed',\n 'timeout',\n 'unknown',\n]);\n\n/** Whether retrying the same payload could plausibly succeed. */\nexport function isRetryableError(error: CopyError): boolean {\n return RETRYABLE_ERRORS.has(error.type);\n}\n\n/**\n * Branded (not `instanceof`) so failures stay recognisable even when the core\n * is bundled twice, e.g. `react-smart-copy` and `react-smart-copy/core` together.\n */\nconst COPY_FAILURE_BRAND = Symbol.for('react-smart-copy.CopyFailure');\n\n/** Error thrown by adapters to carry a fully classified {@link CopyError}. */\nexport class CopyFailure extends Error {\n readonly copyError: CopyError;\n readonly [COPY_FAILURE_BRAND] = true;\n\n constructor(copyError: CopyError) {\n super(copyError.message);\n this.name = 'CopyFailure';\n this.copyError = copyError;\n }\n}\n\nexport function isCopyFailure(value: unknown): value is CopyFailure {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as Record<PropertyKey, unknown>)[COPY_FAILURE_BRAND] === true\n );\n}\n\n/** Shorthand for throwing a classified failure. */\nexport function copyFailure(type: CopyErrorType, message: string, cause?: unknown): CopyFailure {\n return new CopyFailure(createCopyError(type, message, cause));\n}\n\nfunction readString(value: unknown, key: string): string | undefined {\n if (typeof value !== 'object' || value === null) return undefined;\n const field = (value as Record<string, unknown>)[key];\n return typeof field === 'string' ? field : undefined;\n}\n\n/**\n * Classifies anything thrown by the platform or an adapter into a {@link CopyError}.\n * `operation` only tailors the developer-facing message.\n */\nexport function toCopyError(cause: unknown, operation: ClipboardOperation = 'write'): CopyError {\n if (isCopyFailure(cause)) return cause.copyError;\n\n const name = readString(cause, 'name');\n const message = readString(cause, 'message') ?? '';\n const verb = operation === 'read' ? 'read' : 'write';\n\n switch (name) {\n case 'NotAllowedError':\n return /focus/i.test(message)\n ? createCopyError('not-focused', `The document was not focused during the clipboard ${verb}.`, cause)\n : createCopyError('permission-denied', `Clipboard ${verb} permission was denied.`, cause);\n case 'SecurityError':\n return createCopyError('insecure-context', 'The clipboard is blocked in this context.', cause);\n case 'NotSupportedError':\n case 'DataError':\n return createCopyError('unsupported-format', 'The browser rejected this clipboard format.', cause);\n case 'AbortError':\n return createCopyError('aborted', `The clipboard ${verb} was aborted.`, cause);\n case 'TimeoutError':\n return createCopyError('timeout', `The clipboard ${verb} timed out.`, cause);\n default:\n return createCopyError('unknown', message || `The clipboard ${verb} failed for an unknown reason.`, cause);\n }\n}\n\nconst COPY_DESCRIPTIONS: Readonly<Record<CopyErrorType, string>> = {\n unsupported: \"Copying isn't supported in this browser.\",\n 'insecure-context': 'Copying requires a secure (HTTPS) connection.',\n 'permission-denied': 'Clipboard access was blocked. Allow it and try again.',\n 'not-focused': 'The page lost focus while copying. Try again.',\n 'invalid-payload': 'There is nothing to copy.',\n 'unsupported-format': \"This content can't be copied in this browser.\",\n 'blob-generation-failed': \"The image couldn't be prepared for copying.\",\n 'max-retries-exceeded': 'Copying failed after several attempts.',\n 'no-content': 'There is nothing to copy.',\n 'too-large': 'This content is too large to copy.',\n timeout: 'Copying took too long. Try again.',\n aborted: 'Copying was cancelled.',\n unknown: \"Couldn't copy to the clipboard. Try again.\",\n};\n\nconst PASTE_DESCRIPTIONS: Readonly<Record<CopyErrorType, string>> = {\n unsupported: \"Pasting isn't supported in this browser.\",\n 'insecure-context': 'Pasting requires a secure (HTTPS) connection.',\n 'permission-denied': 'Clipboard access was blocked. Allow it and try again.',\n 'not-focused': 'The page lost focus while pasting. Try again.',\n 'invalid-payload': \"The clipboard content couldn't be read.\",\n 'unsupported-format': \"This clipboard content isn't supported here.\",\n 'blob-generation-failed': \"The pasted image couldn't be read.\",\n 'max-retries-exceeded': 'Pasting failed after several attempts.',\n 'no-content': \"The clipboard doesn't contain anything that can be pasted here.\",\n 'too-large': 'The clipboard content is too large to paste.',\n timeout: 'Pasting took too long. Try again.',\n aborted: 'Pasting was cancelled.',\n unknown: \"Couldn't read the clipboard. Try again.\",\n};\n\n/** Default English, user-facing sentence for a copy error. Replace for i18n. */\nexport function describeCopyError(error: CopyError): string {\n return COPY_DESCRIPTIONS[error.type];\n}\n\n/** Drops can only fail in these ways; the rest of the paste wording would mention the clipboard. */\nconst DROP_DESCRIPTIONS: Readonly<Partial<Record<CopyErrorType, string>>> = {\n 'invalid-payload': \"The dropped content couldn't be read.\",\n 'no-content': 'Nothing that was dropped can be used here.',\n 'too-large': 'The dropped content is too large.',\n unknown: \"Couldn't read the dropped content. Try again.\",\n};\n\n/**\n * Default English, user-facing sentence for a paste error. Pass the error\n * state's `source` to word drag-and-drop failures as drops. Replace for i18n.\n */\nexport function describePasteError(error: CopyError, source?: PasteSource): string {\n return (source === 'drop' ? DROP_DESCRIPTIONS[error.type] : undefined) ?? PASTE_DESCRIPTIONS[error.type];\n}\n","import { copyFailure } from '../core/errors';\n\n/** Schemes a copied or pasted link may use by default. Never `javascript:`, `data:`, `vbscript:` or `file:`. */\nexport const DEFAULT_LINK_PROTOCOLS: readonly string[] = /* @__PURE__ */ Object.freeze(['https:', 'http:', 'mailto:', 'tel:']);\n\n/**\n * Query parameters that only track where a click came from: the defaults of\n * {@link cleanLinkUrl}. `utm_` matches every parameter starting with it.\n */\nexport const TRACKING_PARAMETERS: readonly string[] = /* @__PURE__ */ Object.freeze([\n 'utm_',\n 'fbclid',\n 'gclid',\n 'gclsrc',\n 'dclid',\n 'gbraid',\n 'wbraid',\n 'msclkid',\n 'yclid',\n 'twclid',\n 'ttclid',\n 'li_fat_id',\n 'igshid',\n 'igsh',\n 'mc_cid',\n 'mc_eid',\n '_hsenc',\n '_hsmi',\n 'mkt_tok',\n 'oly_anon_id',\n 'oly_enc_id',\n 'vero_id',\n 'wickedid',\n '_gl',\n]);\n\nexport interface CleanLinkOptions {\n /**\n * Parameters to remove: exact names, names ending in `_` (a prefix, like\n * `utm_`), or regular expressions tested against the name. Default {@link TRACKING_PARAMETERS}.\n */\n readonly params?: readonly (string | RegExp)[];\n /** Parameters never removed, even when `params` matches them. */\n readonly keep?: readonly string[];\n}\n\nexport interface LinkUrlOptions {\n /** Resolves relative links. Default: the page's address in a browser; required elsewhere for relative links. */\n readonly base?: string | URL;\n /** Allowed schemes, with the colon. Default {@link DEFAULT_LINK_PROTOCOLS}. */\n readonly protocols?: readonly string[];\n /** Remove tracking parameters: `true` for {@link TRACKING_PARAMETERS}, or your own list. Default `false`. */\n readonly clean?: boolean | CleanLinkOptions;\n}\n\nconst invalid = (message: string) => copyFailure('invalid-payload', message);\n\nfunction baseUrl(base: LinkUrlOptions['base']): string | undefined {\n if (base !== undefined) {\n if (typeof base === 'string' || base instanceof URL) return String(base);\n throw invalid('`base` must be a string or a URL.');\n }\n return typeof location === 'undefined' ? undefined : location.href;\n}\n\nfunction protocolSet(protocols: LinkUrlOptions['protocols']): ReadonlySet<string> {\n const list: unknown = protocols ?? DEFAULT_LINK_PROTOCOLS;\n const valid = (protocol: unknown): protocol is string => typeof protocol === 'string' && /^[a-z][a-z\\d+.-]*:$/i.test(protocol);\n if (!Array.isArray(list) || list.length === 0 || !(list as readonly unknown[]).every(valid)) {\n throw invalid('`protocols` must be a non-empty list of schemes with their colon, like \"https:\".');\n }\n return new Set((list as readonly string[]).map((protocol) => protocol.toLowerCase()));\n}\n\nfunction matcher(params: CleanLinkOptions['params']): (name: string) => boolean {\n const list = params ?? TRACKING_PARAMETERS;\n if (!Array.isArray(list) || !list.every((param) => typeof param === 'string' || param instanceof RegExp)) {\n throw invalid('`clean.params` must be a list of strings and regular expressions.');\n }\n return (name) => {\n const lower = name.toLowerCase();\n return list.some((param) => {\n if (typeof param !== 'string') return new RegExp(param.source, param.flags.replace(/[gy]/g, '')).test(name);\n const wanted = param.toLowerCase();\n return wanted.endsWith('_') ? lower.startsWith(wanted) : lower === wanted;\n });\n };\n}\n\n/** The cleaning step `clean` asks for, or `null`. Throws for an invalid option. */\nfunction cleaner(option: LinkUrlOptions['clean']): ((url: URL) => void) | null {\n const cleaning: unknown = option ?? false; // Plain-JS callers can pass anything.\n if (cleaning === false) return null;\n if (cleaning !== true && (typeof cleaning !== 'object' || cleaning === null)) throw invalid('`clean` must be a boolean or an options object.');\n const settings: CleanLinkOptions = cleaning === true ? {} : cleaning;\n const tracking = matcher(settings.params);\n const keep = settings.keep ?? [];\n if (!Array.isArray(keep) || !keep.every((name: unknown) => typeof name === 'string')) throw invalid('`clean.keep` must be a list of strings.');\n const kept = new Set(keep.map((name) => name.toLowerCase()));\n return (url) => {\n for (const name of [...new Set(url.searchParams.keys())]) {\n if (tracking(name) && !kept.has(name.toLowerCase())) url.searchParams.delete(name);\n }\n };\n}\n\n/**\n * Validates `options` once (throwing a typed `invalid-payload` error for invalid\n * ones) and returns a resolver that throws only for invalid links.\n * @internal\n */\nexport function linkUrlResolver(options: LinkUrlOptions = {}): (input: string | URL) => string {\n const protocols = protocolSet(options.protocols);\n const base = baseUrl(options.base);\n const clean = cleaner(options.clean);\n return (input) => {\n if (typeof input !== 'string' && !(input instanceof URL)) throw invalid('A link must be a string or a URL.');\n const raw = String(input).trim();\n if (raw === '') throw invalid('A link must not be empty.');\n let url: URL;\n try {\n url = new URL(raw, base);\n } catch (cause) {\n throw copyFailure('invalid-payload', `Not a valid link: ${JSON.stringify(raw.slice(0, 200))}.`, cause);\n }\n if (!protocols.has(url.protocol)) {\n throw invalid(`Links with the scheme \"${url.protocol}\" are not allowed (allowed: ${[...protocols].join(', ')}).`);\n }\n // Never copy or paste credentials embedded in a link.\n url.username = '';\n url.password = '';\n clean?.(url);\n return url.href;\n };\n}\n\n/**\n * The link as an absolute, safe URL string, or a typed `invalid-payload` error:\n * relative links are resolved, the scheme must be allowed, user names and\n * passwords are always removed, and tracking parameters optionally.\n */\nexport function resolveLinkUrl(input: string | URL, options: LinkUrlOptions = {}): string {\n return linkUrlResolver(options)(input);\n}\n\n/**\n * Removes tracking parameters (`utm_*`, `fbclid`, `gclid`, ...) from a link, keeping\n * everything else, including the fragment. Also validates it like every link here.\n *\n * @example\n * cleanLinkUrl('https://shop.example/p/42?utm_source=news&color=red'); // 'https://shop.example/p/42?color=red'\n */\nexport function cleanLinkUrl(url: string | URL, options: CleanLinkOptions & Omit<LinkUrlOptions, 'clean'> = {}): string {\n const { params, keep, ...rest } = options;\n return resolveLinkUrl(url, { ...rest, clean: { ...(params === undefined ? {} : { params }), ...(keep === undefined ? {} : { keep }) } });\n}\n","/**\n * What portable rich text may contain: the elements, attributes and CSS that Gmail,\n * Outlook, Apple Mail, Google Docs, Word, Notion and Slack keep, and nothing that\n * can run, load or track. Everything not listed here is left out.\n */\n\n/** Elements written as they are. */\nexport const KEEP: ReadonlySet<string> = /* @__PURE__ */ new Set([\n 'a', 'abbr', 'b', 'bdi', 'bdo', 'blockquote', 'br', 'caption', 'cite', 'code', 'col', 'colgroup', 'dd', 'del', 'dfn', 'div', 'dl', 'dt',\n 'em', 'figcaption', 'figure', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'img', 'ins', 'kbd', 'li', 'mark', 'ol', 'p', 'pre', 'q', 's',\n 'samp', 'small', 'span', 'strong', 'sub', 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'time', 'tr', 'u', 'ul', 'var',\n]);\n\n/** Elements left out with everything inside them: they run, load, embed, or are page chrome. */\nexport const DROP: ReadonlySet<string> = /* @__PURE__ */ new Set([\n 'applet', 'audio', 'base', 'button', 'canvas', 'datalist', 'dialog', 'embed', 'frame', 'frameset', 'head', 'iframe', 'input', 'link',\n 'map', 'math', 'meta', 'meter', 'noembed', 'noframes', 'noscript', 'object', 'option', 'optgroup', 'output', 'param', 'portal',\n 'progress', 'script', 'select', 'slot', 'source', 'style', 'svg', 'template', 'textarea', 'title', 'track', 'video',\n]);\n\n/** Elements that become a `<div>`: blocks without an email-safe equivalent. */\nexport const AS_BLOCK: ReadonlySet<string> = /* @__PURE__ */ new Set([\n 'address', 'article', 'aside', 'body', 'center', 'details', 'fieldset', 'footer', 'form', 'header', 'hgroup', 'html', 'legend',\n 'listing', 'main', 'menu', 'nav', 'plaintext', 'search', 'section', 'summary', 'xmp',\n]);\n\n/** Elements whose children are block-level text in the plain-text version. */\nexport const TEXT_BLOCKS: ReadonlySet<string> = /* @__PURE__ */ new Set([\n 'blockquote', 'caption', 'dd', 'div', 'dl', 'dt', 'figcaption', 'figure', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'li', 'ol', 'p',\n 'pre', 'table', 'tbody', 'tfoot', 'thead', 'tr', 'ul',\n]);\n\n/** What table parts may contain: anything else is moved out of the table by every HTML parser. */\nexport const TABLE_CHILDREN: Readonly<Record<string, ReadonlySet<string>>> = {\n table: /* @__PURE__ */ new Set(['caption', 'colgroup', 'thead', 'tbody', 'tfoot', 'tr']),\n thead: /* @__PURE__ */ new Set(['tr']),\n tbody: /* @__PURE__ */ new Set(['tr']),\n tfoot: /* @__PURE__ */ new Set(['tr']),\n tr: /* @__PURE__ */ new Set(['td', 'th']),\n colgroup: /* @__PURE__ */ new Set(['col']),\n};\n\n/** Elements that hold only text-level content: a block inside one would be split out by HTML parsers. */\nexport const PHRASING: ReadonlySet<string> = /* @__PURE__ */ new Set([\n 'a', 'abbr', 'b', 'bdi', 'bdo', 'cite', 'code', 'del', 'dfn', 'em', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'i', 'ins', 'kbd', 'mark', 'p', 'q',\n 's', 'samp', 'small', 'span', 'strong', 'sub', 'sup', 'time', 'u', 'var',\n]);\n\n/** Table parts: outside their own parent, HTML parsers ignore their tags. */\nexport const TABLE_PARTS: ReadonlySet<string> = /* @__PURE__ */ new Set(['caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr']);\n\nexport const HEADINGS: ReadonlySet<string> = /* @__PURE__ */ new Set(['h1', 'h2', 'h3', 'h4', 'h5', 'h6']);\n\n/** Elements whose start tag closes an open `<p>`: a paragraph holding one is split in two by HTML parsers. */\nexport const CLOSES_P: ReadonlySet<string> = /* @__PURE__ */ new Set([\n 'blockquote', 'dd', 'dl', 'dt', 'figcaption', 'figure', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'li', 'ol', 'p', 'pre', 'table', 'ul',\n]);\n\n/** Where HTML parsers stop looking for an open list item to close: their \"special\" elements, less address, div and p. */\nconst ITEM_SCOPE: ReadonlySet<string> = /* @__PURE__ */ new Set([\n 'blockquote', 'br', 'caption', 'col', 'colgroup', 'dd', 'dl', 'dt', 'figcaption', 'figure', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'img',\n 'li', 'ol', 'pre', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'ul',\n]);\n\n/** Whether a new `li` (or `dd`, `dt`) under `parent` would close an open one, as HTML parsers do with `<li>` in `<li>`. */\nexport function closesItem(name: 'li' | 'dd' | 'dt', parent: Node | null): boolean {\n const group = name === 'li' ? ['li'] : ['dd', 'dt'];\n for (let node = parent; node !== null && node.nodeType === 1; node = node.parentNode) {\n const tag = (node as Element).localName;\n if (group.includes(tag)) return true;\n if (ITEM_SCOPE.has(tag)) return false;\n }\n return false;\n}\n\nconst INTEGER = /^\\d{1,4}$/;\n\n/** Attributes kept per element (after `href` and `src`, which are checked as URLs). */\nexport function attributeAllowed(tag: string, name: string, value: string): boolean {\n switch (name) {\n case 'dir':\n return /^(?:ltr|rtl|auto)$/i.test(value);\n case 'lang':\n return /^[a-z]{2,3}(?:-[a-z\\d]{1,8})*$/i.test(value);\n case 'title':\n // Images write their own title, alt, size and source.\n return ['a', 'abbr', 'dfn'].includes(tag);\n case 'colspan':\n case 'rowspan':\n return (tag === 'td' || tag === 'th') && INTEGER.test(value) && Number(value) >= 1 && Number(value) <= 1000;\n case 'scope':\n return tag === 'th' && /^(?:row|col|rowgroup|colgroup)$/i.test(value);\n case 'span':\n return (tag === 'col' || tag === 'colgroup') && INTEGER.test(value);\n case 'start':\n return tag === 'ol' && /^-?\\d{1,9}$/.test(value);\n case 'reversed':\n return tag === 'ol';\n case 'type':\n return tag === 'ol' && /^[1aAiI]$/.test(value);\n case 'value':\n return tag === 'li' && /^-?\\d{1,9}$/.test(value);\n case 'datetime':\n return tag === 'time' && /^[\\d\\-:T.+ Z]{1,40}$/.test(value);\n default:\n return false;\n }\n}\n","/**\n * Colour space conversions, from the CSS Color 4 specification's sample code.\n * A {@link Color} is stored as extended sRGB: gamma-encoded r, g and b, which go\n * below 0 or above 1 for colours outside sRGB (a Display P3 or OKLCH colour), and\n * alpha in [0, 1]. Every conversion keeps such colours exact until a format needs\n * them in a gamut.\n */\n\n/** A colour: extended sRGB channels (0 to 1 inside sRGB) and alpha (0 to 1). */\nexport interface Color {\n readonly r: number;\n readonly g: number;\n readonly b: number;\n readonly alpha: number;\n}\n\nexport type Vec3 = readonly [number, number, number];\ntype Mat3 = readonly [Vec3, Vec3, Vec3];\n\n/** The gamuts a colour can be mapped into: sRGB (every screen) and Display P3 (wide-gamut screens). */\nexport type Gamut = 'srgb' | 'p3';\n\nexport const color = (r: number, g: number, b: number, alpha = 1): Color => Object.freeze({ r, g, b, alpha });\n\nconst mul = (m: Mat3, [x, y, z]: Vec3): Vec3 => [\n m[0][0] * x + m[0][1] * y + m[0][2] * z,\n m[1][0] * x + m[1][1] * y + m[1][2] * z,\n m[2][0] * x + m[2][1] * y + m[2][2] * z,\n];\n\n/** The sRGB (and Display P3) transfer function, extended to negative values by symmetry. */\nconst toLinear = (c: number): number => {\n const abs = Math.abs(c);\n return abs <= 0.04045 ? c / 12.92 : Math.sign(c) * ((abs + 0.055) / 1.055) ** 2.4;\n};\nconst fromLinear = (c: number): number => {\n const abs = Math.abs(c);\n return abs > 0.0031308 ? Math.sign(c) * (1.055 * abs ** (1 / 2.4) - 0.055) : 12.92 * c;\n};\n\nexport const linearRgb = (c: Color): Vec3 => [toLinear(c.r), toLinear(c.g), toLinear(c.b)];\nexport const fromLinearRgb = ([r, g, b]: Vec3, alpha: number): Color => color(fromLinear(r), fromLinear(g), fromLinear(b), alpha);\n\nconst SRGB_TO_XYZ: Mat3 = [\n [0.41239079926595934, 0.357584339383878, 0.1804807884018343],\n [0.21263900587151027, 0.715168678767756, 0.07219231536073371],\n [0.01933081871559182, 0.11919477979462598, 0.9505321522496607],\n];\nconst XYZ_TO_SRGB: Mat3 = [\n [3.2409699419045226, -1.537383177570094, -0.4986107602930034],\n [-0.9692436362808796, 1.8759675015077202, 0.04155505740717559],\n [0.05563007969699366, -0.20397695888897652, 1.0569715142428786],\n];\nconst P3_TO_XYZ: Mat3 = [\n [0.4865709486482162, 0.26566769316909306, 0.1982172852343625],\n [0.2289745640697488, 0.6917385218365064, 0.079286914093745],\n [0, 0.04511338185890264, 1.043944368900976],\n];\nconst XYZ_TO_P3: Mat3 = [\n [2.493496911941425, -0.9313836179191239, -0.40271078445071684],\n [-0.8294889695615747, 1.7626640603183463, 0.023624685841943577],\n [0.03584583024378447, -0.07617238926804182, 0.9568845240076872],\n];\n/** Bradford chromatic adaptation between the D65 and D50 white points (Lab and LCH use D50). */\nconst D65_TO_D50: Mat3 = [\n [1.0479297925449969, 0.022946870601609652, -0.05019226628920524],\n [0.02962780877005599, 0.9904344267538799, -0.017073799063418826],\n [-0.009243040646204504, 0.015055191490298152, 0.7518742814281371],\n];\nconst D50_TO_D65: Mat3 = [\n [0.955473421488075, -0.02309845494876471, 0.06325924320057072],\n [-0.0283697093338637, 1.0099953980813041, 0.021041441191917323],\n [0.012314014864481998, -0.020507649298898964, 1.330365926242124],\n];\n/** Linear sRGB to OKLab's cone responses, and back. */\nconst LRGB_TO_LMS: Mat3 = [\n [0.412221469470763, 0.5363325372617348, 0.0514459932675022],\n [0.2119034958178252, 0.6806995506452344, 0.1073969535369406],\n [0.0883024591900564, 0.2817188391361215, 0.6299787016738222],\n];\nconst LMS_TO_LRGB: Mat3 = [\n [4.0767416360759574, -3.3077115392580616, 0.2309699031821044],\n [-1.2684379732850317, 2.6097573492876887, -0.3413193760026573],\n [-0.0041960761386756, -0.7034186179359362, 1.7076146940746117],\n];\nconst LMS_TO_OKLAB: Mat3 = [\n [0.210454268309314, 0.7936177747023054, -0.0040720430116193],\n [1.9779985324311684, -2.4285922420485799, 0.450593709617411],\n [0.0259040424655478, 0.7827717124575296, -0.8086757549230774],\n];\nconst OKLAB_TO_LMS: Mat3 = [\n [1, 0.3963377773761749, 0.2158037573099136],\n [1, -0.1055613458156586, -0.0638541728258133],\n [1, -0.0894841775298119, -1.2914855480194092],\n];\n\nexport const toXyz = (c: Color): Vec3 => mul(SRGB_TO_XYZ, linearRgb(c));\nexport const fromXyz = (xyz: Vec3, alpha: number): Color => fromLinearRgb(mul(XYZ_TO_SRGB, xyz), alpha);\n\n/** Display P3 channels (gamma-encoded, 0 to 1 inside P3). */\nexport const toP3 = (c: Color): Vec3 => mul(XYZ_TO_P3, toXyz(c)).map(fromLinear) as unknown as Vec3;\nexport const fromP3 = (p3: Vec3, alpha: number): Color => fromXyz(mul(P3_TO_XYZ, p3.map(toLinear) as unknown as Vec3), alpha);\nexport const fromXyzD50 = (xyz: Vec3, alpha: number): Color => fromXyz(mul(D50_TO_D65, xyz), alpha);\n\n/** OKLab: L in [0, 1], a and b around ±0.4. */\nexport const toOklab = (c: Color): Vec3 => mul(LMS_TO_OKLAB, mul(LRGB_TO_LMS, linearRgb(c)).map(Math.cbrt) as unknown as Vec3);\nexport const fromOklab = (lab: Vec3, alpha: number): Color =>\n fromLinearRgb(mul(LMS_TO_LRGB, mul(OKLAB_TO_LMS, lab).map((v) => v ** 3) as unknown as Vec3), alpha);\n\nconst D50_WHITE: Vec3 = [0.3457 / 0.3585, 1, (1 - 0.3457 - 0.3585) / 0.3585];\nconst KAPPA = 24389 / 27;\nconst EPSILON = 216 / 24389;\n\n/** CIE Lab (D50): L in [0, 100], a and b around ±125. */\nexport const toLab = (c: Color): Vec3 => {\n const [x, y, z] = mul(D65_TO_D50, toXyz(c)).map((v, i) => v / (D50_WHITE[i] as number)) as unknown as Vec3;\n const f = (v: number) => (v > EPSILON ? Math.cbrt(v) : (KAPPA * v + 16) / 116);\n const [fx, fy, fz] = [f(x), f(y), f(z)];\n return [116 * fy - 16, 500 * (fx - fy), 200 * (fy - fz)];\n};\nexport const fromLab = ([l, a, b]: Vec3, alpha: number): Color => {\n const fy = (l + 16) / 116;\n const fx = a / 500 + fy;\n const fz = fy - b / 200;\n const xyz: Vec3 = [\n fx ** 3 > EPSILON ? fx ** 3 : (116 * fx - 16) / KAPPA,\n l > KAPPA * EPSILON ? fy ** 3 : l / KAPPA,\n fz ** 3 > EPSILON ? fz ** 3 : (116 * fz - 16) / KAPPA,\n ];\n return fromXyzD50(xyz.map((v, i) => v * (D50_WHITE[i] as number)) as unknown as Vec3, alpha);\n};\n\n/** Lab-like to its polar form: lightness, chroma, and hue in degrees from 0 to 360. */\nexport const toPolar = ([l, a, b]: Vec3): Vec3 => [l, Math.hypot(a, b), ((Math.atan2(b, a) * 180) / Math.PI + 360) % 360];\nexport const fromPolar = ([l, c, h]: Vec3): Vec3 => [l, c * Math.cos((h * Math.PI) / 180), c * Math.sin((h * Math.PI) / 180)];\n\n/** Hue, saturation and lightness of a colour inside sRGB (hue 0 for greys), with s and l in [0, 1]. */\nexport function toHsl(c: Color): Vec3 {\n const max = Math.max(c.r, c.g, c.b);\n const min = Math.min(c.r, c.g, c.b);\n const l = (max + min) / 2;\n const d = max - min;\n if (d === 0) return [0, 0, l];\n // Callers pass sRGB colours: with d > 0, l is strictly between 0 and 1.\n const s = (max - l) / Math.min(l, 1 - l);\n let h: number;\n if (max === c.r) h = (c.g - c.b) / d + (c.g < c.b ? 6 : 0);\n else if (max === c.g) h = (c.b - c.r) / d + 2;\n else h = (c.r - c.g) / d + 4;\n return [h * 60, s, l];\n}\n\nexport function fromHsl(h: number, s: number, l: number, alpha: number): Color {\n const hue = ((h % 360) + 360) % 360;\n const f = (n: number) => {\n const k = (n + hue / 30) % 12;\n return l - s * Math.min(l, 1 - l) * Math.max(-1, Math.min(k - 3, 9 - k, 1));\n };\n return color(f(0), f(8), f(4), alpha);\n}\n\nexport function fromHwb(h: number, w: number, b: number, alpha: number): Color {\n if (w + b >= 1) {\n const grey = w / (w + b);\n return color(grey, grey, grey, alpha);\n }\n const pure = fromHsl(h, 1, 0.5, 1);\n const scale = (v: number) => v * (1 - w - b) + w;\n return color(scale(pure.r), scale(pure.g), scale(pure.b), alpha);\n}\n\n/** Hue, whiteness and blackness of an sRGB colour, with w and b in [0, 1]. */\nexport function toHwb(c: Color): Vec3 {\n const [h] = toHsl(c);\n return [h, Math.min(c.r, c.g, c.b), 1 - Math.max(c.r, c.g, c.b)];\n}\n\n/** Distance in OKLab: about 0.02 is the smallest difference people notice. */\nconst deltaEOK = (a: Color, b: Color): number => {\n const [l1, a1, b1] = toOklab(a);\n const [l2, a2, b2] = toOklab(b);\n return Math.hypot(l1 - l2, a1 - a2, b1 - b2);\n};\n\nconst channels = (c: Color, gamut: Gamut): Vec3 => (gamut === 'srgb' ? [c.r, c.g, c.b] : toP3(c));\nconst clip01 = (v: number) => Math.min(1, Math.max(0, v));\nconst clipTo = (c: Color, gamut: Gamut): Color => {\n const [x, y, z] = channels(c, gamut).map(clip01) as unknown as Vec3;\n return gamut === 'srgb' ? color(x, y, z, c.alpha) : fromP3([x, y, z], c.alpha);\n};\n\n/** Whether a colour is inside a gamut, within rounding error. */\nexport function inGamut(c: Color, gamut: Gamut = 'srgb'): boolean {\n return channels(c, gamut).every((v) => v >= -1e-6 && v <= 1 + 1e-6);\n}\n\n/**\n * The colour inside `gamut` that looks closest: the CSS Color 4 gamut mapping\n * algorithm, which keeps lightness and hue and reduces chroma in OKLCH until\n * clipping is no longer visible (`\"map\"`), or plain clipping of each channel (`\"clip\"`).\n */\nexport function toGamut(c: Color, gamut: Gamut = 'srgb', method: 'map' | 'clip' = 'map'): Color {\n if (inGamut(c, gamut)) return clipTo(c, gamut);\n if (method === 'clip') return clipTo(c, gamut);\n const [l, chroma, hue] = toPolar(toOklab(c));\n // Lightness comes back from a round trip through linear RGB, where engines' Math.cbrt\n // and ** differ in the last bits: a lightness of 1 can read as 0.9999999998. The\n // tolerance keeps the result the same on every JavaScript engine.\n if (l >= 1 - 1e-7) return clipTo(color(1, 1, 1, c.alpha), gamut);\n if (l <= 1e-7) return clipTo(color(0, 0, 0, c.alpha), gamut);\n const JND = 0.02;\n let low = 0;\n let high = chroma;\n let lowInGamut = true;\n let current = c;\n let clipped = clipTo(current, gamut);\n if (deltaEOK(clipped, current) < JND) return clipped;\n while (high - low > 0.0001) {\n const mid = (low + high) / 2;\n current = fromOklab(fromPolar([l, mid, hue]), c.alpha);\n if (lowInGamut && inGamut(current, gamut)) {\n low = mid;\n continue;\n }\n clipped = clipTo(current, gamut);\n const e = deltaEOK(clipped, current);\n if (e < JND) {\n if (JND - e < 0.0001) return clipped;\n lowInGamut = false;\n low = mid;\n } else {\n high = mid;\n }\n }\n return clipped;\n}\n","/**\n * The 148 named colours of CSS Color 4, as \"name rrggbb\" pairs. Parsed into a map\n * the first time a name is looked up, so the table costs nothing until then.\n */\nconst NAMED = [\n 'aliceblue f0f8ff antiquewhite faebd7 aqua 00ffff aquamarine 7fffd4 azure f0ffff beige f5f5dc bisque ffe4c4',\n 'black 000000 blanchedalmond ffebcd blue 0000ff blueviolet 8a2be2 brown a52a2a burlywood deb887',\n 'cadetblue 5f9ea0 chartreuse 7fff00 chocolate d2691e coral ff7f50 cornflowerblue 6495ed cornsilk fff8dc',\n 'crimson dc143c cyan 00ffff darkblue 00008b darkcyan 008b8b darkgoldenrod b8860b darkgray a9a9a9',\n 'darkgreen 006400 darkgrey a9a9a9 darkkhaki bdb76b darkmagenta 8b008b darkolivegreen 556b2f darkorange ff8c00',\n 'darkorchid 9932cc darkred 8b0000 darksalmon e9967a darkseagreen 8fbc8f darkslateblue 483d8b',\n 'darkslategray 2f4f4f darkslategrey 2f4f4f darkturquoise 00ced1 darkviolet 9400d3 deeppink ff1493',\n 'deepskyblue 00bfff dimgray 696969 dimgrey 696969 dodgerblue 1e90ff firebrick b22222 floralwhite fffaf0',\n 'forestgreen 228b22 fuchsia ff00ff gainsboro dcdcdc ghostwhite f8f8ff gold ffd700 goldenrod daa520 gray 808080',\n 'green 008000 greenyellow adff2f grey 808080 honeydew f0fff0 hotpink ff69b4 indianred cd5c5c indigo 4b0082',\n 'ivory fffff0 khaki f0e68c lavender e6e6fa lavenderblush fff0f5 lawngreen 7cfc00 lemonchiffon fffacd',\n 'lightblue add8e6 lightcoral f08080 lightcyan e0ffff lightgoldenrodyellow fafad2 lightgray d3d3d3',\n 'lightgreen 90ee90 lightgrey d3d3d3 lightpink ffb6c1 lightsalmon ffa07a lightseagreen 20b2aa',\n 'lightskyblue 87cefa lightslategray 778899 lightslategrey 778899 lightsteelblue b0c4de lightyellow ffffe0',\n 'lime 00ff00 limegreen 32cd32 linen faf0e6 magenta ff00ff maroon 800000 mediumaquamarine 66cdaa',\n 'mediumblue 0000cd mediumorchid ba55d3 mediumpurple 9370db mediumseagreen 3cb371 mediumslateblue 7b68ee',\n 'mediumspringgreen 00fa9a mediumturquoise 48d1cc mediumvioletred c71585 midnightblue 191970 mintcream f5fffa',\n 'mistyrose ffe4e1 moccasin ffe4b5 navajowhite ffdead navy 000080 oldlace fdf5e6 olive 808000 olivedrab 6b8e23',\n 'orange ffa500 orangered ff4500 orchid da70d6 palegoldenrod eee8aa palegreen 98fb98 paleturquoise afeeee',\n 'palevioletred db7093 papayawhip ffefd5 peachpuff ffdab9 peru cd853f pink ffc0cb plum dda0dd powderblue b0e0e6',\n 'purple 800080 rebeccapurple 663399 red ff0000 rosybrown bc8f8f royalblue 4169e1 saddlebrown 8b4513',\n 'salmon fa8072 sandybrown f4a460 seagreen 2e8b57 seashell fff5ee sienna a0522d silver c0c0c0 skyblue 87ceeb',\n 'slateblue 6a5acd slategray 708090 slategrey 708090 snow fffafa springgreen 00ff7f steelblue 4682b4 tan d2b48c',\n 'teal 008080 thistle d8bfd8 tomato ff6347 turquoise 40e0d0 violet ee82ee wheat f5deb3 white ffffff',\n 'whitesmoke f5f5f5 yellow ffff00 yellowgreen 9acd32',\n].join(' ');\n\nlet table: Map<string, number> | undefined;\n\n/** The colour for a CSS colour name (lowercase), as 0xrrggbb, or `undefined`. */\nexport function namedColor(name: string): number | undefined {\n if (table === undefined) {\n table = new Map();\n const parts = NAMED.split(' ');\n for (let i = 0; i < parts.length; i += 2) table.set(parts[i] as string, parseInt(parts[i + 1] as string, 16));\n }\n return table.get(name);\n}\n","import { color, fromHsl, fromHwb, fromLab, fromLinearRgb, fromOklab, fromP3, fromPolar, fromXyz, fromXyzD50, type Color, type Vec3 } from './convert';\nimport { namedColor } from './names';\n\n/** Longer input is not a colour: parsing stays cheap whatever is pasted. */\nconst MAX_LENGTH = 256;\n\nconst NUMBER = /^[+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:e[+-]?\\d+)?$/;\nconst HEX = /^#([\\da-f]{3,4}|[\\da-f]{6}|[\\da-f]{8})$/;\nconst FUNCTION = /^([a-z][a-z\\d-]*)\\(([^()]*)\\)$/;\n\ntype Kind = 'number' | 'percent' | 'angle';\ninterface Token {\n readonly kind: Kind | 'none';\n readonly value: number;\n}\n\nconst ANGLE_UNITS: Readonly<Record<string, number>> = { deg: 1, grad: 0.9, rad: 180 / Math.PI, turn: 360 };\n\n/** One component: a number, a percentage, an angle (in degrees) or `none`. */\nfunction token(text: string): Token | null {\n if (text === 'none') return { kind: 'none', value: 0 };\n if (text.endsWith('%')) {\n const body = text.slice(0, -1);\n return NUMBER.test(body) ? { kind: 'percent', value: Number(body) } : null;\n }\n const unit = /[a-z]+$/.exec(text)?.[0];\n if (unit !== undefined) {\n const factor = ANGLE_UNITS[unit];\n const body = text.slice(0, -unit.length);\n // `e` alone is an exponent, never a unit.\n return factor === undefined || !NUMBER.test(body) ? null : { kind: 'angle', value: Number(body) * factor };\n }\n return NUMBER.test(text) ? { kind: 'number', value: Number(text) } : null;\n}\n\nconst clamp = (v: number, min: number, max: number) => Math.min(max, Math.max(min, v));\n\n/** A component's value: numbers as they are, percentages scaled so 100% is `full`. */\nfunction amount(t: Token, full: number, allowed: readonly Kind[]): number | null {\n if (t.kind === 'none') return 0;\n if (!allowed.includes(t.kind)) return null;\n return t.kind === 'percent' ? (t.value / 100) * full : t.value;\n}\n\nconst hueOf = (t: Token): number | null => amount(t, 0, ['number', 'angle']);\nconst alphaOf = (t: Token | undefined): number | null => {\n if (t === undefined) return 1;\n const value = amount(t, 1, ['number', 'percent']);\n return value === null ? null : clamp(value, 0, 1);\n};\n\n/** Splits arguments into three components and an optional alpha; `legacy` for the comma syntax. */\nfunction split(args: string): { readonly parts: Token[]; readonly alpha: Token | undefined; readonly legacy: boolean } | null {\n const legacy = args.includes(',');\n let main: string[];\n let alphaText: string | undefined;\n if (legacy) {\n const list = args.split(',').map((part) => part.trim());\n if (list.length < 3 || list.length > 4) return null;\n main = list.slice(0, 3);\n alphaText = list[3];\n } else {\n const [body, rest, extra] = args.split('/');\n if (extra !== undefined) return null;\n main = (body as string).trim().split(/\\s+/);\n alphaText = rest?.trim();\n if (main.length !== 3 || alphaText === '') return null;\n }\n const parts = main.map(token);\n if (parts.some((part) => part === null)) return null;\n const alpha = alphaText === undefined ? undefined : token(alphaText);\n if (alpha === null) return null;\n // The comma syntax predates `none`.\n if (legacy && [...parts, alpha].some((part) => part?.kind === 'none')) return null;\n return { parts: parts as Token[], alpha, legacy };\n}\n\nfunction rgb(parts: readonly Token[], legacy: boolean): Vec3 | null {\n // The comma syntax takes numbers or percentages, not a mix.\n if (legacy && new Set(parts.map((part) => part.kind)).size !== 1) return null;\n const values = parts.map((part) => amount(part, 255, ['number', 'percent']));\n return values.some((v) => v === null) ? null : (values.map((v) => clamp(v as number, 0, 255) / 255) as unknown as Vec3);\n}\n\nconst PREDEFINED: Readonly<Record<string, (v: Vec3, alpha: number) => Color>> = {\n srgb: ([r, g, b], alpha) => color(r, g, b, alpha),\n 'srgb-linear': fromLinearRgb,\n 'display-p3': fromP3,\n xyz: fromXyz,\n 'xyz-d65': fromXyz,\n 'xyz-d50': fromXyzD50,\n};\n\n/** `color(space c1 c2 c3 / alpha)`. */\nfunction predefined(args: string): Color | null {\n const match = /^([a-z\\d-]+)\\s+(.*)$/.exec(args.trim());\n if (match === null) return null;\n const convert = PREDEFINED[match[1] as string];\n const parsed = split(match[2] as string);\n if (convert === undefined || parsed === null || parsed.legacy) return null;\n const values = parsed.parts.map((part) => amount(part, 1, ['number', 'percent']));\n const alpha = alphaOf(parsed.alpha);\n return values.some((v) => v === null) || alpha === null ? null : convert(values as unknown as Vec3, alpha);\n}\n\nfunction functional(name: string, args: string): Color | null {\n if (name === 'color') return predefined(args);\n const parsed = split(args);\n if (parsed === null) return null;\n const { parts, legacy } = parsed;\n const [a, b, c] = parts as [Token, Token, Token];\n const alpha = alphaOf(parsed.alpha);\n if (alpha === null) return null;\n switch (name) {\n case 'rgb':\n case 'rgba': {\n const values = rgb(parts, legacy);\n return values === null ? null : color(values[0], values[1], values[2], alpha);\n }\n case 'hsl':\n case 'hsla': {\n const hue = hueOf(a);\n // The comma syntax requires percentages for saturation and lightness.\n const kinds: readonly Kind[] = legacy ? ['percent'] : ['number', 'percent'];\n const s = amount(b, 100, kinds);\n const l = amount(c, 100, kinds);\n if (hue === null || s === null || l === null) return null;\n return fromHsl(hue, clamp(s, 0, 100) / 100, clamp(l, 0, 100) / 100, alpha);\n }\n case 'hwb': {\n const hue = hueOf(a);\n const w = amount(b, 100, ['number', 'percent']);\n const k = amount(c, 100, ['number', 'percent']);\n if (legacy || hue === null || w === null || k === null) return null;\n return fromHwb(hue, clamp(w, 0, 100) / 100, clamp(k, 0, 100) / 100, alpha);\n }\n default:\n return legacy ? null : lab(name, a, b, c, alpha);\n }\n}\n\n/** lab(), lch(), oklab() and oklch(). */\nfunction lab(name: string, a: Token, b: Token, c: Token, alpha: number): Color | null {\n const ok = name.startsWith('ok');\n const polar = name.endsWith('ch');\n if (!['lab', 'lch', 'oklab', 'oklch'].includes(name)) return null;\n const lightMax = ok ? 1 : 100;\n const l = amount(a, lightMax, ['number', 'percent']);\n // 100% is 0.4 in OKLab and OKLCH, 125 for Lab's a and b, 150 for LCH's chroma.\n const second = amount(b, ok ? 0.4 : polar ? 150 : 125, ['number', 'percent']);\n const third = polar ? hueOf(c) : amount(c, ok ? 0.4 : 125, ['number', 'percent']);\n if (l === null || second === null || third === null) return null;\n const lightness = clamp(l, 0, lightMax);\n const values: Vec3 = polar ? fromPolar([lightness, Math.max(0, second), third]) : [lightness, second, third];\n return ok ? fromOklab(values, alpha) : fromLab(values, alpha);\n}\n\n/**\n * Parses a CSS colour, or returns `null`: hex (`#rgb`, `#rgba`, `#rrggbb`,\n * `#rrggbbaa`), the 148 named colours and `transparent`, `rgb()` and `hsl()` in\n * both syntaxes, `hwb()`, `lab()`, `lch()`, `oklab()`, `oklch()`, and `color()`\n * in `srgb`, `srgb-linear`, `display-p3`, `xyz`, `xyz-d65` and `xyz-d50`.\n * Never throws. Colours outside sRGB keep their exact value.\n *\n * Not colours on their own: `currentcolor`, system colours, `var()`, `calc()`,\n * `color-mix()` and relative colours.\n *\n * @example\n * parseColor('oklch(62.8% 0.258 29.23)'); // { r: 1, g: 0, b: 0, alpha: 1 } (rounded)\n */\nexport function parseColor(input: string): Color | null {\n if (typeof input !== 'string' || input.length > MAX_LENGTH) return null;\n const text = input.trim().toLowerCase();\n const hex = HEX.exec(text)?.[1];\n if (hex !== undefined) {\n const full = hex.length <= 4 ? hex.replace(/./g, (digit) => digit + digit) : hex;\n const byte = (i: number) => parseInt(full.slice(i, i + 2), 16) / 255;\n return color(byte(0), byte(2), byte(4), full.length === 8 ? byte(6) : 1);\n }\n if (text === 'transparent') return color(0, 0, 0, 0);\n const named = namedColor(text);\n if (named !== undefined) return color(((named >> 16) & 255) / 255, ((named >> 8) & 255) / 255, (named & 255) / 255);\n const match = FUNCTION.exec(text);\n return match === null ? null : functional(match[1] as string, (match[2] as string).trim());\n}\n","import { copyFailure } from '../core/errors';\nimport { toGamut, toHsl, toHwb, toLab, toOklab, toP3, toPolar, type Color } from './convert';\nimport { parseColor } from './parse';\n\n/**\n * How to write a colour:\n * - `hex`: `#ff0000`, `#ff000080` with alpha\n * - `rgb`, `hsl`, `hwb`: `rgb(255 0 0)`, `hsl(0 100% 50%)`, `hwb(0 0% 0%)`\n * - `oklch`, `oklab`: `oklch(62.8% 0.2577 29.23)`, `oklab(62.8% 0.2249 0.1258)`\n * - `lab`, `lch`: `lab(54.29 80.8 69.89)`, `lch(54.29 106.84 40.85)`\n * - `p3`: `color(display-p3 0.9176 0.2003 0.1386)`\n */\nexport type ColorFormat = 'hex' | 'rgb' | 'hsl' | 'hwb' | 'oklch' | 'oklab' | 'lab' | 'lch' | 'p3';\n\nexport const COLOR_FORMATS: readonly ColorFormat[] = /* @__PURE__ */ Object.freeze(['hex', 'rgb', 'hsl', 'hwb', 'oklch', 'oklab', 'lab', 'lch', 'p3']);\n\nexport interface FormatColorOptions {\n /**\n * For colours outside the format's gamut (sRGB for `hex`, `rgb`, `hsl` and `hwb`;\n * Display P3 for `p3`): `\"map\"` (default) finds the closest colour that looks the\n * same, as CSS Color 4 specifies; `\"clip\"` clips each channel, as most browsers draw.\n * `oklch`, `oklab`, `lab` and `lch` hold every colour exactly.\n */\n readonly gamut?: 'map' | 'clip';\n /** The comma syntax for `rgb` and `hsl` (`rgba(255, 0, 0, 0.5)`), for older tools. Default `false`. */\n readonly legacy?: boolean;\n /** Uppercase hex digits (`#FF0000`). Default `false`. */\n readonly uppercase?: boolean;\n /**\n * Decimal places for every non-integer component. Default: per format, the fewest\n * that bring every 8-bit colour back exactly (checked on 836,056 colours).\n */\n readonly precision?: number;\n}\n\n/** A colour, or text to parse as one: throws a typed `invalid-payload` error for text that is not a colour. */\nexport type ColorInput = Color | string;\n\nconst isColor = (value: unknown): value is Color =>\n typeof value === 'object' &&\n value !== null &&\n ['r', 'g', 'b', 'alpha'].every((key) => Number.isFinite((value as Record<string, unknown>)[key]));\n\n/** Resolves a colour input, throwing a typed error for anything that is not one. */\nexport function toColor(input: ColorInput): Color {\n if (typeof input === 'string') {\n const parsed = parseColor(input);\n if (parsed === null) throw copyFailure('invalid-payload', `Not a colour: ${JSON.stringify(input.slice(0, 100))}.`);\n return parsed;\n }\n if (!isColor(input)) throw copyFailure('invalid-payload', 'A colour must be a CSS colour string or an { r, g, b, alpha } object with finite numbers.');\n return input;\n}\n\n/** Rounds to `places` decimals, without trailing zeros or `-0`. */\nfunction num(value: number, places: number): string {\n const factor = 10 ** places;\n const rounded = Math.round(value * factor) / factor;\n return String(Object.is(rounded, -0) ? 0 : rounded);\n}\n\n/** A hue in degrees, with 360 written as 0. */\nconst hue = (value: number, places: number): string => {\n const text = num(value, places);\n return text === '360' ? '0' : text;\n};\n\nconst byte = (v: number) => Math.round(Math.min(1, Math.max(0, v)) * 255);\n\n/** The alpha suffix of a functional notation: nothing when opaque. */\nconst alphaPart = (alpha: number, legacy: boolean, places: number): string =>\n alpha >= 1 ? '' : legacy ? `, ${num(alpha, places)}` : ` / ${num(alpha, places)}`;\n\n/**\n * Writes a colour in a CSS format. Text is parsed first, so this also converts\n * between formats.\n *\n * @example\n * formatColor('rgb(255 0 0)', 'oklch'); // 'oklch(62.8% 0.2577 29.23)'\n * formatColor('color(display-p3 1 0 0)', 'hex'); // '#ff0000' after gamut mapping, never a wrong hue\n */\nexport function formatColor(input: ColorInput, format: ColorFormat = 'hex', options: FormatColorOptions = {}): string {\n const c = toColor(input);\n const { gamut = 'map', legacy = false, uppercase = false, precision } = options;\n const method: unknown = gamut; // Plain-JS callers can pass anything.\n if (method !== 'map' && method !== 'clip') throw copyFailure('invalid-payload', '`gamut` must be \"map\" or \"clip\".');\n if (precision !== undefined && !(Number.isInteger(precision) && precision >= 0 && precision <= 10)) {\n throw copyFailure('invalid-payload', '`precision` must be an integer from 0 to 10.');\n }\n const dp = (fallback: number) => precision ?? fallback;\n const a = c.alpha;\n switch (format) {\n case 'hex': {\n const s = toGamut(c, 'srgb', gamut);\n const digits = [s.r, s.g, s.b, ...(a < 1 ? [a] : [])].map((v) => byte(v).toString(16).padStart(2, '0')).join('');\n return `#${uppercase ? digits.toUpperCase() : digits}`;\n }\n case 'rgb': {\n const s = toGamut(c, 'srgb', gamut);\n const [r, g, b] = [s.r, s.g, s.b].map(byte);\n return legacy ? `${a < 1 ? 'rgba' : 'rgb'}(${String(r)}, ${String(g)}, ${String(b)}${alphaPart(a, true, dp(3))})` : `rgb(${String(r)} ${String(g)} ${String(b)}${alphaPart(a, false, dp(3))})`;\n }\n case 'hsl': {\n const [h, s, l] = toHsl(toGamut(c, 'srgb', gamut));\n const [hh, ss, ll] = [hue(h, dp(2)), `${num(s * 100, dp(2))}%`, `${num(l * 100, dp(2))}%`];\n return legacy ? `${a < 1 ? 'hsla' : 'hsl'}(${hh}, ${ss}, ${ll}${alphaPart(a, true, dp(3))})` : `hsl(${hh} ${ss} ${ll}${alphaPart(a, false, dp(3))})`;\n }\n case 'hwb': {\n const [h, w, b] = toHwb(toGamut(c, 'srgb', gamut));\n return `hwb(${hue(h, dp(2))} ${num(w * 100, dp(2))}% ${num(b * 100, dp(2))}%${alphaPart(a, false, dp(3))})`;\n }\n case 'oklab': {\n const [l, x, y] = toOklab(c);\n return `oklab(${num(l * 100, dp(2))}% ${num(x, dp(5))} ${num(y, dp(5))}${alphaPart(a, false, dp(3))})`;\n }\n case 'oklch': {\n // The hue is written whenever the written chroma isn't 0; with chroma 0 it means nothing.\n const [l, ch, h] = toPolar(toOklab(c));\n const chroma = num(ch, dp(5));\n return `oklch(${num(l * 100, dp(2))}% ${chroma} ${chroma === '0' ? '0' : hue(h, dp(2))}${alphaPart(a, false, dp(3))})`;\n }\n case 'lab': {\n const [l, x, y] = toLab(c);\n return `lab(${num(l, dp(2))} ${num(x, dp(2))} ${num(y, dp(2))}${alphaPart(a, false, dp(3))})`;\n }\n case 'lch': {\n const [l, ch, h] = toPolar(toLab(c));\n const chroma = num(ch, dp(2));\n return `lch(${num(l, dp(2))} ${chroma} ${chroma === '0' ? '0' : hue(h, dp(2))}${alphaPart(a, false, dp(3))})`;\n }\n case 'p3': {\n const [r, g, b] = toP3(toGamut(c, 'p3', gamut));\n return `color(display-p3 ${num(r, dp(4))} ${num(g, dp(4))} ${num(b, dp(4))}${alphaPart(a, false, dp(3))})`;\n }\n default:\n throw copyFailure('invalid-payload', `Unknown colour format ${JSON.stringify(String(format))}: use one of ${COLOR_FORMATS.join(', ')}.`);\n }\n}\n","import { copyFailure } from '../core/errors';\nimport { color, toGamut, type Color } from './convert';\nimport { toColor, type ColorInput } from './format';\n\nconst WHITE = /* @__PURE__ */ color(1, 1, 1);\n\n/** `top` drawn over `bottom`, both made opaque first. */\nfunction over(top: Color, bottom: Color): Color {\n const mix = (a: number, b: number) => a * top.alpha + b * (1 - top.alpha);\n return color(mix(top.r, bottom.r), mix(top.g, bottom.g), mix(top.b, bottom.b));\n}\n\n/** WCAG 2 relative luminance of an opaque sRGB colour. */\nfunction luminance(c: Color): number {\n const lin = (v: number) => (v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4);\n return 0.2126 * lin(c.r) + 0.7152 * lin(c.g) + 0.0722 * lin(c.b);\n}\n\n/**\n * The WCAG 2 contrast ratio of text over a background, from 1 to 21. Colours are\n * mapped into sRGB, a translucent background is drawn over white, and translucent\n * text over the background, as a browser would show them. Never rounded: 4.499 is\n * not 4.5.\n *\n * @example\n * contrastRatio('#767676', '#fff'); // 4.54\n */\nexport function contrastRatio(text: ColorInput, background: ColorInput): number {\n const bg = over(toGamut(toColor(background)), WHITE);\n const fg = over(toGamut(toColor(text)), bg);\n const [light, dark] = [luminance(fg), luminance(bg)].sort((a, b) => b - a) as [number, number];\n return (light + 0.05) / (dark + 0.05);\n}\n\n/** The WCAG 2 level a contrast ratio meets: `AAA`, `AA`, or `fail`. */\nexport type ContrastLevel = 'AAA' | 'AA' | 'fail';\n\nexport interface ContrastLevelOptions {\n /** Large text: at least 24px, or 18.66px bold. Its thresholds are 3 (AA) and 4.5 (AAA) instead of 4.5 and 7. */\n readonly large?: boolean;\n}\n\n/** The WCAG 2 level met by a contrast ratio (`contrastRatio`), for normal or large text. */\nexport function contrastLevel(ratio: number, options: ContrastLevelOptions = {}): ContrastLevel {\n if (!Number.isFinite(ratio) || ratio < 1) throw copyFailure('invalid-payload', 'A contrast ratio is a number from 1 to 21.');\n const [aa, aaa] = options.large === true ? [3, 4.5] : [4.5, 7];\n if (ratio >= aaa) return 'AAA';\n return ratio >= aa ? 'AA' : 'fail';\n}\n","import { contrastRatio } from '../color/contrast';\nimport { color as rgb, toGamut, type Color } from '../color/convert';\nimport { formatColor } from '../color/format';\nimport { parseColor } from '../color/parse';\n\n/** Where styles come from: `getComputedStyle` for a live element, the `style` attribute otherwise. */\nexport interface StyleSource {\n getPropertyValue(name: string): string;\n}\n\n/**\n * How colours are copied:\n * - `readable` (default): every colour, made opaque, except text that would be hard to\n * read where it lands (contrast under 3:1 on its background, or on white), such as\n * light text from a dark theme\n * - `keep`: every colour, made opaque\n * - `none`: no colours: the destination's own text colour and background\n */\nexport type RichColors = 'readable' | 'keep' | 'none';\n\nexport const INHERITED = ['color', 'font-family', 'font-size', 'font-style', 'font-weight', 'text-align', 'white-space', 'text-transform', 'list-style-type', 'border-collapse'] as const;\nconst SIDES = ['top', 'right', 'bottom', 'left'] as const;\nconst OWN = [\n 'background-color',\n 'text-decoration-line',\n 'vertical-align',\n 'border-top-width', 'border-top-style', 'border-top-color', 'padding-top',\n 'border-right-width', 'border-right-style', 'border-right-color', 'padding-right',\n 'border-bottom-width', 'border-bottom-style', 'border-bottom-color', 'padding-bottom',\n 'border-left-width', 'border-left-style', 'border-left-color', 'padding-left',\n] as const;\nexport const PROPERTIES = [...INHERITED, ...OWN] as const;\nexport type Property = (typeof PROPERTIES)[number];\nconst INHERITED_SET: ReadonlySet<Property> = /* @__PURE__ */ new Set<Property>(INHERITED);\n\n/**\n * What an element gets from its parent: the inherited values, with its own declared\n * ones on top. Lists set their own marker, as browsers' default styles do, so a list\n * doesn't inherit its parent list's marker.\n */\nexport function inherit(parent: Values, own?: Values, tag = ''): Values {\n const merged = {} as Record<Property, string>;\n for (const name of PROPERTIES) {\n const value = own === undefined ? '' : own[name];\n const inherits = INHERITED_SET.has(name) && !(name === 'list-style-type' && (tag === 'ul' || tag === 'ol'));\n merged[name] = value !== '' ? value : inherits ? parent[name] : '';\n }\n return merged;\n}\n\n/** Raw values of every property above, as the source reports them (`''` when unset), and the display type. */\nexport type Values = Readonly<Record<Property, string>> & { readonly display?: string };\n\nexport function readValues(source: StyleSource): Values {\n const values = {} as Record<Property, string>;\n for (const name of PROPERTIES) values[name] = source.getPropertyValue(name).trim().toLowerCase();\n return values;\n}\n\n/** Inherited values every rendering starts from: an empty parent for the root. */\nexport const ROOT_PARENT: Values = /* @__PURE__ */ Object.freeze({\n ...(Object.fromEntries(PROPERTIES.map((name) => [name, ''])) as Record<Property, string>),\n 'font-style': 'normal',\n 'font-weight': '400',\n 'text-align': 'start',\n 'white-space': 'normal',\n 'text-transform': 'none',\n 'border-collapse': 'separate',\n});\n\nconst KEYWORDS: Readonly<Record<string, RegExp>> = {\n 'font-style': /^(?:normal|italic|oblique)$/,\n 'text-align': /^(?:left|right|center|justify)$/,\n 'white-space': /^(?:normal|pre|pre-wrap|pre-line|nowrap|break-spaces)$/,\n 'text-transform': /^(?:none|uppercase|lowercase|capitalize)$/,\n 'list-style-type': /^(?:none|disc|circle|square|decimal|decimal-leading-zero|lower-alpha|upper-alpha|lower-latin|upper-latin|lower-roman|upper-roman|lower-greek)$/,\n 'border-collapse': /^(?:collapse|separate)$/,\n 'vertical-align': /^(?:top|bottom)$/,\n};\nconst LENGTH = /^(?:0|\\d{1,4}(?:\\.\\d+)?(?:px|pt|em|%))$/;\nconst FONT_FAMILY = /^[\\w\\s,'\"-]{1,200}$/;\n\n/** Elements whose default style already shows a value: writing it again adds nothing. */\nconst TAG_DEFAULTS: Readonly<Record<string, Readonly<Partial<Record<Property, string>>>>> = {\n b: { 'font-weight': '700' },\n strong: { 'font-weight': '700' },\n th: { 'font-weight': '700', 'text-align': 'center' },\n h1: { 'font-weight': '700' },\n h2: { 'font-weight': '700' },\n h3: { 'font-weight': '700' },\n h4: { 'font-weight': '700' },\n h5: { 'font-weight': '700' },\n h6: { 'font-weight': '700' },\n em: { 'font-style': 'italic' },\n i: { 'font-style': 'italic' },\n cite: { 'font-style': 'italic' },\n dfn: { 'font-style': 'italic' },\n var: { 'font-style': 'italic' },\n pre: { 'white-space': 'pre' },\n ol: { 'list-style-type': 'decimal' },\n ul: { 'list-style-type': 'disc' },\n li: { 'list-style-type': '' },\n a: { 'text-decoration-line': 'underline' },\n u: { 'text-decoration-line': 'underline' },\n ins: { 'text-decoration-line': 'underline' },\n s: { 'text-decoration-line': 'line-through' },\n del: { 'text-decoration-line': 'line-through' },\n};\n\nconst weight = (value: string): string => (value === 'bold' ? '700' : value === 'normal' ? '400' : /^[1-9]00$/.test(value) ? value : '');\n/** `start` and `end` as the left and right they mean in left-to-right text. */\nconst align = (value: string): string => {\n if (value === 'start') return 'left';\n if (value === 'end') return 'right';\n // Engines' internal names for the default centring of table headers.\n return value === '-webkit-center' || value === '-internal-center' || value === '-moz-center' ? 'center' : value;\n};\n\n/** A colour as an opaque hex value, drawn over `under`; `null` for none or invisible. */\nfunction opaque(value: string, under: Color): Color | null {\n const c = parseColor(value);\n if (c === null || c.alpha === 0) return null;\n const mapped = toGamut(c);\n const mix = (top: number, bottom: number) => top * c.alpha + bottom * (1 - c.alpha);\n return rgb(mix(mapped.r, under.r), mix(mapped.g, under.g), mix(mapped.b, under.b));\n}\n\nexport const WHITE: Color = /* @__PURE__ */ rgb(1, 1, 1);\n\n/** Pixel lengths rounded to 2 decimals; other units kept as written. */\nfunction length(value: string): string | null {\n if (!LENGTH.test(value)) return null;\n return value.endsWith('px') ? `${String(Math.round(parseFloat(value) * 100) / 100)}px` : value;\n}\n\nexport interface StyleResult {\n /** The `style` attribute to write, or `''`. */\n readonly css: string;\n /** The background the element's content is drawn on, for its children's contrast checks. */\n readonly background: Color;\n /** Whether a text colour was left out to stay readable. */\n readonly droppedColor: boolean;\n}\n\n/**\n * The declarations to write for an element: inherited properties where they differ\n * from the parent (all of them at the root), and the element's own box and decoration.\n */\nexport function declarations(tag: string, values: Values, parent: Values, background: Color, colors: RichColors): StyleResult {\n const out: string[] = [];\n const defaults = TAG_DEFAULTS[tag] ?? {};\n const changed = (name: Property, value: string) => value !== '' && value !== parent[name] && value !== defaults[name];\n let droppedColor = false;\n let own = background;\n\n // Background first: the text colour's contrast is checked against it.\n if (colors !== 'none') {\n const bg = opaque(values['background-color'], background);\n if (bg !== null) {\n own = bg;\n out.push(`background-color:${formatColor(bg)}`);\n }\n }\n const family = values['font-family'];\n if (changed('font-family', family) && FONT_FAMILY.test(family)) out.push(`font-family:${family}`);\n const size = length(values['font-size']);\n if (size !== null && changed('font-size', values['font-size'])) out.push(`font-size:${size}`);\n const fontWeight = weight(values['font-weight']);\n if (fontWeight !== weight(parent['font-weight']) && changed('font-weight', fontWeight)) out.push(`font-weight:${fontWeight}`);\n for (const name of ['font-style', 'white-space', 'text-transform', 'border-collapse'] as const) {\n const value = values[name];\n if (changed(name, value) && (KEYWORDS[name] as RegExp).test(value)) out.push(`${name}:${value}`);\n }\n const textAlign = align(values['text-align']);\n if (textAlign !== align(parent['text-align']) && textAlign !== defaults['text-align'] && (KEYWORDS['text-align'] as RegExp).test(textAlign)) {\n out.push(`text-align:${textAlign}`);\n }\n if (tag === 'ul' || tag === 'ol') {\n const list = values['list-style-type'];\n if (list !== defaults['list-style-type'] && list !== 'circle' && list !== 'square' && (KEYWORDS['list-style-type'] as RegExp).test(list)) out.push(`list-style-type:${list}`);\n }\n if (colors !== 'none' && changed('color', values['color'])) {\n const text = opaque(values['color'], own);\n if (text !== null) {\n if (colors === 'readable' && contrastRatio(text, own) < 3) droppedColor = true;\n else out.push(`color:${formatColor(text)}`);\n }\n }\n const decoration = values['text-decoration-line'];\n if (decoration !== '' && decoration !== defaults['text-decoration-line'] && /^(?:none|(?:underline|overline|line-through)(?: (?:underline|overline|line-through))*)$/.test(decoration)) {\n // Links are underlined by default in mail: a link drawn without one says so.\n if (decoration !== 'none' || tag === 'a') out.push(`text-decoration:${decoration}`);\n }\n const vertical = values['vertical-align'];\n if ((tag === 'td' || tag === 'th') && (KEYWORDS['vertical-align'] as RegExp).test(vertical)) out.push(`vertical-align:${vertical}`);\n out.push(...box(values, own, colors));\n return { css: out.join(';'), background: own, droppedColor };\n}\n\n/** Borders and padding, as shorthands where every side is the same. */\nfunction box(values: Values, background: Color, colors: RichColors): string[] {\n const borders = SIDES.map((side) => {\n const width = length(values[`border-${side}-width`]);\n const style = values[`border-${side}-style`];\n if (width === null || width === '0' || width === '0px' || !/^(?:solid|dashed|dotted|double)$/.test(style)) return null;\n const lineColor = colors === 'none' ? null : opaque(values[`border-${side}-color`], background);\n return `${width} ${style}${lineColor === null ? '' : ` ${formatColor(lineColor)}`}`;\n });\n const out: string[] = [];\n if (borders.every((border) => border !== null && border === borders[0])) out.push(`border:${borders[0] as string}`);\n else borders.forEach((border, index) => {\n if (border !== null) out.push(`border-${SIDES[index] as string}:${border}`);\n });\n const padding = SIDES.map((side) => length(values[`padding-${side}`]) ?? '0');\n if (padding.some((value) => value !== '0' && value !== '0px')) {\n out.push(`padding:${padding.map((value) => (value === '0px' ? '0' : value)).join(' ')}`);\n }\n return out;\n}\n","import { TEXT_BLOCKS } from './policy';\n\n/**\n * Readable plain text for sanitized rich content: blocks on their own lines, list\n * items with bullets or numbers (indented when nested), table cells separated by tabs,\n * images by their alt text, and preformatted text as it is.\n */\nexport function plainText(root: HTMLElement): string {\n const lines: string[] = [];\n let line = '';\n const flush = () => {\n const trimmed = line.replace(/[ \\t\\u00A0]+$/, '');\n if (trimmed !== '' || (lines.length > 0 && lines[lines.length - 1] !== '')) lines.push(trimmed);\n line = '';\n };\n const breakBlock = () => {\n if (line.trim() !== '') flush();\n else line = '';\n };\n\n const walk = (node: Node, pre: boolean, depth: number): void => {\n if (node.nodeType === 3) {\n const data = (node as Text).data;\n if (pre) line += data.replace(/\\r\\n?/g, '\\n');\n else {\n // Whitespace collapses across text nodes too, as it does when a browser renders it.\n const collapsed = data.replace(/\\s+/g, ' ');\n // A space at the start of a line or a cell shows nothing.\n line += /(?:^|[ \\t])$/.test(line) && collapsed.startsWith(' ') ? collapsed.slice(1) : collapsed;\n }\n if (pre && line.includes('\\n')) {\n const parts = line.split('\\n');\n line = parts.pop() as string;\n for (const part of parts) lines.push(part);\n }\n if (!pre && line.trimStart() === '') line = '';\n return;\n }\n if (node.nodeType !== 1) return;\n const element = node as HTMLElement;\n const tag = element.localName;\n switch (tag) {\n case 'br':\n flush();\n return;\n case 'img':\n line += element.getAttribute('alt') ?? '';\n return;\n case 'hr':\n breakBlock();\n lines.push('\\u2014'.repeat(3));\n return;\n case 'td':\n case 'th':\n if (element.previousElementSibling !== null) line += '\\t';\n element.childNodes.forEach((child) => {\n walk(child, pre, depth);\n });\n return;\n case 'li': {\n breakBlock();\n const list = element.parentElement;\n const ordered = list?.localName === 'ol';\n let marker = '\\u2022';\n if (ordered) {\n const items = Array.from(list.children).filter((child) => child.localName === 'li');\n const start = Number(list.getAttribute('start') ?? '1');\n const own = element.getAttribute('value');\n marker = `${String(own === null ? start + items.indexOf(element) : Number(own))}.`;\n }\n line = `${' '.repeat(Math.max(0, depth - 1))}${marker} `;\n element.childNodes.forEach((child) => {\n walk(child, pre, depth);\n });\n breakBlock();\n return;\n }\n default: {\n const block = TEXT_BLOCKS.has(tag);\n const list = tag === 'ul' || tag === 'ol';\n if (block) breakBlock();\n const keep = pre || tag === 'pre' || /white-space:\\s*pre/.test(element.getAttribute('style') ?? '');\n element.childNodes.forEach((child) => {\n walk(child, keep, list ? depth + 1 : depth);\n });\n if (block) breakBlock();\n }\n }\n };\n walk(root, false, 0);\n flush();\n return lines\n .join('\\n')\n .replace(/\\n{3,}/g, '\\n\\n')\n .trim();\n}\n","import type { Color } from '../color/convert';\nimport { copyFailure } from '../core/errors';\nimport { linkUrlResolver, type LinkUrlOptions } from '../link/url';\nimport { AS_BLOCK, attributeAllowed, closesItem, CLOSES_P, DROP, HEADINGS, KEEP, PHRASING, TABLE_CHILDREN, TABLE_PARTS } from './policy';\nimport { parseColor } from '../color/parse';\nimport { declarations, inherit, readValues, ROOT_PARENT, WHITE, type RichColors, type StyleSource, type Values } from './style';\nimport { plainText } from './text';\n\nexport interface RichOptions extends Pick<LinkUrlOptions, 'protocols'> {\n /** Resolves relative links and images. Default: the source document's address. */\n readonly base?: string | URL;\n /** Default `\"readable\"`. See {@link RichColors}. */\n readonly colors?: RichColors;\n /**\n * Images: `\"keep\"` (default) with absolute `https:` and `http:` addresses and their\n * displayed size; `\"alt\"` writes their alt text instead; `\"drop\"` leaves them out.\n */\n readonly images?: 'keep' | 'alt' | 'drop';\n /** Also keep `data:` images (PNG, JPEG, GIF, WebP, up to 2 MB each). Many mail clients block them. Default `false`. */\n readonly dataImages?: boolean;\n /**\n * Where styles come from: `\"computed\"` (default for elements and selections on the\n * page: what the reader sees), `\"inline\"` (only `style` attributes: the default for\n * HTML strings and detached nodes), or `\"none\"`.\n */\n readonly styles?: 'computed' | 'inline' | 'none';\n /** More elements to leave out, as a CSS selector. `[data-copy-ignore]`, `[hidden]` and `[aria-hidden=\"true\"]` always are. */\n readonly ignore?: string;\n /** The background the content is pasted on, for readability checks. Default `\"#ffffff\"`. */\n readonly background?: string;\n /** Most elements written; the rest is left out and `truncated` is set. Default 10,000. */\n readonly maxElements?: number;\n /** Most characters of HTML written, roughly. Default 1,000,000. */\n readonly maxLength?: number;\n /** The plain-text version. Default: readable text with lists, tables and line breaks. Pass `htmlToMarkdown` for Markdown. */\n readonly text?: (root: HTMLElement) => string;\n /** Reads an element's computed style. Default `getComputedStyle`; set it for DOMs that lack one. */\n readonly computedStyle?: (element: Element) => StyleSource | null;\n}\n\n/**\n * Why something was left out: `unsafe-element` (scripts, embeds, forms, SVG, media),\n * `hidden`, `ignored`, `unsafe-link`, `unsafe-image`, `image` (by the `images` option),\n * `unreadable-color` (by `colors: \"readable\"`), or `misplaced` (content a table can't\n * hold where it is, which every HTML parser would move out of the table).\n */\nexport type RichRemovalReason = 'unsafe-element' | 'hidden' | 'ignored' | 'unsafe-link' | 'unsafe-image' | 'image' | 'unreadable-color' | 'misplaced';\n\nexport interface RichRemoval {\n readonly reason: RichRemovalReason;\n /** The element name, or the URL scheme for links and images. */\n readonly name: string;\n readonly count: number;\n}\n\nexport interface RichResult {\n /** Portable HTML: allowlisted elements and attributes, inline styles, absolute URLs. */\n readonly html: string;\n /** The same content as plain text. */\n readonly text: string;\n /** What was left out, and why: for logs and audits. */\n readonly removed: readonly RichRemoval[];\n /** The content went past `maxElements` or `maxLength` and was cut there. */\n readonly truncated: boolean;\n}\n\n/** What can be copied: an element, a selection range, a fragment, or HTML text. */\nexport type RichSource = Element | DocumentFragment | Range | string;\n\nconst VOID = new Set(['br', 'hr', 'img', 'col']);\nconst BLOCK_DISPLAY = /^(?:block|flex|grid|flow-root|list-item|table)$/;\nconst DATA_IMAGE = /^data:image\\/(?:png|jpeg|gif|webp);base64,[a-z\\d+/]+=*$/i;\n\nfunction positive(value: number | undefined, fallback: number, name: string): number {\n if (value === undefined) return fallback;\n if (Number.isInteger(value) && value > 0) return value;\n throw copyFailure('invalid-payload', `\\`${name}\\` must be a positive integer.`);\n}\n\n/** Whether `source` holds an element that would close a paragraph around it. */\nfunction holdsBlocks(source: Element): boolean {\n for (let child = source.firstElementChild; child !== null; child = child.nextElementSibling) {\n if (CLOSES_P.has(child.localName) || holdsBlocks(child)) return true;\n }\n return false;\n}\n\n/** Whether `node` is (inside) a link in the output. */\nfunction insideLink(node: Node | null): boolean {\n for (let current = node; current !== null; current = current.parentNode) if ((current as Element).localName === 'a') return true;\n return false;\n}\n\nconst isRange = (value: unknown): value is Range =>\n typeof value === 'object' && value !== null && 'commonAncestorContainer' in value && typeof (value as Range).intersectsNode === 'function';\n\nclass Builder {\n readonly removals = new Map<string, RichRemoval>();\n truncated = false;\n private elements = 0;\n private size = 0;\n /** Table parts added around misplaced cells and rows, which later cells and rows share. */\n private readonly implied = new WeakSet<Node>();\n private readonly resolveLink: (url: string) => string;\n private readonly resolveImage: (url: string) => string;\n\n constructor(\n readonly out: Document,\n private readonly options: RichOptions,\n private readonly mode: 'computed' | 'inline' | 'none',\n private readonly computed: (element: Element) => StyleSource | null,\n private readonly colors: RichColors,\n private readonly ignore: string | null,\n private readonly maxElements: number,\n private readonly maxLength: number,\n base: string | URL | undefined,\n ) {\n const baseOption = base === undefined ? {} : { base };\n this.resolveLink = linkUrlResolver({ ...baseOption, ...(options.protocols === undefined ? {} : { protocols: options.protocols }) });\n this.resolveImage = linkUrlResolver({ ...baseOption, protocols: options.dataImages === true ? ['https:', 'http:', 'data:'] : ['https:', 'http:'] });\n }\n\n remove(reason: RichRemovalReason, name: string): void {\n const key = `${reason} ${name}`;\n const known = this.removals.get(key);\n this.removals.set(key, { reason, name, count: (known?.count ?? 0) + 1 });\n }\n\n /** The style values to use for an element, or `null` when it is hidden. */\n private values(element: Element, parent: Values): Values | null {\n if (this.mode === 'computed') {\n const style = this.computed(element);\n if (style === null) return inherit(parent, undefined, element.localName);\n const display = style.getPropertyValue('display').trim();\n const visibility = style.getPropertyValue('visibility').trim();\n if (display === 'none' || visibility === 'hidden' || visibility === 'collapse') return null;\n return { ...readValues(style), display };\n }\n const declared = (element as Partial<HTMLElement>).style;\n if (declared?.getPropertyValue('display').trim() === 'none') return null;\n // Declared values on top of the inherited ones, as the browser would compute them.\n const tag = element.localName;\n return this.mode === 'none' || declared === undefined ? inherit(parent, undefined, tag) : inherit(parent, readValues(declared), tag);\n }\n\n private url(raw: string | null, resolve: (url: string) => string): string | null {\n if (raw === null || raw.trim() === '') return null;\n try {\n return resolve(raw);\n } catch {\n return null;\n }\n }\n\n private budget(cost: number): boolean {\n if (this.elements >= this.maxElements || this.size + cost > this.maxLength) {\n this.truncated = true;\n return false;\n }\n this.size += cost;\n return true;\n }\n\n private scheme = (raw: string | null): string => /^\\s*([a-z][a-z\\d+.-]*):/i.exec(raw ?? '')?.[1]?.toLowerCase() ?? 'relative';\n\n /** Converts `source` into `parent`, keeping only what lies inside `range` when given. */\n node(source: Node, parent: Node, inherited: Values, background: Color, range: Range | null, root = false): void {\n if (source.nodeType === 3) {\n let text = (source as Text).data;\n if (range !== null) {\n const end = source === range.endContainer ? range.endOffset : text.length;\n text = text.slice(source === range.startContainer ? range.startOffset : 0, end);\n }\n if (TABLE_CHILDREN[(parent as Element).localName] !== undefined && text.trim() !== '') {\n this.remove('misplaced', '#text');\n return;\n }\n if (text !== '' && this.budget(text.length)) parent.appendChild(this.out.createTextNode(text));\n return;\n }\n if (source.nodeType === 11 || source.nodeType === 9) {\n this.children(source, parent, inherited, background, range);\n return;\n }\n if (source.nodeType !== 1) return;\n this.element(source as Element, parent, inherited, background, range, root);\n }\n\n children(source: Node, parent: Node, inherited: Values, background: Color, range: Range | null): void {\n for (let child = source.firstChild; child !== null && !this.truncated; child = child.nextSibling) {\n if (range === null || range.intersectsNode(child)) this.node(child, parent, inherited, background, range);\n }\n }\n\n private element(source: Element, parent: Node, inherited: Values, background: Color, range: Range | null, root: boolean): void {\n const tag = source.localName.toLowerCase();\n if (DROP.has(tag) || source.namespaceURI !== 'http://www.w3.org/1999/xhtml') {\n this.remove('unsafe-element', tag);\n return;\n }\n // Attribute checks, not a selector: selector engines are slow to start in DOMs like jsdom.\n if (\n source.hasAttribute('data-copy-ignore') ||\n source.hasAttribute('hidden') ||\n source.getAttribute('aria-hidden') === 'true' ||\n (this.ignore !== null && source.matches(this.ignore))\n ) {\n this.remove('ignored', tag);\n return;\n }\n let values = this.values(source, inherited);\n if (values === null) {\n this.remove('hidden', tag);\n return;\n }\n // A selection's container is page chrome: only its inherited text style is kept.\n if (root && range !== null) values = { ...values, 'background-color': '', 'border-top-style': '', 'border-right-style': '', 'border-bottom-style': '', 'border-left-style': '', 'padding-top': '', 'padding-right': '', 'padding-bottom': '', 'padding-left': '' };\n if (tag === 'img') {\n this.image(source as HTMLImageElement, parent);\n return;\n }\n let name = KEEP.has(tag) ? tag : AS_BLOCK.has(tag) || BLOCK_DISPLAY.test(values.display ?? '') ? 'div' : 'span';\n let href: string | null = null;\n if (tag === 'a') {\n const raw = source.getAttribute('href');\n href = this.url(raw, this.resolveLink);\n if (href === null) {\n if (raw !== null && raw.trim() !== '') this.remove('unsafe-link', this.scheme(raw));\n name = 'span';\n }\n }\n let target = parent;\n let parentTag = (parent as Element).localName;\n // Outside a table, HTML parsers ignore table tags: a selection inside a table gets its table, anything else is a block.\n if (TABLE_PARTS.has(name) && TABLE_CHILDREN[parentTag] === undefined) {\n if (root) {\n target = parent.appendChild(this.out.createElement('table'));\n parentTag = 'table';\n } else if (name === 'col') {\n this.remove('misplaced', tag);\n return;\n } else name = 'div';\n }\n // The table parts that HTML parsers add around cells, rows and columns.\n const implied: string[] = [];\n if (parentTag === 'table' && (name === 'tr' || name === 'td' || name === 'th')) implied.push('tbody');\n if ((name === 'td' || name === 'th') && (implied.length > 0 || parentTag === 'tbody' || parentTag === 'thead' || parentTag === 'tfoot')) implied.push('tr');\n if (parentTag === 'table' && name === 'col') implied.push('colgroup');\n // A table part can hold only its own parts: anything else is left out, not moved around.\n const allowed = TABLE_CHILDREN[implied.at(-1) ?? parentTag];\n if (allowed !== undefined && !allowed.has(name)) {\n this.remove('misplaced', tag);\n return;\n }\n // What HTML parsers would split apart: a paragraph around blocks, a heading in a heading, a list item in a list item.\n if (name === 'p' && holdsBlocks(source)) name = 'div';\n if (HEADINGS.has(name) && HEADINGS.has(parentTag)) name = 'span';\n if ((name === 'li' || name === 'dd' || name === 'dt') && closesItem(name, parent)) name = 'div';\n // Inside text-level content, a block becomes inline and a link inside a link loses its link.\n if (name === 'div' && PHRASING.has(parentTag)) name = 'span';\n if (name === 'a' && insideLink(parent)) name = 'span';\n if (!this.budget(name.length * 2 + 5)) return;\n for (const wrapper of implied) {\n const last = (target as Element).lastElementChild;\n target = last !== null && this.implied.has(last) && last.localName === wrapper ? last : target.appendChild(this.out.createElement(wrapper));\n this.implied.add(target);\n }\n this.elements += 1;\n const out = this.out.createElement(name);\n if (href !== null && name === 'a') out.setAttribute('href', href);\n for (const attribute of Array.from(source.attributes)) {\n const key = attribute.name.toLowerCase();\n if (name === tag && attributeAllowed(tag, key, attribute.value)) out.setAttribute(key, attribute.value);\n }\n const style = declarations(name, values, root ? ROOT_PARENT : inherited, background, this.colors);\n if (style.droppedColor) this.remove('unreadable-color', tag);\n if (style.css !== '' && this.budget(style.css.length)) out.setAttribute('style', style.css);\n target.appendChild(out);\n if (!VOID.has(name)) this.children(source, out, values, style.background, range);\n }\n\n private image(source: HTMLImageElement, parent: Node): void {\n const alt = source.getAttribute('alt') ?? '';\n const policy = this.options.images ?? 'keep';\n if (policy === 'drop') {\n this.remove('image', 'img');\n return;\n }\n const raw = this.mode === 'computed' && source.currentSrc !== '' ? source.currentSrc : source.getAttribute('src');\n const src = policy === 'keep' ? this.url(raw, this.resolveImage) : null;\n const safe = src !== null && (!src.startsWith('data:') || (DATA_IMAGE.test(src) && src.length <= 2_000_000));\n if (!safe) {\n this.remove(policy === 'keep' ? 'unsafe-image' : 'image', policy === 'keep' ? this.scheme(raw) : 'img');\n if (alt !== '' && this.budget(alt.length)) parent.appendChild(this.out.createTextNode(alt));\n return;\n }\n if (!this.budget(src.length + alt.length + 40)) return;\n this.elements += 1;\n const out = this.out.createElement('img');\n out.setAttribute('src', src);\n if (alt !== '') out.setAttribute('alt', alt);\n // Mail clients size images by their attributes: write the displayed size.\n for (const side of ['width', 'height'] as const) {\n const shown = this.mode === 'computed' ? Math.round(source[side]) : NaN;\n const declared = source.getAttribute(side) ?? '';\n const value = shown > 0 ? String(shown) : /^\\d{1,5}$/.test(declared) ? declared : '';\n if (value !== '') out.setAttribute(side, value);\n }\n const title = source.getAttribute('title');\n if (title !== null) out.setAttribute('title', title);\n parent.appendChild(out);\n }\n}\n\n/** The DOM document to read and write with, or a typed error outside a browser. */\nfunction domFor(source: RichSource): { readonly doc: Document; readonly root: Node; readonly range: Range | null; readonly live: boolean } {\n if (typeof source === 'string') {\n if (typeof DOMParser === 'undefined') throw copyFailure('unsupported', 'Reading HTML text needs a DOM (DOMParser); pass a DOM node, or use a browser or jsdom.');\n // A parsed document is inert: scripts never run and nothing is fetched.\n // In standards mode, as pages and mail clients read HTML (not quirks mode, which keeps a table inside a paragraph).\n const doc = new DOMParser().parseFromString(`<!doctype html><body>${source}`, 'text/html');\n return { doc, root: doc.body, range: null, live: false };\n }\n if (isRange(source)) {\n const container = source.commonAncestorContainer;\n const element = container.nodeType === 1 ? container : container.parentNode;\n if (element === null || container.ownerDocument === null) throw copyFailure('invalid-payload', 'The range is not in a document.');\n return { doc: container.ownerDocument, root: element, range: source, live: container.isConnected };\n }\n const value: unknown = source;\n if (typeof value !== 'object' || value === null || !('nodeType' in value) || ((value as Node).nodeType !== 1 && (value as Node).nodeType !== 11)) {\n throw copyFailure('invalid-payload', 'Rich content must be an element, a fragment, a range or HTML text.');\n }\n const node = value as Node;\n return { doc: node.ownerDocument as Document, root: node, range: null, live: node.isConnected };\n}\n\n/**\n * Converts content into portable rich text: the HTML that mail clients, Google Docs,\n * Word, Notion and Slack paste as it looks, plus a plain-text version.\n *\n * - Only safe, widely supported elements and attributes are kept: never scripts,\n * event handlers, embeds, forms or tracking pixels from `data:` or `blob:` URLs.\n * - Styles are inline, from what the reader sees (computed styles) for content on\n * the page. Classes, stylesheets and CSS variables can't travel; their result can.\n * - Every colour becomes an opaque hex value, which every mail client understands\n * (not `oklch()` or `rgb(r g b / 50%)`). Text that would be unreadable on a white\n * page, such as light text from a dark theme, keeps the destination's colour.\n * - Links and images get absolute, scheme-checked URLs; images get their displayed size.\n *\n * Never inserts anything into the page: the output is built in a separate, inert document.\n *\n * @example\n * const { html, text, removed } = prepareRich(articleRef.current);\n */\nexport function prepareRich(source: RichSource, options: RichOptions = {}): RichResult {\n const { doc, root, range, live } = domFor(source);\n // Computed styles need content on a page with a window; anything else has only its style attributes.\n const mode = options.styles ?? (live && doc.defaultView !== null ? 'computed' : 'inline');\n const modeValue: unknown = mode; // Plain-JS callers can pass anything.\n if (modeValue !== 'computed' && modeValue !== 'inline' && modeValue !== 'none') throw copyFailure('invalid-payload', '`styles` must be \"computed\", \"inline\" or \"none\".');\n const colors = options.colors ?? 'readable';\n const colorsValue: unknown = colors;\n if (colorsValue !== 'readable' && colorsValue !== 'keep' && colorsValue !== 'none') throw copyFailure('invalid-payload', '`colors` must be \"readable\", \"keep\" or \"none\".');\n const images: unknown = options.images ?? 'keep';\n if (images !== 'keep' && images !== 'alt' && images !== 'drop') throw copyFailure('invalid-payload', '`images` must be \"keep\", \"alt\" or \"drop\".');\n const view = doc.defaultView;\n const computed = options.computedStyle ?? ((element: Element) => (view === null ? null : view.getComputedStyle(element)));\n const page = options.background === undefined ? WHITE : declarationsBackground(options.background);\n if (options.ignore !== undefined) {\n // An invalid selector is a programming error: it throws a typed error here, not mid-copy.\n try {\n doc.createElement('div').matches(options.ignore);\n } catch (cause) {\n throw copyFailure('invalid-payload', `\\`ignore\\` is not a valid CSS selector: ${options.ignore}`, cause);\n }\n }\n const out = doc.implementation.createHTMLDocument('');\n const builder = new Builder(\n out,\n options,\n mode,\n computed,\n colors,\n options.ignore ?? null,\n positive(options.maxElements, 10_000, 'maxElements'),\n positive(options.maxLength, 1_000_000, 'maxLength'),\n options.base ?? (doc.baseURI === 'about:blank' ? undefined : doc.baseURI),\n );\n const container = out.createElement('div');\n // HTML text is its body's content; anything else is converted with its root element.\n if (typeof source === 'string') builder.children(root, container, ROOT_PARENT, page, null);\n else builder.node(root, container, ROOT_PARENT, page, range, true);\n // Left-out nodes can leave text in pieces: join them, as reading the HTML back would.\n container.normalize();\n const text = (options.text ?? plainText)(container);\n if (typeof text !== 'string') throw copyFailure('invalid-payload', '`text` must return a string.');\n // Whitespace at the very edges shows nothing, and HTML parsers drop it when reading the copy.\n const first = container.firstChild;\n if (first?.nodeType === 3) (first as Text).data = (first as Text).data.replace(/^\\s+/, '');\n const last = container.lastChild;\n if (last?.nodeType === 3) (last as Text).data = (last as Text).data.replace(/\\s+$/, '');\n // Only whitespace is no content: nothing to copy.\n const empty = container.textContent.trim() === '' && container.querySelector('img, br, hr') === null;\n return { html: empty ? '' : container.innerHTML, text: empty ? '' : text, removed: [...builder.removals.values()], truncated: builder.truncated };\n}\n\n/** The destination background as an opaque colour; a typed error for anything else. */\nfunction declarationsBackground(value: string): Color {\n const parsed: Color | null = typeof value === 'string' ? parseColor(value) : null;\n if (parsed === null || parsed.alpha !== 1) throw copyFailure('invalid-payload', '`background` must be an opaque CSS colour.');\n return parsed;\n}\n","import type { CopyInterceptTransform, CopySelection, SyncCopyPayload } from '../core/copy-interceptor';\nimport { copyFailure } from '../core/errors';\nimport type { HtmlPayload } from '../core/payload';\nimport { prepareRich, type RichOptions, type RichSource } from './walk';\n\n/**\n * Content to copy as portable rich text: the sanitized HTML, and its plain text for\n * editors and plain fields. A typed `invalid-payload` error when nothing is left to copy.\n *\n * @example\n * const { copy } = useCopy();\n * <button onClick={() => copy(() => richPayload(noteRef.current))}>Copy note</button>\n */\nexport function richPayload(source: RichSource, options: RichOptions = {}): HtmlPayload {\n const { html, text } = prepareRich(source, options);\n if (html === '' || text === '') throw copyFailure('invalid-payload', 'There is nothing to copy: the content is empty, hidden or entirely left out.');\n return { kind: 'html', html, text };\n}\n\n/**\n * A copy interceptor transform that makes Ctrl/Cmd+C (and cut) of a selection in your\n * page portable: what the reader selected, with the styles they see, sanitized. The\n * plain text stays the browser's own. Selections in text fields are left alone.\n *\n * @example\n * useCopyInterceptor(articleRef, { transform: richTransform() });\n */\nexport function richTransform(options: RichOptions = {}): CopyInterceptTransform {\n return (selection: CopySelection): SyncCopyPayload | undefined => {\n if (selection.field !== null || typeof document === 'undefined') return undefined;\n const live = document.getSelection();\n if (live === null || live.rangeCount === 0) return undefined;\n const parts: string[] = [];\n for (let index = 0; index < live.rangeCount; index += 1) {\n const { html, text } = prepareRich(live.getRangeAt(index), options);\n // Nothing visible left (only scripts or hidden content, say): not worth a paste.\n if (text !== '' || html.includes('<img')) parts.push(html);\n }\n const html = parts.join('');\n return html === '' ? undefined : { kind: 'html', html, text: selection.text };\n };\n}\n"],"mappings":";AA8CA,SAAgB,gBAAgB,MAAqB,SAAiB,OAA4B;CAChG,OAAO,UAAU,KAAA,IAAY;EAAE;EAAM;CAAQ,IAAI;EAAE;EAAM;EAAS;CAAM;AAC1E;;;;;AAmBA,MAAM,qBAAqB,OAAO,IAAI,8BAA8B;;AAGpE,IAAa,cAAb,cAAiC,MAAM;CAIrC,YAAY,WAAsB;EAChC,MAAM,UAAU,OAAO;EAHzB,KAAU,sBAAsB;EAI9B,KAAK,OAAO;EACZ,KAAK,YAAY;CACnB;AACF;;AAWA,SAAgB,YAAY,MAAqB,SAAiB,OAA8B;CAC9F,OAAO,IAAI,YAAY,gBAAgB,MAAM,SAAS,KAAK,CAAC;AAC9D;;;;ACzFA,MAAa,yBAA4D,uBAAO,OAAO;CAAC;CAAU;CAAS;CAAW;AAAM,CAAC;;;;;AAM7H,MAAa,sBAAyD,uBAAO,OAAO;CAClF;CACA;CACA;CACA;CACA;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M;GAAQ;GAAM,MAAM,UAAU;EAAK;CAC9E;AACF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-smart-copy",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Headless, type-safe clipboard interactions for React: copy and paste text, rich HTML, images, spreadsheet tables, typed application data, Markdown, code, privacy-safe images, links and
|
|
3
|
+
"version": "1.17.0",
|
|
4
|
+
"description": "Headless, type-safe clipboard interactions for React: copy and paste text, rich HTML, images, spreadsheet tables, typed application data, Markdown, code, privacy-safe images, links, sharing, colours and portable rich text, with coordinated copy groups, SVG/DOM capture, Trojan Source and homoglyph detection, honest error states, retry and screen-reader announcements.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
7
7
|
"clipboard",
|
|
@@ -51,7 +51,20 @@
|
|
|
51
51
|
"paste-link",
|
|
52
52
|
"web-share",
|
|
53
53
|
"share-button",
|
|
54
|
-
"navigator-share"
|
|
54
|
+
"navigator-share",
|
|
55
|
+
"color",
|
|
56
|
+
"colour",
|
|
57
|
+
"oklch",
|
|
58
|
+
"color-picker",
|
|
59
|
+
"design-tokens",
|
|
60
|
+
"contrast",
|
|
61
|
+
"wcag-contrast",
|
|
62
|
+
"rich-text",
|
|
63
|
+
"copy-html",
|
|
64
|
+
"email-html",
|
|
65
|
+
"html-sanitizer",
|
|
66
|
+
"outlook",
|
|
67
|
+
"gmail"
|
|
55
68
|
],
|
|
56
69
|
"license": "MIT",
|
|
57
70
|
"author": {
|
|
@@ -107,6 +120,12 @@
|
|
|
107
120
|
],
|
|
108
121
|
"share": [
|
|
109
122
|
"./dist/share.d.ts"
|
|
123
|
+
],
|
|
124
|
+
"color": [
|
|
125
|
+
"./dist/color.d.ts"
|
|
126
|
+
],
|
|
127
|
+
"rich": [
|
|
128
|
+
"./dist/rich.d.ts"
|
|
110
129
|
]
|
|
111
130
|
}
|
|
112
131
|
},
|
|
@@ -221,6 +240,26 @@
|
|
|
221
240
|
"default": "./dist/share.cjs"
|
|
222
241
|
}
|
|
223
242
|
},
|
|
243
|
+
"./color": {
|
|
244
|
+
"import": {
|
|
245
|
+
"types": "./dist/color.d.ts",
|
|
246
|
+
"default": "./dist/color.js"
|
|
247
|
+
},
|
|
248
|
+
"require": {
|
|
249
|
+
"types": "./dist/color.d.cts",
|
|
250
|
+
"default": "./dist/color.cjs"
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
"./rich": {
|
|
254
|
+
"import": {
|
|
255
|
+
"types": "./dist/rich.d.ts",
|
|
256
|
+
"default": "./dist/rich.js"
|
|
257
|
+
},
|
|
258
|
+
"require": {
|
|
259
|
+
"types": "./dist/rich.d.cts",
|
|
260
|
+
"default": "./dist/rich.cjs"
|
|
261
|
+
}
|
|
262
|
+
},
|
|
224
263
|
"./package.json": "./package.json"
|
|
225
264
|
},
|
|
226
265
|
"engines": {
|
|
@@ -245,7 +284,7 @@
|
|
|
245
284
|
"verify": "npm run lint && npm run typecheck && npm run test:coverage && npm run build && node scripts/check-dist.js && npm run lint:package && npm run types:consumer && npm run size",
|
|
246
285
|
"changeset": "changeset",
|
|
247
286
|
"release": "npm run verify && changeset publish",
|
|
248
|
-
"site:build": "npm run build && node -e \"for (const f of ['core.js','capture.js','table.js','structured.js','markdown.js','code.js','image.js','link.js','share.js']) require('fs').copyFileSync('dist/'+f,'site/'+f)\" && node scripts/build-changelog.js",
|
|
287
|
+
"site:build": "npm run build && node -e \"for (const f of ['core.js','capture.js','table.js','structured.js','markdown.js','code.js','image.js','link.js','share.js','color.js','rich.js']) require('fs').copyFileSync('dist/'+f,'site/'+f)\" && node scripts/build-changelog.js",
|
|
249
288
|
"site:preview": "npm run site:build && npx --yes serve site",
|
|
250
289
|
"test:coverage": "vitest run --coverage",
|
|
251
290
|
"types:consumer": "tsc -p consumer/tsconfig.bundler.json && tsc -p consumer/tsconfig.nodenext.json",
|
|
@@ -400,6 +439,34 @@
|
|
|
400
439
|
"path": "dist/share.js",
|
|
401
440
|
"import": "{ shareOrCopy }",
|
|
402
441
|
"limit": "4.5 kB"
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
"name": "color, all exports",
|
|
445
|
+
"path": "dist/color.js",
|
|
446
|
+
"limit": "6.8 kB"
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
"name": "color: parseColor + formatColor",
|
|
450
|
+
"path": "dist/color.js",
|
|
451
|
+
"import": "{ parseColor, formatColor }",
|
|
452
|
+
"limit": "5.5 kB"
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
"name": "color: contrastRatio",
|
|
456
|
+
"path": "dist/color.js",
|
|
457
|
+
"import": "{ contrastRatio }",
|
|
458
|
+
"limit": "4.7 kB"
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
"name": "rich, all exports",
|
|
462
|
+
"path": "dist/rich.js",
|
|
463
|
+
"limit": "12.2 kB"
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
"name": "rich: richPayload",
|
|
467
|
+
"path": "dist/rich.js",
|
|
468
|
+
"import": "{ richPayload }",
|
|
469
|
+
"limit": "12 kB"
|
|
403
470
|
}
|
|
404
471
|
],
|
|
405
472
|
"publishConfig": {
|
|
@@ -414,6 +481,7 @@
|
|
|
414
481
|
"@tanstack/table-core": "^9.3.1",
|
|
415
482
|
"@testing-library/dom": "^10.4.2",
|
|
416
483
|
"@testing-library/react": "^16.3.3",
|
|
484
|
+
"@types/culori": "4.0.1",
|
|
417
485
|
"@types/markdown-it": "14.2.0",
|
|
418
486
|
"@types/node": "^22.20.5",
|
|
419
487
|
"@types/react": "^19.3.0",
|
|
@@ -422,6 +490,8 @@
|
|
|
422
490
|
"ag-grid-community": "^36.2.0",
|
|
423
491
|
"arktype": "^2.2.8",
|
|
424
492
|
"axe-core": "^4.14.0",
|
|
493
|
+
"culori": "4.0.2",
|
|
494
|
+
"dompurify": "3.4.17",
|
|
425
495
|
"eslint": "^10.13.0",
|
|
426
496
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
427
497
|
"fast-check": "^4.10.2",
|