@use "sass:map";
@use '../variables'as *;
@use '../mixins'as *;

$indicator-transition-time : $animation-duration-default;
$indicator-item-width      : 24px;
$indicator-item-height     : 24px;
$indicator-item-line       : 24px;

$indicator-item-width-small  : 18px;
$indicator-item-height-small : 18px;
$indicator-item-line-small   : 18px;

$indicator-position             : 4px;
$indicator-position-small       : 3px;
$indicator-position-active      : 3px;
$indicator-position-active-small: 2px;

$indicator-item-transform       : scale(1);
$indicator-item-transform-hover : scale(1.1);
$indicator-item-font-size       : 10px;
$indicator-item-font-size-small : 6px;
$indicator-item-color           : $component-color-default;
$indicator-item-color-dark      : $component-color-default-dark;
$indicator-round-size           : 14px;
$indicator-round-size-small     : 10px;
$indicator-round-border         : 1px solid $indicator-item-color;
$indicator-active-border        : 2px solid $indicator-item-color;
$indicator-round-border-dark    : 1px solid $indicator-item-color-dark;
$indicator-active-border-dark   : 2px solid $indicator-item-color-dark;

$indicator-shade-color              : $component-background-shade;
$indicator-shade-color-dark         : $component-background-shade-dark;
$indicator-shade-color-active       : $component-background-shade-active;
$indicator-shade-color-active-dark  : $component-background-shade-dark-active;
$indicator-shade-border             : 1px solid $indicator-shade-color;
$indicator-shade-active-border      : 2px solid $indicator-shade-color;
$indicator-shade-border-dark        : 1px solid $indicator-shade-color-dark;
$indicator-shade-active-border-dark : 2px solid $indicator-shade-color-dark;

@mixin switcher {
    ul.#{$prefix}-switcher-indicator {
        list-style: none;
        padding   : 0;

        li {
            cursor        : pointer;
            display       : inline-block;
            box-sizing    : border-box;
            margin        : 0;
            position      : relative;
            text-align    : center;
            vertical-align: middle;
            width         : $indicator-item-width;
            height        : $indicator-item-height;
            line-height   : $indicator-item-line;
            font-size     : $indicator-item-font-size;
            transform     : $indicator-item-transform;
            transition    : transform $indicator-transition-time ease-in;

            &:hover {
                transform: $indicator-item-transform-hover;
            }

            &:before {
                content      : "";
                position     : absolute;
                border-radius: 50%;
                top          : $indicator-position;
                left         : $indicator-position;
                width        : $indicator-round-size;
                height       : $indicator-round-size;
                border       : $indicator-round-border;
            }

            &>a {
                content : "";
                height  : 100%;
                width   : 100%;
                position: absolute;
                top     : 0px;
                left    : 0px;
            }

            &.#{$prefix}-active {
                &:before {
                    border: $indicator-active-border;
                    top   : $indicator-position-active;
                    left  : $indicator-position-active;

                    @include component-highlight-shadow($indicator-item-color);
                }
            }
        }
    }
}

@mixin switcher-option-small {
    ul.#{$prefix}-switcher-indicator {
        &.#{$prefix}-small {
            li {
                width      : $indicator-item-width-small;
                height     : $indicator-item-height-small;
                line-height: $indicator-item-line-small;
                font-size  : $indicator-item-font-size-small;

                &:before {
                    width : $indicator-round-size-small;
                    height: $indicator-round-size-small;
                    top   : $indicator-position-small;
                    left  : $indicator-position-small;
                }

                &.#{$prefix}-active {
                    &:before {
                        top : $indicator-position-active-small;
                        left: $indicator-position-active-small;
                    }
                }
            }
        }
    }
}

@mixin switcher-option-shade {
    ul.#{$prefix}-switcher-indicator {
        &.#{$prefix}-shade {
            li {
                &:before {
                    border          : $indicator-shade-border;
                    background-color: $indicator-shade-color;
                }

                &.#{$prefix}-active {
                    &:before {
                        border          : $indicator-shade-active-border;
                        background-color: $indicator-shade-color-active;
                        @include component-highlight-shadow($indicator-shade-color-active);
                    }
                }
            }
        }
    }
}

@mixin switcher-option-shade-dark {
    @include mode-dark {
        ul.#{$prefix}-switcher-indicator {
            &.#{$prefix}-shade {
                li {
                    &:before {
                        border          : $indicator-shade-border-dark;
                        background-color: $indicator-shade-color-dark;
                    }

                    &.#{$prefix}-active {
                        &:before {
                            border          : $indicator-shade-active-border-dark;
                            background-color: $indicator-shade-color-active-dark;
                            @include component-highlight-shadow($indicator-shade-color-active-dark);

                        }
                    }
                }
            }
        }
    }
}

@mixin switcher-option-shade-print {
    @include mode-print {
        ul.#{$prefix}-switcher-indicator {
            &.#{$prefix}-shade {
                li {
                    &:before {
                        border          : $component-print-border;
                        background-color: transparent;
                    }

                    &.#{$prefix}-active {
                        &:before {
                            border          : $component-print-border;
                            background-color: transparent;

                        }
                    }
                }
            }
        }
    }
}

@mixin switcher-dark {
    @include mode-dark {
        ul.#{$prefix}-switcher-indicator {
            li {
                &:before {
                    border: $indicator-round-border-dark;
                }

                &.#{$prefix}-active {
                    &:before {
                        border: $indicator-active-border-dark;
                        @include component-highlight-shadow($indicator-item-color-dark);
                    }
                }
            }
        }
    }
}


@mixin switcher-print {
    @include mode-print {
        ul.#{$prefix}-switcher-indicator {
            li {
                &:before {
                    border: $component-print-border;
                }
            }
        }
    }
}

@mixin definitions($options) {
    @include switcher();

    @if(not-option-disabled($options, 'dark')) {
        @include switcher-dark();
    }

    @if(not-option-disabled($options, 'print')) {
        @include switcher-print();
    }

    @if(not-option-disabled($options, 'shade')) {
        @include switcher-option-shade();

        @if(not-option-disabled($options, 'dark')) {
            @include switcher-option-shade-dark();
        }

        @if(not-option-disabled($options, 'print')) {
            @include switcher-option-shade-print();
        }
    }

    @if(not-option-disabled($options, 'small')) {
        @include switcher-option-small()
    }
}