{"version":3,"sources":["../src/helpers.ts"],"names":["clamp","n","min","max","round","d","p","normalizeHue","h","ANGLE_UNITS","isNumber","isAnyNumber","sanitize","isObject","v","isWs","c","NUM","NUM_OR_NONE","parseNum","isNone","toByte","round3"],"mappings":"aAAO,IAAMA,CAAAA,CAAQ,CAACC,CAAAA,CAAWC,CAAAA,CAAaC,IAAwB,IAAA,CAAK,GAAA,CAAI,KAAK,GAAA,CAAIF,CAAAA,CAAGC,CAAG,CAAA,CAAGC,CAAG,EAEvFC,CAAAA,CAAQ,CAACH,EAAWI,CAAAA,CAAI,CAAA,GAAc,CACjD,IAAMC,CAAAA,CAAI,EAAA,EAAMD,EAChB,OAAO,IAAA,CAAK,MAAMC,CAAAA,CAAIL,CAAC,EAAIK,CAC7B,CAAA,CAIaC,EAAgBC,CAAAA,EAAuBA,CAAAA,EAAK,GAAKA,CAAAA,CAAI,GAAA,CAAMA,GAAMA,CAAAA,CAAI,GAAA,CAAO,KAAO,GAAA,CAEnFC,CAAAA,CAAsC,CAAE,GAAA,CAAK,CAAA,CAAG,IAAA,CAAM,GAAK,IAAA,CAAM,GAAA,CAAK,IAAK,GAAA,EAAO,CAAA,CAAI,KAAK,EAAA,CAAI,CAAA,CAE/FC,EAAYT,CAAAA,EAA4B,OAAOA,GAAM,QAAA,EAAY,CAAC,OAAO,KAAA,CAAMA,CAAC,GAAK,MAAA,CAAO,QAAA,CAASA,CAAC,CAAA,CAGtGU,CAAAA,CAAeV,CAAAA,EAA4B,OAAOA,CAAAA,EAAM,QAAA,CAGxDW,EAAYX,CAAAA,EAAuB,MAAA,CAAO,MAAMA,CAAC,CAAA,CAAI,EAAIA,CAAAA,CAEzDY,CAAAA,CAAYC,GACvB,OAAOA,CAAAA,EAAM,UAAYA,CAAAA,GAAM,IAAA,EAAQ,CAAC,KAAA,CAAM,OAAA,CAAQA,CAAC,CAAA,CAI5CC,CAAAA,CAAQC,CAAAA,EACfA,IAAM,EAAA,EAAOA,CAAAA,EAAK,GAAKA,CAAAA,EAAK,EAAA,CAAY,KACxCA,CAAAA,CAAI,GAAA,CAAa,MAEnBA,CAAAA,GAAM,GAAA,EACNA,IAAM,IAAA,EACLA,CAAAA,EAAK,MAAUA,CAAAA,EAAK,IAAA,EACrBA,IAAM,IAAA,EACNA,CAAAA,GAAM,IAAA,EACNA,CAAAA,GAAM,IAAA,EACNA,CAAAA,GAAM,MACNA,CAAAA,GAAM,KAAA,EACNA,IAAM,KAAA,CAOGC,CAAAA,CAAM,4BACNC,CAAAA,CAAc,CAAA,QAAA,EAAWD,CAAG,CAAA,CAAA,CAAA,CAG5BE,CAAAA,CAAYL,GAAuBA,CAAAA,CAAE,WAAA,KAAkB,MAAA,CAAS,CAAA,CAAI,OAAOA,CAAC,CAAA,CAG5EM,CAAAA,CAAUN,CAAAA,EACrBA,CAAAA,CAAE,MAAA,GAAW,IACZA,CAAAA,CAAE,UAAA,CAAW,CAAC,CAAA,CAAI,EAAA,IAAQ,MAC1BA,CAAAA,CAAE,UAAA,CAAW,CAAC,CAAA,CAAI,EAAA,IAAQ,MAC1BA,CAAAA,CAAE,UAAA,CAAW,CAAC,CAAA,CAAI,EAAA,IAAQ,MAC1BA,CAAAA,CAAE,UAAA,CAAW,CAAC,CAAA,CAAI,EAAA,IAAQ,GAAA,CAGhBO,EAAUpB,CAAAA,EAAuBA,CAAAA,CAAI,EAAKA,CAAAA,CAAI,GAAA,CAAM,KAAK,KAAA,CAAMA,CAAC,CAAA,CAAI,GAAA,CAAO,CAAA,CAG3EqB,CAAAA,CAAUrB,GAAuBA,CAAAA,CAAI,CAAA,CAAKA,EAAI,CAAA,CAAI,IAAA,CAAK,MAAMA,CAAAA,CAAI,GAAI,CAAA,CAAI,GAAA,CAAO,CAAA,CAAK","file":"chunk-N6G3T2DD.cjs","sourcesContent":["export const clamp = (n: number, min: number, max: number): number => Math.min(Math.max(n, min), max);\n\nexport const round = (n: number, d = 0): number => {\n  const p = 10 ** d;\n  return Math.round(p * n) / p;\n};\n\n// Normalize hue to [0, 360). Avoids (h + 360) % 360 which can lose precision\n// when h is already in [0, 360) due to binary floating-point subtraction.\nexport const normalizeHue = (h: number): number => (h >= 0 && h < 360 ? h : ((h % 360) + 360) % 360);\n\nexport const ANGLE_UNITS: Record<string, number> = { deg: 1, grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };\n\nexport const isNumber = (n: unknown): n is number => typeof n === 'number' && !Number.isNaN(n) && Number.isFinite(n);\n\n// Accepts any JS number type (including NaN/±Infinity); use sanitize() before clamping\nexport const isAnyNumber = (n: unknown): n is number => typeof n === 'number';\n\n// Replace NaN with 0; ±Infinity is left for clamp() to handle naturally\nexport const sanitize = (n: number): number => (Number.isNaN(n) ? 0 : n);\n\nexport const isObject = (v: unknown): v is Record<string, unknown> =>\n  typeof v === 'object' && v !== null && !Array.isArray(v);\n\n// Must match JS regex `\\s` exactly, since these scanners replace regexes:\n// [\\t\\n\\v\\f\\r \\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff]\nexport const isWs = (c: number): boolean => {\n  if (c === 32 || (c >= 9 && c <= 13)) return true; // space, \\t \\n \\v \\f \\r — the hot path\n  if (c < 0xa0) return false;\n  return (\n    c === 0xa0 ||\n    c === 0x1680 ||\n    (c >= 0x2000 && c <= 0x200a) ||\n    c === 0x2028 ||\n    c === 0x2029 ||\n    c === 0x202f ||\n    c === 0x205f ||\n    c === 0x3000 ||\n    c === 0xfeff\n  );\n};\n\n// Shared regex fragments. NUM matches a signed decimal, NUM_OR_NONE adds the CSS Color 4 `none` keyword.\n// The alternation is deliberate: the shorter `\\\\d*\\\\.?\\\\d+` is ambiguous and backtracks\n// quadratically on a long digit run that ultimately fails to match.\nexport const NUM = '[+-]?(?:\\\\d*\\\\.\\\\d+|\\\\d+)';\nexport const NUM_OR_NONE = `(?:none|${NUM})`;\n\n/** Parse a CSS Color 4 channel token. `none` → 0; a plain number is returned as-is. */\nexport const parseNum = (v: string): number => (v.toLowerCase() === 'none' ? 0 : Number(v));\n\n/** `none` check without a regex or a toLowerCase allocation. */\nexport const isNone = (v: string): boolean =>\n  v.length === 4 &&\n  (v.charCodeAt(0) | 32) === 110 &&\n  (v.charCodeAt(1) | 32) === 111 &&\n  (v.charCodeAt(2) | 32) === 110 &&\n  (v.charCodeAt(3) | 32) === 101;\n\n/** Clamp+round to a 0-255 byte, avoiding the generic round()'s `10 ** 0` per channel. */\nexport const toByte = (n: number): number => (n > 0 ? (n < 255 ? Math.round(n) : 255) : 0);\n\n/** Clamp+round alpha to 3 decimals, likewise avoiding the generic round(). */\nexport const round3 = (n: number): number => (n > 0 ? (n < 1 ? Math.round(n * 1000) / 1000 : 1) : 0);\n"]}