import { LoaderComponent } from '@agorapulse/ui-animations';
import * as i1 from '@agorapulse/ui-symbol';
import { apFeatureLock, SymbolComponent } from '@agorapulse/ui-symbol';
import { UI_COMPONENTS_SYMBOLS } from '@agorapulse/ui-components/providers';
import * as i0 from '@angular/core';
import { input, EventEmitter, inject, booleanAttribute, HostListener, ViewChild, ContentChild, Output, Input, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
import * as i2 from '@angular/material/menu';
import { MatMenuModule } from '@angular/material/menu';

class IconButtonComponent {
    symbolRegistry;
    elementRef;
    ariaLabel = '';
    name = '';
    color = 'none';
    disabled = false;
    menuTrigger = null;
    symbolId = input(...(ngDevMode ? [undefined, { debugName: "symbolId" }] : /* istanbul ignore next */ []));
    set locked(locked) {
        this._locked = locked;
        if (locked) {
            this.color = 'none';
            this.disabled = false;
            this.loading = false;
        }
    }
    get locked() {
        return this._locked;
    }
    set loading(loading) {
        if (!this.locked) {
            this._loading = loading;
        }
    }
    get loading() {
        return this._loading;
    }
    type = 'flat';
    // eslint-disable-next-line
    onClick = new EventEmitter();
    // eslint-disable-next-line
    onFocus = new EventEmitter();
    // eslint-disable-next-line
    onBlur = new EventEmitter();
    menuOpened = new EventEmitter();
    menuClosed = new EventEmitter();
    symbolComponent;
    buttonElement;
    _loading = false;
    _locked = false;
    hostDataTest = undefined;
    focused = false;
    constructor(symbolRegistry, elementRef) {
        this.symbolRegistry = symbolRegistry;
        this.elementRef = elementRef;
        this.symbolRegistry.registerSymbols([apFeatureLock]);
        this.hostDataTest = this.elementRef.nativeElement.getAttribute('data-test');
        this.symbolRegistry.withSymbols(...(inject(UI_COMPONENTS_SYMBOLS, { optional: true })?.flat() ?? []));
    }
    onClickHandle($event) {
        this.buttonElement.nativeElement.blur();
        this.onClick.emit($event);
        this.onFocus.emit($event);
    }
    onBlurHandle($event) {
        this.focused = false;
        this.onBlur.emit($event);
    }
    onFocusHandle($event) {
        this.focused = true;
        this.onFocus.emit($event);
    }
    onSpaceKeyUp(event) {
        if (this.focused) {
            event.preventDefault();
            this.buttonElement.nativeElement.click();
        }
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: IconButtonComponent, deps: [{ token: i1.SymbolRegistry }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.16", type: IconButtonComponent, isStandalone: true, selector: "ap-icon-button", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: false, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: false, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: false, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, menuTrigger: { classPropertyName: "menuTrigger", publicName: "menuTrigger", isSignal: false, isRequired: false, transformFunction: null }, symbolId: { classPropertyName: "symbolId", publicName: "symbolId", isSignal: true, isRequired: false, transformFunction: null }, locked: { classPropertyName: "locked", publicName: "locked", isSignal: false, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: false, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: false, isRequired: false, transformFunction: null } }, outputs: { onClick: "onClick", onFocus: "onFocus", onBlur: "onBlur", menuOpened: "menuOpened", menuClosed: "menuClosed" }, host: { listeners: { "window:keyup.space": "onSpaceKeyUp($event)" }, properties: { "attr.disabled": "loading || disabled || null" } }, queries: [{ propertyName: "symbolComponent", first: true, predicate: SymbolComponent, descendants: true }], viewQueries: [{ propertyName: "buttonElement", first: true, predicate: ["button"], descendants: true }], ngImport: i0, template: "<button\n    #button\n    #trigger=\"matMenuTrigger\"\n    class=\"icon-button\"\n    type=\"button\"\n    [name]=\"name\"\n    [matMenuTriggerFor]=\"menuTrigger\"\n    [attr.aria-label]=\"ariaLabel || null\"\n    [attr.data-test]=\"hostDataTest ?? name\"\n    [disabled]=\"disabled\"\n    [class.blue]=\"color === 'blue'\"\n    [class.green]=\"color === 'green'\"\n    [class.red]=\"color === 'red'\"\n    [class.flat]=\"type === 'flat'\"\n    [class.stroked]=\"type === 'stroked' || type === 'stroked-transparent'\"\n    [class.transparent]=\"type === 'stroked-transparent'\"\n    [class.loading]=\"loading\"\n    [class.locked]=\"locked\"\n    (click)=\"onClickHandle($event)\"\n    (blur)=\"onBlurHandle($event)\"\n    (focus)=\"onFocusHandle($event)\"\n    (menuOpened)=\"menuOpened.emit()\"\n    (menuClosed)=\"menuClosed.emit()\">\n    @if (!loading) {\n        @if (symbolId()) {\n            <ap-symbol [symbolId]=\"symbolId()\" />\n        } @else {\n            <ng-content />\n        }\n    }\n    @if (loading) {\n        <ap-loader\n            color=\"white\"\n            [diameter]=\"16\" />\n    }\n    @if (locked) {\n        <div class=\"locked-symbol\">\n            <ap-symbol\n                symbolId=\"feature-lock\"\n                size=\"sm\" />\n        </div>\n    }\n</button>\n", styles: ["ap-icon-button{display:flex;width:var(--comp-icon-button-width);max-width:var(--comp-icon-button-width);height:var(--comp-icon-button-height);max-height:var(--comp-icon-button-height)}ap-icon-button[disabled]{pointer-events:none}ap-icon-button button.icon-button{margin:0;display:flex;justify-content:center;align-items:center;width:var(--comp-icon-button-width);max-width:var(--comp-icon-button-width);height:var(--comp-icon-button-height);max-height:var(--comp-icon-button-height);border-radius:var(--comp-icon-button-border-radius);background:transparent;border:none;position:relative;transition:border .25s;padding:var(--comp-icon-button-padding)}@media(hover:hover){ap-icon-button button.icon-button:focus:not(.disabled):not(:active){outline:2px solid var(--ref-color-electric-blue-100);outline-offset:1px}}ap-icon-button button.icon-button:hover{cursor:pointer}ap-icon-button button.icon-button:hover:not(.stroked):not(.locked){background:var(--ref-color-grey-05)}ap-icon-button button.icon-button:active:not(.stroked):not(.locked){background:var(--ref-color-grey-10)}ap-icon-button button.icon-button ap-symbol{display:inline-flex;justify-content:center;align-items:center;width:100%;height:100%;padding:0;margin:0;color:var(--ref-color-grey-60);min-width:calc(var(--comp-icon-button-height) - var(--comp-icon-button-padding) * 2);min-height:calc(var(--comp-icon-button-height) - var(--comp-icon-button-padding) * 2)}ap-icon-button button.icon-button ap-symbol .svg{display:inline-flex!important;justify-content:center;align-items:center}ap-icon-button button.icon-button ap-symbol .svg svg{height:100%;width:100%}ap-icon-button button.icon-button:disabled{cursor:default;pointer-events:none}ap-icon-button button.icon-button:disabled ap-symbol{color:var(--ref-color-grey-20)}ap-icon-button button.icon-button.blue:hover:not(.stroked):not(:disabled){background:var(--ref-color-electric-blue-05)}ap-icon-button button.icon-button.blue:active:not(.stroked):not(:disabled){background:var(--ref-color-electric-blue-10)}ap-icon-button button.icon-button.blue:disabled{border-color:var(--ref-color-electric-blue-20)}ap-icon-button button.icon-button.blue:disabled ap-symbol{color:var(--ref-color-electric-blue-20)}ap-icon-button button.icon-button.blue ap-symbol{color:var(--ref-color-electric-blue-100)}ap-icon-button button.icon-button.green:hover:not(.stroked):not(:disabled){background:var(--ref-color-green-10)}ap-icon-button button.icon-button.green:active:not(.stroked):not(:disabled){background:var(--ref-color-green-20)}ap-icon-button button.icon-button.green:disabled{border-color:var(--ref-color-green-20)}ap-icon-button button.icon-button.green:disabled ap-symbol{color:var(--ref-color-green-20)}ap-icon-button button.icon-button.green ap-symbol{color:var(--ref-color-green-100)}ap-icon-button button.icon-button.red:hover:not(.stroked):not(:disabled){background:var(--ref-color-red-10)}ap-icon-button button.icon-button.red:active:not(.stroked):not(:disabled){background:var(--ref-color-red-20)}ap-icon-button button.icon-button.red:disabled{border-color:var(--ref-color-red-20)}ap-icon-button button.icon-button.red:disabled ap-symbol{color:var(--ref-color-red-20)}ap-icon-button button.icon-button.red ap-symbol{color:var(--ref-color-red-100)}ap-icon-button button.icon-button.stroked{border-width:1px;border-style:solid;background:#fff}ap-icon-button button.icon-button.stroked:not(.loading):not(.locked){border-color:var(--ref-color-grey-20)}ap-icon-button button.icon-button.stroked:hover:not(.locked){border-color:var(--ref-color-grey-40)}ap-icon-button button.icon-button.stroked:active:not(.locked){border-color:var(--ref-color-grey-60)}ap-icon-button button.icon-button.stroked.blue:not(.loading):not(.locked):not(:disabled){border-color:var(--ref-color-electric-blue-100)}ap-icon-button button.icon-button.stroked.blue:not(.loading):not(.locked):not(:disabled):hover:not(.locked):not(:disabled){border-color:var(--ref-color-electric-blue-60)}ap-icon-button button.icon-button.stroked.blue:not(.loading):not(.locked):not(:disabled):active:not(.locked):not(:disabled){border-color:var(--ref-color-electric-blue-100)}ap-icon-button button.icon-button.stroked.blue:disabled{border-color:var(--ref-color-electric-blue-20)}ap-icon-button button.icon-button.stroked.green:not(.loading):not(.locked):not(:disabled){border-color:var(--ref-color-green-100)}ap-icon-button button.icon-button.stroked.green:not(.loading):not(.locked):not(:disabled):hover:not(.locked):not(:disabled){border-color:var(--ref-color-green-60)}ap-icon-button button.icon-button.stroked.green:not(.loading):not(.locked):not(:disabled):active:not(.locked):not(:disabled){border-color:var(--ref-color-green-100)}ap-icon-button button.icon-button.stroked.green:disabled{border-color:var(--ref-color-green-20)}ap-icon-button button.icon-button.stroked.red:not(.loading):not(.locked):not(:disabled){border-color:var(--ref-color-red-100)}ap-icon-button button.icon-button.stroked.red:not(.loading):not(.locked):not(:disabled):hover:not(.locked):not(:disabled){border-color:var(--ref-color-red-60)}ap-icon-button button.icon-button.stroked.red:not(.loading):not(.locked):not(:disabled):active:not(.locked):not(:disabled){border-color:var(--ref-color-red-100)}ap-icon-button button.icon-button.stroked.red:disabled{border-color:var(--ref-color-red-20)}ap-icon-button button.icon-button.stroked.transparent:not(.loading):not(.locked){background:transparent}ap-icon-button button.icon-button.loading{background:var(--ref-color-grey-20);border:none;pointer-events:none}ap-icon-button button.icon-button.locked{background:var(--ref-color-purple-10);color:var(--ref-color-purple-80);border:1px solid var(--ref-color-purple-20)}ap-icon-button button.icon-button.locked:hover{border-color:var(--ref-color-purple-40)}ap-icon-button button.icon-button.locked:active{border-color:var(--ref-color-purple-60)}ap-icon-button button.icon-button.locked ap-symbol{color:var(--ref-color-purple-100)}ap-icon-button button.icon-button.locked .locked-symbol{position:absolute;top:-6px;right:-6px}ap-icon-button button.icon-button.locked .locked-symbol ap-symbol{border-radius:100%;background:var(--ref-color-white)}\n"], dependencies: [{ kind: "component", type: SymbolComponent, selector: "ap-symbol", inputs: ["symbolId", "color", "size"], outputs: ["sizeChange"] }, { kind: "component", type: LoaderComponent, selector: "ap-loader", inputs: ["color", "diameter"] }, { kind: "ngmodule", type: MatMenuModule }, { kind: "directive", type: i2.MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", inputs: ["mat-menu-trigger-for", "matMenuTriggerFor", "matMenuTriggerData", "matMenuTriggerRestoreFocus"], outputs: ["menuOpened", "onMenuOpen", "menuClosed", "onMenuClose"], exportAs: ["matMenuTrigger"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: IconButtonComponent, decorators: [{
            type: Component,
            args: [{ changeDetection: ChangeDetectionStrategy.OnPush, selector: 'ap-icon-button', imports: [SymbolComponent, LoaderComponent, MatMenuModule], encapsulation: ViewEncapsulation.None, host: {
                        '[attr.disabled]': 'loading || disabled || null',
                    }, template: "<button\n    #button\n    #trigger=\"matMenuTrigger\"\n    class=\"icon-button\"\n    type=\"button\"\n    [name]=\"name\"\n    [matMenuTriggerFor]=\"menuTrigger\"\n    [attr.aria-label]=\"ariaLabel || null\"\n    [attr.data-test]=\"hostDataTest ?? name\"\n    [disabled]=\"disabled\"\n    [class.blue]=\"color === 'blue'\"\n    [class.green]=\"color === 'green'\"\n    [class.red]=\"color === 'red'\"\n    [class.flat]=\"type === 'flat'\"\n    [class.stroked]=\"type === 'stroked' || type === 'stroked-transparent'\"\n    [class.transparent]=\"type === 'stroked-transparent'\"\n    [class.loading]=\"loading\"\n    [class.locked]=\"locked\"\n    (click)=\"onClickHandle($event)\"\n    (blur)=\"onBlurHandle($event)\"\n    (focus)=\"onFocusHandle($event)\"\n    (menuOpened)=\"menuOpened.emit()\"\n    (menuClosed)=\"menuClosed.emit()\">\n    @if (!loading) {\n        @if (symbolId()) {\n            <ap-symbol [symbolId]=\"symbolId()\" />\n        } @else {\n            <ng-content />\n        }\n    }\n    @if (loading) {\n        <ap-loader\n            color=\"white\"\n            [diameter]=\"16\" />\n    }\n    @if (locked) {\n        <div class=\"locked-symbol\">\n            <ap-symbol\n                symbolId=\"feature-lock\"\n                size=\"sm\" />\n        </div>\n    }\n</button>\n", styles: ["ap-icon-button{display:flex;width:var(--comp-icon-button-width);max-width:var(--comp-icon-button-width);height:var(--comp-icon-button-height);max-height:var(--comp-icon-button-height)}ap-icon-button[disabled]{pointer-events:none}ap-icon-button button.icon-button{margin:0;display:flex;justify-content:center;align-items:center;width:var(--comp-icon-button-width);max-width:var(--comp-icon-button-width);height:var(--comp-icon-button-height);max-height:var(--comp-icon-button-height);border-radius:var(--comp-icon-button-border-radius);background:transparent;border:none;position:relative;transition:border .25s;padding:var(--comp-icon-button-padding)}@media(hover:hover){ap-icon-button button.icon-button:focus:not(.disabled):not(:active){outline:2px solid var(--ref-color-electric-blue-100);outline-offset:1px}}ap-icon-button button.icon-button:hover{cursor:pointer}ap-icon-button button.icon-button:hover:not(.stroked):not(.locked){background:var(--ref-color-grey-05)}ap-icon-button button.icon-button:active:not(.stroked):not(.locked){background:var(--ref-color-grey-10)}ap-icon-button button.icon-button ap-symbol{display:inline-flex;justify-content:center;align-items:center;width:100%;height:100%;padding:0;margin:0;color:var(--ref-color-grey-60);min-width:calc(var(--comp-icon-button-height) - var(--comp-icon-button-padding) * 2);min-height:calc(var(--comp-icon-button-height) - var(--comp-icon-button-padding) * 2)}ap-icon-button button.icon-button ap-symbol .svg{display:inline-flex!important;justify-content:center;align-items:center}ap-icon-button button.icon-button ap-symbol .svg svg{height:100%;width:100%}ap-icon-button button.icon-button:disabled{cursor:default;pointer-events:none}ap-icon-button button.icon-button:disabled ap-symbol{color:var(--ref-color-grey-20)}ap-icon-button button.icon-button.blue:hover:not(.stroked):not(:disabled){background:var(--ref-color-electric-blue-05)}ap-icon-button button.icon-button.blue:active:not(.stroked):not(:disabled){background:var(--ref-color-electric-blue-10)}ap-icon-button button.icon-button.blue:disabled{border-color:var(--ref-color-electric-blue-20)}ap-icon-button button.icon-button.blue:disabled ap-symbol{color:var(--ref-color-electric-blue-20)}ap-icon-button button.icon-button.blue ap-symbol{color:var(--ref-color-electric-blue-100)}ap-icon-button button.icon-button.green:hover:not(.stroked):not(:disabled){background:var(--ref-color-green-10)}ap-icon-button button.icon-button.green:active:not(.stroked):not(:disabled){background:var(--ref-color-green-20)}ap-icon-button button.icon-button.green:disabled{border-color:var(--ref-color-green-20)}ap-icon-button button.icon-button.green:disabled ap-symbol{color:var(--ref-color-green-20)}ap-icon-button button.icon-button.green ap-symbol{color:var(--ref-color-green-100)}ap-icon-button button.icon-button.red:hover:not(.stroked):not(:disabled){background:var(--ref-color-red-10)}ap-icon-button button.icon-button.red:active:not(.stroked):not(:disabled){background:var(--ref-color-red-20)}ap-icon-button button.icon-button.red:disabled{border-color:var(--ref-color-red-20)}ap-icon-button button.icon-button.red:disabled ap-symbol{color:var(--ref-color-red-20)}ap-icon-button button.icon-button.red ap-symbol{color:var(--ref-color-red-100)}ap-icon-button button.icon-button.stroked{border-width:1px;border-style:solid;background:#fff}ap-icon-button button.icon-button.stroked:not(.loading):not(.locked){border-color:var(--ref-color-grey-20)}ap-icon-button button.icon-button.stroked:hover:not(.locked){border-color:var(--ref-color-grey-40)}ap-icon-button button.icon-button.stroked:active:not(.locked){border-color:var(--ref-color-grey-60)}ap-icon-button button.icon-button.stroked.blue:not(.loading):not(.locked):not(:disabled){border-color:var(--ref-color-electric-blue-100)}ap-icon-button button.icon-button.stroked.blue:not(.loading):not(.locked):not(:disabled):hover:not(.locked):not(:disabled){border-color:var(--ref-color-electric-blue-60)}ap-icon-button button.icon-button.stroked.blue:not(.loading):not(.locked):not(:disabled):active:not(.locked):not(:disabled){border-color:var(--ref-color-electric-blue-100)}ap-icon-button button.icon-button.stroked.blue:disabled{border-color:var(--ref-color-electric-blue-20)}ap-icon-button button.icon-button.stroked.green:not(.loading):not(.locked):not(:disabled){border-color:var(--ref-color-green-100)}ap-icon-button button.icon-button.stroked.green:not(.loading):not(.locked):not(:disabled):hover:not(.locked):not(:disabled){border-color:var(--ref-color-green-60)}ap-icon-button button.icon-button.stroked.green:not(.loading):not(.locked):not(:disabled):active:not(.locked):not(:disabled){border-color:var(--ref-color-green-100)}ap-icon-button button.icon-button.stroked.green:disabled{border-color:var(--ref-color-green-20)}ap-icon-button button.icon-button.stroked.red:not(.loading):not(.locked):not(:disabled){border-color:var(--ref-color-red-100)}ap-icon-button button.icon-button.stroked.red:not(.loading):not(.locked):not(:disabled):hover:not(.locked):not(:disabled){border-color:var(--ref-color-red-60)}ap-icon-button button.icon-button.stroked.red:not(.loading):not(.locked):not(:disabled):active:not(.locked):not(:disabled){border-color:var(--ref-color-red-100)}ap-icon-button button.icon-button.stroked.red:disabled{border-color:var(--ref-color-red-20)}ap-icon-button button.icon-button.stroked.transparent:not(.loading):not(.locked){background:transparent}ap-icon-button button.icon-button.loading{background:var(--ref-color-grey-20);border:none;pointer-events:none}ap-icon-button button.icon-button.locked{background:var(--ref-color-purple-10);color:var(--ref-color-purple-80);border:1px solid var(--ref-color-purple-20)}ap-icon-button button.icon-button.locked:hover{border-color:var(--ref-color-purple-40)}ap-icon-button button.icon-button.locked:active{border-color:var(--ref-color-purple-60)}ap-icon-button button.icon-button.locked ap-symbol{color:var(--ref-color-purple-100)}ap-icon-button button.icon-button.locked .locked-symbol{position:absolute;top:-6px;right:-6px}ap-icon-button button.icon-button.locked .locked-symbol ap-symbol{border-radius:100%;background:var(--ref-color-white)}\n"] }]
        }], ctorParameters: () => [{ type: i1.SymbolRegistry }, { type: i0.ElementRef }], propDecorators: { ariaLabel: [{
                type: Input
            }], name: [{
                type: Input
            }], color: [{
                type: Input
            }], disabled: [{
                type: Input,
                args: [{
                        transform: booleanAttribute,
                    }]
            }], menuTrigger: [{
                type: Input
            }], symbolId: [{ type: i0.Input, args: [{ isSignal: true, alias: "symbolId", required: false }] }], locked: [{
                type: Input
            }], loading: [{
                type: Input
            }], type: [{
                type: Input
            }], onClick: [{
                type: Output
            }], onFocus: [{
                type: Output
            }], onBlur: [{
                type: Output
            }], menuOpened: [{
                type: Output
            }], menuClosed: [{
                type: Output
            }], symbolComponent: [{
                type: ContentChild,
                args: [SymbolComponent]
            }], buttonElement: [{
                type: ViewChild,
                args: ['button']
            }], onSpaceKeyUp: [{
                type: HostListener,
                args: ['window:keyup.space', ['$event']]
            }] } });

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

export { IconButtonComponent };
//# sourceMappingURL=agorapulse-ui-components-icon-button.mjs.map
