text: import * as tslib_1 from "tslib";
  import { Customizations } from '@uifabric/utilities/lib/Customizations';
  import { DefaultFontStyles } from './DefaultFontStyles';
  import { DefaultPalette } from './DefaultPalette';
  import { loadTheme as legacyLoadTheme } from '@microsoft/load-themed-styles';
  var _theme = {
      palette: DefaultPalette,
      semanticColors: _makeSemanticColorsFromPalette(DefaultPalette, false),
      fonts: DefaultFontStyles,
      isInverted: false
  };
  var _onThemeChangeCallbacks = [];
  export var ThemeSettingName = 'theme';
  if (!Customizations.getSettings([ThemeSettingName]).theme) {
      var win = typeof window !== 'undefined' ? window : undefined;
      // tslint:disable:no-string-literal no-any
      if (win && win['FabricConfig'] && win['FabricConfig'].theme) {
          _theme = createTheme(win['FabricConfig'].theme);
      }
      // tslint:enable:no-string-literal no-any
      // Set the default theme.
      Customizations.applySettings((_a = {}, _a[ThemeSettingName] = _theme, _a));
  }
  /**
   * Gets the theme object.
   */
  export function getTheme() {
      return _theme;
  }
  /**
   * Registers a callback that gets called whenever the theme changes.
   * This should only be used when the component cannot automatically get theme changes through its state.
   * This will not register duplicate callbacks.
   */
  export function registerOnThemeChangeCallback(callback) {
      if (_onThemeChangeCallbacks.indexOf(callback) === -1) {
          _onThemeChangeCallbacks.push(callback);
      }
  }
  /**
   * See registerOnThemeChangeCallback().
   * Removes previously registered callbacks.
   */
  export function removeOnThemeChangeCallback(callback) {
      var i = _onThemeChangeCallbacks.indexOf(callback);
      if (i === -1) {
          return;
      }
      _onThemeChangeCallbacks.splice(i, 1);
  }
  /**
   * Applies the theme, while filling in missing slots.
   */
  export function loadTheme(theme) {
      _theme = createTheme(theme);
      // Invoke the legacy method of theming the page as well.
      legacyLoadTheme(tslib_1.__assign({}, _theme.palette, _theme.semanticColors));
      Customizations.applySettings((_a = {}, _a[ThemeSettingName] = _theme, _a));
      _onThemeChangeCallbacks.forEach(function (callback) {
          try {
              callback(_theme);
          }
          catch (e) {
              // don't let a bad callback break everything else
          }
      });
      return _theme;
      var _a;
  }
  /**
   * Creates a custom theme definition which can be used with the Customizer.
   */
  export function createTheme(theme) {
      var newPalette = tslib_1.__assign({}, DefaultPalette, theme.palette);
      if (!theme.palette || !theme.palette.accent) {
          newPalette.accent = newPalette.themePrimary;
      }
      // mix in custom overrides with good slots first, since custom overrides might be used in fixing deprecated slots
      var newSemanticColors = tslib_1.__assign({}, _makeSemanticColorsFromPalette(newPalette, !!theme.isInverted), theme.semanticColors);
      newSemanticColors = tslib_1.__assign({}, _fixDeprecatedSlots(newSemanticColors), theme.semanticColors);
      return {
          palette: newPalette,
          fonts: tslib_1.__assign({}, DefaultFontStyles, theme.fonts),
          semanticColors: newSemanticColors,
          isInverted: !!theme.isInverted
      };
  }
  // Generates all the semantic slot colors based on the Fabric palette.
  // We'll use these as fallbacks for semantic slots that the passed in theme did not define.
  // This does NOT fix deprecated slots.
  function _makeSemanticColorsFromPalette(p, isInverted) {
      var toReturn = {
          bodyBackground: p.white,
          bodyText: p.neutralPrimary,
          bodyTextChecked: p.black,
          bodySubtext: p.neutralSecondary,
          bodyDivider: p.neutralTertiaryAlt,
          disabledBackground: p.neutralLighter,
          disabledText: p.neutralTertiary,
          disabledBodyText: p.neutralTertiaryAlt,
          disabledSubtext: p.neutralQuaternary,
          focusBorder: p.black,
          errorText: !isInverted ? p.redDark : '#ff5f5f',
          warningText: !isInverted ? '#333333' : '#ffffff',
          errorBackground: !isInverted ? 'rgba(232, 17, 35, .2)' : 'rgba(232, 17, 35, .5)',
          blockingBackground: !isInverted ? 'rgba(234, 67, 0, .2)' : 'rgba(234, 67, 0, .5)',
          warningBackground: !isInverted ? 'rgba(255, 185, 0, .2)' : 'rgba(255, 251, 0, .6)',
          warningHighlight: !isInverted ? '#ffb900' : '#fff100',
          successBackground: !isInverted ? 'rgba(186, 216, 10, .2)' : 'rgba(186, 216, 10, .4)',
          inputBorder: p.neutralTertiary,
          inputBorderHovered: p.neutralDark,
          inputBackground: p.white,
          inputBackgroundChecked: p.themePrimary,
          inputBackgroundCheckedHovered: p.themeDarkAlt,
          inputForegroundChecked: p.white,
          inputFocusBorderAlt: p.themePrimary,
          smallInputBorder: p.neutralSecondary,
          inputPlaceholderText: p.neutralSecondary,
          buttonBackground: p.neutralLighter,
          buttonBackgroundChecked: p.neutralTertiaryAlt,
          buttonBackgroundHovered: p.neutralLight,
          buttonBackgroundCheckedHovered: p.neutralLight,
          buttonBorder: 'transparent',
          buttonText: p.neutralPrimary,
          buttonTextHovered: p.black,
          buttonTextChecked: p.neutralDark,
          buttonTextCheckedHovered: p.black,
          menuItemBackgroundHovered: p.neutralLighter,
          menuItemBackgroundChecked: p.neutralLight,
          menuIcon: p.themePrimary,
          menuHeader: p.themePrimary,
          listBackground: p.white,
          listText: p.neutralPrimary,
          listItemBackgroundHovered: p.neutralLighter,
          listItemBackgroundChecked: p.neutralLight,
          listItemBackgroundCheckedHovered: p.neutralQuaternaryAlt,
          link: p.themePrimary,
          linkHovered: p.themeDarker,
          // Deprecated slots, fixed by _fixDeprecatedSlots()
          listTextColor: ''
      };
      return toReturn;
  }
  function _fixDeprecatedSlots(s) {
      s.listTextColor = s.listText;
      return s;
  }
  var _a;
  //# sourceMappingURL=theme.js.map