"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createTheme = void 0;
const styles_1 = require("@mui/material/styles");
const mergeDeep_1 = require("../../utils/mergeDeep");
const breakpoints_1 = require("../breakpoints");
const components_1 = require("../components");
const constants_1 = require("../constants");
const elevation_1 = require("../elevation");
const microSpacing_1 = require("../microSpacing");
const palette_1 = require("../palette");
const shape_1 = require("../shape");
const types_1 = require("../types");
const createTheme = (params) => {
    const { palette, options = {}, breakpoints = breakpoints_1.defaultBreakpoints } = params;
    const baseThemeOptions = {
        typography: types_1.baseTypography,
        breakpoints,
        spacing: constants_1.SPACING,
        palette: (0, palette_1.getPalette)(palette),
        components: (0, components_1.getComponents)(),
    };
    const baseMuiTheme = (0, styles_1.createTheme)(baseThemeOptions);
    const muiTheme = (0, styles_1.createTheme)(baseMuiTheme, {
        typography: (0, types_1.getTypography)(baseMuiTheme),
    });
    const originalSpacing = muiTheme.spacing;
    muiTheme.spacing = ((...args) => {
        args.forEach((arg) => {
            if (typeof arg === 'number') {
                if (!Number.isInteger(arg)) {
                    // biome-ignore lint/suspicious/noConsole: <>
                    console.warn(`⚠️ theme.spacing() вызван с дробным числом "${arg}".`);
                }
                else if (arg < 1 && arg > 0) {
                    // biome-ignore lint/suspicious/noConsole: <>
                    console.warn(`⚠️ theme.spacing() вызван с числом меньше 1 ("${arg}"). Используйте theme.microSpacing().`);
                }
            }
        });
        // biome-ignore lint/suspicious/noExplicitAny: <>
        return originalSpacing(...args);
    });
    // biome-ignore lint/suspicious/noExplicitAny: <>
    return (0, mergeDeep_1.mergeDeep)(muiTheme, {
        elevation: elevation_1.elevation,
        shape: shape_1.shape,
        microSpacing: microSpacing_1.microSpacing,
        ...options,
    });
};
exports.createTheme = createTheme;
