import * as i0 from '@angular/core';
import { Directive, Component, HostBinding, Input, ContentChildren, HostListener, NgModule } from '@angular/core';
import { FadeInOutAnimation, CarouselSlideAnimation } from '@mintplayer/ng-animations';
import { Subject, BehaviorSubject } from 'rxjs';
import { map, takeUntil, take } from 'rxjs/operators';
import * as i1 from '@angular/common';
import { CommonModule } from '@angular/common';

class BsCarouselImageDirective {
    constructor(templateRef) {
        this.templateRef = templateRef;
        this.itemTemplate = this.templateRef;
    }
}
BsCarouselImageDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsCarouselImageDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
BsCarouselImageDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.0.4", type: BsCarouselImageDirective, selector: "*[bsCarouselImage]", ngImport: i0 });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsCarouselImageDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: '*[bsCarouselImage]'
                }]
        }], ctorParameters: function () { return [{ type: i0.TemplateRef }]; } });

class BsCarouselComponent {
    constructor() {
        this.animationsDisabled = false;
        this.indicators = true;
        this._animation = 'slide';
        this.destroyed$ = new Subject();
        this.currentImageCounter$ = new BehaviorSubject(-1);
        this.currentImageIndex$ = this.currentImageCounter$
            .pipe(map((counter) => {
            const l = this.images.length;
            return ((counter % l) + l) % l;
        }))
            .pipe(takeUntil(this.destroyed$));
        this.currentImage$ = this.currentImageIndex$
            .pipe(map((index) => { var _a, _b; return (_b = (_a = this.images.get(index)) === null || _a === void 0 ? void 0 : _a.itemTemplate) !== null && _b !== void 0 ? _b : null; }))
            .pipe(takeUntil(this.destroyed$));
    }
    ngOnDestroy() {
        this.destroyed$.next(true);
    }
    ngAfterContentInit() {
        if (this.images.length > 0) {
            this.currentImageCounter$.next(0);
        }
        else {
            this.currentImageCounter$.next(-1);
        }
    }
    //#region Animation
    set animation(value) {
        this.animationsDisabled = true;
        this._animation = value;
        setTimeout(() => {
            this.animationsDisabled = false;
        }, 20);
    }
    get animation() {
        return this._animation;
    }
    //#endregion
    previousImage() {
        this.currentImageCounter$
            .pipe(take(1))
            .subscribe((currentImageCounter) => {
            this.currentImageCounter$.next(currentImageCounter - 1);
        });
    }
    nextImage() {
        this.currentImageCounter$
            .pipe(take(1))
            .subscribe((currentImageCounter) => {
            this.currentImageCounter$.next(currentImageCounter + 1);
        });
    }
    setCurrentImage(index) {
        const currentValue = this.currentImageCounter$.value;
        const l = this.images.length;
        const counterMod = ((currentValue % l) + l) % l;
        const newValue = currentValue - counterMod + index;
        this.currentImageCounter$.next(newValue);
    }
    onKeyPress(ev) {
        switch (ev.key) {
            case 'ArrowLeft':
                this.previousImage();
                break;
            case 'ArrowRight':
                this.nextImage();
                break;
        }
        ev.preventDefault();
    }
}
BsCarouselComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsCarouselComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
BsCarouselComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.4", type: BsCarouselComponent, selector: "bs-carousel", inputs: { indicators: "indicators", animation: "animation" }, host: { listeners: { "document:keydown.ArrowLeft": "onKeyPress($event)", "document:keydown.ArrowRight": "onKeyPress($event)" }, properties: { "@.disabled": "this.animationsDisabled" } }, queries: [{ propertyName: "images", predicate: BsCarouselImageDirective }], ngImport: i0, template: "<div class=\"carousel slide\">\n    <div *ngIf=\"indicators\" class=\"carousel-indicators\">\n        <button *ngFor=\"let image of images; let i = index\" type=\"button\" (click)=\"setCurrentImage(i)\"\n            [class.active]=\"(currentImageIndex$ | async) === i\" data-bs-target\n            [attr.aria-current]=\"(currentImageIndex$ | async) === i ? true : null\"\n            [attr.aria-label]=\"'Slide ' + i\"></button>\n    </div>\n\n    <div class=\"carousel-inner\" [@carouselSlide]=\"currentImageCounter$ | async\" *ngIf=\"animation === 'slide'\">\n        <ng-container *ngFor=\"let image of images; let i = index\">\n            <div class=\"carousel-item\" [class.active]=\"true\" *ngIf=\"(currentImageIndex$ | async) === i\">\n                <ng-container [ngTemplateOutlet]=\"image.itemTemplate\"></ng-container>    \n            </div>\n        </ng-container>\n    </div>\n    <div class=\"carousel-inner\" *ngIf=\"animation === 'fade'\">\n        <ng-container *ngFor=\"let image of images; let i = index\">\n            <div class=\"carousel-item\" [class.active]=\"true\" @fadeInOut *ngIf=\"(currentImageIndex$ | async) === i\">\n                <ng-container [ngTemplateOutlet]=\"image.itemTemplate\"></ng-container>    \n            </div>\n        </ng-container>\n    </div>\n\n    <button class=\"carousel-control-prev\" type=\"button\" (click)=\"previousImage()\">\n        <span class=\"carousel-control-prev-icon\" aria-hidden=\"true\"></span>\n        <span class=\"visually-hidden\">Previous</span>\n    </button>\n    <button class=\"carousel-control-next\" type=\"button\" (click)=\"nextImage()\">\n        <span class=\"carousel-control-next-icon\" aria-hidden=\"true\"></span>\n        <span class=\"visually-hidden\">Next</span>\n    </button>\n</div>", styles: [":host ::ng-deep .carousel{position:relative}:host ::ng-deep .carousel.pointer-event{touch-action:pan-y}:host ::ng-deep .carousel-inner{position:relative;width:100%;overflow:hidden}:host ::ng-deep .carousel-inner:after{display:block;clear:both;content:\"\"}:host ::ng-deep .carousel-item{position:relative;display:none;float:left;width:100%;margin-right:-100%;-webkit-backface-visibility:hidden;backface-visibility:hidden;transition:transform .6s ease-in-out}@media (prefers-reduced-motion: reduce){:host ::ng-deep .carousel-item{transition:none}}:host ::ng-deep .carousel-item.active,:host ::ng-deep .carousel-item-next,:host ::ng-deep .carousel-item-prev{display:block}:host ::ng-deep .carousel-item-next:not(.carousel-item-start),:host ::ng-deep .active.carousel-item-end{transform:translate(100%)}:host ::ng-deep .carousel-item-prev:not(.carousel-item-end),:host ::ng-deep .active.carousel-item-start{transform:translate(-100%)}:host ::ng-deep .carousel-fade .carousel-item{opacity:0;transition-property:opacity;transform:none}:host ::ng-deep .carousel-fade .carousel-item.active,:host ::ng-deep .carousel-fade .carousel-item-next.carousel-item-start,:host ::ng-deep .carousel-fade .carousel-item-prev.carousel-item-end{z-index:1;opacity:1}:host ::ng-deep .carousel-fade .active.carousel-item-start,:host ::ng-deep .carousel-fade .active.carousel-item-end{z-index:0;opacity:0;transition:opacity 0s .6s}@media (prefers-reduced-motion: reduce){:host ::ng-deep .carousel-fade .active.carousel-item-start,:host ::ng-deep .carousel-fade .active.carousel-item-end{transition:none}}:host ::ng-deep .carousel-control-prev,:host ::ng-deep .carousel-control-next{position:absolute;top:0;bottom:0;z-index:1;display:flex;align-items:center;justify-content:center;width:15%;padding:0;color:#fff;text-align:center;background:none;border:0;opacity:.5;transition:opacity .15s ease}@media (prefers-reduced-motion: reduce){:host ::ng-deep .carousel-control-prev,:host ::ng-deep .carousel-control-next{transition:none}}:host ::ng-deep .carousel-control-prev:hover,:host ::ng-deep .carousel-control-prev:focus,:host ::ng-deep .carousel-control-next:hover,:host ::ng-deep .carousel-control-next:focus{color:#fff;text-decoration:none;outline:0;opacity:.9}:host ::ng-deep .carousel-control-prev{left:0}:host ::ng-deep .carousel-control-next{right:0}:host ::ng-deep .carousel-control-prev-icon,:host ::ng-deep .carousel-control-next-icon{display:inline-block;width:2rem;height:2rem;background-repeat:no-repeat;background-position:50%;background-size:100% 100%}:host ::ng-deep .carousel-control-prev-icon{background-image:url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath d='M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z'/%3e%3c/svg%3e\")}:host ::ng-deep .carousel-control-next-icon{background-image:url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath d='M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e\")}:host ::ng-deep .carousel-indicators{position:absolute;right:0;bottom:0;left:0;z-index:2;display:flex;justify-content:center;padding:0;margin-right:15%;margin-bottom:1rem;margin-left:15%;list-style:none}:host ::ng-deep .carousel-indicators [data-bs-target]{box-sizing:content-box;flex:0 1 auto;width:30px;height:3px;padding:0;margin-right:3px;margin-left:3px;text-indent:-999px;cursor:pointer;background-color:#fff;background-clip:padding-box;border:0;border-top:10px solid transparent;border-bottom:10px solid transparent;opacity:.5;transition:opacity .6s ease}@media (prefers-reduced-motion: reduce){:host ::ng-deep .carousel-indicators [data-bs-target]{transition:none}}:host ::ng-deep .carousel-indicators .active{opacity:1}:host ::ng-deep .carousel-caption{position:absolute;right:15%;bottom:1.25rem;left:15%;padding-top:1.25rem;padding-bottom:1.25rem;color:#fff;text-align:center}:host ::ng-deep .carousel-dark .carousel-control-prev-icon,:host ::ng-deep .carousel-dark .carousel-control-next-icon{filter:invert(1) grayscale(100)}:host ::ng-deep .carousel-dark .carousel-indicators [data-bs-target]{background-color:#000}:host ::ng-deep .carousel-dark .carousel-caption{color:#000}:host ::ng-deep .carousel{min-height:100px}\n"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }], animations: [FadeInOutAnimation, CarouselSlideAnimation] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsCarouselComponent, decorators: [{
            type: Component,
            args: [{ selector: 'bs-carousel', animations: [FadeInOutAnimation, CarouselSlideAnimation], template: "<div class=\"carousel slide\">\n    <div *ngIf=\"indicators\" class=\"carousel-indicators\">\n        <button *ngFor=\"let image of images; let i = index\" type=\"button\" (click)=\"setCurrentImage(i)\"\n            [class.active]=\"(currentImageIndex$ | async) === i\" data-bs-target\n            [attr.aria-current]=\"(currentImageIndex$ | async) === i ? true : null\"\n            [attr.aria-label]=\"'Slide ' + i\"></button>\n    </div>\n\n    <div class=\"carousel-inner\" [@carouselSlide]=\"currentImageCounter$ | async\" *ngIf=\"animation === 'slide'\">\n        <ng-container *ngFor=\"let image of images; let i = index\">\n            <div class=\"carousel-item\" [class.active]=\"true\" *ngIf=\"(currentImageIndex$ | async) === i\">\n                <ng-container [ngTemplateOutlet]=\"image.itemTemplate\"></ng-container>    \n            </div>\n        </ng-container>\n    </div>\n    <div class=\"carousel-inner\" *ngIf=\"animation === 'fade'\">\n        <ng-container *ngFor=\"let image of images; let i = index\">\n            <div class=\"carousel-item\" [class.active]=\"true\" @fadeInOut *ngIf=\"(currentImageIndex$ | async) === i\">\n                <ng-container [ngTemplateOutlet]=\"image.itemTemplate\"></ng-container>    \n            </div>\n        </ng-container>\n    </div>\n\n    <button class=\"carousel-control-prev\" type=\"button\" (click)=\"previousImage()\">\n        <span class=\"carousel-control-prev-icon\" aria-hidden=\"true\"></span>\n        <span class=\"visually-hidden\">Previous</span>\n    </button>\n    <button class=\"carousel-control-next\" type=\"button\" (click)=\"nextImage()\">\n        <span class=\"carousel-control-next-icon\" aria-hidden=\"true\"></span>\n        <span class=\"visually-hidden\">Next</span>\n    </button>\n</div>", styles: [":host ::ng-deep .carousel{position:relative}:host ::ng-deep .carousel.pointer-event{touch-action:pan-y}:host ::ng-deep .carousel-inner{position:relative;width:100%;overflow:hidden}:host ::ng-deep .carousel-inner:after{display:block;clear:both;content:\"\"}:host ::ng-deep .carousel-item{position:relative;display:none;float:left;width:100%;margin-right:-100%;-webkit-backface-visibility:hidden;backface-visibility:hidden;transition:transform .6s ease-in-out}@media (prefers-reduced-motion: reduce){:host ::ng-deep .carousel-item{transition:none}}:host ::ng-deep .carousel-item.active,:host ::ng-deep .carousel-item-next,:host ::ng-deep .carousel-item-prev{display:block}:host ::ng-deep .carousel-item-next:not(.carousel-item-start),:host ::ng-deep .active.carousel-item-end{transform:translate(100%)}:host ::ng-deep .carousel-item-prev:not(.carousel-item-end),:host ::ng-deep .active.carousel-item-start{transform:translate(-100%)}:host ::ng-deep .carousel-fade .carousel-item{opacity:0;transition-property:opacity;transform:none}:host ::ng-deep .carousel-fade .carousel-item.active,:host ::ng-deep .carousel-fade .carousel-item-next.carousel-item-start,:host ::ng-deep .carousel-fade .carousel-item-prev.carousel-item-end{z-index:1;opacity:1}:host ::ng-deep .carousel-fade .active.carousel-item-start,:host ::ng-deep .carousel-fade .active.carousel-item-end{z-index:0;opacity:0;transition:opacity 0s .6s}@media (prefers-reduced-motion: reduce){:host ::ng-deep .carousel-fade .active.carousel-item-start,:host ::ng-deep .carousel-fade .active.carousel-item-end{transition:none}}:host ::ng-deep .carousel-control-prev,:host ::ng-deep .carousel-control-next{position:absolute;top:0;bottom:0;z-index:1;display:flex;align-items:center;justify-content:center;width:15%;padding:0;color:#fff;text-align:center;background:none;border:0;opacity:.5;transition:opacity .15s ease}@media (prefers-reduced-motion: reduce){:host ::ng-deep .carousel-control-prev,:host ::ng-deep .carousel-control-next{transition:none}}:host ::ng-deep .carousel-control-prev:hover,:host ::ng-deep .carousel-control-prev:focus,:host ::ng-deep .carousel-control-next:hover,:host ::ng-deep .carousel-control-next:focus{color:#fff;text-decoration:none;outline:0;opacity:.9}:host ::ng-deep .carousel-control-prev{left:0}:host ::ng-deep .carousel-control-next{right:0}:host ::ng-deep .carousel-control-prev-icon,:host ::ng-deep .carousel-control-next-icon{display:inline-block;width:2rem;height:2rem;background-repeat:no-repeat;background-position:50%;background-size:100% 100%}:host ::ng-deep .carousel-control-prev-icon{background-image:url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath d='M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z'/%3e%3c/svg%3e\")}:host ::ng-deep .carousel-control-next-icon{background-image:url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath d='M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e\")}:host ::ng-deep .carousel-indicators{position:absolute;right:0;bottom:0;left:0;z-index:2;display:flex;justify-content:center;padding:0;margin-right:15%;margin-bottom:1rem;margin-left:15%;list-style:none}:host ::ng-deep .carousel-indicators [data-bs-target]{box-sizing:content-box;flex:0 1 auto;width:30px;height:3px;padding:0;margin-right:3px;margin-left:3px;text-indent:-999px;cursor:pointer;background-color:#fff;background-clip:padding-box;border:0;border-top:10px solid transparent;border-bottom:10px solid transparent;opacity:.5;transition:opacity .6s ease}@media (prefers-reduced-motion: reduce){:host ::ng-deep .carousel-indicators [data-bs-target]{transition:none}}:host ::ng-deep .carousel-indicators .active{opacity:1}:host ::ng-deep .carousel-caption{position:absolute;right:15%;bottom:1.25rem;left:15%;padding-top:1.25rem;padding-bottom:1.25rem;color:#fff;text-align:center}:host ::ng-deep .carousel-dark .carousel-control-prev-icon,:host ::ng-deep .carousel-dark .carousel-control-next-icon{filter:invert(1) grayscale(100)}:host ::ng-deep .carousel-dark .carousel-indicators [data-bs-target]{background-color:#000}:host ::ng-deep .carousel-dark .carousel-caption{color:#000}:host ::ng-deep .carousel{min-height:100px}\n"] }]
        }], ctorParameters: function () { return []; }, propDecorators: { animationsDisabled: [{
                type: HostBinding,
                args: ['@.disabled']
            }], indicators: [{
                type: Input
            }], images: [{
                type: ContentChildren,
                args: [BsCarouselImageDirective]
            }], animation: [{
                type: Input
            }], onKeyPress: [{
                type: HostListener,
                args: ['document:keydown.ArrowLeft', ['$event']]
            }, {
                type: HostListener,
                args: ['document:keydown.ArrowRight', ['$event']]
            }] } });

class BsCarouselModule {
}
BsCarouselModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsCarouselModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
BsCarouselModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.0.4", ngImport: i0, type: BsCarouselModule, declarations: [BsCarouselComponent,
        BsCarouselImageDirective], imports: [CommonModule], exports: [BsCarouselComponent,
        BsCarouselImageDirective] });
BsCarouselModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsCarouselModule, imports: [CommonModule] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsCarouselModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [
                        BsCarouselComponent,
                        BsCarouselImageDirective
                    ],
                    imports: [
                        CommonModule
                    ],
                    exports: [
                        BsCarouselComponent,
                        BsCarouselImageDirective
                    ]
                }]
        }] });

/**
 * Generated bundle index. Do not edit.
 */

export { BsCarouselComponent, BsCarouselImageDirective, BsCarouselModule };
//# sourceMappingURL=mintplayer-ng-bootstrap-carousel.mjs.map
