import * as i0 from '@angular/core';
import { Component, Input, ViewChild, Directive, NgModule } from '@angular/core';
import { Color } from '@mintplayer/ng-bootstrap';
import * as i1 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i2 from '@angular/forms';
import { FormsModule } from '@angular/forms';
import * as i3 from '@mintplayer/ng-bootstrap/dropdown';
import { BsDropdownModule } from '@mintplayer/ng-bootstrap/dropdown';
import * as i4 from '@mintplayer/ng-bootstrap/has-overlay';
import { BsHasOverlayModule } from '@mintplayer/ng-bootstrap/has-overlay';
import * as i5 from '@mintplayer/ng-bootstrap/toggle-button';
import { BsToggleButtonModule } from '@mintplayer/ng-bootstrap/toggle-button';
import * as i6 from '@mintplayer/ng-bootstrap/button-type';
import { BsButtonTypeModule } from '@mintplayer/ng-bootstrap/button-type';
import { FocusOnLoadModule } from '@mintplayer/ng-focus-on-load';

class BsMultiselectComponent {
    constructor() {
        this.colors = Color;
        this.items = [];
        this.selectedItems = [];
    }
    // itemChange(item: any, ev: Event) {
    itemChange(item, value) {
        // const value = (<any>ev.target).checked;
        if (value) {
            this.selectedItems.push(item);
        }
        else {
            this.selectedItems.splice(this.selectedItems.findIndex((i) => i === item), 1);
        }
    }
}
BsMultiselectComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsMultiselectComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
BsMultiselectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.4", type: BsMultiselectComponent, selector: "bs-multiselect", inputs: { items: "items", selectedItems: "selectedItems" }, viewQueries: [{ propertyName: "defaultButtonTemplate", first: true, predicate: ["defaultButtonTemplate"], descendants: true }], ngImport: i0, template: "<bs-has-overlay></bs-has-overlay>\n<div bsDropdown [hasBackdrop]=\"true\" [closeOnClickOutside]=\"true\">\n    <button bsDropdownToggle [color]=\"colors.primary\">\n        <ng-container *ngTemplateOutlet=\"buttonTemplate ?? defaultButtonTemplate; context: { $implicit: selectedItems.length }\"></ng-container>\n    </button>\n    <div *bsDropdownMenu class=\"bg-white mw-250px p-3 border rounded shadow\">\n        <ng-container *ngTemplateOutlet=\"headerTemplate\"></ng-container>\n        <hr class=\"my-2\" *ngIf=\"headerTemplate\">\n        <bs-toggle-button *ngFor=\"let item of items\" [ngModel]=\"selectedItems.indexOf(item) > -1\" (ngModelChange)=\"itemChange(item, $event)\" class=\"d-block\">{{ item }}</bs-toggle-button>\n        <hr class=\"my-2\" *ngIf=\"footerTemplate\">\n        <ng-container *ngTemplateOutlet=\"footerTemplate\"></ng-container>\n    </div>\n</div>\n<ng-template #defaultButtonTemplate let-count>\n    {{ count }} selected\n</ng-template>", styles: [".mw-250px{min-width:250px}\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: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i3.BsDropdownDirective, selector: "[bsDropdown]", inputs: ["hasBackdrop", "sameWidth", "closeOnClickOutside", "sameDropdownWidth", "isOpen"], outputs: ["isOpenChange"] }, { kind: "directive", type: i3.BsDropdownToggleDirective, selector: "[bsDropdownToggle]" }, { kind: "directive", type: i3.BsDropdownMenuDirective, selector: "[bsDropdownMenu]" }, { kind: "component", type: i4.BsHasOverlayComponent, selector: "bs-has-overlay" }, { kind: "component", type: i5.BsToggleButtonComponent, selector: "bs-toggle-button", inputs: ["type", "isToggled", "disabled", "name", "value", "group"], outputs: ["isToggledChange"] }, { kind: "directive", type: i5.BsToggleButtonValueAccessor, selector: "bs-toggle-button" }, { kind: "directive", type: i6.BsButtonTypeDirective, selector: "button[color],input[type=\"button\"][color],input[type=\"submit\"][color]", inputs: ["color"] }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsMultiselectComponent, decorators: [{
            type: Component,
            args: [{ selector: 'bs-multiselect', template: "<bs-has-overlay></bs-has-overlay>\n<div bsDropdown [hasBackdrop]=\"true\" [closeOnClickOutside]=\"true\">\n    <button bsDropdownToggle [color]=\"colors.primary\">\n        <ng-container *ngTemplateOutlet=\"buttonTemplate ?? defaultButtonTemplate; context: { $implicit: selectedItems.length }\"></ng-container>\n    </button>\n    <div *bsDropdownMenu class=\"bg-white mw-250px p-3 border rounded shadow\">\n        <ng-container *ngTemplateOutlet=\"headerTemplate\"></ng-container>\n        <hr class=\"my-2\" *ngIf=\"headerTemplate\">\n        <bs-toggle-button *ngFor=\"let item of items\" [ngModel]=\"selectedItems.indexOf(item) > -1\" (ngModelChange)=\"itemChange(item, $event)\" class=\"d-block\">{{ item }}</bs-toggle-button>\n        <hr class=\"my-2\" *ngIf=\"footerTemplate\">\n        <ng-container *ngTemplateOutlet=\"footerTemplate\"></ng-container>\n    </div>\n</div>\n<ng-template #defaultButtonTemplate let-count>\n    {{ count }} selected\n</ng-template>", styles: [".mw-250px{min-width:250px}\n"] }]
        }], propDecorators: { items: [{
                type: Input
            }], selectedItems: [{
                type: Input
            }], defaultButtonTemplate: [{
                type: ViewChild,
                args: ['defaultButtonTemplate']
            }] } });

class BsHeaderTemplateDirective {
    constructor(template, multiselect) {
        multiselect.headerTemplate = template;
    }
}
BsHeaderTemplateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsHeaderTemplateDirective, deps: [{ token: i0.TemplateRef }, { token: BsMultiselectComponent }], target: i0.ɵɵFactoryTarget.Directive });
BsHeaderTemplateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.0.4", type: BsHeaderTemplateDirective, selector: "[bsHeaderTemplate]", ngImport: i0 });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsHeaderTemplateDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: '[bsHeaderTemplate]'
                }]
        }], ctorParameters: function () { return [{ type: i0.TemplateRef }, { type: BsMultiselectComponent }]; } });

class BsFooterTemplateDirective {
    constructor(template, multiselect) {
        multiselect.footerTemplate = template;
    }
}
BsFooterTemplateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsFooterTemplateDirective, deps: [{ token: i0.TemplateRef }, { token: BsMultiselectComponent }], target: i0.ɵɵFactoryTarget.Directive });
BsFooterTemplateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.0.4", type: BsFooterTemplateDirective, selector: "[bsFooterTemplate]", ngImport: i0 });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsFooterTemplateDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: '[bsFooterTemplate]'
                }]
        }], ctorParameters: function () { return [{ type: i0.TemplateRef }, { type: BsMultiselectComponent }]; } });

class BsButtonTemplateDirective {
    constructor(template, multiselect) {
        multiselect.buttonTemplate = template;
    }
}
BsButtonTemplateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsButtonTemplateDirective, deps: [{ token: i0.TemplateRef }, { token: BsMultiselectComponent }], target: i0.ɵɵFactoryTarget.Directive });
BsButtonTemplateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.0.4", type: BsButtonTemplateDirective, selector: "[bsButtonTemplate]", ngImport: i0 });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsButtonTemplateDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: '[bsButtonTemplate]'
                }]
        }], ctorParameters: function () { return [{ type: i0.TemplateRef }, { type: BsMultiselectComponent }]; } });

class BsMultiselectModule {
}
BsMultiselectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsMultiselectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
BsMultiselectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.0.4", ngImport: i0, type: BsMultiselectModule, declarations: [BsMultiselectComponent,
        BsHeaderTemplateDirective,
        BsFooterTemplateDirective,
        BsButtonTemplateDirective], imports: [CommonModule,
        FormsModule,
        BsDropdownModule,
        BsToggleButtonModule,
        BsButtonTypeModule,
        BsHasOverlayModule,
        FocusOnLoadModule], exports: [BsMultiselectComponent,
        BsHeaderTemplateDirective,
        BsFooterTemplateDirective,
        BsButtonTemplateDirective] });
BsMultiselectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsMultiselectModule, imports: [CommonModule,
        FormsModule,
        BsDropdownModule,
        BsToggleButtonModule,
        BsButtonTypeModule,
        BsHasOverlayModule,
        FocusOnLoadModule] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsMultiselectModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [
                        BsMultiselectComponent,
                        BsHeaderTemplateDirective,
                        BsFooterTemplateDirective,
                        BsButtonTemplateDirective
                    ],
                    imports: [
                        CommonModule,
                        FormsModule,
                        BsDropdownModule,
                        BsToggleButtonModule,
                        BsButtonTypeModule,
                        BsHasOverlayModule,
                        FocusOnLoadModule,
                    ],
                    exports: [
                        BsMultiselectComponent,
                        BsHeaderTemplateDirective,
                        BsFooterTemplateDirective,
                        BsButtonTemplateDirective
                    ]
                }]
        }] });

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

export { BsButtonTemplateDirective, BsFooterTemplateDirective, BsHeaderTemplateDirective, BsMultiselectComponent, BsMultiselectModule };
//# sourceMappingURL=mintplayer-ng-bootstrap-multiselect.mjs.map
