"use strict";
/* Socket Lib - Built with rolldown */
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_primordials_array = require('../primordials/array.js');

//#region src/themes/resolve.ts
/**
* Rainbow gradient colors used for the `'rainbow'` color keyword. 10 hues —
* cycles through the full color spectrum with smooth transitions.
*/
const RAINBOW_GRADIENT = [
	[
		255,
		100,
		120
	],
	[
		255,
		140,
		80
	],
	[
		255,
		180,
		60
	],
	[
		220,
		200,
		80
	],
	[
		120,
		200,
		100
	],
	[
		80,
		200,
		180
	],
	[
		80,
		160,
		220
	],
	[
		140,
		120,
		220
	],
	[
		200,
		100,
		200
	],
	[
		255,
		100,
		140
	]
];
/**
* Create new theme from complete specification.
*
* @example
*   ;```ts
*   const theme = createTheme({
*     name: 'custom',
*     displayName: 'Custom',
*     colors: {
*       primary: [255, 100, 200],
*       success: 'greenBright',
*       error: 'redBright',
*       warning: 'yellowBright',
*       info: 'blueBright',
*       step: 'cyanBright',
*       text: 'white',
*       textDim: 'gray',
*       link: 'cyanBright',
*       prompt: 'primary',
*     },
*   })
*   ```
*
* @param config - Theme configuration.
*
* @returns Theme object
*/
function createTheme(config) {
	return {
		__proto__: null,
		name: config.name,
		displayName: config.displayName,
		colors: {
			__proto__: null,
			...config.colors
		},
		effects: config.effects ? {
			__proto__: null,
			...config.effects
		} : void 0,
		meta: config.meta ? {
			__proto__: null,
			...config.meta
		} : void 0
	};
}
/**
* Extend existing theme with custom overrides. Deep merge of colors and
* effects.
*
* @example
*   ;```ts
*   const custom = extendTheme(SOCKET_THEME, {
*     name: 'custom',
*     colors: { primary: [255, 100, 200] },
*   })
*   ```
*
* @param base - Base theme.
* @param overrides - Custom overrides.
*
* @returns Extended theme
*/
function extendTheme(base, overrides) {
	return {
		__proto__: null,
		...base,
		...overrides,
		colors: {
			__proto__: null,
			...base.colors,
			...overrides.colors
		},
		effects: overrides.effects ? {
			__proto__: null,
			...base.effects,
			...overrides.effects,
			spinner: overrides.effects.spinner !== void 0 ? {
				__proto__: null,
				...base.effects?.spinner,
				...overrides.effects.spinner
			} : base.effects?.spinner,
			shimmer: overrides.effects.shimmer !== void 0 ? {
				__proto__: null,
				...base.effects?.shimmer,
				...overrides.effects.shimmer
			} : base.effects?.shimmer,
			pulse: overrides.effects.pulse !== void 0 ? {
				__proto__: null,
				...base.effects?.pulse,
				...overrides.effects.pulse
			} : base.effects?.pulse
		} : base.effects,
		meta: overrides.meta ? {
			__proto__: null,
			...base.meta,
			...overrides.meta
		} : base.meta
	};
}
/**
* Resolve color reference to concrete value. Handles semantic keywords:
* 'primary', 'secondary', 'rainbow', 'inherit'
*
* @example
*   ;```ts
*   resolveColor('primary', theme.colors)
*   resolveColor([255, 0, 0], theme.colors)
*   ```
*
* @param value - Color reference.
* @param colors - Theme palette.
*
* @returns Resolved color
*/
function resolveColor(value, colors) {
	if (typeof value === "string") {
		if (value === "primary") return colors.primary;
		if (value === "secondary") return colors.secondary ?? colors.primary;
		if (value === "inherit") return "inherit";
		if (value === "rainbow") return RAINBOW_GRADIENT;
		return value;
	}
	return value;
}
/**
* Resolve shimmer color with gradient support.
*
* @example
*   ;```ts
*   resolveShimmerColor('rainbow', theme)
*   resolveShimmerColor('primary', theme)
*   ```
*
* @param value - Shimmer color.
* @param theme - Theme context.
*
* @returns Resolved color
*/
function resolveShimmerColor(value, theme) {
	if (!value) return "inherit";
	if (value === "rainbow") return RAINBOW_GRADIENT;
	if (value === "inherit") return "inherit";
	if (require_primordials_array.ArrayIsArray(value)) {
		if (value.length > 0 && require_primordials_array.ArrayIsArray(value[0])) return value;
		return value;
	}
	return resolveColor(value, theme.colors);
}

//#endregion
exports.RAINBOW_GRADIENT = RAINBOW_GRADIENT;
exports.createTheme = createTheme;
exports.extendTheme = extendTheme;
exports.resolveColor = resolveColor;
exports.resolveShimmerColor = resolveShimmerColor;