UNPKG

@a_ng_d/utils-ui-color-palette

Version:

Core utilities library for UI Color Palette - a color management plugin for design tools. This library provides the foundational color manipulation, contrast calculation, and palette generation features used in the plugin.

1,159 lines (1,149 loc) 54.7 kB
var U = Object.defineProperty; var K = (r, p, h) => p in r ? U(r, p, { enumerable: !0, configurable: !0, writable: !0, value: h }) : r[p] = h; var C = (r, p, h) => K(r, typeof p != "symbol" ? p + "" : p, h); import { c as v } from "../../index-Beb8qoyd.js"; var I = Object.defineProperty, R = (r, p, h) => p in r ? I(r, p, { enumerable: !0, configurable: !0, writable: !0, value: h }) : r[p] = h, M = (r, p, h) => R(r, typeof p != "symbol" ? p + "" : p, h); class d { constructor(p) { M(this, "string"), M(this, "doSnakeCase", () => this.string.toLowerCase().split(" ").join("_").replace(/[@/$^%#&!?.,;:+=<>(){}"«»]/g, "")), M(this, "doPascalCase", () => this.string.charAt(0).toUpperCase() + this.string.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g, (h) => h.toUpperCase()).replace(/[@/$^%#&!?.,;:+=<>(){}"«» ]/g, "").slice(1)), M(this, "doKebabCase", () => this.string.toLowerCase().split(" ").join("-").replace(/[@/$^%#&!?.,;:+=<>(){}"«»]/g, "")), M(this, "doCamelCase", () => this.string.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g, (h) => h.toUpperCase()).replace(/[@/$^%#&!?.,;:+=<>(){}"«» ]/g, "")), this.string = p; } } const j = (r) => { const p = r.split(":"); if (p.length !== 3) return null; const [h, c, m] = p; return !h || !c || !m ? null : { themeId: h, colorId: c, shadeName: m }; }, L = (r, p, h) => { const c = r.themes.find((i) => i.id === p), m = c == null ? void 0 : c.colors.find((i) => i.id === h); return (m == null ? void 0 : m.name) ?? null; }, F = (r, p) => { var h; return ((h = r.themes.find((c) => c.id === p)) == null ? void 0 : h.name) ?? null; }, x = (r) => r.themes.filter((p) => p.type === "custom theme").length === 0 ? r.themes.filter((p) => p.type === "default theme") : r.themes.filter((p) => p.type === "custom theme"), g = (r, p) => p.refs.map((h) => { if (h.shadeId === null) return { themeId: h.themeId, themeName: F(r, h.themeId), colorName: null, shadeName: null, isUnbound: !0 }; const c = j(h.shadeId); return c ? { themeId: h.themeId, themeName: F(r, h.themeId), colorName: L(r, h.themeId, c.colorId), shadeName: c.shadeName, isUnbound: !1 } : { themeId: h.themeId, themeName: F(r, h.themeId), colorName: null, shadeName: null, isUnbound: !0 }; }), w = (r, p) => { const h = [], c = [], m = []; return p.tokens.forEach((i) => { if (i.isExcluded) { m.push(i); return; } g(r, i).every((e) => e.isUnbound) ? c.push(i) : h.push(i); }), { bound: h, unbound: c, excluded: m }; }, V = (r, p) => { const { bound: h, unbound: c } = w(r, p), m = x(r), i = m.filter((a) => a.type === "custom theme"), o = {}; c.length > 0 && (o._unbound = c.map((a) => a.pathNames.join("."))); const e = (a, t, s) => { let n = a; for (let l = 0; l < t.length - 1; l++) { const f = t[l]; (typeof n[f] != "object" || n[f] === null) && (n[f] = {}), n = n[f]; } n[t[t.length - 1]] = s; }, u = (a, t) => ({ $ref: `${new d(a).doKebabCase()}.${t}` }); return i.length === 0 ? h.forEach((a) => { const t = a.pathNames.map((l) => new d(l).doKebabCase()), n = g(r, a).find((l) => !l.isUnbound); !n || !n.colorName || !n.shadeName || e(o, t, u(n.colorName, n.shadeName)); }) : m.forEach((a) => { const t = new d(a.name).doKebabCase(), s = {}; h.forEach((n) => { const l = n.pathNames.map((b) => new d(b).doKebabCase()), $ = g(r, n).find((b) => b.themeId === a.id); !$ || $.isUnbound || !$.colorName || !$.shadeName || e(s, l, u($.colorName, $.shadeName)); }), o[t] = s; }), JSON.stringify(o, null, 2); }, O = (r, p) => { const { bound: h, unbound: c } = w(r, p), m = x(r), i = r.themes.find((t) => t.type === "default theme") ?? m[0], o = m.filter((t) => t.type === "custom theme"), e = ["import UIKit", ""]; c.length > 0 && (e.push("// Unbound semantic tokens"), c.forEach((t) => e.push(`// ${t.pathNames.join("-")}`)), e.push("")); const u = (t) => new d(t.join(" ")).doCamelCase(), a = (t, s, n) => { const l = new d(s).doCamelCase(), f = n === "source" ? "Source" : new d(n).doPascalCase(); return t ? `Color.${new d(t).doPascalCase()}.${l}${f}` : `Color.${l}${f}`; }; return e.push("struct SemanticToken {"), o.length === 0 ? h.forEach((t) => { const s = g(r, t), n = s.find((l) => l.themeId === i.id && !l.isUnbound) ?? s.find((l) => !l.isUnbound); !n || !n.colorName || !n.shadeName || e.push( ` static let ${u(t.pathNames)} = ${a(null, n.colorName, n.shadeName)}` ); }) : m.forEach((t) => { const s = new d(t.name).doPascalCase(); e.push(` struct ${s} {`), h.forEach((n) => { const f = g(r, n).find(($) => $.themeId === t.id); !f || f.isUnbound || !f.colorName || !f.shadeName || e.push( ` static let ${u(n.pathNames)} = ${a(t.name, f.colorName, f.shadeName)}` ); }), e.push(" }"); }), e.push("}"), e.join(` `); }, P = (r, p) => { const { bound: h, unbound: c } = w(r, p), m = x(r), i = r.themes.find((t) => t.type === "default theme") ?? m[0], o = m.filter((t) => t.type === "custom theme"), e = ['@import "tailwindcss";', ""]; c.length > 0 && (e.push("/* Unbound semantic tokens */"), c.forEach((t) => e.push(`/* ${t.pathNames.join("-")} */`)), e.push("")); const u = (t) => `--color-${t.map((s) => new d(s).doKebabCase()).join("-")}`, a = (t, s) => `var(--color-${new d(t).doKebabCase()}-${s})`; return e.push("@theme {"), h.forEach((t) => { const s = g(r, t), n = s.find((l) => l.themeId === i.id && !l.isUnbound) ?? s.find((l) => !l.isUnbound); !n || !n.colorName || !n.shadeName || e.push( ` ${u(t.pathNames)}: ${a(n.colorName, n.shadeName)};` ); }), e.push("}"), o.forEach((t) => { const s = []; h.forEach((n) => { const l = g(r, n), f = l.find((b) => b.themeId === t.id), $ = l.find((b) => b.themeId === i.id && !b.isUnbound) ?? l.find((b) => !b.isUnbound); !f || f.isUnbound || !f.colorName || !f.shadeName || $ && $.colorName === f.colorName && $.shadeName === f.shadeName || s.push( ` ${u(n.pathNames)}: ${a(f.colorName, f.shadeName)};` ); }), s.length !== 0 && (e.push(""), e.push(`/* ${t.name} */`), e.push(`[data-theme='${new d(t.name).doKebabCase()}'] {`), e.push(...s), e.push("}")); }), e.join(` `); }, H = (r, p) => { const { bound: h, unbound: c } = w(r, p), m = x(r), i = r.themes.find((t) => t.type === "default theme") ?? m[0], o = m.filter((t) => t.type === "custom theme"), e = []; e.push("// Semantic token map. Import alongside primitives.js:"), e.push("// const primitives = require('./primitives.js')"), e.push("// const semantics = require('./semantics.js')(primitives)"), e.push(""), c.length > 0 && (e.push("// Unbound semantic tokens"), c.forEach((t) => e.push(`// ${t.pathNames.join("-")}`)), e.push("")); const u = (t) => `'${t.map((s) => new d(s).doKebabCase()).join("-")}'`, a = (t, s, n) => { const l = new d(s).doKebabCase(); return t ? `primitives['${t}']['${l}']['${n}']` : `primitives['${l}']['${n}']`; }; return e.push("module.exports = function (primitives) {"), e.push(" return {"), o.length === 0 ? h.forEach((t) => { const s = g(r, t), n = s.find((l) => l.themeId === i.id && !l.isUnbound) ?? s.find((l) => !l.isUnbound); !n || !n.colorName || !n.shadeName || e.push( ` ${u(t.pathNames)}: ${a(null, n.colorName, n.shadeName)},` ); }) : m.forEach((t) => { const s = new d(t.name).doKebabCase(); e.push(` '${s}': {`), h.forEach((n) => { const f = g(r, n).find(($) => $.themeId === t.id); !f || f.isUnbound || !f.colorName || !f.shadeName || e.push( ` ${u(n.pathNames)}: ${a(s, f.colorName, f.shadeName)},` ); }), e.push(" },"); }), e.push(" }"), e.push("}"), e.join(` `); }, B = (r, p) => { const { bound: h, unbound: c } = w(r, p), m = x(r), i = r.themes.find((t) => t.type === "default theme") ?? m[0], o = m.filter((t) => t.type === "custom theme"), e = ["import SwiftUI", ""]; c.length > 0 && (e.push("// Unbound semantic tokens"), c.forEach((t) => e.push(`// ${t.pathNames.join("-")}`)), e.push("")); const u = (t) => new d(t.join(" ")).doCamelCase(), a = (t, s, n) => { const l = new d(s).doCamelCase(), f = n === "source" ? "Source" : new d(n).doPascalCase(); return t ? `Color.Token().${new d(t).doCamelCase()}${new d(s).doPascalCase()}${f}` : `Color.Token().${l}${f}`; }; return e.push("public extension Color {"), e.push(" static let SemanticToken = Color.SemanticTokenColor()"), e.push(" struct SemanticTokenColor {"), o.length === 0 ? h.forEach((t) => { const s = g(r, t), n = s.find((l) => l.themeId === i.id && !l.isUnbound) ?? s.find((l) => !l.isUnbound); !n || !n.colorName || !n.shadeName || e.push( ` public let ${u(t.pathNames)} = ${a(null, n.colorName, n.shadeName)}` ); }) : m.forEach((t) => { const s = new d(t.name).doCamelCase(); h.forEach((n) => { const f = g(r, n).find((b) => b.themeId === t.id); if (!f || f.isUnbound || !f.colorName || !f.shadeName) return; const $ = s + new d(n.pathNames.join(" ")).doPascalCase().replace(/\s+/g, ""); e.push( ` public let ${$} = ${a(t.name, f.colorName, f.shadeName)}` ); }); }), e.push(" }"), e.push("}"), e.join(` `); }, G = (r, p) => { const { bound: h, unbound: c } = w(r, p), m = x(r), i = r.themes.find((s) => s.type === "default theme") ?? m[0], o = m.filter((s) => s.type === "custom theme"), e = {}; c.length > 0 && (e._unbound = c.map((s) => s.pathNames.join("."))); const u = (s, n, l) => { let f = s; for (let $ = 0; $ < n.length - 1; $++) { const b = n[$]; (typeof f[b] != "object" || f[b] === null) && (f[b] = {}), f = f[b]; } f[n[n.length - 1]] = l; }, a = (s, n) => `{color.${new d(s).doKebabCase()}.${n}}`, t = {}; return h.forEach((s) => { const n = s.pathNames.map((b) => new d(b).doKebabCase()), l = g(r, s), f = l.find((b) => b.themeId === i.id && !b.isUnbound) ?? l.find((b) => !b.isUnbound); if (!f || !f.colorName || !f.shadeName) return; const $ = { type: "color", value: a(f.colorName, f.shadeName) }; s.description && ($.comment = s.description), u(t, n, $); }), e.semantic = t, o.forEach((s) => { const n = new d(s.name).doKebabCase(), l = {}; h.forEach((f) => { const $ = f.pathNames.map((k) => new d(k).doKebabCase()), b = g(r, f), N = b.find((k) => k.themeId === s.id), y = b.find((k) => k.themeId === i.id && !k.isUnbound) ?? b.find((k) => !k.isUnbound); if (!N || N.isUnbound || !N.colorName || !N.shadeName || y && y.colorName === N.colorName && y.shadeName === N.shadeName) return; const T = { type: "color", value: a(N.colorName, N.shadeName) }; u(l, $, T); }), Object.keys(l).length > 0 && (e[n] = l); }), JSON.stringify(e, null, 2); }, A = (r, p) => { const { bound: h, unbound: c } = w(r, p), m = x(r), i = r.themes.find((s) => s.type === "default theme") ?? m[0], o = m.filter((s) => s.type === "custom theme"), e = []; c.length > 0 && (e.push("// Unbound semantic tokens"), c.forEach((s) => e.push(`// ${s.pathNames.join("-")}`)), e.push("")); const u = (s) => s.map((n) => new d(n).doKebabCase()).join("-"), a = (s, n) => `$${new d(s).doKebabCase()}-${n}`, t = (s, n) => `var(--${new d(s).doKebabCase()}-${n})`; return o.length === 0 ? (h.forEach((s) => { const n = g(r, s), l = n.find((f) => f.themeId === i.id && !f.isUnbound) ?? n.find((f) => !f.isUnbound); !l || !l.colorName || !l.shadeName || e.push( `$${u(s.pathNames)}: ${a(l.colorName, l.shadeName)};` ); }), e.join(` `)) : (h.forEach((s) => { e.push(`$${u(s.pathNames)}: var(--${u(s.pathNames)});`); }), e.push(""), m.forEach((s) => { const n = s.type === "default theme", l = `${new d(s.name).doKebabCase()}-semantics`; e.push(`@mixin ${l} {`), h.forEach((f) => { const b = g(r, f).find((N) => N.themeId === s.id); !b || b.isUnbound || !b.colorName || !b.shadeName || e.push( ` --${u(f.pathNames)}: ${t(b.colorName, b.shadeName)};` ); }), e.push("}"), e.push(""), n ? (e.push(":root {"), e.push(` @include ${l};`), e.push("}")) : (e.push(`:root[data-theme='${new d(s.name).doKebabCase()}'] {`), e.push(` @include ${l};`), e.push("}")), e.push(""); }), e.join(` `).replace(/\n+$/, ` `)); }, _ = (r, p) => { const { bound: h, unbound: c } = w(r, p), m = x(r), i = r.themes.find((t) => t.type === "default theme") ?? m[0], o = m.filter((t) => t.type === "custom theme"), e = [ '<?xml version="1.0" encoding="utf-8"?>', "<resources>" ]; c.length > 0 && (e.push(" <!-- Unbound semantic tokens -->"), c.forEach((t) => e.push(` <!-- ${t.pathNames.join("-")} -->`))); const u = (t) => t.map((s) => new d(s).doSnakeCase()).join("_"), a = (t, s, n) => { const l = new d(s).doSnakeCase(), f = n === "source" ? "source" : n; return t ? `@color/${new d(t).doSnakeCase()}_${l}_${f}` : `@color/${l}_${f}`; }; return o.length === 0 ? h.forEach((t) => { const s = g(r, t), n = s.find((l) => l.themeId === i.id && !l.isUnbound) ?? s.find((l) => !l.isUnbound); !n || !n.colorName || !n.shadeName || e.push( ` <color name="${u(t.pathNames)}">${a(null, n.colorName, n.shadeName)}</color>` ); }) : m.forEach((t) => { const s = new d(t.name).doSnakeCase(); e.push(` <!-- ${t.name} -->`), h.forEach((n) => { const f = g(r, n).find(($) => $.themeId === t.id); !f || f.isUnbound || !f.colorName || !f.shadeName || e.push( ` <color name="${s}_${u(n.pathNames)}">${a(t.name, f.colorName, f.shadeName)}</color>` ); }); }), e.push("</resources>"), e.join(` `); }, S = (r) => { const p = r.name, h = (o, e, u) => ({ $type: "color", $value: e.isTransparent ? v(u.hex).alpha(e.alpha ?? 1).hex() : e.hex, $description: o.description !== "" ? o.description + " - " + e.description : e.description }), c = (o, e) => ({ name: o, group: "Modes", description: e, selectedTokenSets: { [`${p}/${o}`]: "enabled" } }), m = r.themes.filter((o) => o.type === "custom theme").length === 0 ? r.themes.filter((o) => o.type === "default theme") : r.themes.filter((o) => o.type === "custom theme"), i = { $themes: m.filter((o) => o.type === "custom theme").map((o) => c(o.name, o.description)), $metadata: { activeThemes: [], tokenSetOrder: m.filter((o) => o.type === "custom theme").map( (o) => `${new d(p).doSnakeCase()}/${new d(o.name).doSnakeCase()}` ), activeSets: [] } }; return m[0].type === "custom theme" ? m.forEach((o) => { i[`${p}/${o.name}`] = {}, o.colors.forEach((e) => { const u = e.shades.find( (a) => a.type === "source color" ); e.shades.forEach((a) => { a && u && (i[`${p}/${o.name}`][`${new d(e.name).doSnakeCase()}.${a.name}`] = h(e, a, u)); }); }); }) : m.forEach((o) => { i[p] = {}, o.colors.forEach((e) => { const u = e.shades.find( (a) => a.type === "source color" ); e.shades.forEach((a) => { a && u && (i[p][`${new d(e.name).doSnakeCase()}.${a.name}`] = h(e, a, u)); }); }); }), JSON.stringify(i, null, " "); }, J = (r, p) => { const h = JSON.parse(S(r)), { bound: c, unbound: m } = w(r, p), i = x(r), o = r.themes.find((n) => n.type === "default theme") ?? i[0], e = i.filter((n) => n.type === "custom theme"), u = r.name, a = (n, l) => `{${new d(n).doSnakeCase()}.${l}}`, t = e.length === 0 ? u : `${u}/semantic`; h[t] = h[t] ?? {}; const s = h[t]; return c.forEach((n) => { const l = n.pathNames.map((N) => new d(N).doSnakeCase()).join("."), f = g(r, n), $ = f.find((N) => N.themeId === o.id && !N.isUnbound) ?? f.find((N) => !N.isUnbound); if (!$ || !$.colorName || !$.shadeName) return; const b = { $type: "color", $value: a($.colorName, $.shadeName) }; n.description && (b.$description = n.description), s[l] = b; }), e.forEach((n) => { const l = `${u}/${new d(n.name).doSnakeCase()}-semantic`, f = {}; c.forEach(($) => { const b = $.pathNames.map((k) => new d(k).doSnakeCase()).join("."), N = g(r, $), y = N.find((k) => k.themeId === n.id), T = N.find( (k) => k.themeId === o.id && !k.isUnbound ) ?? N.find((k) => !k.isUnbound); !y || y.isUnbound || !y.colorName || !y.shadeName || T && T.colorName === y.colorName && T.shadeName === y.shadeName || (f[b] = { $type: "color", $value: a(y.colorName, y.shadeName) }); }), Object.keys(f).length > 0 && (h[l] = f); }), m.length > 0 && (h._unbound = m.map((n) => n.pathNames.join("."))), JSON.stringify(h, null, " "); }, X = (r, p) => { const { bound: h, unbound: c } = w(r, p), m = x(r), i = r.themes.find((t) => t.type === "default theme") ?? m[0], o = m.filter((t) => t.type === "custom theme"), e = []; c.length > 0 && (e.push("// Unbound semantic tokens"), c.forEach((t) => e.push(`// ${t.pathNames.join("-")}`)), e.push("")); const u = (t) => t.map((s) => new d(s).doKebabCase()).join("-"), a = (t, s) => `@${new d(t).doKebabCase()}-${s}`; return o.length === 0 ? (h.forEach((t) => { const s = g(r, t), n = s.find((l) => l.themeId === i.id && !l.isUnbound) ?? s.find((l) => !l.isUnbound); !n || !n.colorName || !n.shadeName || e.push( `@${u(t.pathNames)}: ${a(n.colorName, n.shadeName)};` ); }), e.join(` `)) : (m.forEach((t) => { const s = t.type === "default theme", n = `${new d(t.name).doKebabCase()}-semantics`; e.push(`.${n}() {`), h.forEach((l) => { const $ = g(r, l).find((b) => b.themeId === t.id); !$ || $.isUnbound || !$.colorName || !$.shadeName || e.push( ` @${u(l.pathNames)}: ${a($.colorName, $.shadeName)};` ); }), e.push("}"), e.push(""), s ? (e.push(":root {"), e.push(` .${n}();`), e.push("}")) : (e.push(`:root[data-theme='${new d(t.name).doKebabCase()}'] {`), e.push(` .${n}();`), e.push("}")), e.push(""); }), e.join(` `).replace(/\n+$/, ` `)); }, z = (r, p) => { const { bound: h, unbound: c } = w(r, p), m = x(r), i = r.themes.find((t) => t.type === "default theme") ?? m[0], o = m.filter((t) => t.type === "custom theme"), e = {}; c.length > 0 && (e.$description = "Unbound semantic tokens (no resolution): " + c.map((t) => t.pathNames.join(".")).join(", ")); const u = (t, s, n) => { let l = t; for (let f = 0; f < s.length - 1; f++) { const $ = s[f]; (typeof l[$] != "object" || l[$] === null) && (l[$] = {}), l = l[$]; } l[s[s.length - 1]] = n; }, a = (t, s) => `{${new d(t).doKebabCase()}.${s}}`; return h.forEach((t) => { const s = t.pathNames.map((b) => new d(b).doKebabCase()), n = g(r, t), l = n.find((b) => b.themeId === i.id && !b.isUnbound) ?? n.find((b) => !b.isUnbound); if (!l || !l.colorName || !l.shadeName) return; const f = { $type: "color", $value: a(l.colorName, l.shadeName) }; t.description && (f.$description = t.description); const $ = {}; o.forEach((b) => { const N = n.find((y) => y.themeId === b.id); !N || N.isUnbound || !N.colorName || !N.shadeName || l.colorName === N.colorName && l.shadeName === N.shadeName || ($[new d(b.name).doKebabCase()] = { $value: a(N.colorName, N.shadeName) }); }), Object.keys($).length > 0 && (f.$extensions = { mode: $ }), u(e, s, f); }), JSON.stringify(e, null, 2); }, E = (r) => /[",\n]/.test(r) ? `"${r.replace(/"/g, '""')}"` : r, Z = (r, p) => { const h = ["path,themeId,colorId,shadeName,shadeId"]; return p.tokens.forEach((c) => { const m = c.pathNames.join("/"); c.refs.forEach((i) => { if (i.shadeId === null) { h.push(`${E(m)},${E(i.themeId)},,,`); return; } const o = j(i.shadeId); if (!o) { h.push(`${E(m)},${E(i.themeId)},,,${E(i.shadeId)}`); return; } h.push( `${E(m)},${E(i.themeId)},${E(o.colorId)},${E(o.shadeName)},${E(i.shadeId)}` ); }); }), h.join(` `); }, q = (r, p) => { const { bound: h, unbound: c } = w(r, p), m = x(r), i = r.themes.find((t) => t.type === "default theme") ?? m[0], o = []; c.length > 0 && (o.push("/* Unbound semantic tokens */"), c.forEach((t) => o.push(`/* ${t.pathNames.join("-")} */`)), o.push("")); const e = (t) => `--${t.map((s) => new d(s).doKebabCase()).join("-")}`, u = (t, s) => `var(--${new d(t).doKebabCase()}-${s})`, a = []; return h.forEach((t) => { const s = g(r, t), n = s.find((l) => l.themeId === i.id && !l.isUnbound) ?? s.find((l) => !l.isUnbound); !n || !n.colorName || !n.shadeName || a.push( ` ${e(t.pathNames)}: ${u(n.colorName, n.shadeName)};` ); }), o.push(":root {"), o.push(...a), o.push("}"), m.filter((t) => t.type === "custom theme").forEach((t) => { const s = []; h.forEach((n) => { const l = g(r, n), f = l.find((b) => b.themeId === t.id), $ = l.find((b) => b.themeId === i.id && !b.isUnbound) ?? l.find((b) => !b.isUnbound); !f || f.isUnbound || !f.colorName || !f.shadeName || $ && $.colorName === f.colorName && $.shadeName === f.shadeName || s.push( ` ${e(n.pathNames)}: ${u(f.colorName, f.shadeName)};` ); }), s.length !== 0 && (o.push(""), o.push(`/* ${t.name} */`), o.push(`:root[data-theme='${new d(t.name).doKebabCase()}'] {`), o.push(...s), o.push("}")); }), o.join(` `); }, W = (r, p) => { const { bound: h, unbound: c } = w(r, p), m = x(r), i = r.themes.find((t) => t.type === "default theme") ?? m[0], o = m.filter((t) => t.type === "custom theme"), e = ["import androidx.compose.ui.graphics.Color", ""]; c.length > 0 && (e.push("// Unbound semantic tokens"), c.forEach((t) => e.push(`// ${t.pathNames.join("-")}`)), e.push("")); const u = (t) => t.map((s) => new d(s).doSnakeCase()).join("_"), a = (t, s, n) => { const l = new d(s).doSnakeCase(), f = n === "source" ? "source" : n; return t ? `${new d(t).doSnakeCase()}_${l}_${f}` : `${l}_${f}`; }; return o.length === 0 ? h.forEach((t) => { const s = g(r, t), n = s.find((l) => l.themeId === i.id && !l.isUnbound) ?? s.find((l) => !l.isUnbound); !n || !n.colorName || !n.shadeName || e.push( `val ${u(t.pathNames)} = ${a(null, n.colorName, n.shadeName)}` ); }) : m.forEach((t) => { const s = new d(t.name).doSnakeCase(); e.push(`// ${t.name}`), h.forEach((n) => { const f = g(r, n).find(($) => $.themeId === t.id); !f || f.isUnbound || !f.colorName || !f.shadeName || e.push( `val ${s}_${u(n.pathNames)} = ${a(t.name, f.colorName, f.shadeName)}` ); }), e.push(""); }), e.join(` `).replace(/\n+$/, ` `); }, Q = (r) => { const p = r.themes.filter((i) => i.type === "custom theme").length === 0 ? r.themes.filter((i) => i.type === "default theme") : r.themes.filter((i) => i.type === "custom theme"), h = {}, c = (i) => (isNaN(i.hsl[0]) && (i.hsl[0] = 0), isNaN(i.lch[2]) && (i.lch[2] = 0), isNaN(i.oklch[2]) && (i.oklch[2] = 0), { rgb: { r: Math.floor(i.rgb[0]), g: Math.floor(i.rgb[1]), b: Math.floor(i.rgb[2]) }, gl: { r: parseFloat(i.gl[0].toFixed(3)), g: parseFloat(i.gl[1].toFixed(3)), b: parseFloat(i.gl[2].toFixed(3)) }, lch: { l: Math.floor(i.lch[0]), c: Math.floor(i.lch[1]), h: Math.floor(i.lch[2]) }, oklch: { l: parseFloat(i.oklch[0].toFixed(3)), c: parseFloat(i.oklch[1].toFixed(3)), h: Math.floor(i.oklch[2]) }, lab: { l: Math.floor(i.lab[0]), a: Math.floor(i.lab[1]), b: Math.floor(i.lab[2]) }, oklab: { l: parseFloat(i.oklab[0].toFixed(3)), a: parseFloat(i.oklab[1].toFixed(3)), b: parseFloat(i.oklab[2].toFixed(3)) }, hsl: { h: Math.floor(i.hsl[0]), s: Math.floor(i.hsl[1] * 100), l: Math.floor(i.hsl[2] * 100) }, hsluv: { h: Math.floor(i.hsluv[0]), s: Math.floor(i.hsluv[1]), l: Math.floor(i.hsluv[2]) }, hex: i.hex, description: i.description, type: "color shade/tint" }), m = (i, o) => ({ rgb: { r: Math.floor(o.rgb[0]), g: Math.floor(o.rgb[1]), b: Math.floor(o.rgb[2]) }, gl: { r: parseFloat(o.gl[0].toFixed(3)), g: parseFloat(o.gl[1].toFixed(3)), b: parseFloat(o.gl[2].toFixed(3)) }, lch: { l: Math.floor(o.lch[0]), c: Math.floor(o.lch[1]), h: Math.floor(o.lch[2]) }, oklch: { l: parseFloat(o.oklch[0].toFixed(3)), c: parseFloat(o.oklch[1].toFixed(3)), h: Math.floor(o.oklch[2]) }, lab: { l: Math.floor(o.lab[0]), a: Math.floor(o.lab[1]), b: Math.floor(o.lab[2]) }, oklab: { l: parseFloat(o.oklab[0].toFixed(3)), a: parseFloat(o.oklab[1].toFixed(3)), b: parseFloat(o.oklab[2].toFixed(3)) }, hsl: { h: Math.floor(o.hsl[0]), s: Math.floor(o.hsl[1] * 100), l: Math.floor(o.hsl[2] * 100) }, hsluv: { h: Math.floor(o.hsluv[0]), s: Math.floor(o.hsluv[1]), l: Math.floor(o.hsluv[2]) }, hex: o.hex, alpha: i.alpha, description: i.description, type: "color shade/tint" }); return p[0].type === "custom theme" ? p.forEach((i) => { h[i.name] = {}, i.colors.forEach((o) => { const e = o.shades.find( (u) => u.type === "source color" ); h[i.name][o.name] = {}, o.shades.forEach((u) => { u && e && (h[i.name][o.name][u.name] = u.isTransparent ? m(u, e) : c(u)); }), h[i.name][o.name].description = o.description, h[i.name][o.name].type = "color"; }), h[i.name].description = i.description, h[i.name].type = "color mode"; }) : p.forEach((i) => { i.colors.forEach((o) => { const e = o.shades.find( (u) => u.type === "source color" ); h[o.name] = {}, o.shades.forEach((u) => { u && e && (h[o.name][u.name] = u.isTransparent ? m(u, e) : c(u)); }), h[o.name].description = o.description, h[o.name].type = "color"; }); }), h.description = r.description, h.type = "color palette", JSON.stringify(h, null, " "); }, Y = (r) => { const p = r.themes.filter((c) => c.type === "custom theme").length === 0 ? r.themes.filter((c) => c.type === "default theme") : r.themes.filter((c) => c.type === "custom theme"), h = []; return p.forEach((c) => { const m = []; c.colors.forEach((i) => { const o = i.shades.find((e) => e.type === "source color"); m.push(`// ${i.name}`), i.shades.reverse().forEach((e) => { m.push( e.isTransparent ? `static let ${new d(i.name).doPascalCase()}${e.name === "source" ? "Source" : e.name} = UIColor(red: ${o == null ? void 0 : o.gl[0].toFixed( 3 )}, green: ${o == null ? void 0 : o.gl[1].toFixed(3)}, blue: ${o == null ? void 0 : o.gl[2].toFixed( 3 )}, alpha: ${e.alpha ?? 1})` : `static let ${new d(i.name).doPascalCase()}${e.name === "source" ? "Source" : e.name} = UIColor(red: ${e.gl[0].toFixed( 3 )}, green: ${e.gl[1].toFixed(3)}, blue: ${e.gl[2].toFixed( 3 )})` ); }), m.push(""); }), m.pop(), p[0].type === "custom theme" ? h.push( `// ${c.name} struct ${new d(c.name).doPascalCase()} { ${m.join( ` ` )} }` ) : h.push(`${m.join(` `)}`); }), `import UIKit struct Color { ${h.join(` `)} }`; }, D = (r) => { const p = r.themes.filter((c) => c.type === "custom theme").length === 0 ? r.themes.filter((c) => c.type === "default theme") : r.themes.filter((c) => c.type === "custom theme"); let h = `@import "tailwindcss"; @theme { --color-*: initial; `; return p[0].type !== "custom theme" ? p.forEach((c) => { c.colors.forEach((m) => { const i = m.shades.find( (a) => a.type === "source color" ), o = new d(m.name).doKebabCase(); h += ` /* ${m.name} */ `, m.shades.sort().forEach((a) => { const t = a.isTransparent ? v((i == null ? void 0 : i.hex) ?? "#000000").alpha(a.alpha ?? 1).hex() : a.hex, s = new d(a.name).doKebabCase(); h += ` --color-${o}-${s}: ${t}; `; }); const e = m === c.colors[c.colors.length - 1], u = c === p[p.length - 1]; e && u || (h += ` `); }); }) : p.forEach((c) => { const m = new d(c.name).doKebabCase(); c.colors.forEach((i) => { const o = i.shades.find( (t) => t.type === "source color" ), e = new d(i.name).doKebabCase(); h += ` /* ${c.name} - ${i.name} */ `, i.shades.forEach((t) => { const s = t.isTransparent ? v((o == null ? void 0 : o.hex) ?? "#000000").alpha(t.alpha ?? 1).hex() : t.hex, n = new d(t.name).doKebabCase(); h += ` --color-${m}-${e}-${n}: ${s}; `; }); const u = i === c.colors[c.colors.length - 1], a = c === p[p.length - 1]; u && a || (h += ` `); }); }), h += `} `, h; }, ee = (r) => { const p = r.themes.filter((c) => c.type === "custom theme").length === 0 ? r.themes.filter((c) => c.type === "default theme") : r.themes.filter((c) => c.type === "custom theme"), h = { theme: { colors: {} } }; return r.themes[0].colors.forEach((c) => { h.theme.colors[new d(c.name).doKebabCase()] = {}; }), p[0].type === "custom theme" ? p.forEach((c) => { c.colors.forEach((m) => { const i = m.shades.find( (o) => o.type === "source color" ); h.theme.colors[new d(m.name).doKebabCase()][new d(c.name).doKebabCase()] = {}, m.shades.forEach((o) => { h.theme.colors[new d(m.name).doKebabCase()][new d(c.name).doKebabCase()][new d(o.name).doKebabCase()] = o.isTransparent ? v((i == null ? void 0 : i.hex) ?? "#000000").alpha(o.alpha ?? 1).hex() : o.hex; }); }); }) : p.forEach((c) => { c.colors.forEach((m) => { const i = m.shades.find( (o) => o.type === "source color" ); h.theme.colors[new d(m.name).doKebabCase()] = {}, m.shades.sort().forEach((o) => { h.theme.colors[new d(m.name).doKebabCase()][new d(o.name).doKebabCase()] = o.isTransparent ? v((i == null ? void 0 : i.hex) ?? "#000000").alpha(o.alpha ?? 1).hex() : o.hex; }); }); }), `/** @type {import('tailwindcss').Config} */ module.exports = ${JSON.stringify(h, null, " ")}`; }, oe = (r) => { const p = r.themes.filter((c) => c.type === "custom theme").length === 0 ? r.themes.filter((c) => c.type === "default theme") : r.themes.filter((c) => c.type === "custom theme"), h = []; return p.forEach((c) => { c.colors.forEach((m) => { const i = m.shades.find((e) => e.type === "source color"), o = []; o.push( `// ${p[0].type === "custom theme" ? c.name + " - " : ""}${m.name}` ), m.shades.reverse().forEach((e) => { o.push( e.isTransparent ? `public let ${p[0].type === "custom theme" ? new d(c.name + " " + m.name).doPascalCase() : new d(m.name).doPascalCase()}${e.name === "source" ? "Source" : e.name} = Color(red: ${i == null ? void 0 : i.gl[0].toFixed( 3 )}, green: ${i == null ? void 0 : i.gl[1].toFixed(3)}, blue: ${e.gl[2].toFixed( 3 )}).opacity(${e.alpha ?? 1})` : `public let ${p[0].type === "custom theme" ? new d(c.name + " " + m.name).doPascalCase() : new d(m.name).doPascalCase()}${e.name === "source" ? "Source" : e.name} = Color(red: ${e.gl[0].toFixed( 3 )}, green: ${e.gl[1].toFixed(3)}, blue: ${e.gl[2].toFixed( 3 )})` ); }), o.push(""), o.forEach((e) => h.push(e)); }); }), h.pop(), `import SwiftUI public extension Color { static let Token = Color.TokenColor() struct TokenColor { ${h.join( ` ` )} } }`; }, te = (r) => { const p = r.themes.filter((m) => m.type === "custom theme").length === 0 ? r.themes.filter((m) => m.type === "default theme") : r.themes.filter((m) => m.type === "custom theme"), h = { color: {} }, c = (m, i, o) => ({ type: "color", value: i.isTransparent ? v(o.hex).alpha(i.alpha ?? 1).hex() : i.hex, comment: m.description !== "" ? m.description + " - " + i.description : i.description }); return r.themes[0].colors.forEach((m) => { h.color[m.name] = {}; }), p[0].type === "custom theme" ? p.forEach((m) => { m.colors.forEach((i) => { const o = i.shades.find( (e) => e.type === "source color" ); h.color[i.name][m.name] = {}, i.shades.forEach((e) => { e && o && (h.color[i.name][m.name][e.name] = c( i, e, o )); }); }); }) : p.forEach((m) => { m.colors.forEach((i) => { const o = i.shades.find( (e) => e.type === "source color" ); h.color[i.name] = {}, i.shades.forEach((e) => { e && o && (h.color[i.name][e.name] = c(i, e, o)); }); }); }), JSON.stringify(h, null, " "); }, se = (r, p) => { const h = r.themes.filter((s) => s.type === "custom theme").length === 0 ? r.themes.filter((s) => s.type === "default theme") : r.themes.filter((s) => s.type === "custom theme"), c = [], m = [], i = (s) => { var l; isNaN(s.hsl[0]) && (s.hsl[0] = 0), isNaN(s.lch[2]) && (s.lch[2] = 0), isNaN(s.oklch[2]) && (s.oklch[2] = 0); const n = { RGB: () => `rgb(${Math.floor(s.rgb[0])} ${Math.floor( s.rgb[1] )} ${Math.floor(s.rgb[2])})`, HEX: () => s.hex, HSL: () => `hsl(${Math.floor(s.hsl[0])} ${Math.floor( s.hsl[1] * 100 )}% ${Math.floor(s.hsl[2] * 100)}%)`, LCH: () => `lch(${Math.floor(s.lch[0])}% ${Math.floor( s.lch[1] )} ${Math.floor(s.lch[2])})`, OKLCH: () => `oklch(${Math.floor(s.oklch[0] * 100)}% ${s.oklch[1].toFixed(3)} ${Math.floor(s.oklch[2])})` }; return (l = n[p ?? "RGB"]) == null ? void 0 : l.call(n); }, o = (s, n) => { var f; isNaN(s.hsl[0]) && (s.hsl[0] = 0), isNaN(s.lch[2]) && (s.lch[2] = 0), isNaN(s.oklch[2]) && (s.oklch[2] = 0); const l = { RGB: () => { var $; return `rgb(${Math.floor(n.rgb[0])} ${Math.floor( n.rgb[1] )} ${Math.floor(n.rgb[2])} / ${(($ = s.alpha) == null ? void 0 : $.toFixed(2)) ?? 1})`; }, HEX: () => v(n.hex).alpha(s.alpha ?? 1).hex(), HSL: () => { var $; return `hsl(${Math.floor(n.hsl[0])} ${Math.floor( n.hsl[1] * 100 )}%, ${Math.floor(n.hsl[2] * 100)}% / ${(($ = s.alpha) == null ? void 0 : $.toFixed(2)) ?? 1})`; }, LCH: () => { var $; return `lch(${Math.floor(n.lch[0])}% ${Math.floor( n.lch[1] )} ${Math.floor(n.lch[2])} / ${(($ = s.alpha) == null ? void 0 : $.toFixed(2)) ?? 1})`; }, OKLCH: () => { var $; return `oklch(${Math.floor(n.oklch[0 * 100])}% ${n.oklch[1].toFixed(3)} ${Math.floor(n.oklch[2])} / ${(($ = s.alpha) == null ? void 0 : $.toFixed(2)) ?? 1})`; } }; return (f = l[p ?? "RGB"]) == null ? void 0 : f.call(l); }, e = h.find( (s) => s.type === "default theme" ); if (e) { const s = []; return e.colors.forEach((n, l) => { l > 0 && s.push(""), s.push(`// ${n.name}`), n.shades.reverse().forEach((f) => { const $ = n.shades.find((N) => N.type === "source color"), b = `$${new d(n.name).doKebabCase()}-${f.name}`; $ && s.push( `${b}: ${f.isTransparent ? o(f, $) : i(f)};` ); }); }), c.push(s.join(` `)), c.join(` `); } h.forEach((s) => { const n = new d(s.name).doKebabCase(), l = []; l.push(`// ${s.name}`), l.push(`@mixin ${n} {`), s.colors.forEach((f, $) => { $ > 0 && l.push(""), l.push(` // ${f.name}`), f.shades.reverse().forEach((b) => { const N = f.shades.find((k) => k.type === "source color"), T = `--${new d(f.name).doKebabCase()}-${b.name}`; N && l.push( ` ${T}: ${b.isTransparent ? o(b, N) : i(b)};` ); }); }), l.push("}"), c.push(l.join(` `)); }); const u = /* @__PURE__ */ new Set(); if (h.forEach((s) => { s.colors.forEach((n) => { n.shades.forEach((l) => { if (n.shades.find(($) => $.type === "source color")) { const b = `--${new d(n.name).doKebabCase()}-${l.name}`; u.add(b); } }); }); }), u.size > 0) { const s = /* @__PURE__ */ new Map(); u.forEach((n) => { const l = n.match(/--([a-zA-Z0-9-]+)-([a-zA-Z0-9-]+)/); if (l) { const f = l[1]; s.has(f) || s.set(f, []); const $ = `$${n.substring(2)}`; s.get(f).push(`${$}: var(${n});`); } }), s.forEach((n, l) => { m.push( `// ${l.charAt(0).toUpperCase() + l.slice(1)}` ), m.push(...n), m.push(""); }), m.length > 0 && m[m.length - 1] === "" && m.pop(), c.push(m.join(` `)); } const a = [":root {"]; h.forEach((s, n) => { const l = new d(s.name).doKebabCase(); a.push(` &[data-theme="${l}"] { @include ${l}; }`), n !== h.length - 1 && a.push(""); }), a.push("}"), c.push(a.join(` `)); const t = []; return h.forEach((s) => { const n = new d(s.name).doKebabCase(); t.push(`.${n} { @include ${n}; }`); }), c.push(t.join(` `)), c.join(` `); }, ne = (r) => { const p = r.themes.filter((c) => c.type === "custom theme").length === 0 ? r.themes.filter((c) => c.type === "default theme") : r.themes.filter((c) => c.type === "custom theme"), h = []; return p.forEach((c) => { c.colors.forEach((m) => { const i = m.shades.find((e) => e.type === "source color"), o = []; o.push( `<!--${p[0].type === "custom theme" ? `${c.name} - ${m.name}-->` : `${m.name}-->`}` ), m.shades.reverse().forEach((e) => { o.push( `<color name="${p[0].type === "custom theme" ? new d(c.name + " " + m.name).doSnakeCase() : new d(m.name).doSnakeCase()}_${e.name}">${e.isTransparent ? v((i == null ? void 0 : i.hex) ?? "#000000").alpha(e.alpha ?? 1).hex() : e.hex}</color>` ); }), o.push(""), o.forEach((e) => h.push(e)); }); }), h.pop(), `<?xml version="1.0" encoding="utf-8"?> <resources> ${h.join( ` ` )} </resources>`; }, ae = (r, p) => { const h = r.themes.filter((a) => a.type === "custom theme").length === 0 ? r.themes.filter((a) => a.type === "default theme") : r.themes.filter((a) => a.type === "custom theme"), c = [], m = (a) => { var s; isNaN(a.hsl[0]) && (a.hsl[0] = 0), isNaN(a.lch[2]) && (a.lch[2] = 0), isNaN(a.oklch[2]) && (a.oklch[2] = 0); const t = { RGB: () => `rgb(${Math.floor(a.rgb[0])} ${Math.floor( a.rgb[1] )} ${Math.floor(a.rgb[2])})`, HEX: () => a.hex, HSL: () => `hsl(${Math.floor(a.hsl[0])} ${Math.floor( a.hsl[1] * 100 )}% ${Math.floor(a.hsl[2] * 100)}%)`, LCH: () => `lch(${Math.floor(a.lch[0])}% ${Math.floor( a.lch[1] )} ${Math.floor(a.lch[2])})`, OKLCH: () => `oklch(${Math.floor(a.oklch[0] * 100)}% ${a.oklch[1].toFixed(3)} ${Math.floor(a.oklch[2])})` }; return (s = t[p ?? "RGB"]) == null ? void 0 : s.call(t); }, i = (a, t) => { var n; isNaN(a.hsl[0]) && (a.hsl[0] = 0), isNaN(a.lch[2]) && (a.lch[2] = 0), isNaN(a.oklch[2]) && (a.oklch[2] = 0); const s = { RGB: () => { var l; return `rgb(${Math.floor(t.rgb[0])} ${Math.floor( t.rgb[1] )} ${Math.floor(t.rgb[2])} / ${((l = a.alpha) == null ? void 0 : l.toFixed(2)) ?? 1})`; }, HEX: () => v(t.hex).alpha(a.alpha ?? 1).hex(), HSL: () => { var l; return `hsl(${Math.floor(t.hsl[0])} ${Math.floor( t.hsl[1] * 100 )}% ${Math.floor(t.hsl[2] * 100)}% / ${((l = a.alpha) == null ? void 0 : l.toFixed(2)) ?? 1})`; }, LCH: () => { var l; return `lch(${Math.floor(t.lch[0])}% ${Math.floor( t.lch[1] )} ${Math.floor(t.lch[2])} / ${((l = a.alpha) == null ? void 0 : l.toFixed(2)) ?? 1})`; }, OKLCH: () => { var l; return `oklch(${Math.floor(t.oklch[0] * 100)}% ${t.oklch[1].toFixed(3)} ${Math.floor(t.oklch[2])} / ${((l = a.alpha) == null ? void 0 : l.toFixed(2)) ?? 1})`; } }; return (n = s[p ?? "RGB"]) == null ? void 0 : n.call(s); }, o = h.find( (a) => a.type === "default theme" ); if (o) { const a = []; return o.colors.forEach((t, s) => { s > 0 && a.push(""), a.push(`// ${t.name}`), t.shades.reverse().forEach((n) => { const l = t.shades.find(($) => $.type === "source color"), f = `@${new d(t.name).doKebabCase()}-${n.name}`; l && a.push( `${f}: ${n.isTransparent ? i(n, l) : m(n)};` ); }); }), c.push(a.join(` `)), c.join(` `); } h.forEach((a) => { const t = new d(a.name).doKebabCase(), s = []; s.push(`// ${a.name}`), s.push(`.${t}() {`), a.colors.forEach((n, l) => { l > 0 && s.push(""), s.push(` // ${n.name}`), n.shades.reverse().forEach((f) => { const $ = n.shades.find((N) => N.type === "source color"), b = `@${new d(n.name).doKebabCase()}-${f.name}`; $ && s.push( ` ${b}: ${f.isTransparent ? i(f, $) : m(f)};` ); }); }), s.push("}"), c.push(s.join(` `)); }); const e = [":root {"]; h.forEach((a, t) => { const s = new d(a.name).doKebabCase(); e.push(` &[data-theme="${s}"] { .${s}(); }`), t !== h.length - 1 && e.push(""); }), e.push("}"), c.push(e.join(` `)); const u = []; return h.forEach((a) => { const t = new d(a.name).doKebabCase(); u.push(`.${t} { .${t}(); }`); }), c.push(u.join(` `)), c.join(` `); }, ie = (r, p) => { const h = r.themes.filter((o) => o.type === "custom theme").length === 0 ? r.themes.filter((o) => o.type === "default theme") : r.themes.filter((o) => o.type === "custom theme"), c = {}, m = (o) => { var u; isNaN(o.oklch[2]) && (o.oklch[2] = 0); const e = { RGB: () => ({ colorSpace: "srgb", components: [ parseFloat(o.gl[0].toFixed(3)), parseFloat(o.gl[1].toFixed(3)), parseFloat(o.gl[2].toFixed(3)) ], hex: o.hex }), OKLCH: () => ({ colorSpace: "oklch", components: [ parseFloat(o.oklch[0].toFixed(3)), parseFloat(o.oklch[1].toFixed(3)), parseFloat(o.oklch[2].toFixed(0)) ], hex: o.hex }) }; return (u = e[p ?? "RGB"]) == null ? void 0 : u.call(e); }, i = (o, e) => { var a; isNaN(e.oklch[2]) && (e.oklch[2] = 0); const u = { RGB: () => ({ colorSpace: "srgb", components: [ parseFloat(o.gl[0].toFixed(3)), parseFloat(o.gl[1].toFixed(3)), parseFloat(o.gl[2].toFixed(3)) ], hex: o.hex, alpha: e.alpha }), OKLCH: () => ({ colorSpace: "oklch", components: [ parseFloat(o.oklch[0].toFixed(3)), parseFloat(o.oklch[1].toFixed(3)), parseFloat(o.oklch[2].toFixed(0)) ], hex: o.hex, alpha: e.alpha }) }; return (a = u[p ?? "RGB"]) == null ? void 0 : a.call(u); }; return h[0].type === "custom theme" ? h.forEach((o) => { o.colors.forEach((e) => { const u = e.shades.find( (a) => a.type === "source color" ); c[e.name] || (c[e.name] = { $type: "color" }), e.shades.forEach((a) => { !c[e.name][a.name] && u && (c[e.name][a.name] = { $type: "color", $value: a.isTransparent ? i(u, a) : m(a), $description: e.description !== "" ? e.description + " - " + a.description : a.description, $extensions: { mode: {}, "com.uicp.wcag": {}, "com.uicp.apca": {} } }), u && (c[e.name][a.name].$extensions.mode[o.name] = a.isTransparent ? i(u, a) : m(a), a.textContrast && (c[e.name][a.name].$extensions["com.uicp.wcag"][o.name] = { light: { score: a.textContrast.wcag.light.score, ratio: a.textContrast.wcag.light.ratio }, dark: { score: a.textContrast.wcag.dark.score, ratio: a.textContrast.wcag.dark.ratio } }, c[e.name][a.name].$extensions["com.uicp.apca"][o.name] = { light: { score: a.textContrast.apca.light.lc, recommendation: a.textContrast.apca.light.recommendedUsage }, dark: { score: a.textContrast.apca.dark.lc, recommendation: a.textContrast.apca.dark.recommendedUsage } })); }); }); }) : h.forEach((o) => { o.colors.forEach((e) => { const u = e.shades.find( (a) => a.type === "source color" ); c[e.name] = {}, e.shades.forEach((a) => { a && u && (c[e.name][a.name] = { $type: "color", $value: a.isTransparent ? i(u, a) : m(a), $description: e.description !== "" ? e.description + " - " + a.description : a.description, ...a.textContrast && { $extensions: { "com.uicp.wcag": { light: { score: a.textContrast.wcag.light.score, ratio: a.textContrast.wcag.light.ratio }, dark: { score: a.textContrast.wcag.dark.score, ratio: a.textContrast.wcag.dark.ratio } }, "com.uicp.apca": { light: { score: a.textContrast.apca.light.lc, recommendation: a.textContrast.apca.light.recommendedUsage }, dark: { score: a.textContrast.apca.dark.lc, recommendation: a.textContrast.apca.dark.recommendedUsage } } } } }); }); }); }), JSON.stringify(c, null, " "); }, re = (r) => { const p = r.themes.filter((u) => u.type === "custom theme").length === 0 ? r.themes.filter((u) => u.type === "default theme") : r.themes.filter((u) => u.type === "custom theme"), h = [], c = [], m = [], i = [], o = [], e = []; return p.forEach((u) => { u.colors.forEach((a) => { a.shades.forEach((t) => { m.push(t.name), i.push(Math.floor(t.lch[0])), o.push(Math.floor(t.lch[1])), e.push(Math.floor(t.lch[2])); }), h.push({ name: a.name, csv: `${a.name},Lightness,Chroma,Hue ${m.map((t, s) => `${t},${i[s]},${o[s]},${e[s]}`).join(` `)}` }), m.splice(0, m.length), i.splice(0, i.length), o.splice(0, o.length), e.splice(0, e.length); }), c.push({ name: u.name, colors: h.map((a) => a), type: u.type }), h.splice(0, h.length); }), c; }, ce = (r, p) => { const h = r.themes.filter((o) => o.type === "custom theme").length === 0 ? r.themes.filter((o) => o.type === "default theme") : r.themes.filter((o) => o.type === "custom theme"), c = [], m = (o) => { var u; isNaN(o.hsl[0]) && (o.hsl[0] = 0), isNaN(o.lch[2]) && (o.lch[2] = 0), isNaN(o.oklch[2]) && (o.oklch[2] = 0); const e = { RGB: () => `rgb(${Math.floor(o.rgb[0])} ${Math.floor( o.rgb[1] )} ${Math.floor(o.rgb[2])})`, HEX: () => o.hex, HSL: () => `hsl(${Math.floor(o.hsl[0])} ${Math.floor( o.hsl[1] * 100 )}% ${Math.floor(o.hsl[2] * 100)}%)`, LCH: () => `lch(${Math.floor(o.lch[0])}% ${Math.floor( o.lch[1] )} ${Math.floor(o.lch[2])})`, OKLCH: () => `oklch(${Math.floor(o.oklch[0] * 100)}% ${o.oklch[1].toFixed(3)} ${Math.floor(o.oklch[2])})`, P3: () => `color(display-p3 ${o.gl[0].toFixed(3)} ${o.gl[1].toFixed( 3 )} ${o.gl[2].toFixed(3)})` }; return (u = e[p ?? "RGB"]) == null ? void 0 : u.call(e); }, i = (o, e) => { var a; isNaN(o.hsl[0]) && (o.hsl[0] = 0), isNaN(o.lch[2]) && (o.lch[2] = 0), isNaN(o.oklch[2]) && (o.oklch[2] = 0); const u = { RGB: () => { var t; return `rgb(${Math.floor(e.rgb[0])} ${Math.floor( e.rgb[1] )} ${Math.floor(e.rgb[2])} / ${((t = o.alpha) == null ? void 0 : t.toFixed(2)) ?? 1})`; }, HEX: () => v(e.hex).alpha(o.alpha ?? 1).hex(), HSL: () => { var t; return `hsl(${Math.floor(e.hsl[0])} ${Math.floor( e.hsl[1] * 100 )}% ${Math.floor(e.hsl[2] * 100)}% / ${((t = o.alpha) == null ? void 0 : t.toFixed(2)) ?? 1})`; }, LCH: () => { var t; return `lch(${Math.floor(e.lch[0])}% ${Math.floor( e.lch[1] )} ${Math.floor(e.lch[2])} / ${((t = o.alpha) == null ? void 0 : t.toFixed(2)) ?? 1})`; }, OKLCH: () => { var t; return `oklch(${Math.floor(e.oklch[0 * 100])}% ${e.oklch[1].toFixed(3)} ${Math.floor(e.oklch[2])} / ${((t = o.alpha) == null ? void 0 : t.toFixed(2)) ?? 1})`; }, P3: () => { var t; return `color(display-p3 ${e.gl[0].toFixed(3)} ${e.gl[1].toFixed( 3 )} ${e.gl[2].toFixed(3)} / ${((t = o.alpha) == null ? void 0 : t.toFixed(2)) ?? 1})`; } }; return (a = u[p ?? "RGB"]) == null ? void 0 : a.call(u); }; return h.forEach((o) => { const e = []; o.colors.forEach((u) => { e.push(`/* ${u.name} */`), u.shades.reverse().forEach((a) => { const t = u.shades.find((s) => s.type === "source color"); t && e.push( `--${new d(u.name).doKebabCase()}-${a.name}: ${a.isTransparent ? i(a, t) : m(a)};` ); }), e.push(""); }), e.pop(), c.push( `${o.type === "custom theme" ? `/* ${o.name} */ ` : ""}:root${o.type === "custom theme" ? `[data-theme='${new d(o.name).doKebabCase()}']` : ""} { ${e.join(` `)} }` ); }), c.join(` `); }, he = (r) => { const p = r.themes.filter((c) => c.type === "custom theme").length === 0 ? r.themes.filter((c) => c.type === "default theme") : r.themes.filter((c) => c.type === "custom theme"), h = []; return p.forEach((c) => { c.colors.