@import '../core/style/elevation';
@import '../core/theming/palette';
@import '../core/theming/theming';
@import '../core/typography/typography-utils';

$mat-chip-remove-font-size: 18px;

@mixin mat-chips-color($foreground, $background) {
  background-color: $background;
  color: $foreground;

  .mat-chip-remove {
    color: $foreground;
    opacity: 0.4;
  }
}

@mixin mat-chips-theme-color($palette) {
  @include mat-chips-color(mat-color($palette, default-contrast), mat-color($palette));

  .mat-ripple-element {
    background: mat-color($palette, default-contrast, 0.1);
  }
}

@mixin mat-chips-theme($theme) {
  $is-dark-theme: map-get($theme, is-dark);
  $primary: map-get($theme, primary);
  $accent: map-get($theme, accent);
  $warn: map-get($theme, warn);
  $background: map-get($theme, background);
  $foreground: map-get($theme, foreground);

  $unselected-background: mat-color($background, unselected-chip);
  $unselected-foreground: mat-color($foreground, text);

  .mat-chip.mat-standard-chip {
    @include mat-chips-color($unselected-foreground, $unselected-background);

    &:not(.mat-chip-disabled) {
      &:active {
        @include _mat-theme-elevation(3, $theme);
      }

      .mat-chip-remove:hover {
        opacity: 0.54;
      }
    }

    &.mat-chip-disabled {
      opacity: 0.4;
    }

    &::after {
      background: map_get($foreground, base);
    }
  }

  .mat-chip.mat-standard-chip.mat-chip-selected {
    &.mat-primary {
      @include mat-chips-theme-color($primary);
    }

    &.mat-warn {
      @include mat-chips-theme-color($warn);
    }

    &.mat-accent {
      @include mat-chips-theme-color($accent);
    }
  }
}

@mixin mat-chips-typography($config) {
  .mat-chip {
    font-size: mat-font-size($config, body-2);
    font-weight: mat-font-weight($config, body-2);

    .mat-chip-trailing-icon.mat-icon,
    .mat-chip-remove.mat-icon {
      font-size: $mat-chip-remove-font-size;
    }
  }
}
