@use 'sass:map';
@use '~@angular/material' as mat;
@use '~@mtna/core-angular' as mtna;

@mixin i18n-editor-theme($palette, $foreground, $is-dark) {
  mtna-i18n-editor-focus-indicator {
    background: transparent;
    &.mtna-i18n-editor-focus-indicator-show-inactive {
      background-color: mat.get-color-from-palette($foreground, divider);
    }
    &::after {
      background-color: mat.get-color-from-palette($palette);
    }
  }

  rds-c-rich-text-editor {
    $swift-ease-out-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1);

    border-color: mat.get-color-from-palette($foreground, divider, if($is-dark, 0.3, 0.12));
    &:hover {
      border-color: mat.get-color-from-palette($foreground, divider, if($is-dark, 1, 0.87));
      transition: border-color 600ms $swift-ease-out-timing-function;
    }
    &.active {
      border-color: mat.get-color-from-palette($palette);
      transition: border-color 100ms $swift-ease-out-timing-function;
    }
  }

  @include mtna.select-wrapper-theme($palette, $foreground, $is-dark);
  @include mtna.tab-wrapper-theme($palette, $foreground, $is-dark);
}

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

  rds-c-i18n-rich-text-editor {
    &.mat-accent {
      @include i18n-editor-theme($accent, $foreground, $is-dark-theme);
    }
    &.mat-primary {
      @include i18n-editor-theme($primary, $foreground, $is-dark-theme);
    }
    &.mat-warn {
      @include i18n-editor-theme($warn, $foreground, $is-dark-theme);
    }
  }
}

@mixin typography($theme) {
  $typography-config: mat.get-typography-config($theme);
}

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

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