import { defineConfig } from 'vite';
import uni from '@dcloudio/vite-plugin-uni';
import { unovite } from './uni_modules/unocss'

export default defineConfig({
	plugins: [
		uni(),
		unovite({
			theme: {
				colors: {
					secondary: 'var(--un-text-color-secondary)',
					placeholder: 'var(--un-text-color-placeholder)',
					disabled: 'var(--un-text-color-disabled)',
					white: 'var(--un-text-color-white)',
					content: 'var(--un-text-color)',
					muted: 'var(--un-text-color-muted)',
					page: 'var(--un-bg-color-page)',
					primary: {
						DEFAULT: 'var(--un-color-primary)',
						'light': 'var(--un-color-primary-light)',
						'lighter': 'var(--un-color-primary-lighter)',
						'dark': 'var(--un-color-primary-dark)'
					},
					success: {
						DEFAULT: 'var(--un-color-success)',
						'light': 'var(--un-color-success-light)',
						'lighter': 'var(--un-color-success-lighter)',
						'dark': 'var(--un-color-success-dark)'
					},
					warning: {
						DEFAULT: 'var(--un-color-warning)',
						'light': 'var(--un-color-warning-light)',
						'lighter': 'var(--un-color-warning-lighter)',
						'dark': 'var(--un-color-warning-dark)'
					},
					error: {
						DEFAULT: 'var(--un-color-error)',
						'light': 'var(--un-color-error-light)',
						'lighter': 'var(--un-color-error-lighter)',
						'dark': 'var(--un-color-error-dark)'
					},
					info: {
						DEFAULT: 'var(--un-color-info)',
						'light': 'var(--un-color-info-light)',
						'lighter': 'var(--un-color-info-lighter)',
						'dark': 'var(--un-color-info-dark)'
					}
				}
			},
			rules: [
				[
					/^[mp][xy]-[A-z0-9\.]+$/,
					([prefix, value]) => [
						[(prefix[0] === 'p' ? 'padding' : 'margin') + '-' + (prefix[1] === 'x' ? 'left' : 'top'), /[A-z]+$/.test(value) ? value : value + 'rpx'],
						[(prefix[0] === 'p' ? 'padding' : 'margin') + '-' + (prefix[1] === 'x' ? 'right' : 'bottom'), /[A-z]+$/.test(value) ? value : value + 'rpx'],
					]
				]
			]
		})
	]
});