"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var build_theme_css_vars_exports = {};
__export(build_theme_css_vars_exports, {
  buildThemeCssVars: () => buildThemeCssVars,
  buildThemePortalCssVars: () => buildThemePortalCssVars
});
module.exports = __toCommonJS(build_theme_css_vars_exports);
var import_lodash = __toESM(require("lodash"));
var import_text_style_transformer = require("../text-style-transformer.js");
var import_custom_styles = require("./generators/custom-styles.js");
var import_palette = require("./generators/palette.js");
var import_typography = require("./generators/typography.js");
var import_theme_utils = require("./theme-utils.js");
const buildThemeCssVars = (theme, documentStyle) => {
  const documentStyleTheme = import_text_style_transformer.TextStyleTransformer.fromDocumentStyle(documentStyle).toTheme();
  const mergedTheme = import_lodash.default.merge({}, theme, documentStyleTheme);
  const { palette, colorPalette, paletteConfig, typography, customStyles, nativeStyle } = mergedTheme;
  const paletteResult = colorPalette ? (0, import_palette.createColorPalette)(colorPalette, paletteConfig) : (0, import_palette.createPalette)(palette, paletteConfig);
  const { paletteVarsObject } = paletteResult;
  const typographyVarsObject = (0, import_typography.createTypography)(typography);
  const paletteCustomStyles = colorPalette ? (0, import_palette.mapColorPaletteToCustomStyles)(colorPalette) : {};
  const mergedCustomStyles = import_lodash.default.merge({}, paletteCustomStyles, customStyles);
  const customsVarsObject = (0, import_custom_styles.createCustomStyles)({
    customStyles: mergedCustomStyles,
    nativeStyle
  });
  const breakoutVars = {
    "breakout-normal-padding-start": theme?.breakout?.normalPadding.start ?? "0",
    "breakout-normal-padding-end": theme?.breakout?.normalPadding.end ?? "0",
    "breakout-full-width-padding-start": theme?.breakout?.fullWidthPadding?.start ?? "0",
    "breakout-full-width-padding-end": theme?.breakout?.fullWidthPadding?.end ?? "0"
  };
  const themeColorVars = colorPalette ? (0, import_palette.createThemeColorVars)(colorPalette) : paletteResult.colors ? (0, import_palette.createThemeColorVarsFromLegacyPalette)(paletteResult.colors) : {};
  const varsObj = {
    ...paletteVarsObject,
    ...themeColorVars,
    ...typographyVarsObject,
    ...customsVarsObject,
    ...breakoutVars
  };
  return (0, import_theme_utils.buildCssVarsObj)(varsObj);
};
const buildThemePortalCssVars = (theme) => {
  const { palette, colorPalette, paletteConfig, settingsStyles, customStyles = {} } = theme;
  const portalPaletteResult = colorPalette ? (0, import_palette.createColorPalette)(colorPalette, { settingsActionColor: paletteConfig?.settingsActionColor }) : (0, import_palette.createPalette)(palette, { settingsActionColor: paletteConfig?.settingsActionColor });
  const customsVarsObject = (0, import_custom_styles.createCustomStyles)({
    customStyles: { staticToolbar: customStyles?.staticToolbar },
    settingsStyles
  });
  const themeColorVars = colorPalette ? (0, import_palette.createThemeColorVars)(colorPalette) : portalPaletteResult.colors ? (0, import_palette.createThemeColorVarsFromLegacyPalette)(portalPaletteResult.colors) : {};
  return (0, import_theme_utils.buildCssVarsObj)({
    settingsActionColor: portalPaletteResult.paletteVarsObject.settingsActionColor,
    settingsActionColorTuple: portalPaletteResult.paletteVarsObject.settingsActionColorTuple,
    ...themeColorVars,
    ...customsVarsObject
  });
};
//# sourceMappingURL=build-theme-css-vars.js.map
