@use 'sass:map';
@use '../core/theming/theming';
@use '../core/ripple/ripple-theme';
@use '../core/selection/pseudo-checkbox/pseudo-checkbox-theme';
@use './option/option-theme';
@use './option/optgroup-theme';
@use '../core/style/elevation';
@use '../core/style/private';

/// @deprecated Use `mat.core-color` instead. See https://material.angular.io/guide/mdc-migration for information about migrating.
/// @breaking-change 17.0.0
@mixin color($config-or-theme) {
  $config: theming.get-color-config($config-or-theme);

  // Wrapper element that provides the theme background when the user's content isn't
  // inside of a `mat-sidenav-container`. Note that we need to exclude the ampersand
  // selector in case the mixin is included at the top level.
  .mat-app-background#{if(&, ', &.mat-app-background', '')} {
    $background: map.get($config, background);
    $foreground: map.get($config, foreground);

    background-color: theming.get-color-from-palette($background, background);
    color: theming.get-color-from-palette($foreground, text);
  }

  // Provides external CSS classes for each elevation value. Each CSS class is formatted as
  // `mat-elevation-z$zValue` where `$zValue` corresponds to the z-space to which the element is
  // elevated.
  @for $zValue from 0 through 24 {
    .#{elevation.$prefix}#{$zValue} {
      @include private.private-theme-elevation($zValue, $config);
    }
  }

  // Marker that is used to determine whether the user has added a theme to their page.
  @at-root {
    .mat-theme-loaded-marker {
      display: none;
    }
  }
}

// Mixin that renders all of the core styles that depend on the theme.
/// @deprecated Use `mat.core-theme` instead. See https://material.angular.io/guide/mdc-migration for information about migrating.
/// @breaking-change 17.0.0
@mixin theme($theme-or-color-config) {
  $theme: theming.private-legacy-get-theme($theme-or-color-config);
  // Wrap the sub-theme includes in the duplicate theme styles mixin. This ensures that
  // there won't be multiple warnings. e.g. if `mat-core-theme` reports a warning, then
  // the imported themes (such as `mat-ripple-theme`) should not report again.
  @include theming.private-check-duplicate-theme-styles($theme, 'mat-legacy-core') {
    // Legacy-specific themes.
    @include option-theme.theme($theme);
    @include optgroup-theme.theme($theme);

    // Non-legacy themes that are forwarded.
    @include ripple-theme.theme($theme);
    @include pseudo-checkbox-theme.theme($theme);

    $color: theming.get-color-config($theme);
    @if $color != null {
      @include color($color);
    }
  }
}
