{"version":3,"file":"constants.mjs","sources":["../../../src/color/constants.ts"],"sourcesContent":["/**\n * Regex matching color in RGB or RGBA formats (ex: `rgb(0, 0, 0)`, `rgba(255, 100, 10, 0.5)`, `rgba( 255 , 100 , 10 , 0.5 )`, `rgb(1,1,1)`, `rgba(100%, 60%, 10%, 0.5)`)\n * Also matching rgba(r g b / a) as per new specs\n * https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb\n * Formal syntax at the time of writing:\n * <rgb()> =\n *  rgb( [ <percentage> | none ]{3} [ / [ <alpha-value> | none ] ]? )  |\n *  rgb( [ <number> | none ]{3} [ / [ <alpha-value> | none ] ]? )\n * <alpha-value> = <number> | <percentage>\n *\n * For learners this is how you can read this regex\n * Regular expression for matching an rgba or rgb CSS color value\n *\n * /^          # Beginning of the string\n * rgba?       # \"rgb\" or \"rgba\"\n * \\(\\s*       # Opening parenthesis and optional whitespace\n * (\\d{0,3}    # 0 to three digits R channel\n *  (?:\\.\\d+)? # Optional decimal with one or more digits\n * )           # End of capturing group for the first color component\n * %?          # Optional percent sign after the first color component\n * \\s*         # Optional whitespace\n * [\\s|,]      # Separator between color components can be a space or comma\n * \\s*         # Optional whitespace\n * (\\d{0,3}    # 0 to three digits G channel\n *  (?:\\.\\d+)? # Optional decimal with one or more digits\n * )           # End of capturing group for the second color component\n * %?          # Optional percent sign after the second color component\n * \\s*         # Optional whitespace\n * [\\s|,]      # Separator between color components can be a space or comma\n * \\s*         # Optional whitespace\n * (\\d{0,3}    # 0 to three digits B channel\n *  (?:\\.\\d+)? # Optional decimal with one or more digits\n * )           # End of capturing group for the third color component\n * %?          # Optional percent sign after the third color component\n * \\s*         # Optional whitespace\n * (?:         # Beginning of non-capturing group for alpha value\n *  \\s*        # Optional whitespace\n *  [,/]       # Comma or slash separator for alpha value\n *  \\s*        # Optional whitespace\n *  (\\d{0,3}   # Zero to three digits\n *    (?:\\.\\d+)? # Optional decimal with one or more digits\n *  )          # End of capturing group for alpha value\n *  %?         # Optional percent sign after alpha value\n *  \\s*        # Optional whitespace\n * )?          # End of non-capturing group for alpha value (optional)\n * \\)          # Closing parenthesis\n * $           # End of the string\n *\n * The alpha channel can be in the format 0.4 .7 or 1 or 73%\n *\n * WARNING this regex doesn't fail on off spec colors. it matches everything that could be a color.\n * So the spec does not allow for `rgba(30 , 45%  35, 49%)` but this will work anyways for us\n */\nexport const reRGBa = () =>\n  /^rgba?\\(\\s*(\\d{0,3}(?:\\.\\d+)?%?)\\s*[\\s|,]\\s*(\\d{0,3}(?:\\.\\d+)?%?)\\s*[\\s|,]\\s*(\\d{0,3}(?:\\.\\d+)?%?)\\s*(?:\\s*[,/]\\s*(\\d{0,3}(?:\\.\\d+)?%?)\\s*)?\\)$/i;\n\n/**\n * Regex matching color in HSL or HSLA formats (ex: hsl(0, 0, 0), rgba(255, 100, 10, 0.5), rgba( 255 , 100 , 10 , 0.5 ), rgb(1,1,1), rgba(100%, 60%, 10%, 0.5))\n * Also matching rgba(r g b / a) as per new specs\n * https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hsl\n * Formal syntax at the time of writing:\n * <hsl()> =\n *   hsl( [ <hue> | none ] [ <percentage> | none ] [ <percentage> | none ] [ / [ <alpha-value> | none ] ]? )\n *\n * <hue> =\n *   <number>  |\n *   <angle>\n *\n * <alpha-value> =\n *   <number>      |\n *   <percentage>\n *\n * For learners this is how you can read this regex\n * Regular expression for matching an hsla or hsl CSS color value\n *\n * /^hsla?\\(         // Matches the beginning of the string and the opening parenthesis of \"hsl\" or \"hsla\"\n * \\s*               // Matches any whitespace characters (space, tab, etc.) zero or more times\n * (\\d{0,3}          // Hue: 0 to three digits - start capture in a group\n * (?:\\.\\d+)?        // Hue: Optional (non capture group) decimal with one or more digits.\n * (?:deg|turn|rad)? // Hue: Optionally include suffix deg or turn or rad\n * )                 // Hue: End capture group\n * \\s*               // Matches any whitespace characters zero or more times\n * [\\s|,]            // Matches a space, tab or comma\n * \\s*               // Matches any whitespace characters zero or more times\n * (\\d{0,3}          // Saturation: 0 to three digits - start capture in a group\n * (?:\\.\\d+)?        // Saturation: Optional decimal with one or more digits in a non-capturing group\n * %?)               // Saturation: match optional % character and end capture group\n * \\s*               // Matches any whitespace characters zero or more times\n * [\\s|,]            // Matches a space, tab or comma\n * \\s*               // Matches any whitespace characters zero or more times\n * (\\d{0,3}          // Lightness: 0 to three digits - start capture in a group\n * (?:\\.\\d+)?        // Lightness: Optional decimal with one or more digits in a non-capturing group\n * %?)                // Lightness: match % character and end capture group\n * \\s*               // Matches any whitespace characters zero or more times\n * (?:               // Alpha: Begins a non-capturing group for the alpha value\n *   \\s*             // Matches any whitespace characters zero or more times\n *   [,/]            // Matches a comma or forward slash\n *   \\s*             // Matches any whitespace characters zero or more times\n *   (\\d*(?:\\.\\d+)?%?) // Matches zero or more digits, optionally followed by a decimal point and one or more digits, followed by an optional percentage sign and captures it in a group\n *   \\s*             // Matches any whitespace characters zero or more times\n * )?                // Makes the alpha value group optional\n * \\)                // Matches the closing parenthesis\n * $/i               // Matches the end of the string and sets the regular expression to case-insensitive mode\n *\n * WARNING this regex doesn't fail on off spec colors. It matches everything that could be a color.\n * So the spec does not allow `hsl(30 , 45%  35, 49%)` but this will work anyways for us.\n */\nexport const reHSLa = () =>\n  /^hsla?\\(\\s*([+-]?\\d{0,3}(?:\\.\\d+)?(?:deg|turn|rad)?)\\s*[\\s|,]\\s*(\\d{0,3}(?:\\.\\d+)?%?)\\s*[\\s|,]\\s*(\\d{0,3}(?:\\.\\d+)?%?)\\s*(?:\\s*[,/]\\s*(\\d*(?:\\.\\d+)?%?)\\s*)?\\)$/i;\n\n/**\n * Regex matching color in HEX format (ex: #FF5544CC, #FF5555, 010155, aff)\n */\nexport const reHex = () => /^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i;\n"],"names":["reRGBa","reHSLa","reHex"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACaA,MAAAA,MAAM,GAAGA,MACpB,mJAAkJ;;AAEpJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACaC,MAAAA,MAAM,GAAGA,MACpB,mKAAkK;;AAEpK;AACA;AACA;AACaC,MAAAA,KAAK,GAAGA,MAAM;;;;"}