@use '../variables'as *;
@use '../mixins'as *;

$spinner-color-default      : $component-color-default;
$spinner-color-inverse      : $component-color-inverse;
$spinner-color-inverse-dark : $component-color-inverse-dark;
$spinner-color-default-dark : $component-color-default-dark;

@mixin spinner {
    .#{$prefix}-spinner {
        display        : inline-flex;
        align-items    : center;
        justify-content: center;
        text-align     : center;

        svg {
            max-width      : 100%;
            box-sizing     : border-box;
            height         : auto;
            order          : 0;
            fill           : none;
            stroke         : $spinner-color-default;
            stroke-opacity : 1;
            stroke-width   : 1px;
            stroke-linecap : round;
            stroke-linejoin: miter;
        }
    }

    #circle_spinner_path_2 {
        stroke-dasharray         : 39;
        animation                : strokeMove1 3s cubic-bezier(0.34, 0.64, 0.47, 1.07);
        transform-origin         : center;
        animation-iteration-count: infinite;
    }

    #circle_spinner_path_1 {
        stroke-dasharray         : 52;
        // transform: rotate(90deg);
        animation                : strokeMove 3s cubic-bezier(0.34, 0.64, 0.47, 1.07);
        transform-origin         : center;
        animation-iteration-count: infinite;
    }

    .animation-spinner-circle {
        stroke-dasharray         : 53;
        // transform: rotate(90deg);
        animation                : strokeMove 3s cubic-bezier(0.34, 0.64, 0.47, 1.07);
        transform-origin         : center;
        animation-iteration-count: infinite;
    }

    .animation-spinner-circle_double {
        path {
            &:nth-of-type(1) {
                stroke-dasharray         : 53;
                animation                : strokeMove 3s cubic-bezier(0.34, 0.64, 0.47, 1.07);
                transform-origin         : center;
                animation-iteration-count: infinite;
            }

            &:nth-of-type(2) {
                stroke-dasharray         : 41;
                // transform: rotate(90deg);
                animation                : strokeMove1 3s cubic-bezier(0.34, 0.64, 0.47, 1.07);
                transform-origin         : center;
                animation-iteration-count: infinite;
            }
        }

    }

    @keyframes strokeMove {
        0% {
            stroke-dashoffset: 53;
            transform        : rotate(0);
        }

        50% {
            stroke-dashoffset: 0;
            transform        : rotate(180deg);
        }

        100% {
            stroke-dashoffset: -53;
            transform        : rotate(360deg);
        }
    }

    @keyframes strokeMove1 {
        0% {
            stroke-dashoffset: 41;
            transform        : rotate(180deg);
        }

        50% {
            stroke-dashoffset: 0;
            transform        : rotate(360deg);
        }

        100% {
            stroke-dashoffset: -41;
            transform        : rotate(540deg);
        }
    }
}

@mixin spinner-dark {
    .#{$prefix}-dark {
        .#{$prefix}-spinner {
            svg {
                stroke: $spinner-color-default-dark;
            }
        }
    }
}

@mixin spinner-print {
    .#{$prefix}-print {
        .#{$prefix}-spinner {
            svg {
                stroke: $component-print-color;
            }
        }
    }
}

@mixin definitions($options: ()) {
    @include spinner();

    @if(not-option-disabled($options, 'dark')) {
        @include spinner-dark();
    }

    @if(not-option-disabled($options, 'print')) {
        @include spinner-print();
    }
}