import { resolveColorValue, badgeBackground, badgeForeground, contrastBorder, listFocusBackground, listFocusForeground, listFocusOutline, listActiveSelectionBackground, listActiveSelectionForeground, listActiveSelectionIconForeground, listInactiveSelectionBackground, listInactiveSelectionIconForeground, listInactiveSelectionForeground, listInactiveFocusBackground, listInactiveFocusOutline, listHoverBackground, listHoverForeground, listDropBackground, activeContrastBorder, listFilterWidgetBackground, listFilterWidgetOutline, listFilterWidgetNoMatchesOutline, widgetShadow, treeIndentGuidesStroke, tableColumnsBorder, tableOddRowsBackgroundColor, menuBorder, menuForeground, menuBackground, menuSelectionForeground, menuSelectionBackground, menuSelectionBorder, menuSeparatorBackground, scrollbarShadow, scrollbarSliderBackground, scrollbarSliderHoverBackground, scrollbarSliderActiveBackground } from "./colorRegistry.mjs";
function computeStyles(theme, styleMap) {
  const styles = /* @__PURE__ */ Object.create(null);
  for (let key in styleMap) {
    const value = styleMap[key];
    if (value) {
      styles[key] = resolveColorValue(value, theme);
    }
  }
  return styles;
}
function attachStyler(themeService, styleMap, widgetOrCallback) {
  function applyStyles() {
    const styles = computeStyles(themeService.getColorTheme(), styleMap);
    if (typeof widgetOrCallback === "function") {
      widgetOrCallback(styles);
    } else {
      widgetOrCallback.style(styles);
    }
  }
  applyStyles();
  return themeService.onDidColorThemeChange(applyStyles);
}
function attachBadgeStyler(widget, themeService, style) {
  return attachStyler(themeService, {
    badgeBackground: (style === null || style === void 0 ? void 0 : style.badgeBackground) || badgeBackground,
    badgeForeground: (style === null || style === void 0 ? void 0 : style.badgeForeground) || badgeForeground,
    badgeBorder: contrastBorder
  }, widget);
}
function attachListStyler(widget, themeService, overrides) {
  return attachStyler(themeService, Object.assign(Object.assign({}, defaultListStyles), overrides || {}), widget);
}
const defaultListStyles = {
  listFocusBackground,
  listFocusForeground,
  listFocusOutline,
  listActiveSelectionBackground,
  listActiveSelectionForeground,
  listActiveSelectionIconForeground,
  listFocusAndSelectionBackground: listActiveSelectionBackground,
  listFocusAndSelectionForeground: listActiveSelectionForeground,
  listInactiveSelectionBackground,
  listInactiveSelectionIconForeground,
  listInactiveSelectionForeground,
  listInactiveFocusBackground,
  listInactiveFocusOutline,
  listHoverBackground,
  listHoverForeground,
  listDropBackground,
  listSelectionOutline: activeContrastBorder,
  listHoverOutline: activeContrastBorder,
  listFilterWidgetBackground,
  listFilterWidgetOutline,
  listFilterWidgetNoMatchesOutline,
  listMatchesShadow: widgetShadow,
  treeIndentGuidesStroke,
  tableColumnsBorder,
  tableOddRowsBackgroundColor
};
const defaultMenuStyles = {
  shadowColor: widgetShadow,
  borderColor: menuBorder,
  foregroundColor: menuForeground,
  backgroundColor: menuBackground,
  selectionForegroundColor: menuSelectionForeground,
  selectionBackgroundColor: menuSelectionBackground,
  selectionBorderColor: menuSelectionBorder,
  separatorColor: menuSeparatorBackground,
  scrollbarShadow,
  scrollbarSliderBackground,
  scrollbarSliderHoverBackground,
  scrollbarSliderActiveBackground
};
function attachMenuStyler(widget, themeService, style) {
  return attachStyler(themeService, Object.assign(Object.assign({}, defaultMenuStyles), style), widget);
}
export {
  attachBadgeStyler,
  attachListStyler,
  attachMenuStyler,
  attachStyler,
  computeStyles,
  defaultListStyles,
  defaultMenuStyles
};
