react-smart-copy 1.17.2 → 1.19.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.
Files changed (154) hide show
  1. package/README.md +86 -5
  2. package/dist/capture.cjs +30 -153
  3. package/dist/capture.cjs.map +1 -1
  4. package/dist/capture.d.cts +2 -25
  5. package/dist/capture.d.ts +2 -25
  6. package/dist/capture.js +5 -128
  7. package/dist/capture.js.map +1 -1
  8. package/dist/chunks/clipboard-adapter-Cfz-rzw3.cjs +102 -0
  9. package/dist/chunks/clipboard-adapter-Cfz-rzw3.cjs.map +1 -0
  10. package/dist/chunks/clipboard-adapter-CtH4VELE.d.cts +43 -0
  11. package/dist/chunks/clipboard-adapter-DEXkXxwV.js +97 -0
  12. package/dist/chunks/clipboard-adapter-DEXkXxwV.js.map +1 -0
  13. package/dist/chunks/clipboard-adapter-Ds0irroN.d.ts +43 -0
  14. package/dist/chunks/contrast-C6CVklEI.cjs +842 -0
  15. package/dist/chunks/contrast-C6CVklEI.cjs.map +1 -0
  16. package/dist/chunks/contrast-DpK2JIVu.js +789 -0
  17. package/dist/chunks/contrast-DpK2JIVu.js.map +1 -0
  18. package/dist/chunks/copy-interceptor-C6NABy1l.d.ts +141 -0
  19. package/dist/chunks/copy-interceptor-CZWzGOkL.d.cts +141 -0
  20. package/dist/chunks/core-Cp2HSpaz.js +1035 -0
  21. package/dist/chunks/core-Cp2HSpaz.js.map +1 -0
  22. package/dist/chunks/core-DYf_Lhbe.cjs +1142 -0
  23. package/dist/chunks/core-DYf_Lhbe.cjs.map +1 -0
  24. package/dist/chunks/deadline-C29AlS_Q.js +46 -0
  25. package/dist/chunks/deadline-C29AlS_Q.js.map +1 -0
  26. package/dist/chunks/deadline-DkiB8ZHE.cjs +51 -0
  27. package/dist/chunks/deadline-DkiB8ZHE.cjs.map +1 -0
  28. package/dist/chunks/errors-9h8sdFFX.js +120 -0
  29. package/dist/chunks/errors-9h8sdFFX.js.map +1 -0
  30. package/dist/chunks/errors-BwOF6T_M.cjs +167 -0
  31. package/dist/chunks/errors-BwOF6T_M.cjs.map +1 -0
  32. package/dist/chunks/index-mr7sSAgP.d.ts +426 -0
  33. package/dist/chunks/index-vz0iW5V2.d.cts +426 -0
  34. package/dist/chunks/inert-html-D75NyVvT.js +34 -0
  35. package/dist/chunks/inert-html-D75NyVvT.js.map +1 -0
  36. package/dist/chunks/inert-html-DyxjWDok.cjs +39 -0
  37. package/dist/chunks/inert-html-DyxjWDok.cjs.map +1 -0
  38. package/dist/chunks/mime--LB7kdqG.cjs +153 -0
  39. package/dist/chunks/mime--LB7kdqG.cjs.map +1 -0
  40. package/dist/chunks/mime-aa-HA2dm.js +100 -0
  41. package/dist/chunks/mime-aa-HA2dm.js.map +1 -0
  42. package/dist/chunks/paste-adapter--SPL4PRE.d.cts +35 -0
  43. package/dist/chunks/paste-adapter-uahXnTYk.d.ts +35 -0
  44. package/dist/chunks/paste-reader-Bo01IMC_.cjs +289 -0
  45. package/dist/chunks/paste-reader-Bo01IMC_.cjs.map +1 -0
  46. package/dist/chunks/paste-reader-D9i7yMXF.js +224 -0
  47. package/dist/chunks/paste-reader-D9i7yMXF.js.map +1 -0
  48. package/dist/chunks/paste-reader-DcXnRWQr.d.cts +96 -0
  49. package/dist/chunks/paste-reader-DcXnRWQr.d.ts +96 -0
  50. package/dist/chunks/payload-CUymxwim.cjs +100 -0
  51. package/dist/chunks/payload-CUymxwim.cjs.map +1 -0
  52. package/dist/chunks/payload-CcwKJ_bU.d.cts +162 -0
  53. package/dist/chunks/payload-Cl_8hCI5.d.ts +162 -0
  54. package/dist/chunks/payload-DGw-JOo7.js +71 -0
  55. package/dist/chunks/payload-DGw-JOo7.js.map +1 -0
  56. package/dist/chunks/payload-DI5AorDz.js +103 -0
  57. package/dist/chunks/payload-DI5AorDz.js.map +1 -0
  58. package/dist/chunks/payload-J6GjHuh3.cjs +132 -0
  59. package/dist/chunks/payload-J6GjHuh3.cjs.map +1 -0
  60. package/dist/chunks/share-Bop47Znn.js +208 -0
  61. package/dist/chunks/share-Bop47Znn.js.map +1 -0
  62. package/dist/chunks/share-C0esXvRK.d.cts +115 -0
  63. package/dist/chunks/share-ayDz974N.cjs +231 -0
  64. package/dist/chunks/share-ayDz974N.cjs.map +1 -0
  65. package/dist/chunks/share-e7FenIr2.d.ts +115 -0
  66. package/dist/chunks/text-field-Ba8W3v4R.cjs +77 -0
  67. package/dist/chunks/text-field-Ba8W3v4R.cjs.map +1 -0
  68. package/dist/chunks/text-field-C0SGmvvR.d.cts +18 -0
  69. package/dist/chunks/text-field-C0SGmvvR.d.ts +18 -0
  70. package/dist/chunks/text-field-DUvrMMaK.js +66 -0
  71. package/dist/chunks/text-field-DUvrMMaK.js.map +1 -0
  72. package/dist/chunks/url-B9jdFGQy.cjs +86 -0
  73. package/dist/chunks/url-B9jdFGQy.cjs.map +1 -0
  74. package/dist/chunks/url-BcMYVCXQ.js +135 -0
  75. package/dist/chunks/url-BcMYVCXQ.js.map +1 -0
  76. package/dist/chunks/url-D4PGsRm8.cjs +164 -0
  77. package/dist/chunks/url-D4PGsRm8.cjs.map +1 -0
  78. package/dist/chunks/url-DWdElCT3.d.cts +43 -0
  79. package/dist/chunks/url-DWdElCT3.d.ts +43 -0
  80. package/dist/chunks/url-vJaFPbNL.js +57 -0
  81. package/dist/chunks/url-vJaFPbNL.js.map +1 -0
  82. package/dist/code.cjs +22 -113
  83. package/dist/code.cjs.map +1 -1
  84. package/dist/code.d.cts +4 -28
  85. package/dist/code.d.ts +4 -28
  86. package/dist/code.js +5 -96
  87. package/dist/code.js.map +1 -1
  88. package/dist/color.cjs +21 -893
  89. package/dist/color.cjs.map +1 -1
  90. package/dist/color.d.cts +4 -28
  91. package/dist/color.d.ts +4 -28
  92. package/dist/color.js +4 -876
  93. package/dist/color.js.map +1 -1
  94. package/dist/core.cjs +52 -1659
  95. package/dist/core.d.cts +8 -878
  96. package/dist/core.d.ts +8 -878
  97. package/dist/core.js +7 -1614
  98. package/dist/image.cjs +23 -94
  99. package/dist/image.cjs.map +1 -1
  100. package/dist/image.d.cts +1 -0
  101. package/dist/image.d.ts +1 -0
  102. package/dist/image.js +3 -74
  103. package/dist/image.js.map +1 -1
  104. package/dist/index.cjs +74 -2072
  105. package/dist/index.cjs.map +1 -1
  106. package/dist/index.d.cts +8 -978
  107. package/dist/index.d.ts +8 -978
  108. package/dist/index.js +7 -2005
  109. package/dist/index.js.map +1 -1
  110. package/dist/link.cjs +26 -339
  111. package/dist/link.cjs.map +1 -1
  112. package/dist/link.d.cts +5 -83
  113. package/dist/link.d.ts +5 -83
  114. package/dist/link.js +7 -320
  115. package/dist/link.js.map +1 -1
  116. package/dist/markdown.cjs +19 -159
  117. package/dist/markdown.cjs.map +1 -1
  118. package/dist/markdown.d.cts +3 -16
  119. package/dist/markdown.d.ts +3 -16
  120. package/dist/markdown.js +6 -146
  121. package/dist/markdown.js.map +1 -1
  122. package/dist/rich.cjs +1123 -940
  123. package/dist/rich.cjs.map +1 -1
  124. package/dist/rich.d.cts +101 -91
  125. package/dist/rich.d.ts +101 -91
  126. package/dist/rich.js +1099 -919
  127. package/dist/rich.js.map +1 -1
  128. package/dist/share.cjs +5 -640
  129. package/dist/share.d.cts +3 -248
  130. package/dist/share.d.ts +3 -248
  131. package/dist/share.js +1 -637
  132. package/dist/structured.cjs +13 -95
  133. package/dist/structured.cjs.map +1 -1
  134. package/dist/structured.d.cts +2 -11
  135. package/dist/structured.d.ts +2 -11
  136. package/dist/structured.js +4 -86
  137. package/dist/structured.js.map +1 -1
  138. package/dist/table.cjs +13 -40
  139. package/dist/table.cjs.map +1 -1
  140. package/dist/table.d.cts +2 -12
  141. package/dist/table.d.ts +2 -12
  142. package/dist/table.js +4 -31
  143. package/dist/table.js.map +1 -1
  144. package/dist/testing.cjs +10 -43
  145. package/dist/testing.cjs.map +1 -1
  146. package/dist/testing.d.cts +6 -181
  147. package/dist/testing.d.ts +6 -181
  148. package/dist/testing.js +3 -36
  149. package/dist/testing.js.map +1 -1
  150. package/package.json +37 -5
  151. package/dist/core.cjs.map +0 -1
  152. package/dist/core.js.map +0 -1
  153. package/dist/share.cjs.map +0 -1
  154. package/dist/share.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contrast-DpK2JIVu.js","names":[],"sources":["../../src/color/convert.ts","../../src/color/names.ts","../../src/color/parse.ts","../../src/color/format.ts","../../src/color/contrast.ts"],"sourcesContent":["/**\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\n/** Applies `f` to each component; the result stays a three-component vector. */\nexport const map3 = ([x, y, z]: Vec3, f: (v: number, i: 0 | 1 | 2) => number): Vec3 => [f(x, 0), f(y, 1), f(z, 2)];\n/** Three numbers as a vector, or null when one is missing. */\nexport const vec3 = ([x, y, z]: readonly (number | null)[]): Vec3 | null =>\n typeof x === 'number' && typeof y === 'number' && typeof z === 'number' ? [x, y, z] : null;\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 => map3(mul(XYZ_TO_P3, toXyz(c)), fromLinear);\nexport const fromP3 = (p3: Vec3, alpha: number): Color => fromXyz(mul(P3_TO_XYZ, map3(p3, toLinear)), 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, map3(mul(LRGB_TO_LMS, linearRgb(c)), Math.cbrt));\nexport const fromOklab = (lab: Vec3, alpha: number): Color =>\n fromLinearRgb(mul(LMS_TO_LRGB, map3(mul(OKLAB_TO_LMS, lab), (v) => v ** 3)), 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] = map3(mul(D65_TO_D50, toXyz(c)), (v, i) => v / D50_WHITE[i]);\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(map3(xyz, (v, i) => v * D50_WHITE[i]), 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\nconst clip01 = (v: number) => Math.min(1, Math.max(0, v));\n\n/**\n * Below this spread between channels a colour is grey: what is left is rounding error from\n * converting it (from Lab, OKLCH, P3...), and its hue and saturation would be noise. The\n * faintest real tint in 8-bit sRGB, such as #fffffe, has a spread of about 0.004.\n */\nconst GREY = 1e-9;\n\n/**\n * Hue, saturation and lightness of a colour inside sRGB (hue 0 for greys), with s and l in [0, 1].\n * Channels are clipped first: colours count as inside sRGB within rounding error, a little past 0 or 1.\n */\nexport function toHsl(c: Color): Vec3 {\n const [r, g, b] = map3([c.r, c.g, c.b], clip01);\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n const l = (max + min) / 2;\n const d = max - min;\n if (d < GREY) return [0, 0, l];\n // Clipped, with d > 0: l is strictly between 0 and 1, and s is at most 1.\n const s = (max - l) / Math.min(l, 1 - l);\n let h: number;\n if (max === r) h = (g - b) / d + (g < b ? 6 : 0);\n else if (max === g) h = (b - r) / d + 2;\n else h = (r - 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] (channels clipped, as in `toHsl`). */\nexport function toHwb(c: Color): Vec3 {\n const [h] = toHsl(c);\n const [r, g, b] = map3([c.r, c.g, c.b], clip01);\n return [h, Math.min(r, g, b), 1 - Math.max(r, g, 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 clipTo = (c: Color, gamut: Gamut): Color => {\n const [x, y, z] = map3(channels(c, gamut), clip01);\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, map3, vec3, 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 const vector = vec3(values);\n return vector === null ? null : map3(vector, (v) => clamp(v, 0, 255) / 255);\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 const vector = vec3(values);\n return vector === null || alpha === null ? null : convert(vector, 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"],"mappings":";;;AAsBA,MAAa,SAAS,GAAW,GAAW,GAAW,QAAQ,MAAa,OAAO,OAAO;CAAE;CAAG;CAAG;CAAG;AAAM,CAAC;AAE5G,MAAM,OAAO,GAAS,CAAC,GAAG,GAAG,OAAmB;CAC9C,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC,KAAK;CACtC,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC,KAAK;CACtC,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC,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AI,GAAG,OAAO,CAAC,CAAC;AAC/E;;AAGA,SAAS,UAAU,GAAkB;CACnC,MAAM,OAAO,MAAe,KAAK,SAAU,IAAI,UAAU,IAAI,QAAS,UAAU;CAChF,OAAO,QAAS,IAAI,EAAE,CAAC,IAAI,QAAS,IAAI,EAAE,CAAC,IAAI,QAAS,IAAI,EAAE,CAAC;AACjE;;;;;;;;;;AAWA,SAAgB,cAAc,MAAkB,YAAgC;CAC9E,MAAM,KAAK,KAAK,QAAQ,QAAQ,UAAU,CAAC,GAAG,KAAK;CAEnD,MAAM,CAAC,OAAO,QAAQ,CAAC,UADZ,KAAK,QAAQ,QAAQ,IAAI,CAAC,GAAG,EACN,CAAC,GAAG,UAAU,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC;CACzE,QAAQ,QAAQ,QAAS,OAAO;AAClC;;AAWA,SAAgB,cAAc,OAAe,UAAgC,CAAC,GAAkB;CAC9F,IAAI,CAAC,OAAO,SAAS,KAAK,KAAK,QAAQ,GAAG,MAAM,YAAY,mBAAmB,4CAA4C;CAC3H,MAAM,CAAC,IAAI,OAAO,QAAQ,UAAU,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC;CAC7D,IAAI,SAAS,KAAK,OAAO;CACzB,OAAO,SAAS,KAAK,OAAO;AAC9B"}
@@ -0,0 +1,141 @@
1
+
2
+ import { f as TextPayload, l as JsonPayload, o as HtmlPayload, v as CopyError } from "./payload-Cl_8hCI5.js";
3
+ //#region src/core/copy-interceptor.d.ts
4
+ /**
5
+ * Native copy interception: rewrite, redact or block what lands on the
6
+ * clipboard when the user copies (Ctrl/Cmd+C, context menu) or cuts inside a
7
+ * scope.
8
+ *
9
+ * Writes go through `event.clipboardData` synchronously, so no permission
10
+ * prompt, no secure-context requirement, and it works in every browser. The
11
+ * price is that only strings can be written, which the types enforce.
12
+ *
13
+ * Not a security boundary: users can still screenshot, use dev tools or
14
+ * disable script. Treat redaction as a guard against accidents.
15
+ */
16
+ type InterceptedCopyKind = 'copy' | 'cut';
17
+ declare const DEFAULT_INTERCEPTED_EVENTS: readonly InterceptedCopyKind[];
18
+ /** The writable slice of `DataTransfer` during a `copy`/`cut` event. */
19
+ interface ClipboardDataLike {
20
+ setData(format: string, data: string): void;
21
+ clearData?(format?: string): void;
22
+ }
23
+ /** Structural `ClipboardEvent`: DOM and React clipboard events both satisfy it. */
24
+ interface CopyEventLike {
25
+ readonly type: string;
26
+ readonly target: EventTarget | null;
27
+ readonly clipboardData: ClipboardDataLike | null;
28
+ readonly defaultPrevented: boolean;
29
+ preventDefault(): void;
30
+ }
31
+ /** What the user selected when they copied. */
32
+ interface CopySelection {
33
+ readonly kind: InterceptedCopyKind;
34
+ /** What the browser would put on the clipboard as `text/plain`. */
35
+ readonly text: string;
36
+ /** Serialised HTML of the selection; `null` inside text inputs. */
37
+ readonly html: string | null;
38
+ /** A detached clone of the selected nodes, safe to mutate; `null` inside text inputs. */
39
+ readonly fragment: DocumentFragment | null;
40
+ /** The `<input>`/`<textarea>` the selection lives in, if any. */
41
+ readonly field: HTMLInputElement | HTMLTextAreaElement | null;
42
+ /** Whether a `cut` would remove the selection (form field or contenteditable). */
43
+ readonly editable: boolean;
44
+ }
45
+ /**
46
+ * A multi payload whose items are all strings; the only kind `setData` accepts.
47
+ * Web custom formats (`web …`) are skipped: only the async Clipboard API writes them.
48
+ */
49
+ interface SyncMultiPayload {
50
+ readonly kind: 'multi';
51
+ readonly items: readonly {
52
+ readonly mimeType: string;
53
+ readonly data: string;
54
+ readonly optional?: boolean;
55
+ }[];
56
+ }
57
+ /** Payloads writable synchronously during a copy event. Images need the async clipboard. */
58
+ type SyncCopyPayload = TextPayload | HtmlPayload | JsonPayload | SyncMultiPayload;
59
+ /**
60
+ * What a transform returns:
61
+ * - a string or payload: write that instead of the selection
62
+ * - `false`: block the copy (nothing reaches the clipboard; a cut deletes nothing)
63
+ * - `null` / `undefined`: leave the browser's default copy untouched
64
+ *
65
+ * Must be synchronous: the clipboard closes when the event handler returns.
66
+ */
67
+ type CopyInterceptDecision = string | SyncCopyPayload | false | null | undefined;
68
+ type CopyInterceptTransform = (selection: CopySelection) => CopyInterceptDecision;
69
+ /**
70
+ * When the transform throws or returns something unwritable:
71
+ * - `'block'` (default): nothing is copied. Safe for redaction.
72
+ * - `'native'`: the browser's default copy proceeds unmodified.
73
+ */
74
+ type CopyInterceptFailureMode = 'block' | 'native';
75
+ interface CopyInterceptOptions {
76
+ readonly transform: CopyInterceptTransform;
77
+ readonly failureMode?: CopyInterceptFailureMode;
78
+ }
79
+ type CopyInterceptPassReason =
80
+ /** Not a `copy`/`cut` event. */
81
+ 'unsupported-event' |
82
+ /** Another handler already called `preventDefault()`. */
83
+ 'already-handled' |
84
+ /** Nothing readable was selected. */
85
+ 'no-selection' |
86
+ /** The transform returned `null`/`undefined`. */
87
+ 'declined';
88
+ type CopyInterceptOutcome = {
89
+ readonly status: 'passed';
90
+ readonly reason: CopyInterceptPassReason;
91
+ readonly selection: CopySelection | null;
92
+ } | {
93
+ readonly status: 'written';
94
+ readonly selection: CopySelection;
95
+ readonly payload: SyncCopyPayload;
96
+ /** For an editable `cut`: whether the selection was removed. Always `false` for `copy`. */
97
+ readonly deleted: boolean;
98
+ } | {
99
+ readonly status: 'blocked';
100
+ readonly selection: CopySelection;
101
+ } | {
102
+ readonly status: 'failed';
103
+ readonly selection: CopySelection;
104
+ readonly error: CopyError;
105
+ /** What actually happened to the copy. */
106
+ readonly fallback: CopyInterceptFailureMode;
107
+ };
108
+ /** Reads the selection behind a copy event, or `null` if nothing readable is selected. */
109
+ declare function readCopySelection(event: CopyEventLike): CopySelection | null;
110
+ /**
111
+ * Applies a transform to one `copy`/`cut` event. Use directly from an
112
+ * `onCopy` handler, or let {@link registerCopyInterceptor} scope it.
113
+ */
114
+ declare function interceptCopyEvent(event: CopyEventLike, options: CopyInterceptOptions): CopyInterceptOutcome;
115
+ interface CopyInterceptorOptions extends CopyInterceptOptions {
116
+ /**
117
+ * When one selection touches several scopes, exactly one handles it: the
118
+ * highest `priority`, then the innermost, then the first in the document.
119
+ * The winner sees the *whole* selection. Give redaction scopes a higher
120
+ * priority so text copied across them is always masked. Default `0`.
121
+ */
122
+ readonly priority?: number;
123
+ /** Which events to intercept. Default: both `copy` and `cut`. */
124
+ readonly events?: readonly InterceptedCopyKind[];
125
+ /** Every outcome for selections inside this scope, including `passed`. */
126
+ readonly onIntercept?: (outcome: CopyInterceptOutcome) => void;
127
+ /** Called when the transform failed; the outcome's `fallback` says what happened to the copy. */
128
+ readonly onError?: (error: CopyError) => void;
129
+ }
130
+ /**
131
+ * Intercepts native copies and cuts whose selection touches `root`. Returns
132
+ * an unsubscribe function. Pass a getter to always read the latest options.
133
+ *
134
+ * One listener per document serves every scope, so overlapping scopes
135
+ * resolve deterministically (see `priority`) regardless of registration order.
136
+ * Handlers that call `preventDefault()` first (e.g. a React `onCopy`) win.
137
+ */
138
+ declare function registerCopyInterceptor(root: Element, options: CopyInterceptorOptions | (() => CopyInterceptorOptions)): () => void;
139
+ //#endregion
140
+ export { registerCopyInterceptor as _, CopyInterceptOptions as a, CopyInterceptTransform as c, DEFAULT_INTERCEPTED_EVENTS as d, InterceptedCopyKind as f, readCopySelection as g, interceptCopyEvent as h, CopyInterceptFailureMode as i, CopyInterceptorOptions as l, SyncMultiPayload as m, CopyEventLike as n, CopyInterceptOutcome as o, SyncCopyPayload as p, CopyInterceptDecision as r, CopyInterceptPassReason as s, ClipboardDataLike as t, CopySelection as u };
141
+ //# sourceMappingURL=copy-interceptor-C6NABy1l.d.ts.map
@@ -0,0 +1,141 @@
1
+
2
+ import { f as TextPayload, l as JsonPayload, o as HtmlPayload, v as CopyError } from "./payload-CcwKJ_bU.cjs";
3
+ //#region src/core/copy-interceptor.d.ts
4
+ /**
5
+ * Native copy interception: rewrite, redact or block what lands on the
6
+ * clipboard when the user copies (Ctrl/Cmd+C, context menu) or cuts inside a
7
+ * scope.
8
+ *
9
+ * Writes go through `event.clipboardData` synchronously, so no permission
10
+ * prompt, no secure-context requirement, and it works in every browser. The
11
+ * price is that only strings can be written, which the types enforce.
12
+ *
13
+ * Not a security boundary: users can still screenshot, use dev tools or
14
+ * disable script. Treat redaction as a guard against accidents.
15
+ */
16
+ type InterceptedCopyKind = 'copy' | 'cut';
17
+ declare const DEFAULT_INTERCEPTED_EVENTS: readonly InterceptedCopyKind[];
18
+ /** The writable slice of `DataTransfer` during a `copy`/`cut` event. */
19
+ interface ClipboardDataLike {
20
+ setData(format: string, data: string): void;
21
+ clearData?(format?: string): void;
22
+ }
23
+ /** Structural `ClipboardEvent`: DOM and React clipboard events both satisfy it. */
24
+ interface CopyEventLike {
25
+ readonly type: string;
26
+ readonly target: EventTarget | null;
27
+ readonly clipboardData: ClipboardDataLike | null;
28
+ readonly defaultPrevented: boolean;
29
+ preventDefault(): void;
30
+ }
31
+ /** What the user selected when they copied. */
32
+ interface CopySelection {
33
+ readonly kind: InterceptedCopyKind;
34
+ /** What the browser would put on the clipboard as `text/plain`. */
35
+ readonly text: string;
36
+ /** Serialised HTML of the selection; `null` inside text inputs. */
37
+ readonly html: string | null;
38
+ /** A detached clone of the selected nodes, safe to mutate; `null` inside text inputs. */
39
+ readonly fragment: DocumentFragment | null;
40
+ /** The `<input>`/`<textarea>` the selection lives in, if any. */
41
+ readonly field: HTMLInputElement | HTMLTextAreaElement | null;
42
+ /** Whether a `cut` would remove the selection (form field or contenteditable). */
43
+ readonly editable: boolean;
44
+ }
45
+ /**
46
+ * A multi payload whose items are all strings; the only kind `setData` accepts.
47
+ * Web custom formats (`web …`) are skipped: only the async Clipboard API writes them.
48
+ */
49
+ interface SyncMultiPayload {
50
+ readonly kind: 'multi';
51
+ readonly items: readonly {
52
+ readonly mimeType: string;
53
+ readonly data: string;
54
+ readonly optional?: boolean;
55
+ }[];
56
+ }
57
+ /** Payloads writable synchronously during a copy event. Images need the async clipboard. */
58
+ type SyncCopyPayload = TextPayload | HtmlPayload | JsonPayload | SyncMultiPayload;
59
+ /**
60
+ * What a transform returns:
61
+ * - a string or payload: write that instead of the selection
62
+ * - `false`: block the copy (nothing reaches the clipboard; a cut deletes nothing)
63
+ * - `null` / `undefined`: leave the browser's default copy untouched
64
+ *
65
+ * Must be synchronous: the clipboard closes when the event handler returns.
66
+ */
67
+ type CopyInterceptDecision = string | SyncCopyPayload | false | null | undefined;
68
+ type CopyInterceptTransform = (selection: CopySelection) => CopyInterceptDecision;
69
+ /**
70
+ * When the transform throws or returns something unwritable:
71
+ * - `'block'` (default): nothing is copied. Safe for redaction.
72
+ * - `'native'`: the browser's default copy proceeds unmodified.
73
+ */
74
+ type CopyInterceptFailureMode = 'block' | 'native';
75
+ interface CopyInterceptOptions {
76
+ readonly transform: CopyInterceptTransform;
77
+ readonly failureMode?: CopyInterceptFailureMode;
78
+ }
79
+ type CopyInterceptPassReason =
80
+ /** Not a `copy`/`cut` event. */
81
+ 'unsupported-event' |
82
+ /** Another handler already called `preventDefault()`. */
83
+ 'already-handled' |
84
+ /** Nothing readable was selected. */
85
+ 'no-selection' |
86
+ /** The transform returned `null`/`undefined`. */
87
+ 'declined';
88
+ type CopyInterceptOutcome = {
89
+ readonly status: 'passed';
90
+ readonly reason: CopyInterceptPassReason;
91
+ readonly selection: CopySelection | null;
92
+ } | {
93
+ readonly status: 'written';
94
+ readonly selection: CopySelection;
95
+ readonly payload: SyncCopyPayload;
96
+ /** For an editable `cut`: whether the selection was removed. Always `false` for `copy`. */
97
+ readonly deleted: boolean;
98
+ } | {
99
+ readonly status: 'blocked';
100
+ readonly selection: CopySelection;
101
+ } | {
102
+ readonly status: 'failed';
103
+ readonly selection: CopySelection;
104
+ readonly error: CopyError;
105
+ /** What actually happened to the copy. */
106
+ readonly fallback: CopyInterceptFailureMode;
107
+ };
108
+ /** Reads the selection behind a copy event, or `null` if nothing readable is selected. */
109
+ declare function readCopySelection(event: CopyEventLike): CopySelection | null;
110
+ /**
111
+ * Applies a transform to one `copy`/`cut` event. Use directly from an
112
+ * `onCopy` handler, or let {@link registerCopyInterceptor} scope it.
113
+ */
114
+ declare function interceptCopyEvent(event: CopyEventLike, options: CopyInterceptOptions): CopyInterceptOutcome;
115
+ interface CopyInterceptorOptions extends CopyInterceptOptions {
116
+ /**
117
+ * When one selection touches several scopes, exactly one handles it: the
118
+ * highest `priority`, then the innermost, then the first in the document.
119
+ * The winner sees the *whole* selection. Give redaction scopes a higher
120
+ * priority so text copied across them is always masked. Default `0`.
121
+ */
122
+ readonly priority?: number;
123
+ /** Which events to intercept. Default: both `copy` and `cut`. */
124
+ readonly events?: readonly InterceptedCopyKind[];
125
+ /** Every outcome for selections inside this scope, including `passed`. */
126
+ readonly onIntercept?: (outcome: CopyInterceptOutcome) => void;
127
+ /** Called when the transform failed; the outcome's `fallback` says what happened to the copy. */
128
+ readonly onError?: (error: CopyError) => void;
129
+ }
130
+ /**
131
+ * Intercepts native copies and cuts whose selection touches `root`. Returns
132
+ * an unsubscribe function. Pass a getter to always read the latest options.
133
+ *
134
+ * One listener per document serves every scope, so overlapping scopes
135
+ * resolve deterministically (see `priority`) regardless of registration order.
136
+ * Handlers that call `preventDefault()` first (e.g. a React `onCopy`) win.
137
+ */
138
+ declare function registerCopyInterceptor(root: Element, options: CopyInterceptorOptions | (() => CopyInterceptorOptions)): () => void;
139
+ //#endregion
140
+ export { registerCopyInterceptor as _, CopyInterceptOptions as a, CopyInterceptTransform as c, DEFAULT_INTERCEPTED_EVENTS as d, InterceptedCopyKind as f, readCopySelection as g, interceptCopyEvent as h, CopyInterceptFailureMode as i, CopyInterceptorOptions as l, SyncMultiPayload as m, CopyEventLike as n, CopyInterceptOutcome as o, SyncCopyPayload as p, CopyInterceptDecision as r, CopyInterceptPassReason as s, ClipboardDataLike as t, CopySelection as u };
141
+ //# sourceMappingURL=copy-interceptor-CZWzGOkL.d.cts.map