@kgalexander/mcreate 1.0.1 → 1.0.3

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