@use "@angular/material" as mat;
@use "template" as template;
@forward "template";

/* Disable duplication warnings caused by nested theming support. */
mat.$theme-ignore-duplication-warnings: true;

@mixin create-theme($name, $definition, $nested-only: false) {
    $theme-container: "[li-theme='#{$name}']:not([active='false'])";

    @if ($nested-only == false) {
        #{$theme-container} {
            @include mat.all-component-themes($definition);

            @content;
        }
    }

    /* Support nested theme container definitions */
    [li-theme]:not([li-theme="#{$name}"]) {
        #{$theme-container} {
            @include mat.all-component-colors($definition);

            @content;
        }
    }
}

@mixin create-nested-theme($name, $definition) {
    @include create-theme(
        $name,
        $definition,
        $nested-only: true
    ) {
        @content;
    }
}

@function m2-define-theme(
    $primary,
    $accent,
    $warn,
    $is-dark: false
) {
    @if $is-dark {
        @return mat.m2-define-dark-theme((
            color: (
                primary: $primary,
                accent: $accent,
                warn: $warn
            )
        ));
    } @else {
        @return mat.m2-define-light-theme((
            color: (
                primary: $primary,
                accent: $accent,
                warn: $warn
            )
        ));
    }
}

@mixin m2-declare-theme(
    $name,
    $primary,
    $accent,
    $warn,
    $is-dark: false
) {
    @include create-theme($name, m2-define-theme(
        $primary: $primary,
        $accent: $accent,
        $warn: $warn,
        $is-dark: $is-dark
    )) {
        @content;
    }
}

@mixin m2-declare-template-theme($is-dark: false) {
    @include m2-declare-theme(
        $name: template.$template-theme-name,
        $primary: template.$m2-template-primary-palette,
        $accent: template.$m2-template-accent-palette,
        $warn: template.$m2-template-warn-palette,
        $is-dark: $is-dark
    ) {
        @content;
    }
}

/** 
 * @description Includes base styles for the application that are not theme-dependent.
*/
@mixin m2-all-static-component-dimensions() {
    @include mat.all-component-typographies();
    
    // The following mixins include base theme styles that are only needed once per application. These
    // theme styles do not depend on the color, typography, or density settings in your theme. However,
    // these styles may differ depending on the theme's design system. Currently all themes use the
    // Material 2 design system, but in the future it may be possible to create theme based on other
    // design systems, such as Material 3.
    @include mat.all-component-bases(m2-define-theme(
        $primary: template.$m2-template-primary-palette,
        $accent: template.$m2-template-accent-palette,
        $warn: template.$m2-template-warn-palette
    ));
}