// (C) 2022-2025 GoodData Corporation
import { colorPaletteToColors, idRef, } from "@gooddata/sdk-model";
import { DefaultColorPalette } from "@gooddata/sdk-ui";
/**
 * Dummy theme metadata object which represents the default colors of GD.
 *
 * This object is used as default when rendering theme as a sequence of colored elements in styling
 * picker. It's properties are also used as defaults when some custom theme is missing a crucial
 * property for the same rendering purposes.
 *
 * @internal
 */
export const defaultThemeMetadataObject = {
    id: "default-theme",
    ref: idRef("default-theme"),
    uri: "",
    type: "theme",
    description: "",
    production: false,
    deprecated: false,
    unlisted: false,
    title: "Indigo",
    theme: {
        palette: {
            primary: {
                base: "#14b2e2",
            },
            complementary: {
                c0: "#fff",
                c1: "#303442",
                c7: "#778491",
                c8: "#464e56",
                c9: "#000",
            },
        },
    },
};
/**
 * This function transforms a theme metadata object into an array of colors which is used
 * to render the theme in styling picker. When provided theme object is missing some properties,
 * defaults are taken from the {@link defaultThemeMetadataObject}.
 *
 * @internal
 */
export const getColorsPreviewFromTheme = (theme) => {
    const { theme: defaultTheme } = defaultThemeMetadataObject;
    const defaultPalette = defaultTheme?.palette;
    const defaultComplementary = defaultPalette?.complementary;
    const defaultPrimary = defaultPalette?.primary;
    const color1 = theme.dashboards?.navigation?.backgroundColor ||
        theme.palette?.complementary?.c1 ||
        defaultComplementary?.c1 ||
        "";
    const color2 = theme.dashboards?.content?.backgroundColor ||
        theme.palette?.complementary?.c0 ||
        defaultComplementary?.c0 ||
        "";
    const color3 = theme.palette?.primary?.base || defaultPrimary?.base || "";
    const color4 = theme.dashboards?.content?.kpiWidget?.kpi?.primaryMeasureColor ||
        theme.palette?.complementary?.c9 ||
        defaultComplementary?.c9 ||
        "";
    const color5 = theme.dashboards?.title?.color || theme.palette?.complementary?.c8 || defaultComplementary?.c8 || "";
    const color6 = theme.palette?.complementary?.c7 || defaultComplementary?.c7 || "";
    return [color1, color2, color3, color4, color5, color6];
};
/**
 * Dummy theme metadata object which represents the default colors of GD.
 *
 * This object is used as default when rendering theme as a sequence of colored elements in styling
 * picker. It's properties are also used as defaults when some custom theme is missing a crucial
 * property for the same rendering purposes.
 *
 * @internal
 */
export const defaultColorPaletteMetadataObject = {
    id: "default-color-palette",
    ref: idRef("default-color-palette"),
    uri: "",
    type: "colorPalette",
    description: "",
    production: false,
    deprecated: false,
    unlisted: false,
    title: "Indigo",
    colorPalette: DefaultColorPalette,
};
/**
 * This function transforms a color palette into an array of max ten colors which is used
 * to render the color palette in styling picker.
 *
 * @internal
 */
export const getColorsPreviewFromColorPalette = (colorPalette) => {
    return colorPaletteToColors(colorPalette).slice(0, 10);
};
