UNPKG

@devlander/colors

Version:

Color utility package used between packages

3 lines (2 loc) 27.9 kB
"use strict";function r(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function e(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,i(n.key),n)}}function t(r,e,t){return(e=i(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function n(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),t.push.apply(t,n)}return t}function o(r){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?n(Object(o),!0).forEach((function(e){t(r,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}))}return r}function a(e,t){return function(r){if(Array.isArray(r))return r}(e)||function(r,e){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var n,o,a,i,l=[],g=!0,u=!1;try{if(a=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;g=!1}else for(;!(g=(n=a.call(t)).done)&&(l.push(n.value),l.length!==e);g=!0);}catch(r){u=!0,o=r}finally{try{if(!g&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(u)throw o}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return r(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(r){var e=function(r,e){if("object"!=typeof r||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==typeof e?e:e+""}function l(r){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},l(r)}var g=function(r,e){var t;t=e>1?e/100:e;var n=Math.min(Math.max(t,0),1);return o(o({},r),{},{a:n})},u=function(r,e){if(e&&!0===e&&console.log("Testing hex: ".concat(r)),"string"!=typeof r)return!1;var t=/^#?([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(r);return e&&!0===e&&(console.log("Testing hex: ".concat(r)),console.log("Result for ".concat(r,": ").concat(t))),t};function b(r){var e=r.r,t=r.g,n=r.b,o=r.a;return e<0||e>255||(t<0||t>255||(n<0||n>255||void 0!==o&&(o<0||o>1)))}var c,h=function(r){try{var e=r.match(/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/);if(!e)return!1;var t=a(e.map(Number),4);return!b({r:t[1],g:t[2],b:t[3]})}catch(e){return console.error("Error validating RGB string: ".concat(r),e),!1}},s=function(r){try{var e=r.match(/^rgba?\(\s*((?:\d{1,3}%?\s*,\s*){2})(?:\d{1,3}%?\s*,\s*)\d{1,3}%?\s*(?:,\s*([+-]?\d*\.?\d+)\s*)?\)$/);if(!e)return!1;var t=function(r){var e=Number(r.replace("%",""));return r.includes("%")?2.55*e:e};return!b({r:t(e[1].trim()),g:t(e[2].trim()),b:t(e[3].trim()),a:void 0!==e[4]?Number(e[4]):void 0})}catch(e){return console.error("Error validating RGBA string: ".concat(r),e),!1}},f=function(r){return!!(arguments.length>1&&void 0!==arguments[1]?arguments[1]:["transparent"]).includes(r)||(u(r)||h(r)||s(r))},d=function(r,e){var t=Math.abs(e)>1?e/100:e;return{r:Math.min(255,Math.max(0,Math.round(e<0?r.r*(1+e):r.r+t*(255-r.r)))),g:Math.min(255,Math.max(0,Math.round(e<0?r.g*(1+e):r.g+t*(255-r.g)))),b:Math.min(255,Math.max(0,Math.round(e<0?r.b*(1+e):r.b+t*(255-r.b))))}},p=function(r,e){var t=Math.abs(e)>1?e/100:e;return{r:Math.max(0,Math.min(255,Math.round(e<0?r.r-t*(255-r.r):r.r*(1-t)))),g:Math.max(0,Math.min(255,Math.round(e<0?r.g-t*(255-r.g):r.g*(1-t)))),b:Math.max(0,Math.min(255,Math.round(e<0?r.b-t*(255-r.b):r.b*(1-t))))}},y=function(r){var e=function(r){return r.toString(16).padStart(2,"0")};return"#".concat(e(r.r)).concat(e(r.g)).concat(e(r.b)).toUpperCase()},x=function(r){if(void 0!==r.a){var e=Math.round(10*r.a)/10;return"rgba(".concat(r.r,", ").concat(r.g,", ").concat(r.b,", ").concat(e,")")}return"rgb(".concat(r.r,", ").concat(r.g,", ").concat(r.b,")")},m=function(r,e,t){var n;n=Math.abs(t)>1?t/100:t;var o=Math.min(Math.max(n,-1),1);return{r:Math.round(r.r*Math.abs(o)+e.r*(1-Math.abs(o))),g:Math.round(r.g*Math.abs(o)+e.g*(1-Math.abs(o))),b:Math.round(r.b*Math.abs(o)+e.b*(1-Math.abs(o)))}},F=function(r){try{var e=null;if(h(r)){e=/^rgb\(\s*(\d{1,3}%?)\s*,\s*(\d{1,3}%?)\s*,\s*(\d{1,3}%?)\s*\)$/.exec(r)}else if(s(r)){e=/^rgba\(\s*(\d{1,3}%?)\s*,\s*(\d{1,3}%?)\s*,\s*(\d{1,3}%?)\s*,\s*(0|1|0?\.\d+)\s*\)$/.exec(r)}if(e){var t=a(e.slice(1).map((function(r){return r.endsWith("%")?(e=r,Math.round(2.55*parseFloat(e))):Number(r);var e})),4),n=t[0],o=t[1],i=t[2],l=t[3],g={r:n,g:o,b:i};return void 0!==l&&(g.a=Number(l)),g}return null}catch(r){return console.error("Error parsing RGB string:",r),null}};function v(r,e,t){return e=E(e),function(r,e){if(e&&("object"==l(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return A(r)}(r,w()?Reflect.construct(e,t||[],E(r).constructor):e.apply(r,t))}function w(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(r){}return(w=function(){return!!r})()}function B(r){var e=function(r){if("object"!=l(r)||!r)return r;var e=r[Symbol.toPrimitive];if(void 0!==e){var t=e.call(r,"string");if("object"!=l(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}(r);return"symbol"==l(e)?e:String(e)}function k(r){return k="function"==typeof Symbol&&"symbol"==l(Symbol.iterator)?function(r){return l(r)}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":l(r)},k(r)}function D(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,B(n.key),n)}}function E(r){return E=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},E(r)}function C(r,e){return C=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,e){return r.__proto__=e,r},C(r,e)}function S(r){var e="function"==typeof Map?new Map:void 0;return S=function(r){if(null===r||!function(r){try{return-1!==Function.toString.call(r).indexOf("[native code]")}catch(e){return"function"==typeof r}}(r))return r;if("function"!=typeof r)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(r))return e.get(r);e.set(r,t)}function t(){return function(r,e,t){if(w())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var o=new(r.bind.apply(r,n));return t&&C(o,t.prototype),o}(r,arguments,E(this).constructor)}return t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),C(t,r)},S(r)}function A(r){if(void 0===r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}(c={}).NONE="",c.K="K",c.M="M",c.B="B",c.T="T",c.P="P",c.E="E";!function(){function r(e,t,n){var o;return function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r),o=v(this,r,[e]),Error.captureStackTrace?Error.captureStackTrace(A(o),o.constructor):o.stack=(new Error).stack,o.name="DevlanderError",t&&(o.code=t),n&&(o.config=n),Object.defineProperty(A(o),"DevlanderError",{value:!0}),o}var e,t;(function(r,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),e&&C(r,e)})(r,S(Error)),e=r,t=[{key:"from",value:function(e,t,n,o){var a=Object.create(r.prototype);return function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0,o={};if(null==r)return e;var a=r;do{for(var i=Object.getOwnPropertyNames(a),l=i.length-1;l>=0;l--){var g=i[l];n&&!n(g,r,e)||o[g]||(e[g]=a[g],o[g]=!0)}a=Object.getPrototypeOf(a)}while(a&&(!t||t(a))&&a!==Object.prototype)}(e,a,(function(r){return r!==Error.prototype}),(function(r){return"DevlanderError"!==r})),r.call(a,e.message,t,n),a.cause=e,a.name=e.name,o&&Object.assign(a,o),a}}],null&&D(e.prototype,null),t&&D(e,t),Object.defineProperty(e,"prototype",{writable:!1})}();var M=function(r){return function(e){return k(e)===r}};!function(r){r["4:3"]="4:3",r["16:9"]="16:9",r["1:1"]="1:1",r["3:2"]="3:2",r["8:5"]="8:5"}({});var G,O=(G=Object.create(null),function(r){var e=toString.call(r);return G[e]||(G[e]=e.slice(8,-1).toLowerCase())}),P=function(r){return r=r.toLowerCase(),function(e){return O(e)===r}};P("ArrayBuffer"),P("Date"),P("File");var R=M("number"),j=function(r){return"string"==typeof r?""!==r.trim()&&r.trim()===r&&!isNaN(Number(r))&&isFinite(Number(r)):"number"==typeof r?!isNaN(r)&&isFinite(r):R(r)};var L={exports:{}},T=String,I=function(){return{isColorSupported:!1,reset:T,bold:T,dim:T,italic:T,underline:T,inverse:T,hidden:T,strikethrough:T,black:T,red:T,green:T,yellow:T,blue:T,magenta:T,cyan:T,white:T,gray:T,bgBlack:T,bgRed:T,bgGreen:T,bgYellow:T,bgBlue:T,bgMagenta:T,bgCyan:T,bgWhite:T}};L.exports=I(),L.exports.createColors=I,function(r){r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")&&r.default}(L.exports);var q,N=function(r,e){if("string"!=typeof r)return e&&!0===e&&console.log("Invalid type for hex: ".concat(l(r))),!1;var t=/^#?([0-9A-Fa-f]{3}|[0-9A-Fa-f]{4}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(r);return e&&!0===e&&console.log("Testing hex: ".concat(r,", Result: ").concat(t)),t},W=function(r){if(!r||"string"!=typeof r)throw new Error("Invalid hex color");var e=r.replace(/^#/,"");if(!N("#".concat(e)))throw new Error("Invalid hex color");var t=3===e.length||4===e.length,n=function(r){return r.repeat(2)};if(![3,4,6,8].includes(e.length))throw new Error("Invalid hex color length");return{r:t?n(e.slice(0,1)):r.slice(0,2),g:t?n(r.slice(1,2)):r.slice(2,4),b:t?n(r.slice(2,3)):r.slice(4,6),a:(t?n(r.slice(3,4)):r.slice(6,8))||"ff"}},V=function(r){return parseInt(r,16)},H=function(r){var e;e=!function(r){return null!==r&&"object"===k(r)}(r)||function(r){return M("string")(r)}(r)?W(r):{r:r.r,g:r.g,b:r.b,a:"a"in r?r.a:"ff"};var t=e,n=t.r,o=t.g,a=t.b,i=t.a,l={r:V(n),g:V(o),b:V(a)};return l.a=void 0!==i&&"ff"!==i?+(V(i)/255).toFixed(2):1,Y(l)},Y=function(r){return["r","g","b","a"].forEach((function(e){void 0!==r[e]&&isNaN(r[e])&&(r[e]=1)})),r},_=["transparent"],$=function(r){"undefined"!=typeof console&&"function"==typeof console.log&&console.log(r)},K=function(r,e,t){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:_;try{if(n.includes(r))return r;if(e<0||e>100)return $("Alpha value should be between 0.0 and 1.0. Returning default color."),"#FF0000";if(f(r)){var o=null;if(u(r)){var a=W(r);o=H(a)}else if(h(r))o=F(r);else{if(!s(r))throw new Error("Invalid color format");o=F(r)}if(!o)throw new Error("Failed to parse color");var i="light"===t?.2:-.2;o="light"===t?d(o,i):p(o,i);var l=e;if(u(r)){var b=m(o,{r:255,g:255,b:255},l);return y(b)}var c=g(o,l);return x(c)}return $("Failed to convert ".concat(r," into a color. Returning default color.")),"#FF0000"}catch(e){return e instanceof Error?$("Error adjusting color with value: ".concat(r,". Returning default color. Error: ").concat(e.message)):$("Error adjusting color with value: ".concat(r,". Returning default color. Unknown error.")),"#FF0000"}},z=function(){return function(r,t,n){return t&&e(r.prototype,t),n&&e(r,n),Object.defineProperty(r,"prototype",{writable:!1}),r}((function r(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"light";if(function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r),this.mode=t,"string"==typeof e){var n=e.replace("#","");this.color={r:V(n.substring(0,2)),g:V(n.substring(2,4)),b:V(n.substring(4,6))},8===n.length&&(this.color.a=+(V(n.substring(6,8))/255).toFixed(2))}else this.color=e}),[{key:"darken",value:function(r){return this.color=p(this.color,r),this}},{key:"lighten",value:function(r){return this.color=d(this.color,r),this}},{key:"rgb",value:function(){return x(this.color)}},{key:"hex",value:function(){return y(this.color)}},{key:"invert",value:function(){return this.mode="light"===this.mode?"dark":"light",K(this.hex(),1,this.mode)}},{key:"alpha",value:function(r){return this.color=g(this.color,r),this.color}},{key:"blend",value:function(r,e){return this.color=m(this.color,e,r),this}},{key:"getColor",value:function(){return this.color}}])}(),U=function(r){return r.AliceBlue="aliceblue",r.AntiqueWhite="antiquewhite",r.Aqua="aqua",r.Aquamarine="aquamarine",r.Azure="azure",r.Beige="beige",r.Bisque="bisque",r.Black="black",r.BlanchedAlmond="blanchedalmond",r.Blue="blue",r.BlueViolet="blueviolet",r.Brown="brown",r.BurlyWood="burlywood",r.CadetBlue="cadetblue",r.Chartreuse="chartreuse",r.Chocolate="chocolate",r.Coral="coral",r.CornflowerBlue="cornflowerblue",r.Cornsilk="cornsilk",r.Crimson="crimson",r.Cyan="cyan",r.DarkBlue="darkblue",r.DarkCyan="darkcyan",r.DarkGoldenRod="darkgoldenrod",r.DarkGray="darkgray",r.DarkGreen="darkgreen",r.DarkGrey="darkgrey",r.DarkKhaki="darkkhaki",r.DarkMagenta="darkmagenta",r.DarkOliveGreen="darkolivegreen",r.DarkOrange="darkorange",r.DarkOrchid="darkorchid",r.DarkRed="darkred",r.DarkSalmon="darksalmon",r.DarkSeaGreen="darkseagreen",r.DarkSlateBlue="darkslateblue",r.DarkSlateGray="darkslategray",r.DarkTurquoise="darkturquoise",r.DarkViolet="darkviolet",r.DeepPink="deeppink",r.DeepSkyBlue="deepskyblue",r.DimGray="dimgray",r.DimGrey="dimgrey",r.DodgerBlue="dodgerblue",r.FireBrick="firebrick",r.FloralWhite="floralwhite",r.ForestGreen="forestgreen",r.Fuchsia="fuchsia",r.Gainsboro="gainsboro",r.GhostWhite="ghostwhite",r.Gold="gold",r.GoldenRod="goldenrod",r.Gray="gray",r.Green="green",r.GreenYellow="greenyellow",r.HoneyDew="honeydew",r.HotPink="hotpink",r.IndianRed="indianred",r.Indigo="indigo",r.Ivory="ivory",r.Khaki="khaki",r.Lavender="lavender",r.LavenderBlush="lavenderblush",r.LawnGreen="lawngreen",r.LemonChiffon="lemonchiffon",r.LightBlue="lightblue",r.LightCoral="lightcoral",r.LightCyan="lightcyan",r.LightGoldenRodYellow="lightgoldenrodyellow",r.LightGray="lightgray",r.LightGreen="lightgreen",r.LightGrey="lightgrey",r.LightPink="lightpink",r.LightSalmon="lightsalmon",r.LightSeaGreen="lightseagreen",r.LightSkyBlue="lightskyblue",r.LightSlateGray="lightslategray",r.LightSteelBlue="lightsteelblue",r.LightYellow="lightyellow",r.Lime="lime",r.LimeGreen="limegreen",r.Linen="linen",r.Magenta="magenta",r.Maroon="maroon",r.MediumAquaMarine="mediumaquamarine",r.MediumBlue="mediumblue",r.MediumOrchid="mediumorchid",r.MediumPurple="mediumpurple",r.MediumSeaGreen="mediumseagreen",r.MediumSlateBlue="mediumslateblue",r.MediumSpringGreen="mediumspringgreen",r.MediumTurquoise="mediumturquoise",r.MediumVioletRed="mediumvioletred",r.MidnightBlue="midnightblue",r.MintCream="mintcream",r.MistyRose="mistyrose",r.Moccasin="moccasin",r.NavajoWhite="navajowhite",r.Navy="navy",r.OldLace="oldlace",r.Olive="olive",r.OliveDrab="olivedrab",r.Orange="orange",r.OrangeRed="orangered",r.Orchid="orchid",r.PaleGoldenRod="palegoldenrod",r.PaleGreen="palegreen",r.PaleTurquoise="paleturquoise",r.PaleVioletRed="palevioletred",r.PapayaWhip="papayawhip",r.PeachPuff="peachpuff",r.Peru="peru",r.Pink="pink",r.Plum="plum",r.PowderBlue="powderblue",r.Purple="purple",r.RebeccaPurple="rebeccapurple",r.Red="red",r.RosyBrown="rosybrown",r.RoyalBlue="royalblue",r.SaddleBrown="saddlebrown",r.Salmon="salmon",r.SandyBrown="sandybrown",r.SeaGreen="seagreen",r.SeaShell="seashell",r.Sienna="sienna",r.Silver="silver",r.SkyBlue="skyblue",r.SlateBlue="slateblue",r.SlateGray="slategray",r.Snow="snow",r.SpringGreen="springgreen",r.SteelBlue="steelblue",r.Tan="tan",r.Teal="teal",r.Thistle="thistle",r.Tomato="tomato",r.Turquoise="turquoise",r.Violet="violet",r.Wheat="wheat",r.White="white",r.WhiteSmoke="whitesmoke",r.Yellow="yellow",r.YellowGreen="yellowgreen",r}({}),X=(t(t(t(t(t(t(t(t(t(t(q={},U.AliceBlue,{rgb:{r:240,g:248,b:255},hex:"#F0F8FF"}),U.AntiqueWhite,{rgb:{r:250,g:235,b:215},hex:"#FAEBD7"}),U.Aqua,{rgb:{r:0,g:255,b:255},hex:"#00FFFF"}),U.Aquamarine,{rgb:{r:127,g:255,b:212},hex:"#7FFFD4"}),U.Azure,{rgb:{r:240,g:255,b:255},hex:"#F0FFFF"}),U.Beige,{rgb:{r:245,g:245,b:220},hex:"#F5F5DC"}),U.Bisque,{rgb:{r:255,g:228,b:196},hex:"#FFE4C4"}),U.Black,{rgb:{r:0,g:0,b:0},hex:"#000000"}),U.BlanchedAlmond,{rgb:{r:255,g:235,b:205},hex:"#FFEBCD"}),U.Blue,{rgb:{r:0,g:0,b:255},hex:"#0000FF"}),t(t(t(t(t(t(t(t(t(t(q,U.BlueViolet,{rgb:{r:138,g:43,b:226},hex:"#8A2BE2"}),U.Brown,{rgb:{r:165,g:42,b:42},hex:"#A52A2A"}),U.BurlyWood,{rgb:{r:222,g:184,b:135},hex:"#DEB887"}),U.CadetBlue,{rgb:{r:95,g:158,b:160},hex:"#5F9EA0"}),U.Chartreuse,{rgb:{r:127,g:255,b:0},hex:"#7FFF00"}),U.Chocolate,{rgb:{r:210,g:105,b:30},hex:"#D2691E"}),U.Coral,{rgb:{r:255,g:127,b:80},hex:"#FF7F50"}),U.CornflowerBlue,{rgb:{r:100,g:149,b:237},hex:"#6495ED"}),U.Cornsilk,{rgb:{r:255,g:248,b:220},hex:"#FFF8DC"}),U.Crimson,{rgb:{r:220,g:20,b:60},hex:"#DC143C"}),t(t(t(t(t(t(t(t(t(t(q,U.Cyan,{rgb:{r:0,g:255,b:255},hex:"#00FFFF"}),U.DarkBlue,{rgb:{r:0,g:0,b:139},hex:"#00008B"}),U.DarkCyan,{rgb:{r:0,g:139,b:139},hex:"#008B8B"}),U.DarkGoldenRod,{rgb:{r:184,g:134,b:11},hex:"#B8860B"}),U.DarkGray,{rgb:{r:169,g:169,b:169},hex:"#A9A9A9"}),U.DarkGreen,{rgb:{r:0,g:100,b:0},hex:"#006400"}),U.DarkGrey,{rgb:{r:169,g:169,b:169},hex:"#A9A9A9"}),U.DarkKhaki,{rgb:{r:189,g:183,b:107},hex:"#BDB76B"}),U.DarkMagenta,{rgb:{r:139,g:0,b:139},hex:"#8B008B"}),U.DarkOliveGreen,{rgb:{r:85,g:107,b:47},hex:"#556B2F"}),t(t(t(t(t(t(t(t(t(t(q,U.DarkOrange,{rgb:{r:255,g:140,b:0},hex:"#FF8C00"}),U.DarkOrchid,{rgb:{r:153,g:50,b:204},hex:"#9932CC"}),U.DarkRed,{rgb:{r:139,g:0,b:0},hex:"#8B0000"}),U.DarkSalmon,{rgb:{r:233,g:150,b:122},hex:"#E9967A"}),U.DarkSeaGreen,{rgb:{r:143,g:188,b:143},hex:"#8FBC8F"}),U.DarkSlateBlue,{rgb:{r:72,g:61,b:139},hex:"#483D8B"}),U.DarkSlateGray,{rgb:{r:47,g:79,b:79},hex:"#2F4F4F"}),U.DarkTurquoise,{rgb:{r:0,g:206,b:209},hex:"#00CED1"}),U.DarkViolet,{rgb:{r:148,g:0,b:211},hex:"#9400D3"}),U.DeepPink,{rgb:{r:255,g:20,b:147},hex:"#FF1493"}),t(t(t(t(t(t(t(t(t(t(q,U.DeepSkyBlue,{rgb:{r:0,g:191,b:255},hex:"#00BFFF"}),U.DimGray,{rgb:{r:105,g:105,b:105},hex:"#696969"}),U.DimGrey,{rgb:{r:105,g:105,b:105},hex:"#696969"}),U.DodgerBlue,{rgb:{r:30,g:144,b:255},hex:"#1E90FF"}),U.FireBrick,{rgb:{r:178,g:34,b:34},hex:"#B22222"}),U.FloralWhite,{rgb:{r:255,g:250,b:240},hex:"#FFFAF0"}),U.ForestGreen,{rgb:{r:34,g:139,b:34},hex:"#228B22"}),U.Fuchsia,{rgb:{r:255,g:0,b:255},hex:"#FF00FF"}),U.Gainsboro,{rgb:{r:220,g:220,b:220},hex:"#DCDCDC"}),U.GhostWhite,{rgb:{r:248,g:248,b:255},hex:"#F8F8FF"}),t(t(t(t(t(t(t(t(t(t(q,U.Gold,{rgb:{r:255,g:215,b:0},hex:"#FFD700"}),U.GoldenRod,{rgb:{r:218,g:165,b:32},hex:"#DAA520"}),U.Gray,{rgb:{r:128,g:128,b:128},hex:"#808080"}),U.Green,{rgb:{r:0,g:128,b:0},hex:"#008000"}),U.GreenYellow,{rgb:{r:173,g:255,b:47},hex:"#ADFF2F"}),U.HoneyDew,{rgb:{r:240,g:255,b:240},hex:"#F0FFF0"}),U.HotPink,{rgb:{r:255,g:105,b:180},hex:"#FF69B4"}),U.IndianRed,{rgb:{r:205,g:92,b:92},hex:"#CD5C5C"}),U.Indigo,{rgb:{r:75,g:0,b:130},hex:"#4B0082"}),U.Ivory,{rgb:{r:255,g:255,b:240},hex:"#FFFFF0"}),t(t(t(t(t(t(t(t(t(t(q,U.Khaki,{rgb:{r:240,g:230,b:140},hex:"#F0E68C"}),U.Lavender,{rgb:{r:230,g:230,b:250},hex:"#E6E6FA"}),U.LavenderBlush,{rgb:{r:255,g:240,b:245},hex:"#FFF0F5"}),U.LawnGreen,{rgb:{r:124,g:252,b:0},hex:"#7CFC00"}),U.LemonChiffon,{rgb:{r:255,g:250,b:205},hex:"#FFFACD"}),U.LightBlue,{rgb:{r:173,g:216,b:230},hex:"#ADD8E6"}),U.LightCoral,{rgb:{r:240,g:128,b:128},hex:"#F08080"}),U.LightCyan,{rgb:{r:224,g:255,b:255},hex:"#E0FFFF"}),U.LightGoldenRodYellow,{rgb:{r:250,g:250,b:210},hex:"#FAFAD2"}),U.LightGray,{rgb:{r:211,g:211,b:211},hex:"#D3D3D3"}),t(t(t(t(t(t(t(t(t(t(q,U.LightGreen,{rgb:{r:144,g:238,b:144},hex:"#90EE90"}),U.LightGrey,{rgb:{r:211,g:211,b:211},hex:"#D3D3D3"}),U.LightPink,{rgb:{r:255,g:182,b:193},hex:"#FFB6C1"}),U.LightSalmon,{rgb:{r:255,g:160,b:122},hex:"#FFA07A"}),U.LightSeaGreen,{rgb:{r:32,g:178,b:170},hex:"#20B2AA"}),U.LightSkyBlue,{rgb:{r:135,g:206,b:250},hex:"#87CEFA"}),U.LightSlateGray,{rgb:{r:119,g:136,b:153},hex:"#778899"}),U.LightSteelBlue,{rgb:{r:176,g:196,b:222},hex:"#B0C4DE"}),U.LightYellow,{rgb:{r:255,g:255,b:224},hex:"#FFFFE0"}),U.Lime,{rgb:{r:0,g:255,b:0},hex:"#00FF00"}),t(t(t(t(t(t(t(t(t(t(q,U.LimeGreen,{rgb:{r:50,g:205,b:50},hex:"#32CD32"}),U.Linen,{rgb:{r:250,g:240,b:230},hex:"#FAF0E6"}),U.Magenta,{rgb:{r:255,g:0,b:255},hex:"#FF00FF"}),U.Maroon,{rgb:{r:128,g:0,b:0},hex:"#800000"}),U.MediumAquaMarine,{rgb:{r:102,g:205,b:170},hex:"#66CDAA"}),U.MediumBlue,{rgb:{r:0,g:0,b:205},hex:"#0000CD"}),U.MediumOrchid,{rgb:{r:186,g:85,b:211},hex:"#BA55D3"}),U.MediumPurple,{rgb:{r:147,g:112,b:219},hex:"#9370DB"}),U.MediumSeaGreen,{rgb:{r:60,g:179,b:113},hex:"#3CB371"}),U.MediumSlateBlue,{rgb:{r:123,g:104,b:238},hex:"#7B68EE"}),t(t(t(t(t(t(t(t(t(t(q,U.MediumSpringGreen,{rgb:{r:0,g:250,b:154},hex:"#00FA9A"}),U.MediumTurquoise,{rgb:{r:72,g:209,b:204},hex:"#48D1CC"}),U.MediumVioletRed,{rgb:{r:199,g:21,b:133},hex:"#C71585"}),U.MidnightBlue,{rgb:{r:25,g:25,b:112},hex:"#191970"}),U.MintCream,{rgb:{r:245,g:255,b:250},hex:"#F5FFFA"}),U.MistyRose,{rgb:{r:255,g:228,b:225},hex:"#FFE4E1"}),U.Moccasin,{rgb:{r:255,g:228,b:181},hex:"#FFE4B5"}),U.NavajoWhite,{rgb:{r:255,g:222,b:173},hex:"#FFDEAD"}),U.Navy,{rgb:{r:0,g:0,b:128},hex:"#000080"}),U.OldLace,{rgb:{r:253,g:245,b:230},hex:"#FDF5E6"}),t(t(t(t(t(t(t(t(t(t(q,U.Olive,{rgb:{r:128,g:128,b:0},hex:"#808000"}),U.OliveDrab,{rgb:{r:107,g:142,b:35},hex:"#6B8E23"}),U.Orange,{rgb:{r:255,g:165,b:0},hex:"#FFA500"}),U.OrangeRed,{rgb:{r:255,g:69,b:0},hex:"#FF4500"}),U.Orchid,{rgb:{r:218,g:112,b:214},hex:"#DA70D6"}),U.PaleGoldenRod,{rgb:{r:238,g:232,b:170},hex:"#EEE8AA"}),U.PaleGreen,{rgb:{r:152,g:251,b:152},hex:"#98FB98"}),U.PaleTurquoise,{rgb:{r:175,g:238,b:238},hex:"#AFEEEE"}),U.PaleVioletRed,{rgb:{r:219,g:112,b:147},hex:"#DB7093"}),U.PapayaWhip,{rgb:{r:255,g:239,b:213},hex:"#FFEFD5"}),t(t(t(t(t(t(t(t(t(t(q,U.PeachPuff,{rgb:{r:255,g:218,b:185},hex:"#FFDAB9"}),U.Peru,{rgb:{r:205,g:133,b:63},hex:"#CD853F"}),U.Pink,{rgb:{r:255,g:192,b:203},hex:"#FFC0CB"}),U.Plum,{rgb:{r:221,g:160,b:221},hex:"#DDA0DD"}),U.PowderBlue,{rgb:{r:176,g:224,b:230},hex:"#B0E0E6"}),U.Purple,{rgb:{r:128,g:0,b:128},hex:"#800080"}),U.RebeccaPurple,{rgb:{r:102,g:51,b:153},hex:"#663399"}),U.Red,{rgb:{r:255,g:0,b:0},hex:"#FF0000"}),U.RosyBrown,{rgb:{r:188,g:143,b:143},hex:"#BC8F8F"}),U.RoyalBlue,{rgb:{r:65,g:105,b:225},hex:"#4169E1"}),t(t(t(t(t(t(t(t(t(t(q,U.SaddleBrown,{rgb:{r:139,g:69,b:19},hex:"#8B4513"}),U.Salmon,{rgb:{r:250,g:128,b:114},hex:"#FA8072"}),U.SandyBrown,{rgb:{r:244,g:164,b:96},hex:"#F4A460"}),U.SeaGreen,{rgb:{r:46,g:139,b:87},hex:"#2E8B57"}),U.SeaShell,{rgb:{r:255,g:245,b:238},hex:"#FFF5EE"}),U.Sienna,{rgb:{r:160,g:82,b:45},hex:"#A0522D"}),U.Silver,{rgb:{r:192,g:192,b:192},hex:"#C0C0C0"}),U.SkyBlue,{rgb:{r:135,g:206,b:235},hex:"#87CEEB"}),U.SlateBlue,{rgb:{r:106,g:90,b:205},hex:"#6A5ACD"}),U.SlateGray,{rgb:{r:112,g:128,b:144},hex:"#708090"}),t(t(t(t(t(t(t(t(t(t(q,U.Snow,{rgb:{r:255,g:250,b:250},hex:"#FFFAFA"}),U.SpringGreen,{rgb:{r:0,g:255,b:127},hex:"#00FF7F"}),U.SteelBlue,{rgb:{r:70,g:130,b:180},hex:"#4682B4"}),U.Tan,{rgb:{r:210,g:180,b:140},hex:"#D2B48C"}),U.Teal,{rgb:{r:0,g:128,b:128},hex:"#008080"}),U.Thistle,{rgb:{r:216,g:191,b:216},hex:"#D8BFD8"}),U.Tomato,{rgb:{r:255,g:99,b:71},hex:"#FF6347"}),U.Turquoise,{rgb:{r:64,g:224,b:208},hex:"#40E0D0"}),U.Violet,{rgb:{r:238,g:130,b:238},hex:"#EE82EE"}),U.Wheat,{rgb:{r:245,g:222,b:179},hex:"#F5DEB3"}),t(t(t(t(q,U.White,{rgb:{r:255,g:255,b:255},hex:"#FFFFFF"}),U.WhiteSmoke,{rgb:{r:245,g:245,b:245},hex:"#F5F5F5"}),U.Yellow,{rgb:{r:255,g:255,b:0},hex:"#FFFF00"}),U.YellowGreen,{rgb:{r:154,g:205,b:50},hex:"#9ACD32"}));function J(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(!u(r))throw new Error("Invalid hex color");var t=r.replace(/^#/,""),n=W(t),o=n.r,a=n.g,i=n.b;if(!o||!a||!i||2!==o.length||2!==a.length||2!==i.length)throw new TypeError("Invalid color components");var l,g=V(o),b=V(a),c=V(i);if("number"==typeof e){if(e<0||e>1)throw new Error("Invalid alpha value");l=e}else if(j(e)){if((l=parseFloat(e))<0||l>1)throw new Error("Invalid alpha value")}else l=1;return x({r:g,g:b,b:c,a:l})}exports.Color=z,exports.ColorNames=U,exports.RGBAToHexAlpha=function(r){var e,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=null===(e=r.match(/\d+\.?\d*/g))||void 0===e?void 0:e.map(Number);if(!n)throw new Error("Invalid RGBA/RGB input");var o=n.map((function(r,e){3===e&&(r=Math.round(255*r));var t=r.toString(16);return 1===t.length?"0"+t:t}));return t&&4===o.length&&o.pop(),"#"+o.join("")},exports.adjustColor=K,exports.applyAlphaToColor=g,exports.blendColors=m,exports.canBeConvertedIntoColor=f,exports.cssColors=X,exports.darkenColor=p,exports.darkenColorByShade=function(r,e){var t=function(r){return/^#([A-Fa-f0-9]{3}){1,2}$/.test(r)};if(!r||"number"!=typeof e)throw new Error("Both color and amount are required");if(e<0)throw new Error("Amount must be a positive number");var n=t(r)?function(r){if(!t(r))throw new Error("Invalid HEX format");var e=r.substring(1).split("");3===e.length&&(e=[e[0],e[0],e[1],e[1],e[2],e[2]]);var n=parseInt(e.join(""),16);return[n>>16&255,n>>8&255,255&n]}(r):function(r){var e=r.match(/\d+/g);if(!e||e.length<3)throw new Error("Invalid RGB format");return[parseInt(e[0],10),parseInt(e[1],10),parseInt(e[2],10)]}(r);return function(r,e){var t=a(r.map((function(r){return Math.max(0,r-e)})),3),n=t[0],o=t[1],i=t[2];return"rgba(".concat(n,", ").concat(o,", ").concat(i,", 1)")}(n,e)},exports.formatDecimalObjectToRgba=function(r,e){try{var t=r.r,n=r.g,o=r.b,a=r.a,i=void 0!==e&&j(e)?Math.round(10*parseFloat(e))/10:a;return x({r:t,g:n,b:o,a:i})}catch(r){return console.error("Error formatting decimal object to RGBA string:",r),x({r:0,g:0,b:0,a:1})}},exports.hexToDecimal=V,exports.hexToRgb=function(r){if(!u(r))throw new Error("Invalid hex color");r="#"===r.charAt(0)?r.slice(1):r;var e=parseInt(r,16),t=e>>16&255,n=e>>8&255,o=255&e;return 8===r.length?J(r,(e>>24&255)/255):x({r:t,g:n,b:o})},exports.hexToRgba=J,exports.hexesToDecimals=H,exports.hslToRgb=function(r,e,t){e/=100,t/=100;var n=(1-Math.abs(2*t-1))*e,o=n*(1-Math.abs(r/60%2-1)),a=t-n/2,i=0,l=0,g=0;return 0<=r&&r<60?(i=n,l=o,g=0):60<=r&&r<120?(i=o,l=n,g=0):120<=r&&r<180?(i=0,l=n,g=o):180<=r&&r<240?(i=0,l=o,g=n):240<=r&&r<300?(i=o,l=0,g=n):300<=r&&r<360&&(i=n,l=0,g=o),[i=Math.round(255*(i+a)),l=Math.round(255*(l+a)),g=Math.round(255*(g+a))]},exports.isHexColor=N,exports.isRgbaOutOfRange=b,exports.isValidAlphaHexCode=function(r){return/^#([A-Fa-f0-9]{8})$/.test(r)},exports.isValidHex=u,exports.isValidRgb=h,exports.isValidRgba=s,exports.lightenColor=d,exports.logFromPackage=$,exports.parseColor=function(r){if(!f(r))throw new Error("Invalid color format");try{var e=null;if(u(r)){var t=W(r);e=H(t)}else if(h(r)){e=F(r)}else if(s(r)){e=F(r)}return e?b(e)?{r:0,g:0,b:0,a:1}:e:{r:0,g:0,b:0,a:1}}catch(e){return console.error("Error parsing color value: ".concat(r),e),{r:0,g:0,b:0,a:1}}},exports.parseHex=W,exports.parseRgbString=F,exports.toHexColor=y,exports.toRgbString=x; //# sourceMappingURL=index.js.map