@kgalexander/mcreate 1.0.0 → 1.0.2

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 (3) hide show
  1. package/dist/index.js +1610 -39
  2. package/dist/index.mjs +1583 -12
  3. package/package.json +3 -2
package/dist/index.mjs CHANGED
@@ -2712,8 +2712,1579 @@ function useTemplateColors() {
2712
2712
  return useMemo3(() => getTemplateColors(template), [template]);
2713
2713
  }
2714
2714
 
2715
+ // node_modules/color-name/index.js
2716
+ var colors = {
2717
+ aliceblue: [240, 248, 255],
2718
+ antiquewhite: [250, 235, 215],
2719
+ aqua: [0, 255, 255],
2720
+ aquamarine: [127, 255, 212],
2721
+ azure: [240, 255, 255],
2722
+ beige: [245, 245, 220],
2723
+ bisque: [255, 228, 196],
2724
+ black: [0, 0, 0],
2725
+ blanchedalmond: [255, 235, 205],
2726
+ blue: [0, 0, 255],
2727
+ blueviolet: [138, 43, 226],
2728
+ brown: [165, 42, 42],
2729
+ burlywood: [222, 184, 135],
2730
+ cadetblue: [95, 158, 160],
2731
+ chartreuse: [127, 255, 0],
2732
+ chocolate: [210, 105, 30],
2733
+ coral: [255, 127, 80],
2734
+ cornflowerblue: [100, 149, 237],
2735
+ cornsilk: [255, 248, 220],
2736
+ crimson: [220, 20, 60],
2737
+ cyan: [0, 255, 255],
2738
+ darkblue: [0, 0, 139],
2739
+ darkcyan: [0, 139, 139],
2740
+ darkgoldenrod: [184, 134, 11],
2741
+ darkgray: [169, 169, 169],
2742
+ darkgreen: [0, 100, 0],
2743
+ darkgrey: [169, 169, 169],
2744
+ darkkhaki: [189, 183, 107],
2745
+ darkmagenta: [139, 0, 139],
2746
+ darkolivegreen: [85, 107, 47],
2747
+ darkorange: [255, 140, 0],
2748
+ darkorchid: [153, 50, 204],
2749
+ darkred: [139, 0, 0],
2750
+ darksalmon: [233, 150, 122],
2751
+ darkseagreen: [143, 188, 143],
2752
+ darkslateblue: [72, 61, 139],
2753
+ darkslategray: [47, 79, 79],
2754
+ darkslategrey: [47, 79, 79],
2755
+ darkturquoise: [0, 206, 209],
2756
+ darkviolet: [148, 0, 211],
2757
+ deeppink: [255, 20, 147],
2758
+ deepskyblue: [0, 191, 255],
2759
+ dimgray: [105, 105, 105],
2760
+ dimgrey: [105, 105, 105],
2761
+ dodgerblue: [30, 144, 255],
2762
+ firebrick: [178, 34, 34],
2763
+ floralwhite: [255, 250, 240],
2764
+ forestgreen: [34, 139, 34],
2765
+ fuchsia: [255, 0, 255],
2766
+ gainsboro: [220, 220, 220],
2767
+ ghostwhite: [248, 248, 255],
2768
+ gold: [255, 215, 0],
2769
+ goldenrod: [218, 165, 32],
2770
+ gray: [128, 128, 128],
2771
+ green: [0, 128, 0],
2772
+ greenyellow: [173, 255, 47],
2773
+ grey: [128, 128, 128],
2774
+ honeydew: [240, 255, 240],
2775
+ hotpink: [255, 105, 180],
2776
+ indianred: [205, 92, 92],
2777
+ indigo: [75, 0, 130],
2778
+ ivory: [255, 255, 240],
2779
+ khaki: [240, 230, 140],
2780
+ lavender: [230, 230, 250],
2781
+ lavenderblush: [255, 240, 245],
2782
+ lawngreen: [124, 252, 0],
2783
+ lemonchiffon: [255, 250, 205],
2784
+ lightblue: [173, 216, 230],
2785
+ lightcoral: [240, 128, 128],
2786
+ lightcyan: [224, 255, 255],
2787
+ lightgoldenrodyellow: [250, 250, 210],
2788
+ lightgray: [211, 211, 211],
2789
+ lightgreen: [144, 238, 144],
2790
+ lightgrey: [211, 211, 211],
2791
+ lightpink: [255, 182, 193],
2792
+ lightsalmon: [255, 160, 122],
2793
+ lightseagreen: [32, 178, 170],
2794
+ lightskyblue: [135, 206, 250],
2795
+ lightslategray: [119, 136, 153],
2796
+ lightslategrey: [119, 136, 153],
2797
+ lightsteelblue: [176, 196, 222],
2798
+ lightyellow: [255, 255, 224],
2799
+ lime: [0, 255, 0],
2800
+ limegreen: [50, 205, 50],
2801
+ linen: [250, 240, 230],
2802
+ magenta: [255, 0, 255],
2803
+ maroon: [128, 0, 0],
2804
+ mediumaquamarine: [102, 205, 170],
2805
+ mediumblue: [0, 0, 205],
2806
+ mediumorchid: [186, 85, 211],
2807
+ mediumpurple: [147, 112, 219],
2808
+ mediumseagreen: [60, 179, 113],
2809
+ mediumslateblue: [123, 104, 238],
2810
+ mediumspringgreen: [0, 250, 154],
2811
+ mediumturquoise: [72, 209, 204],
2812
+ mediumvioletred: [199, 21, 133],
2813
+ midnightblue: [25, 25, 112],
2814
+ mintcream: [245, 255, 250],
2815
+ mistyrose: [255, 228, 225],
2816
+ moccasin: [255, 228, 181],
2817
+ navajowhite: [255, 222, 173],
2818
+ navy: [0, 0, 128],
2819
+ oldlace: [253, 245, 230],
2820
+ olive: [128, 128, 0],
2821
+ olivedrab: [107, 142, 35],
2822
+ orange: [255, 165, 0],
2823
+ orangered: [255, 69, 0],
2824
+ orchid: [218, 112, 214],
2825
+ palegoldenrod: [238, 232, 170],
2826
+ palegreen: [152, 251, 152],
2827
+ paleturquoise: [175, 238, 238],
2828
+ palevioletred: [219, 112, 147],
2829
+ papayawhip: [255, 239, 213],
2830
+ peachpuff: [255, 218, 185],
2831
+ peru: [205, 133, 63],
2832
+ pink: [255, 192, 203],
2833
+ plum: [221, 160, 221],
2834
+ powderblue: [176, 224, 230],
2835
+ purple: [128, 0, 128],
2836
+ rebeccapurple: [102, 51, 153],
2837
+ red: [255, 0, 0],
2838
+ rosybrown: [188, 143, 143],
2839
+ royalblue: [65, 105, 225],
2840
+ saddlebrown: [139, 69, 19],
2841
+ salmon: [250, 128, 114],
2842
+ sandybrown: [244, 164, 96],
2843
+ seagreen: [46, 139, 87],
2844
+ seashell: [255, 245, 238],
2845
+ sienna: [160, 82, 45],
2846
+ silver: [192, 192, 192],
2847
+ skyblue: [135, 206, 235],
2848
+ slateblue: [106, 90, 205],
2849
+ slategray: [112, 128, 144],
2850
+ slategrey: [112, 128, 144],
2851
+ snow: [255, 250, 250],
2852
+ springgreen: [0, 255, 127],
2853
+ steelblue: [70, 130, 180],
2854
+ tan: [210, 180, 140],
2855
+ teal: [0, 128, 128],
2856
+ thistle: [216, 191, 216],
2857
+ tomato: [255, 99, 71],
2858
+ turquoise: [64, 224, 208],
2859
+ violet: [238, 130, 238],
2860
+ wheat: [245, 222, 179],
2861
+ white: [255, 255, 255],
2862
+ whitesmoke: [245, 245, 245],
2863
+ yellow: [255, 255, 0],
2864
+ yellowgreen: [154, 205, 50]
2865
+ };
2866
+ for (const key in colors) Object.freeze(colors[key]);
2867
+ var color_name_default = Object.freeze(colors);
2868
+
2869
+ // node_modules/color-string/index.js
2870
+ var reverseNames = /* @__PURE__ */ Object.create(null);
2871
+ for (const name in color_name_default) {
2872
+ if (Object.hasOwn(color_name_default, name)) {
2873
+ reverseNames[color_name_default[name]] = name;
2874
+ }
2875
+ }
2876
+ var cs = {
2877
+ to: {},
2878
+ get: {}
2879
+ };
2880
+ cs.get = function(string) {
2881
+ const prefix = string.slice(0, 3).toLowerCase();
2882
+ let value;
2883
+ let model;
2884
+ switch (prefix) {
2885
+ case "hsl": {
2886
+ value = cs.get.hsl(string);
2887
+ model = "hsl";
2888
+ break;
2889
+ }
2890
+ case "hwb": {
2891
+ value = cs.get.hwb(string);
2892
+ model = "hwb";
2893
+ break;
2894
+ }
2895
+ default: {
2896
+ value = cs.get.rgb(string);
2897
+ model = "rgb";
2898
+ break;
2899
+ }
2900
+ }
2901
+ if (!value) {
2902
+ return null;
2903
+ }
2904
+ return { model, value };
2905
+ };
2906
+ cs.get.rgb = function(string) {
2907
+ if (!string) {
2908
+ return null;
2909
+ }
2910
+ const abbr = /^#([a-f\d]{3,4})$/i;
2911
+ const hex = /^#([a-f\d]{6})([a-f\d]{2})?$/i;
2912
+ const rgba = /^rgba?\(\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)\s*(?:[\s,|/]\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(%?)\s*)?\)$/i;
2913
+ const per = /^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/i;
2914
+ const keyword = /^(\w+)$/;
2915
+ let rgb = [0, 0, 0, 1];
2916
+ let match;
2917
+ let i;
2918
+ let hexAlpha;
2919
+ if (match = string.match(hex)) {
2920
+ hexAlpha = match[2];
2921
+ match = match[1];
2922
+ for (i = 0; i < 3; i++) {
2923
+ const i2 = i * 2;
2924
+ rgb[i] = Number.parseInt(match.slice(i2, i2 + 2), 16);
2925
+ }
2926
+ if (hexAlpha) {
2927
+ rgb[3] = Number.parseInt(hexAlpha, 16) / 255;
2928
+ }
2929
+ } else if (match = string.match(abbr)) {
2930
+ match = match[1];
2931
+ hexAlpha = match[3];
2932
+ for (i = 0; i < 3; i++) {
2933
+ rgb[i] = Number.parseInt(match[i] + match[i], 16);
2934
+ }
2935
+ if (hexAlpha) {
2936
+ rgb[3] = Number.parseInt(hexAlpha + hexAlpha, 16) / 255;
2937
+ }
2938
+ } else if (match = string.match(rgba)) {
2939
+ for (i = 0; i < 3; i++) {
2940
+ rgb[i] = Number.parseFloat(match[i + 1]);
2941
+ }
2942
+ if (match[4]) {
2943
+ rgb[3] = match[5] ? Number.parseFloat(match[4]) * 0.01 : Number.parseFloat(match[4]);
2944
+ }
2945
+ } else if (match = string.match(per)) {
2946
+ for (i = 0; i < 3; i++) {
2947
+ rgb[i] = Math.round(Number.parseFloat(match[i + 1]) * 2.55);
2948
+ }
2949
+ if (match[4]) {
2950
+ rgb[3] = match[5] ? Number.parseFloat(match[4]) * 0.01 : Number.parseFloat(match[4]);
2951
+ }
2952
+ } else if (match = string.toLowerCase().match(keyword)) {
2953
+ if (match[1] === "transparent") {
2954
+ return [0, 0, 0, 0];
2955
+ }
2956
+ if (!Object.hasOwn(color_name_default, match[1])) {
2957
+ return null;
2958
+ }
2959
+ rgb = color_name_default[match[1]].slice();
2960
+ rgb[3] = 1;
2961
+ return rgb;
2962
+ } else {
2963
+ return null;
2964
+ }
2965
+ for (i = 0; i < 3; i++) {
2966
+ rgb[i] = clamp(rgb[i], 0, 255);
2967
+ }
2968
+ rgb[3] = clamp(rgb[3], 0, 1);
2969
+ return rgb;
2970
+ };
2971
+ cs.get.hsl = function(string) {
2972
+ if (!string) {
2973
+ return null;
2974
+ }
2975
+ const hsl = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:e[+-]?\d+)?)\s*)?\)$/i;
2976
+ const match = string.match(hsl);
2977
+ if (match) {
2978
+ const alpha = Number.parseFloat(match[4]);
2979
+ const h = (Number.parseFloat(match[1]) % 360 + 360) % 360;
2980
+ const s = clamp(Number.parseFloat(match[2]), 0, 100);
2981
+ const l = clamp(Number.parseFloat(match[3]), 0, 100);
2982
+ const a = clamp(Number.isNaN(alpha) ? 1 : alpha, 0, 1);
2983
+ return [h, s, l, a];
2984
+ }
2985
+ return null;
2986
+ };
2987
+ cs.get.hwb = function(string) {
2988
+ if (!string) {
2989
+ return null;
2990
+ }
2991
+ const hwb = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*[\s,]\s*([+-]?[\d.]+)%\s*[\s,]\s*([+-]?[\d.]+)%\s*(?:[\s,]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:e[+-]?\d+)?)\s*)?\)$/i;
2992
+ const match = string.match(hwb);
2993
+ if (match) {
2994
+ const alpha = Number.parseFloat(match[4]);
2995
+ const h = (Number.parseFloat(match[1]) % 360 + 360) % 360;
2996
+ const w = clamp(Number.parseFloat(match[2]), 0, 100);
2997
+ const b = clamp(Number.parseFloat(match[3]), 0, 100);
2998
+ const a = clamp(Number.isNaN(alpha) ? 1 : alpha, 0, 1);
2999
+ return [h, w, b, a];
3000
+ }
3001
+ return null;
3002
+ };
3003
+ cs.to.hex = function(...rgba) {
3004
+ return "#" + hexDouble(rgba[0]) + hexDouble(rgba[1]) + hexDouble(rgba[2]) + (rgba[3] < 1 ? hexDouble(Math.round(rgba[3] * 255)) : "");
3005
+ };
3006
+ cs.to.rgb = function(...rgba) {
3007
+ return rgba.length < 4 || rgba[3] === 1 ? "rgb(" + Math.round(rgba[0]) + ", " + Math.round(rgba[1]) + ", " + Math.round(rgba[2]) + ")" : "rgba(" + Math.round(rgba[0]) + ", " + Math.round(rgba[1]) + ", " + Math.round(rgba[2]) + ", " + rgba[3] + ")";
3008
+ };
3009
+ cs.to.rgb.percent = function(...rgba) {
3010
+ const r = Math.round(rgba[0] / 255 * 100);
3011
+ const g = Math.round(rgba[1] / 255 * 100);
3012
+ const b = Math.round(rgba[2] / 255 * 100);
3013
+ return rgba.length < 4 || rgba[3] === 1 ? "rgb(" + r + "%, " + g + "%, " + b + "%)" : "rgba(" + r + "%, " + g + "%, " + b + "%, " + rgba[3] + ")";
3014
+ };
3015
+ cs.to.hsl = function(...hsla) {
3016
+ return hsla.length < 4 || hsla[3] === 1 ? "hsl(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%)" : "hsla(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%, " + hsla[3] + ")";
3017
+ };
3018
+ cs.to.hwb = function(...hwba) {
3019
+ let a = "";
3020
+ if (hwba.length >= 4 && hwba[3] !== 1) {
3021
+ a = ", " + hwba[3];
3022
+ }
3023
+ return "hwb(" + hwba[0] + ", " + hwba[1] + "%, " + hwba[2] + "%" + a + ")";
3024
+ };
3025
+ cs.to.keyword = function(...rgb) {
3026
+ return reverseNames[rgb.slice(0, 3)];
3027
+ };
3028
+ function clamp(number_, min, max) {
3029
+ return Math.min(Math.max(min, number_), max);
3030
+ }
3031
+ function hexDouble(number_) {
3032
+ const string_ = Math.round(number_).toString(16).toUpperCase();
3033
+ return string_.length < 2 ? "0" + string_ : string_;
3034
+ }
3035
+ var color_string_default = cs;
3036
+
3037
+ // node_modules/color-convert/conversions.js
3038
+ var reverseKeywords = {};
3039
+ for (const key of Object.keys(color_name_default)) {
3040
+ reverseKeywords[color_name_default[key]] = key;
3041
+ }
3042
+ var convert = {
3043
+ rgb: { channels: 3, labels: "rgb" },
3044
+ hsl: { channels: 3, labels: "hsl" },
3045
+ hsv: { channels: 3, labels: "hsv" },
3046
+ hwb: { channels: 3, labels: "hwb" },
3047
+ cmyk: { channels: 4, labels: "cmyk" },
3048
+ xyz: { channels: 3, labels: "xyz" },
3049
+ lab: { channels: 3, labels: "lab" },
3050
+ oklab: { channels: 3, labels: ["okl", "oka", "okb"] },
3051
+ lch: { channels: 3, labels: "lch" },
3052
+ oklch: { channels: 3, labels: ["okl", "okc", "okh"] },
3053
+ hex: { channels: 1, labels: ["hex"] },
3054
+ keyword: { channels: 1, labels: ["keyword"] },
3055
+ ansi16: { channels: 1, labels: ["ansi16"] },
3056
+ ansi256: { channels: 1, labels: ["ansi256"] },
3057
+ hcg: { channels: 3, labels: ["h", "c", "g"] },
3058
+ apple: { channels: 3, labels: ["r16", "g16", "b16"] },
3059
+ gray: { channels: 1, labels: ["gray"] }
3060
+ };
3061
+ var conversions_default = convert;
3062
+ var LAB_FT = (6 / 29) ** 3;
3063
+ function srgbNonlinearTransform(c) {
3064
+ const cc = c > 31308e-7 ? 1.055 * c ** (1 / 2.4) - 0.055 : c * 12.92;
3065
+ return Math.min(Math.max(0, cc), 1);
3066
+ }
3067
+ function srgbNonlinearTransformInv(c) {
3068
+ return c > 0.04045 ? ((c + 0.055) / 1.055) ** 2.4 : c / 12.92;
3069
+ }
3070
+ for (const model of Object.keys(convert)) {
3071
+ if (!("channels" in convert[model])) {
3072
+ throw new Error("missing channels property: " + model);
3073
+ }
3074
+ if (!("labels" in convert[model])) {
3075
+ throw new Error("missing channel labels property: " + model);
3076
+ }
3077
+ if (convert[model].labels.length !== convert[model].channels) {
3078
+ throw new Error("channel and label counts mismatch: " + model);
3079
+ }
3080
+ const { channels, labels } = convert[model];
3081
+ delete convert[model].channels;
3082
+ delete convert[model].labels;
3083
+ Object.defineProperty(convert[model], "channels", { value: channels });
3084
+ Object.defineProperty(convert[model], "labels", { value: labels });
3085
+ }
3086
+ convert.rgb.hsl = function(rgb) {
3087
+ const r = rgb[0] / 255;
3088
+ const g = rgb[1] / 255;
3089
+ const b = rgb[2] / 255;
3090
+ const min = Math.min(r, g, b);
3091
+ const max = Math.max(r, g, b);
3092
+ const delta = max - min;
3093
+ let h;
3094
+ let s;
3095
+ switch (max) {
3096
+ case min: {
3097
+ h = 0;
3098
+ break;
3099
+ }
3100
+ case r: {
3101
+ h = (g - b) / delta;
3102
+ break;
3103
+ }
3104
+ case g: {
3105
+ h = 2 + (b - r) / delta;
3106
+ break;
3107
+ }
3108
+ case b: {
3109
+ h = 4 + (r - g) / delta;
3110
+ break;
3111
+ }
3112
+ }
3113
+ h = Math.min(h * 60, 360);
3114
+ if (h < 0) {
3115
+ h += 360;
3116
+ }
3117
+ const l = (min + max) / 2;
3118
+ if (max === min) {
3119
+ s = 0;
3120
+ } else if (l <= 0.5) {
3121
+ s = delta / (max + min);
3122
+ } else {
3123
+ s = delta / (2 - max - min);
3124
+ }
3125
+ return [h, s * 100, l * 100];
3126
+ };
3127
+ convert.rgb.hsv = function(rgb) {
3128
+ let rdif;
3129
+ let gdif;
3130
+ let bdif;
3131
+ let h;
3132
+ let s;
3133
+ const r = rgb[0] / 255;
3134
+ const g = rgb[1] / 255;
3135
+ const b = rgb[2] / 255;
3136
+ const v = Math.max(r, g, b);
3137
+ const diff = v - Math.min(r, g, b);
3138
+ const diffc = function(c) {
3139
+ return (v - c) / 6 / diff + 1 / 2;
3140
+ };
3141
+ if (diff === 0) {
3142
+ h = 0;
3143
+ s = 0;
3144
+ } else {
3145
+ s = diff / v;
3146
+ rdif = diffc(r);
3147
+ gdif = diffc(g);
3148
+ bdif = diffc(b);
3149
+ switch (v) {
3150
+ case r: {
3151
+ h = bdif - gdif;
3152
+ break;
3153
+ }
3154
+ case g: {
3155
+ h = 1 / 3 + rdif - bdif;
3156
+ break;
3157
+ }
3158
+ case b: {
3159
+ h = 2 / 3 + gdif - rdif;
3160
+ break;
3161
+ }
3162
+ }
3163
+ if (h < 0) {
3164
+ h += 1;
3165
+ } else if (h > 1) {
3166
+ h -= 1;
3167
+ }
3168
+ }
3169
+ return [
3170
+ h * 360,
3171
+ s * 100,
3172
+ v * 100
3173
+ ];
3174
+ };
3175
+ convert.rgb.hwb = function(rgb) {
3176
+ const r = rgb[0];
3177
+ const g = rgb[1];
3178
+ let b = rgb[2];
3179
+ const h = convert.rgb.hsl(rgb)[0];
3180
+ const w = 1 / 255 * Math.min(r, Math.min(g, b));
3181
+ b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
3182
+ return [h, w * 100, b * 100];
3183
+ };
3184
+ convert.rgb.oklab = function(rgb) {
3185
+ const r = srgbNonlinearTransformInv(rgb[0] / 255);
3186
+ const g = srgbNonlinearTransformInv(rgb[1] / 255);
3187
+ const b = srgbNonlinearTransformInv(rgb[2] / 255);
3188
+ const lp = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
3189
+ const mp = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
3190
+ const sp = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
3191
+ const l = 0.2104542553 * lp + 0.793617785 * mp - 0.0040720468 * sp;
3192
+ const aa = 1.9779984951 * lp - 2.428592205 * mp + 0.4505937099 * sp;
3193
+ const bb = 0.0259040371 * lp + 0.7827717662 * mp - 0.808675766 * sp;
3194
+ return [l * 100, aa * 100, bb * 100];
3195
+ };
3196
+ convert.rgb.cmyk = function(rgb) {
3197
+ const r = rgb[0] / 255;
3198
+ const g = rgb[1] / 255;
3199
+ const b = rgb[2] / 255;
3200
+ const k = Math.min(1 - r, 1 - g, 1 - b);
3201
+ const c = (1 - r - k) / (1 - k) || 0;
3202
+ const m = (1 - g - k) / (1 - k) || 0;
3203
+ const y = (1 - b - k) / (1 - k) || 0;
3204
+ return [c * 100, m * 100, y * 100, k * 100];
3205
+ };
3206
+ function comparativeDistance(x, y) {
3207
+ return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
3208
+ }
3209
+ convert.rgb.keyword = function(rgb) {
3210
+ const reversed = reverseKeywords[rgb];
3211
+ if (reversed) {
3212
+ return reversed;
3213
+ }
3214
+ let currentClosestDistance = Number.POSITIVE_INFINITY;
3215
+ let currentClosestKeyword;
3216
+ for (const keyword of Object.keys(color_name_default)) {
3217
+ const value = color_name_default[keyword];
3218
+ const distance = comparativeDistance(rgb, value);
3219
+ if (distance < currentClosestDistance) {
3220
+ currentClosestDistance = distance;
3221
+ currentClosestKeyword = keyword;
3222
+ }
3223
+ }
3224
+ return currentClosestKeyword;
3225
+ };
3226
+ convert.keyword.rgb = function(keyword) {
3227
+ return [...color_name_default[keyword]];
3228
+ };
3229
+ convert.rgb.xyz = function(rgb) {
3230
+ const r = srgbNonlinearTransformInv(rgb[0] / 255);
3231
+ const g = srgbNonlinearTransformInv(rgb[1] / 255);
3232
+ const b = srgbNonlinearTransformInv(rgb[2] / 255);
3233
+ const x = r * 0.4124564 + g * 0.3575761 + b * 0.1804375;
3234
+ const y = r * 0.2126729 + g * 0.7151522 + b * 0.072175;
3235
+ const z = r * 0.0193339 + g * 0.119192 + b * 0.9503041;
3236
+ return [x * 100, y * 100, z * 100];
3237
+ };
3238
+ convert.rgb.lab = function(rgb) {
3239
+ const xyz = convert.rgb.xyz(rgb);
3240
+ let x = xyz[0];
3241
+ let y = xyz[1];
3242
+ let z = xyz[2];
3243
+ x /= 95.047;
3244
+ y /= 100;
3245
+ z /= 108.883;
3246
+ x = x > LAB_FT ? x ** (1 / 3) : 7.787 * x + 16 / 116;
3247
+ y = y > LAB_FT ? y ** (1 / 3) : 7.787 * y + 16 / 116;
3248
+ z = z > LAB_FT ? z ** (1 / 3) : 7.787 * z + 16 / 116;
3249
+ const l = 116 * y - 16;
3250
+ const a = 500 * (x - y);
3251
+ const b = 200 * (y - z);
3252
+ return [l, a, b];
3253
+ };
3254
+ convert.hsl.rgb = function(hsl) {
3255
+ const h = hsl[0] / 360;
3256
+ const s = hsl[1] / 100;
3257
+ const l = hsl[2] / 100;
3258
+ let t3;
3259
+ let value;
3260
+ if (s === 0) {
3261
+ value = l * 255;
3262
+ return [value, value, value];
3263
+ }
3264
+ const t2 = l < 0.5 ? l * (1 + s) : l + s - l * s;
3265
+ const t1 = 2 * l - t2;
3266
+ const rgb = [0, 0, 0];
3267
+ for (let i = 0; i < 3; i++) {
3268
+ t3 = h + 1 / 3 * -(i - 1);
3269
+ if (t3 < 0) {
3270
+ t3++;
3271
+ }
3272
+ if (t3 > 1) {
3273
+ t3--;
3274
+ }
3275
+ if (6 * t3 < 1) {
3276
+ value = t1 + (t2 - t1) * 6 * t3;
3277
+ } else if (2 * t3 < 1) {
3278
+ value = t2;
3279
+ } else if (3 * t3 < 2) {
3280
+ value = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
3281
+ } else {
3282
+ value = t1;
3283
+ }
3284
+ rgb[i] = value * 255;
3285
+ }
3286
+ return rgb;
3287
+ };
3288
+ convert.hsl.hsv = function(hsl) {
3289
+ const h = hsl[0];
3290
+ let s = hsl[1] / 100;
3291
+ let l = hsl[2] / 100;
3292
+ let smin = s;
3293
+ const lmin = Math.max(l, 0.01);
3294
+ l *= 2;
3295
+ s *= l <= 1 ? l : 2 - l;
3296
+ smin *= lmin <= 1 ? lmin : 2 - lmin;
3297
+ const v = (l + s) / 2;
3298
+ const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
3299
+ return [h, sv * 100, v * 100];
3300
+ };
3301
+ convert.hsv.rgb = function(hsv) {
3302
+ const h = hsv[0] / 60;
3303
+ const s = hsv[1] / 100;
3304
+ let v = hsv[2] / 100;
3305
+ const hi = Math.floor(h) % 6;
3306
+ const f = h - Math.floor(h);
3307
+ const p = 255 * v * (1 - s);
3308
+ const q = 255 * v * (1 - s * f);
3309
+ const t = 255 * v * (1 - s * (1 - f));
3310
+ v *= 255;
3311
+ switch (hi) {
3312
+ case 0: {
3313
+ return [v, t, p];
3314
+ }
3315
+ case 1: {
3316
+ return [q, v, p];
3317
+ }
3318
+ case 2: {
3319
+ return [p, v, t];
3320
+ }
3321
+ case 3: {
3322
+ return [p, q, v];
3323
+ }
3324
+ case 4: {
3325
+ return [t, p, v];
3326
+ }
3327
+ case 5: {
3328
+ return [v, p, q];
3329
+ }
3330
+ }
3331
+ };
3332
+ convert.hsv.hsl = function(hsv) {
3333
+ const h = hsv[0];
3334
+ const s = hsv[1] / 100;
3335
+ const v = hsv[2] / 100;
3336
+ const vmin = Math.max(v, 0.01);
3337
+ let sl;
3338
+ let l;
3339
+ l = (2 - s) * v;
3340
+ const lmin = (2 - s) * vmin;
3341
+ sl = s * vmin;
3342
+ sl /= lmin <= 1 ? lmin : 2 - lmin;
3343
+ sl = sl || 0;
3344
+ l /= 2;
3345
+ return [h, sl * 100, l * 100];
3346
+ };
3347
+ convert.hwb.rgb = function(hwb) {
3348
+ const h = hwb[0] / 360;
3349
+ let wh = hwb[1] / 100;
3350
+ let bl = hwb[2] / 100;
3351
+ const ratio = wh + bl;
3352
+ let f;
3353
+ if (ratio > 1) {
3354
+ wh /= ratio;
3355
+ bl /= ratio;
3356
+ }
3357
+ const i = Math.floor(6 * h);
3358
+ const v = 1 - bl;
3359
+ f = 6 * h - i;
3360
+ if ((i & 1) !== 0) {
3361
+ f = 1 - f;
3362
+ }
3363
+ const n = wh + f * (v - wh);
3364
+ let r;
3365
+ let g;
3366
+ let b;
3367
+ switch (i) {
3368
+ default:
3369
+ case 6:
3370
+ case 0: {
3371
+ r = v;
3372
+ g = n;
3373
+ b = wh;
3374
+ break;
3375
+ }
3376
+ case 1: {
3377
+ r = n;
3378
+ g = v;
3379
+ b = wh;
3380
+ break;
3381
+ }
3382
+ case 2: {
3383
+ r = wh;
3384
+ g = v;
3385
+ b = n;
3386
+ break;
3387
+ }
3388
+ case 3: {
3389
+ r = wh;
3390
+ g = n;
3391
+ b = v;
3392
+ break;
3393
+ }
3394
+ case 4: {
3395
+ r = n;
3396
+ g = wh;
3397
+ b = v;
3398
+ break;
3399
+ }
3400
+ case 5: {
3401
+ r = v;
3402
+ g = wh;
3403
+ b = n;
3404
+ break;
3405
+ }
3406
+ }
3407
+ return [r * 255, g * 255, b * 255];
3408
+ };
3409
+ convert.cmyk.rgb = function(cmyk) {
3410
+ const c = cmyk[0] / 100;
3411
+ const m = cmyk[1] / 100;
3412
+ const y = cmyk[2] / 100;
3413
+ const k = cmyk[3] / 100;
3414
+ const r = 1 - Math.min(1, c * (1 - k) + k);
3415
+ const g = 1 - Math.min(1, m * (1 - k) + k);
3416
+ const b = 1 - Math.min(1, y * (1 - k) + k);
3417
+ return [r * 255, g * 255, b * 255];
3418
+ };
3419
+ convert.xyz.rgb = function(xyz) {
3420
+ const x = xyz[0] / 100;
3421
+ const y = xyz[1] / 100;
3422
+ const z = xyz[2] / 100;
3423
+ let r;
3424
+ let g;
3425
+ let b;
3426
+ r = x * 3.2404542 + y * -1.5371385 + z * -0.4985314;
3427
+ g = x * -0.969266 + y * 1.8760108 + z * 0.041556;
3428
+ b = x * 0.0556434 + y * -0.2040259 + z * 1.0572252;
3429
+ r = srgbNonlinearTransform(r);
3430
+ g = srgbNonlinearTransform(g);
3431
+ b = srgbNonlinearTransform(b);
3432
+ return [r * 255, g * 255, b * 255];
3433
+ };
3434
+ convert.xyz.lab = function(xyz) {
3435
+ let x = xyz[0];
3436
+ let y = xyz[1];
3437
+ let z = xyz[2];
3438
+ x /= 95.047;
3439
+ y /= 100;
3440
+ z /= 108.883;
3441
+ x = x > LAB_FT ? x ** (1 / 3) : 7.787 * x + 16 / 116;
3442
+ y = y > LAB_FT ? y ** (1 / 3) : 7.787 * y + 16 / 116;
3443
+ z = z > LAB_FT ? z ** (1 / 3) : 7.787 * z + 16 / 116;
3444
+ const l = 116 * y - 16;
3445
+ const a = 500 * (x - y);
3446
+ const b = 200 * (y - z);
3447
+ return [l, a, b];
3448
+ };
3449
+ convert.xyz.oklab = function(xyz) {
3450
+ const x = xyz[0] / 100;
3451
+ const y = xyz[1] / 100;
3452
+ const z = xyz[2] / 100;
3453
+ const lp = Math.cbrt(0.8189330101 * x + 0.3618667424 * y - 0.1288597137 * z);
3454
+ const mp = Math.cbrt(0.0329845436 * x + 0.9293118715 * y + 0.0361456387 * z);
3455
+ const sp = Math.cbrt(0.0482003018 * x + 0.2643662691 * y + 0.633851707 * z);
3456
+ const l = 0.2104542553 * lp + 0.793617785 * mp - 0.0040720468 * sp;
3457
+ const a = 1.9779984951 * lp - 2.428592205 * mp + 0.4505937099 * sp;
3458
+ const b = 0.0259040371 * lp + 0.7827717662 * mp - 0.808675766 * sp;
3459
+ return [l * 100, a * 100, b * 100];
3460
+ };
3461
+ convert.oklab.oklch = function(oklab) {
3462
+ return convert.lab.lch(oklab);
3463
+ };
3464
+ convert.oklab.xyz = function(oklab) {
3465
+ const ll = oklab[0] / 100;
3466
+ const a = oklab[1] / 100;
3467
+ const b = oklab[2] / 100;
3468
+ const l = (0.999999998 * ll + 0.396337792 * a + 0.215803758 * b) ** 3;
3469
+ const m = (1.000000008 * ll - 0.105561342 * a - 0.063854175 * b) ** 3;
3470
+ const s = (1.000000055 * ll - 0.089484182 * a - 1.291485538 * b) ** 3;
3471
+ const x = 1.227013851 * l - 0.55779998 * m + 0.281256149 * s;
3472
+ const y = -0.040580178 * l + 1.11225687 * m - 0.071676679 * s;
3473
+ const z = -0.076381285 * l - 0.421481978 * m + 1.58616322 * s;
3474
+ return [x * 100, y * 100, z * 100];
3475
+ };
3476
+ convert.oklab.rgb = function(oklab) {
3477
+ const ll = oklab[0] / 100;
3478
+ const aa = oklab[1] / 100;
3479
+ const bb = oklab[2] / 100;
3480
+ const l = (ll + 0.3963377774 * aa + 0.2158037573 * bb) ** 3;
3481
+ const m = (ll - 0.1055613458 * aa - 0.0638541728 * bb) ** 3;
3482
+ const s = (ll - 0.0894841775 * aa - 1.291485548 * bb) ** 3;
3483
+ const r = srgbNonlinearTransform(4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s);
3484
+ const g = srgbNonlinearTransform(-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s);
3485
+ const b = srgbNonlinearTransform(-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s);
3486
+ return [r * 255, g * 255, b * 255];
3487
+ };
3488
+ convert.oklch.oklab = function(oklch) {
3489
+ return convert.lch.lab(oklch);
3490
+ };
3491
+ convert.lab.xyz = function(lab) {
3492
+ const l = lab[0];
3493
+ const a = lab[1];
3494
+ const b = lab[2];
3495
+ let x;
3496
+ let y;
3497
+ let z;
3498
+ y = (l + 16) / 116;
3499
+ x = a / 500 + y;
3500
+ z = y - b / 200;
3501
+ const y2 = y ** 3;
3502
+ const x2 = x ** 3;
3503
+ const z2 = z ** 3;
3504
+ y = y2 > LAB_FT ? y2 : (y - 16 / 116) / 7.787;
3505
+ x = x2 > LAB_FT ? x2 : (x - 16 / 116) / 7.787;
3506
+ z = z2 > LAB_FT ? z2 : (z - 16 / 116) / 7.787;
3507
+ x *= 95.047;
3508
+ y *= 100;
3509
+ z *= 108.883;
3510
+ return [x, y, z];
3511
+ };
3512
+ convert.lab.lch = function(lab) {
3513
+ const l = lab[0];
3514
+ const a = lab[1];
3515
+ const b = lab[2];
3516
+ let h;
3517
+ const hr = Math.atan2(b, a);
3518
+ h = hr * 360 / 2 / Math.PI;
3519
+ if (h < 0) {
3520
+ h += 360;
3521
+ }
3522
+ const c = Math.sqrt(a * a + b * b);
3523
+ return [l, c, h];
3524
+ };
3525
+ convert.lch.lab = function(lch) {
3526
+ const l = lch[0];
3527
+ const c = lch[1];
3528
+ const h = lch[2];
3529
+ const hr = h / 360 * 2 * Math.PI;
3530
+ const a = c * Math.cos(hr);
3531
+ const b = c * Math.sin(hr);
3532
+ return [l, a, b];
3533
+ };
3534
+ convert.rgb.ansi16 = function(args, saturation = null) {
3535
+ const [r, g, b] = args;
3536
+ let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;
3537
+ value = Math.round(value / 50);
3538
+ if (value === 0) {
3539
+ return 30;
3540
+ }
3541
+ let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
3542
+ if (value === 2) {
3543
+ ansi += 60;
3544
+ }
3545
+ return ansi;
3546
+ };
3547
+ convert.hsv.ansi16 = function(args) {
3548
+ return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
3549
+ };
3550
+ convert.rgb.ansi256 = function(args) {
3551
+ const r = args[0];
3552
+ const g = args[1];
3553
+ const b = args[2];
3554
+ if (r >> 4 === g >> 4 && g >> 4 === b >> 4) {
3555
+ if (r < 8) {
3556
+ return 16;
3557
+ }
3558
+ if (r > 248) {
3559
+ return 231;
3560
+ }
3561
+ return Math.round((r - 8) / 247 * 24) + 232;
3562
+ }
3563
+ const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
3564
+ return ansi;
3565
+ };
3566
+ convert.ansi16.rgb = function(args) {
3567
+ args = args[0];
3568
+ let color = args % 10;
3569
+ if (color === 0 || color === 7) {
3570
+ if (args > 50) {
3571
+ color += 3.5;
3572
+ }
3573
+ color = color / 10.5 * 255;
3574
+ return [color, color, color];
3575
+ }
3576
+ const mult = (Math.trunc(args > 50) + 1) * 0.5;
3577
+ const r = (color & 1) * mult * 255;
3578
+ const g = (color >> 1 & 1) * mult * 255;
3579
+ const b = (color >> 2 & 1) * mult * 255;
3580
+ return [r, g, b];
3581
+ };
3582
+ convert.ansi256.rgb = function(args) {
3583
+ args = args[0];
3584
+ if (args >= 232) {
3585
+ const c = (args - 232) * 10 + 8;
3586
+ return [c, c, c];
3587
+ }
3588
+ args -= 16;
3589
+ let rem;
3590
+ const r = Math.floor(args / 36) / 5 * 255;
3591
+ const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
3592
+ const b = rem % 6 / 5 * 255;
3593
+ return [r, g, b];
3594
+ };
3595
+ convert.rgb.hex = function(args) {
3596
+ const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
3597
+ const string = integer.toString(16).toUpperCase();
3598
+ return "000000".slice(string.length) + string;
3599
+ };
3600
+ convert.hex.rgb = function(args) {
3601
+ const match = args.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);
3602
+ if (!match) {
3603
+ return [0, 0, 0];
3604
+ }
3605
+ let colorString = match[0];
3606
+ if (match[0].length === 3) {
3607
+ colorString = [...colorString].map((char) => char + char).join("");
3608
+ }
3609
+ const integer = Number.parseInt(colorString, 16);
3610
+ const r = integer >> 16 & 255;
3611
+ const g = integer >> 8 & 255;
3612
+ const b = integer & 255;
3613
+ return [r, g, b];
3614
+ };
3615
+ convert.rgb.hcg = function(rgb) {
3616
+ const r = rgb[0] / 255;
3617
+ const g = rgb[1] / 255;
3618
+ const b = rgb[2] / 255;
3619
+ const max = Math.max(Math.max(r, g), b);
3620
+ const min = Math.min(Math.min(r, g), b);
3621
+ const chroma = max - min;
3622
+ let hue;
3623
+ const grayscale = chroma < 1 ? min / (1 - chroma) : 0;
3624
+ if (chroma <= 0) {
3625
+ hue = 0;
3626
+ } else if (max === r) {
3627
+ hue = (g - b) / chroma % 6;
3628
+ } else if (max === g) {
3629
+ hue = 2 + (b - r) / chroma;
3630
+ } else {
3631
+ hue = 4 + (r - g) / chroma;
3632
+ }
3633
+ hue /= 6;
3634
+ hue %= 1;
3635
+ return [hue * 360, chroma * 100, grayscale * 100];
3636
+ };
3637
+ convert.hsl.hcg = function(hsl) {
3638
+ const s = hsl[1] / 100;
3639
+ const l = hsl[2] / 100;
3640
+ const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);
3641
+ let f = 0;
3642
+ if (c < 1) {
3643
+ f = (l - 0.5 * c) / (1 - c);
3644
+ }
3645
+ return [hsl[0], c * 100, f * 100];
3646
+ };
3647
+ convert.hsv.hcg = function(hsv) {
3648
+ const s = hsv[1] / 100;
3649
+ const v = hsv[2] / 100;
3650
+ const c = s * v;
3651
+ let f = 0;
3652
+ if (c < 1) {
3653
+ f = (v - c) / (1 - c);
3654
+ }
3655
+ return [hsv[0], c * 100, f * 100];
3656
+ };
3657
+ convert.hcg.rgb = function(hcg) {
3658
+ const h = hcg[0] / 360;
3659
+ const c = hcg[1] / 100;
3660
+ const g = hcg[2] / 100;
3661
+ if (c === 0) {
3662
+ return [g * 255, g * 255, g * 255];
3663
+ }
3664
+ const pure = [0, 0, 0];
3665
+ const hi = h % 1 * 6;
3666
+ const v = hi % 1;
3667
+ const w = 1 - v;
3668
+ let mg = 0;
3669
+ switch (Math.floor(hi)) {
3670
+ case 0: {
3671
+ pure[0] = 1;
3672
+ pure[1] = v;
3673
+ pure[2] = 0;
3674
+ break;
3675
+ }
3676
+ case 1: {
3677
+ pure[0] = w;
3678
+ pure[1] = 1;
3679
+ pure[2] = 0;
3680
+ break;
3681
+ }
3682
+ case 2: {
3683
+ pure[0] = 0;
3684
+ pure[1] = 1;
3685
+ pure[2] = v;
3686
+ break;
3687
+ }
3688
+ case 3: {
3689
+ pure[0] = 0;
3690
+ pure[1] = w;
3691
+ pure[2] = 1;
3692
+ break;
3693
+ }
3694
+ case 4: {
3695
+ pure[0] = v;
3696
+ pure[1] = 0;
3697
+ pure[2] = 1;
3698
+ break;
3699
+ }
3700
+ default: {
3701
+ pure[0] = 1;
3702
+ pure[1] = 0;
3703
+ pure[2] = w;
3704
+ }
3705
+ }
3706
+ mg = (1 - c) * g;
3707
+ return [
3708
+ (c * pure[0] + mg) * 255,
3709
+ (c * pure[1] + mg) * 255,
3710
+ (c * pure[2] + mg) * 255
3711
+ ];
3712
+ };
3713
+ convert.hcg.hsv = function(hcg) {
3714
+ const c = hcg[1] / 100;
3715
+ const g = hcg[2] / 100;
3716
+ const v = c + g * (1 - c);
3717
+ let f = 0;
3718
+ if (v > 0) {
3719
+ f = c / v;
3720
+ }
3721
+ return [hcg[0], f * 100, v * 100];
3722
+ };
3723
+ convert.hcg.hsl = function(hcg) {
3724
+ const c = hcg[1] / 100;
3725
+ const g = hcg[2] / 100;
3726
+ const l = g * (1 - c) + 0.5 * c;
3727
+ let s = 0;
3728
+ if (l > 0 && l < 0.5) {
3729
+ s = c / (2 * l);
3730
+ } else if (l >= 0.5 && l < 1) {
3731
+ s = c / (2 * (1 - l));
3732
+ }
3733
+ return [hcg[0], s * 100, l * 100];
3734
+ };
3735
+ convert.hcg.hwb = function(hcg) {
3736
+ const c = hcg[1] / 100;
3737
+ const g = hcg[2] / 100;
3738
+ const v = c + g * (1 - c);
3739
+ return [hcg[0], (v - c) * 100, (1 - v) * 100];
3740
+ };
3741
+ convert.hwb.hcg = function(hwb) {
3742
+ const w = hwb[1] / 100;
3743
+ const b = hwb[2] / 100;
3744
+ const v = 1 - b;
3745
+ const c = v - w;
3746
+ let g = 0;
3747
+ if (c < 1) {
3748
+ g = (v - c) / (1 - c);
3749
+ }
3750
+ return [hwb[0], c * 100, g * 100];
3751
+ };
3752
+ convert.apple.rgb = function(apple) {
3753
+ return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
3754
+ };
3755
+ convert.rgb.apple = function(rgb) {
3756
+ return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
3757
+ };
3758
+ convert.gray.rgb = function(args) {
3759
+ return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
3760
+ };
3761
+ convert.gray.hsl = function(args) {
3762
+ return [0, 0, args[0]];
3763
+ };
3764
+ convert.gray.hsv = convert.gray.hsl;
3765
+ convert.gray.hwb = function(gray) {
3766
+ return [0, 100, gray[0]];
3767
+ };
3768
+ convert.gray.cmyk = function(gray) {
3769
+ return [0, 0, 0, gray[0]];
3770
+ };
3771
+ convert.gray.lab = function(gray) {
3772
+ return [gray[0], 0, 0];
3773
+ };
3774
+ convert.gray.hex = function(gray) {
3775
+ const value = Math.round(gray[0] / 100 * 255) & 255;
3776
+ const integer = (value << 16) + (value << 8) + value;
3777
+ const string = integer.toString(16).toUpperCase();
3778
+ return "000000".slice(string.length) + string;
3779
+ };
3780
+ convert.rgb.gray = function(rgb) {
3781
+ const value = (rgb[0] + rgb[1] + rgb[2]) / 3;
3782
+ return [value / 255 * 100];
3783
+ };
3784
+
3785
+ // node_modules/color-convert/route.js
3786
+ function buildGraph() {
3787
+ const graph = {};
3788
+ const models2 = Object.keys(conversions_default);
3789
+ for (let { length } = models2, i = 0; i < length; i++) {
3790
+ graph[models2[i]] = {
3791
+ // http://jsperf.com/1-vs-infinity
3792
+ // micro-opt, but this is simple.
3793
+ distance: -1,
3794
+ parent: null
3795
+ };
3796
+ }
3797
+ return graph;
3798
+ }
3799
+ function deriveBFS(fromModel) {
3800
+ const graph = buildGraph();
3801
+ const queue = [fromModel];
3802
+ graph[fromModel].distance = 0;
3803
+ while (queue.length > 0) {
3804
+ const current = queue.pop();
3805
+ const adjacents = Object.keys(conversions_default[current]);
3806
+ for (let { length } = adjacents, i = 0; i < length; i++) {
3807
+ const adjacent = adjacents[i];
3808
+ const node = graph[adjacent];
3809
+ if (node.distance === -1) {
3810
+ node.distance = graph[current].distance + 1;
3811
+ node.parent = current;
3812
+ queue.unshift(adjacent);
3813
+ }
3814
+ }
3815
+ }
3816
+ return graph;
3817
+ }
3818
+ function link(from, to) {
3819
+ return function(args) {
3820
+ return to(from(args));
3821
+ };
3822
+ }
3823
+ function wrapConversion(toModel, graph) {
3824
+ const path = [graph[toModel].parent, toModel];
3825
+ let fn = conversions_default[graph[toModel].parent][toModel];
3826
+ let cur = graph[toModel].parent;
3827
+ while (graph[cur].parent) {
3828
+ path.unshift(graph[cur].parent);
3829
+ fn = link(conversions_default[graph[cur].parent][cur], fn);
3830
+ cur = graph[cur].parent;
3831
+ }
3832
+ fn.conversion = path;
3833
+ return fn;
3834
+ }
3835
+ function route(fromModel) {
3836
+ const graph = deriveBFS(fromModel);
3837
+ const conversion = {};
3838
+ const models2 = Object.keys(graph);
3839
+ for (let { length } = models2, i = 0; i < length; i++) {
3840
+ const toModel = models2[i];
3841
+ const node = graph[toModel];
3842
+ if (node.parent === null) {
3843
+ continue;
3844
+ }
3845
+ conversion[toModel] = wrapConversion(toModel, graph);
3846
+ }
3847
+ return conversion;
3848
+ }
3849
+ var route_default = route;
3850
+
3851
+ // node_modules/color-convert/index.js
3852
+ var convert2 = {};
3853
+ var models = Object.keys(conversions_default);
3854
+ function wrapRaw(fn) {
3855
+ const wrappedFn = function(...args) {
3856
+ const arg0 = args[0];
3857
+ if (arg0 === void 0 || arg0 === null) {
3858
+ return arg0;
3859
+ }
3860
+ if (arg0.length > 1) {
3861
+ args = arg0;
3862
+ }
3863
+ return fn(args);
3864
+ };
3865
+ if ("conversion" in fn) {
3866
+ wrappedFn.conversion = fn.conversion;
3867
+ }
3868
+ return wrappedFn;
3869
+ }
3870
+ function wrapRounded(fn) {
3871
+ const wrappedFn = function(...args) {
3872
+ const arg0 = args[0];
3873
+ if (arg0 === void 0 || arg0 === null) {
3874
+ return arg0;
3875
+ }
3876
+ if (arg0.length > 1) {
3877
+ args = arg0;
3878
+ }
3879
+ const result = fn(args);
3880
+ if (typeof result === "object") {
3881
+ for (let { length } = result, i = 0; i < length; i++) {
3882
+ result[i] = Math.round(result[i]);
3883
+ }
3884
+ }
3885
+ return result;
3886
+ };
3887
+ if ("conversion" in fn) {
3888
+ wrappedFn.conversion = fn.conversion;
3889
+ }
3890
+ return wrappedFn;
3891
+ }
3892
+ for (const fromModel of models) {
3893
+ convert2[fromModel] = {};
3894
+ Object.defineProperty(convert2[fromModel], "channels", { value: conversions_default[fromModel].channels });
3895
+ Object.defineProperty(convert2[fromModel], "labels", { value: conversions_default[fromModel].labels });
3896
+ const routes = route_default(fromModel);
3897
+ const routeModels = Object.keys(routes);
3898
+ for (const toModel of routeModels) {
3899
+ const fn = routes[toModel];
3900
+ convert2[fromModel][toModel] = wrapRounded(fn);
3901
+ convert2[fromModel][toModel].raw = wrapRaw(fn);
3902
+ }
3903
+ }
3904
+ var color_convert_default = convert2;
3905
+
3906
+ // node_modules/color/index.js
3907
+ var skippedModels = [
3908
+ // To be honest, I don't really feel like keyword belongs in color convert, but eh.
3909
+ "keyword",
3910
+ // Gray conflicts with some method names, and has its own method defined.
3911
+ "gray",
3912
+ // Shouldn't really be in color-convert either...
3913
+ "hex"
3914
+ ];
3915
+ var hashedModelKeys = {};
3916
+ for (const model of Object.keys(color_convert_default)) {
3917
+ hashedModelKeys[[...color_convert_default[model].labels].sort().join("")] = model;
3918
+ }
3919
+ var limiters = {};
3920
+ function Color(object, model) {
3921
+ if (!(this instanceof Color)) {
3922
+ return new Color(object, model);
3923
+ }
3924
+ if (model && model in skippedModels) {
3925
+ model = null;
3926
+ }
3927
+ if (model && !(model in color_convert_default)) {
3928
+ throw new Error("Unknown model: " + model);
3929
+ }
3930
+ let i;
3931
+ let channels;
3932
+ if (object == null) {
3933
+ this.model = "rgb";
3934
+ this.color = [0, 0, 0];
3935
+ this.valpha = 1;
3936
+ } else if (object instanceof Color) {
3937
+ this.model = object.model;
3938
+ this.color = [...object.color];
3939
+ this.valpha = object.valpha;
3940
+ } else if (typeof object === "string") {
3941
+ const result = color_string_default.get(object);
3942
+ if (result === null) {
3943
+ throw new Error("Unable to parse color from string: " + object);
3944
+ }
3945
+ this.model = result.model;
3946
+ channels = color_convert_default[this.model].channels;
3947
+ this.color = result.value.slice(0, channels);
3948
+ this.valpha = typeof result.value[channels] === "number" ? result.value[channels] : 1;
3949
+ } else if (object.length > 0) {
3950
+ this.model = model || "rgb";
3951
+ channels = color_convert_default[this.model].channels;
3952
+ const newArray = Array.prototype.slice.call(object, 0, channels);
3953
+ this.color = zeroArray(newArray, channels);
3954
+ this.valpha = typeof object[channels] === "number" ? object[channels] : 1;
3955
+ } else if (typeof object === "number") {
3956
+ this.model = "rgb";
3957
+ this.color = [
3958
+ object >> 16 & 255,
3959
+ object >> 8 & 255,
3960
+ object & 255
3961
+ ];
3962
+ this.valpha = 1;
3963
+ } else {
3964
+ this.valpha = 1;
3965
+ const keys = Object.keys(object);
3966
+ if ("alpha" in object) {
3967
+ keys.splice(keys.indexOf("alpha"), 1);
3968
+ this.valpha = typeof object.alpha === "number" ? object.alpha : 0;
3969
+ }
3970
+ const hashedKeys = keys.sort().join("");
3971
+ if (!(hashedKeys in hashedModelKeys)) {
3972
+ throw new Error("Unable to parse color from object: " + JSON.stringify(object));
3973
+ }
3974
+ this.model = hashedModelKeys[hashedKeys];
3975
+ const { labels } = color_convert_default[this.model];
3976
+ const color = [];
3977
+ for (i = 0; i < labels.length; i++) {
3978
+ color.push(object[labels[i]]);
3979
+ }
3980
+ this.color = zeroArray(color);
3981
+ }
3982
+ if (limiters[this.model]) {
3983
+ channels = color_convert_default[this.model].channels;
3984
+ for (i = 0; i < channels; i++) {
3985
+ const limit = limiters[this.model][i];
3986
+ if (limit) {
3987
+ this.color[i] = limit(this.color[i]);
3988
+ }
3989
+ }
3990
+ }
3991
+ this.valpha = Math.max(0, Math.min(1, this.valpha));
3992
+ if (Object.freeze) {
3993
+ Object.freeze(this);
3994
+ }
3995
+ }
3996
+ Color.prototype = {
3997
+ toString() {
3998
+ return this.string();
3999
+ },
4000
+ toJSON() {
4001
+ return this[this.model]();
4002
+ },
4003
+ string(places) {
4004
+ let self = this.model in color_string_default.to ? this : this.rgb();
4005
+ self = self.round(typeof places === "number" ? places : 1);
4006
+ const arguments_ = self.valpha === 1 ? self.color : [...self.color, this.valpha];
4007
+ return color_string_default.to[self.model](...arguments_);
4008
+ },
4009
+ percentString(places) {
4010
+ const self = this.rgb().round(typeof places === "number" ? places : 1);
4011
+ const arguments_ = self.valpha === 1 ? self.color : [...self.color, this.valpha];
4012
+ return color_string_default.to.rgb.percent(...arguments_);
4013
+ },
4014
+ array() {
4015
+ return this.valpha === 1 ? [...this.color] : [...this.color, this.valpha];
4016
+ },
4017
+ object() {
4018
+ const result = {};
4019
+ const { channels } = color_convert_default[this.model];
4020
+ const { labels } = color_convert_default[this.model];
4021
+ for (let i = 0; i < channels; i++) {
4022
+ result[labels[i]] = this.color[i];
4023
+ }
4024
+ if (this.valpha !== 1) {
4025
+ result.alpha = this.valpha;
4026
+ }
4027
+ return result;
4028
+ },
4029
+ unitArray() {
4030
+ const rgb = this.rgb().color;
4031
+ rgb[0] /= 255;
4032
+ rgb[1] /= 255;
4033
+ rgb[2] /= 255;
4034
+ if (this.valpha !== 1) {
4035
+ rgb.push(this.valpha);
4036
+ }
4037
+ return rgb;
4038
+ },
4039
+ unitObject() {
4040
+ const rgb = this.rgb().object();
4041
+ rgb.r /= 255;
4042
+ rgb.g /= 255;
4043
+ rgb.b /= 255;
4044
+ if (this.valpha !== 1) {
4045
+ rgb.alpha = this.valpha;
4046
+ }
4047
+ return rgb;
4048
+ },
4049
+ round(places) {
4050
+ places = Math.max(places || 0, 0);
4051
+ return new Color([...this.color.map(roundToPlace(places)), this.valpha], this.model);
4052
+ },
4053
+ alpha(value) {
4054
+ if (value !== void 0) {
4055
+ return new Color([...this.color, Math.max(0, Math.min(1, value))], this.model);
4056
+ }
4057
+ return this.valpha;
4058
+ },
4059
+ // Rgb
4060
+ red: getset("rgb", 0, maxfn(255)),
4061
+ green: getset("rgb", 1, maxfn(255)),
4062
+ blue: getset("rgb", 2, maxfn(255)),
4063
+ hue: getset(["hsl", "hsv", "hsl", "hwb", "hcg"], 0, (value) => (value % 360 + 360) % 360),
4064
+ saturationl: getset("hsl", 1, maxfn(100)),
4065
+ lightness: getset("hsl", 2, maxfn(100)),
4066
+ saturationv: getset("hsv", 1, maxfn(100)),
4067
+ value: getset("hsv", 2, maxfn(100)),
4068
+ chroma: getset("hcg", 1, maxfn(100)),
4069
+ gray: getset("hcg", 2, maxfn(100)),
4070
+ white: getset("hwb", 1, maxfn(100)),
4071
+ wblack: getset("hwb", 2, maxfn(100)),
4072
+ cyan: getset("cmyk", 0, maxfn(100)),
4073
+ magenta: getset("cmyk", 1, maxfn(100)),
4074
+ yellow: getset("cmyk", 2, maxfn(100)),
4075
+ black: getset("cmyk", 3, maxfn(100)),
4076
+ x: getset("xyz", 0, maxfn(95.047)),
4077
+ y: getset("xyz", 1, maxfn(100)),
4078
+ z: getset("xyz", 2, maxfn(108.833)),
4079
+ l: getset("lab", 0, maxfn(100)),
4080
+ a: getset("lab", 1),
4081
+ b: getset("lab", 2),
4082
+ keyword(value) {
4083
+ if (value !== void 0) {
4084
+ return new Color(value);
4085
+ }
4086
+ return color_convert_default[this.model].keyword(this.color);
4087
+ },
4088
+ hex(value) {
4089
+ if (value !== void 0) {
4090
+ return new Color(value);
4091
+ }
4092
+ return color_string_default.to.hex(...this.rgb().round().color);
4093
+ },
4094
+ hexa(value) {
4095
+ if (value !== void 0) {
4096
+ return new Color(value);
4097
+ }
4098
+ const rgbArray = this.rgb().round().color;
4099
+ let alphaHex = Math.round(this.valpha * 255).toString(16).toUpperCase();
4100
+ if (alphaHex.length === 1) {
4101
+ alphaHex = "0" + alphaHex;
4102
+ }
4103
+ return color_string_default.to.hex(...rgbArray) + alphaHex;
4104
+ },
4105
+ rgbNumber() {
4106
+ const rgb = this.rgb().color;
4107
+ return (rgb[0] & 255) << 16 | (rgb[1] & 255) << 8 | rgb[2] & 255;
4108
+ },
4109
+ luminosity() {
4110
+ const rgb = this.rgb().color;
4111
+ const lum = [];
4112
+ for (const [i, element] of rgb.entries()) {
4113
+ const chan = element / 255;
4114
+ lum[i] = chan <= 0.04045 ? chan / 12.92 : ((chan + 0.055) / 1.055) ** 2.4;
4115
+ }
4116
+ return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];
4117
+ },
4118
+ contrast(color2) {
4119
+ const lum1 = this.luminosity();
4120
+ const lum2 = color2.luminosity();
4121
+ if (lum1 > lum2) {
4122
+ return (lum1 + 0.05) / (lum2 + 0.05);
4123
+ }
4124
+ return (lum2 + 0.05) / (lum1 + 0.05);
4125
+ },
4126
+ level(color2) {
4127
+ const contrastRatio = this.contrast(color2);
4128
+ if (contrastRatio >= 7) {
4129
+ return "AAA";
4130
+ }
4131
+ return contrastRatio >= 4.5 ? "AA" : "";
4132
+ },
4133
+ isDark() {
4134
+ const rgb = this.rgb().color;
4135
+ const yiq = (rgb[0] * 2126 + rgb[1] * 7152 + rgb[2] * 722) / 1e4;
4136
+ return yiq < 128;
4137
+ },
4138
+ isLight() {
4139
+ return !this.isDark();
4140
+ },
4141
+ negate() {
4142
+ const rgb = this.rgb();
4143
+ for (let i = 0; i < 3; i++) {
4144
+ rgb.color[i] = 255 - rgb.color[i];
4145
+ }
4146
+ return rgb;
4147
+ },
4148
+ lighten(ratio) {
4149
+ const hsl = this.hsl();
4150
+ hsl.color[2] += hsl.color[2] * ratio;
4151
+ return hsl;
4152
+ },
4153
+ darken(ratio) {
4154
+ const hsl = this.hsl();
4155
+ hsl.color[2] -= hsl.color[2] * ratio;
4156
+ return hsl;
4157
+ },
4158
+ saturate(ratio) {
4159
+ const hsl = this.hsl();
4160
+ hsl.color[1] += hsl.color[1] * ratio;
4161
+ return hsl;
4162
+ },
4163
+ desaturate(ratio) {
4164
+ const hsl = this.hsl();
4165
+ hsl.color[1] -= hsl.color[1] * ratio;
4166
+ return hsl;
4167
+ },
4168
+ whiten(ratio) {
4169
+ const hwb = this.hwb();
4170
+ hwb.color[1] += hwb.color[1] * ratio;
4171
+ return hwb;
4172
+ },
4173
+ blacken(ratio) {
4174
+ const hwb = this.hwb();
4175
+ hwb.color[2] += hwb.color[2] * ratio;
4176
+ return hwb;
4177
+ },
4178
+ grayscale() {
4179
+ const rgb = this.rgb().color;
4180
+ const value = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;
4181
+ return Color.rgb(value, value, value);
4182
+ },
4183
+ fade(ratio) {
4184
+ return this.alpha(this.valpha - this.valpha * ratio);
4185
+ },
4186
+ opaquer(ratio) {
4187
+ return this.alpha(this.valpha + this.valpha * ratio);
4188
+ },
4189
+ rotate(degrees) {
4190
+ const hsl = this.hsl();
4191
+ let hue = hsl.color[0];
4192
+ hue = (hue + degrees) % 360;
4193
+ hue = hue < 0 ? 360 + hue : hue;
4194
+ hsl.color[0] = hue;
4195
+ return hsl;
4196
+ },
4197
+ mix(mixinColor, weight) {
4198
+ if (!mixinColor || !mixinColor.rgb) {
4199
+ throw new Error('Argument to "mix" was not a Color instance, but rather an instance of ' + typeof mixinColor);
4200
+ }
4201
+ const color1 = mixinColor.rgb();
4202
+ const color2 = this.rgb();
4203
+ const p = weight === void 0 ? 0.5 : weight;
4204
+ const w = 2 * p - 1;
4205
+ const a = color1.alpha() - color2.alpha();
4206
+ const w1 = ((w * a === -1 ? w : (w + a) / (1 + w * a)) + 1) / 2;
4207
+ const w2 = 1 - w1;
4208
+ return Color.rgb(
4209
+ w1 * color1.red() + w2 * color2.red(),
4210
+ w1 * color1.green() + w2 * color2.green(),
4211
+ w1 * color1.blue() + w2 * color2.blue(),
4212
+ color1.alpha() * p + color2.alpha() * (1 - p)
4213
+ );
4214
+ }
4215
+ };
4216
+ for (const model of Object.keys(color_convert_default)) {
4217
+ if (skippedModels.includes(model)) {
4218
+ continue;
4219
+ }
4220
+ const { channels } = color_convert_default[model];
4221
+ Color.prototype[model] = function(...arguments_) {
4222
+ if (this.model === model) {
4223
+ return new Color(this);
4224
+ }
4225
+ if (arguments_.length > 0) {
4226
+ return new Color(arguments_, model);
4227
+ }
4228
+ return new Color([...assertArray(color_convert_default[this.model][model].raw(this.color)), this.valpha], model);
4229
+ };
4230
+ Color[model] = function(...arguments_) {
4231
+ let color = arguments_[0];
4232
+ if (typeof color === "number") {
4233
+ color = zeroArray(arguments_, channels);
4234
+ }
4235
+ return new Color(color, model);
4236
+ };
4237
+ }
4238
+ function roundTo(number, places) {
4239
+ return Number(number.toFixed(places));
4240
+ }
4241
+ function roundToPlace(places) {
4242
+ return function(number) {
4243
+ return roundTo(number, places);
4244
+ };
4245
+ }
4246
+ function getset(model, channel, modifier) {
4247
+ model = Array.isArray(model) ? model : [model];
4248
+ for (const m of model) {
4249
+ (limiters[m] || (limiters[m] = []))[channel] = modifier;
4250
+ }
4251
+ model = model[0];
4252
+ return function(value) {
4253
+ let result;
4254
+ if (value !== void 0) {
4255
+ if (modifier) {
4256
+ value = modifier(value);
4257
+ }
4258
+ result = this[model]();
4259
+ result.color[channel] = value;
4260
+ return result;
4261
+ }
4262
+ result = this[model]().color[channel];
4263
+ if (modifier) {
4264
+ result = modifier(result);
4265
+ }
4266
+ return result;
4267
+ };
4268
+ }
4269
+ function maxfn(max) {
4270
+ return function(v) {
4271
+ return Math.max(0, Math.min(max, v));
4272
+ };
4273
+ }
4274
+ function assertArray(value) {
4275
+ return Array.isArray(value) ? value : [value];
4276
+ }
4277
+ function zeroArray(array, length) {
4278
+ for (let i = 0; i < length; i++) {
4279
+ if (typeof array[i] !== "number") {
4280
+ array[i] = 0;
4281
+ }
4282
+ }
4283
+ return array;
4284
+ }
4285
+ var color_default = Color;
4286
+
2715
4287
  // src/components/ui/color-picker.tsx
2716
- import Color from "color";
2717
4288
  import { PipetteIcon } from "lucide-react";
2718
4289
  import { Slider } from "radix-ui";
2719
4290
  import {
@@ -2742,8 +4313,8 @@ var ColorPicker = ({
2742
4313
  className,
2743
4314
  ...props
2744
4315
  }) => {
2745
- const selectedColor = Color(value);
2746
- const defaultColor = Color(defaultValue);
4316
+ const selectedColor = color_default(value);
4317
+ const defaultColor = color_default(defaultValue);
2747
4318
  const [hue, setHue] = useState6(selectedColor.hue() || defaultColor.hue() || 0);
2748
4319
  const [saturation, setSaturation] = useState6(
2749
4320
  selectedColor.saturationl() || defaultColor.saturationl() || 100
@@ -2763,7 +4334,7 @@ var ColorPicker = ({
2763
4334
  alphaRef.current = alpha;
2764
4335
  useEffect4(() => {
2765
4336
  if (value) {
2766
- const color = Color(value);
4337
+ const color = color_default(value);
2767
4338
  const hsl = color.hsl().object();
2768
4339
  setHue(hsl.h);
2769
4340
  setSaturation(hsl.s);
@@ -2797,7 +4368,7 @@ var ColorPicker = ({
2797
4368
  alphaRef.current = updates.a;
2798
4369
  }
2799
4370
  if (onChange) {
2800
- const color = Color.hsl(newH, newS, newL).alpha(newA / 100);
4371
+ const color = color_default.hsl(newH, newS, newL).alpha(newA / 100);
2801
4372
  const rgba = color.rgb().array();
2802
4373
  onChange([rgba[0], rgba[1], rgba[2], newA / 100]);
2803
4374
  }
@@ -2910,7 +4481,7 @@ var ColorPickerEyeDropper = ({ className, ...props }) => {
2910
4481
  try {
2911
4482
  const eyeDropper = new EyeDropper();
2912
4483
  const result = await eyeDropper.open();
2913
- const color = Color(result.sRGBHex);
4484
+ const color = color_default(result.sRGBHex);
2914
4485
  const [h, s, l] = color.hsl().array();
2915
4486
  updateColor({ h, s, l, a: 100 });
2916
4487
  } catch (error) {
@@ -2949,7 +4520,7 @@ var PercentageInput = ({ className, ...props }) => {
2949
4520
  };
2950
4521
  var ColorPickerFormat = ({ className, ...props }) => {
2951
4522
  const { hue, saturation, lightness, alpha, mode } = useColorPicker();
2952
- const color = Color.hsl(hue, saturation, lightness, alpha / 100);
4523
+ const color = color_default.hsl(hue, saturation, lightness, alpha / 100);
2953
4524
  if (mode === "hex") {
2954
4525
  const hex = color.hex();
2955
4526
  return /* @__PURE__ */ jsxs23(
@@ -4423,14 +5994,14 @@ import { useState as useState12, useEffect as useEffect6, useMemo as useMemo11,
4423
5994
  import { useState as useState11, useCallback as useCallback21 } from "react";
4424
5995
  function useEditableValue(options) {
4425
5996
  const { externalValue, onChange, toLocal, toExternal } = options;
4426
- const convert = toLocal ?? String;
4427
- const [localValue, setLocalValue] = useState11(convert(externalValue));
5997
+ const convert3 = toLocal ?? String;
5998
+ const [localValue, setLocalValue] = useState11(convert3(externalValue));
4428
5999
  const [isFocused, setIsFocused] = useState11(false);
4429
- const displayValue = isFocused ? localValue : convert(externalValue);
6000
+ const displayValue = isFocused ? localValue : convert3(externalValue);
4430
6001
  const handleFocus = useCallback21(() => {
4431
- setLocalValue(convert(externalValue));
6002
+ setLocalValue(convert3(externalValue));
4432
6003
  setIsFocused(true);
4433
- }, [externalValue, convert]);
6004
+ }, [externalValue, convert3]);
4434
6005
  const handleBlur = useCallback21(() => {
4435
6006
  setIsFocused(false);
4436
6007
  if (toExternal) {