// © 2022 SolarWinds Worldwide, LLC. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to
//  deal in the Software without restriction, including without limitation the
//  rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
//  sell copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//  THE SOFTWARE.
import { ChangeDetectorRef, Component, ElementRef, forwardRef, HostBinding, HostListener, Input, Optional, ViewChild, ViewEncapsulation, } from "@angular/core";
import { MenuGroupComponent } from "../menu-group/menu-group.component";
import { MenuItemBaseComponent } from "../menu-item/menu-item-base";
import * as i0 from "@angular/core";
import * as i1 from "../menu-group/menu-group.component";
import * as i2 from "../../../switch/switch.component";
/**
 * @ignore
 */
/**
 * Menu item component with check/uncheck option,
 * use (change) event to get state of this item
 */
export class MenuSwitchComponent extends MenuItemBaseComponent {
    constructor(group, cd) {
        super(group, cd);
        this.group = group;
        this.checked = false;
        // Is needed to predefine item state, sets nui-switch [disabled] property
        this.disabled = false;
    }
    stopPropagationOfClick(event) {
        event.stopPropagation();
        if (!this.disabled) {
            event.preventDefault();
            this.checked = !this.checked;
            this.actionDone.emit(this.checked);
        }
    }
    get checkedClass() {
        return this.checked;
    }
    doAction() {
        this.checked = !this.checked;
        this.actionDone.emit(this.checked);
    }
}
MenuSwitchComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: MenuSwitchComponent, deps: [{ token: i1.MenuGroupComponent, optional: true }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
MenuSwitchComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: MenuSwitchComponent, selector: "nui-menu-switch", inputs: { checked: "checked", disabled: "disabled" }, host: { attributes: { "role": "menuitemcheckbox" }, listeners: { "click": "stopPropagationOfClick($event)" }, properties: { "class.checked": "this.checkedClass" } }, providers: [
        {
            provide: MenuItemBaseComponent,
            useExisting: forwardRef(() => MenuSwitchComponent),
        },
    ], viewQueries: [{ propertyName: "menuItem", first: true, predicate: ["menuSwitch"], descendants: true }], usesInheritance: true, ngImport: i0, template: `
        <div
            class="nui-menu-item__switch"
            tabindex="0"
            #menuSwitch
            tabIndex="-1"
        >
            <nui-switch [value]="checked" [disabled]="disabled">
                <ng-content></ng-content>
            </nui-switch>
        </div>
    `, isInline: true, styles: [".nui-menu .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__switch:hover,.nui-menu-popup-host .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__switch:hover,.nui-menu-popup .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__switch:hover{cursor:not-allowed}.nui-menu .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__switch:focus,.nui-menu-popup-host .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__switch:focus,.nui-menu-popup .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__switch:focus{outline:none;box-shadow:none;background-color:var(--transparent,transparent)}.nui-menu .nui-menu-item>.nui-menu-item__switch .nui-switch,.nui-menu-popup-host .nui-menu-item>.nui-menu-item__switch .nui-switch,.nui-menu-popup .nui-menu-item>.nui-menu-item__switch .nui-switch{padding:0}.nui-menu .nui-menu-item>.nui-menu-item__switch .nui-switch:hover,.nui-menu-popup-host .nui-menu-item>.nui-menu-item__switch .nui-switch:hover,.nui-menu-popup .nui-menu-item>.nui-menu-item__switch .nui-switch:hover{cursor:pointer}.nui-menu .nui-menu-item>.nui-menu-item__switch .nui-switch__label:hover,.nui-menu-popup-host .nui-menu-item>.nui-menu-item__switch .nui-switch__label:hover,.nui-menu-popup .nui-menu-item>.nui-menu-item__switch .nui-switch__label:hover{cursor:pointer}\n"], components: [{ type: i2.SwitchComponent, selector: "nui-switch", inputs: ["value", "disabled", "ariaLabel"], outputs: ["valueChange"] }], encapsulation: i0.ViewEncapsulation.None });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: MenuSwitchComponent, decorators: [{
            type: Component,
            args: [{ selector: "nui-menu-switch", template: `
        <div
            class="nui-menu-item__switch"
            tabindex="0"
            #menuSwitch
            tabIndex="-1"
        >
            <nui-switch [value]="checked" [disabled]="disabled">
                <ng-content></ng-content>
            </nui-switch>
        </div>
    `, providers: [
                        {
                            provide: MenuItemBaseComponent,
                            useExisting: forwardRef(() => MenuSwitchComponent),
                        },
                    ], encapsulation: ViewEncapsulation.None, host: { role: "menuitemcheckbox" }, styles: [".nui-menu .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__switch:hover,.nui-menu-popup-host .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__switch:hover,.nui-menu-popup .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__switch:hover{cursor:not-allowed}.nui-menu .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__switch:focus,.nui-menu-popup-host .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__switch:focus,.nui-menu-popup .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__switch:focus{outline:none;box-shadow:none;background-color:var(--transparent,transparent)}.nui-menu .nui-menu-item>.nui-menu-item__switch .nui-switch,.nui-menu-popup-host .nui-menu-item>.nui-menu-item__switch .nui-switch,.nui-menu-popup .nui-menu-item>.nui-menu-item__switch .nui-switch{padding:0}.nui-menu .nui-menu-item>.nui-menu-item__switch .nui-switch:hover,.nui-menu-popup-host .nui-menu-item>.nui-menu-item__switch .nui-switch:hover,.nui-menu-popup .nui-menu-item>.nui-menu-item__switch .nui-switch:hover{cursor:pointer}.nui-menu .nui-menu-item>.nui-menu-item__switch .nui-switch__label:hover,.nui-menu-popup-host .nui-menu-item>.nui-menu-item__switch .nui-switch__label:hover,.nui-menu-popup .nui-menu-item>.nui-menu-item__switch .nui-switch__label:hover{cursor:pointer}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.MenuGroupComponent, decorators: [{
                    type: Optional
                }] }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { checked: [{
                type: Input
            }], disabled: [{
                type: Input
            }], menuItem: [{
                type: ViewChild,
                args: ["menuSwitch"]
            }], stopPropagationOfClick: [{
                type: HostListener,
                args: ["click", ["$event"]]
            }], checkedClass: [{
                type: HostBinding,
                args: ["class.checked"]
            }] } });
//# sourceMappingURL=data:application/json;base64, 