/**
 * @license
 * Copyright Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
import { __decorate } from "tslib";
import { coerceBoolean, CustomElement, FoundationProperty } from '@tylertech/forge-core';
import { KeyboardShortcutAdapter } from './keyboard-shortcut-adapter';
import { KeyboardShortcutFoundation } from './keyboard-shortcut-foundation';
import { KEYBOARD_SHORTCUT_CONSTANTS } from './keyboard-shortcut-constants';
import { BaseComponent } from '../core/base/base-component';
/**
 * The web component class behind the `<forge-keyboard-shortcut>` custom element.
 *
 * @tag forge-keyboard-shortcut
 */
let KeyboardShortcutComponent = class KeyboardShortcutComponent extends BaseComponent {
    static get observedAttributes() {
        return [
            KEYBOARD_SHORTCUT_CONSTANTS.attributes.KEY,
            KEYBOARD_SHORTCUT_CONSTANTS.attributes.TARGET,
            KEYBOARD_SHORTCUT_CONSTANTS.attributes.GLOBAL,
            KEYBOARD_SHORTCUT_CONSTANTS.attributes.ALLOW_WHILE_TYPING,
            KEYBOARD_SHORTCUT_CONSTANTS.attributes.PREVENT_DEFAULT,
            KEYBOARD_SHORTCUT_CONSTANTS.attributes.CAPTURE,
            KEYBOARD_SHORTCUT_CONSTANTS.attributes.USE_CODE,
            KEYBOARD_SHORTCUT_CONSTANTS.attributes.DISABLED
        ];
    }
    constructor() {
        super();
        this._foundation = new KeyboardShortcutFoundation(new KeyboardShortcutAdapter(this));
    }
    connectedCallback() {
        this._foundation.initialize();
    }
    disconnectedCallback() {
        this._foundation.disconnect();
    }
    attributeChangedCallback(name, oldValue, newValue) {
        switch (name) {
            case KEYBOARD_SHORTCUT_CONSTANTS.attributes.KEY:
                this.key = newValue;
                break;
            case KEYBOARD_SHORTCUT_CONSTANTS.attributes.TARGET:
                this.target = newValue;
                break;
            case KEYBOARD_SHORTCUT_CONSTANTS.attributes.GLOBAL:
                this.global = coerceBoolean(newValue);
                break;
            case KEYBOARD_SHORTCUT_CONSTANTS.attributes.ALLOW_WHILE_TYPING:
                this.allowWhileTyping = coerceBoolean(newValue);
                break;
            case KEYBOARD_SHORTCUT_CONSTANTS.attributes.PREVENT_DEFAULT:
                this.preventDefault = coerceBoolean(newValue);
                break;
            case KEYBOARD_SHORTCUT_CONSTANTS.attributes.CAPTURE:
                this.capture = coerceBoolean(newValue);
                break;
            case KEYBOARD_SHORTCUT_CONSTANTS.attributes.USE_CODE:
                this.useCode = coerceBoolean(newValue);
                break;
            case KEYBOARD_SHORTCUT_CONSTANTS.attributes.DISABLED:
                this.disabled = coerceBoolean(newValue);
                break;
        }
    }
    /** Alias for key. */
    get keyBinding() {
        return this.key;
    }
    set keyBinding(value) {
        this.key = value;
    }
};
__decorate([
    FoundationProperty()
], KeyboardShortcutComponent.prototype, "key", void 0);
__decorate([
    FoundationProperty()
], KeyboardShortcutComponent.prototype, "target", void 0);
__decorate([
    FoundationProperty()
], KeyboardShortcutComponent.prototype, "global", void 0);
__decorate([
    FoundationProperty()
], KeyboardShortcutComponent.prototype, "allowWhileTyping", void 0);
__decorate([
    FoundationProperty()
], KeyboardShortcutComponent.prototype, "preventDefault", void 0);
__decorate([
    FoundationProperty()
], KeyboardShortcutComponent.prototype, "capture", void 0);
__decorate([
    FoundationProperty()
], KeyboardShortcutComponent.prototype, "useCode", void 0);
__decorate([
    FoundationProperty()
], KeyboardShortcutComponent.prototype, "disabled", void 0);
__decorate([
    FoundationProperty()
], KeyboardShortcutComponent.prototype, "activateCallback", void 0);
KeyboardShortcutComponent = __decorate([
    CustomElement({
        name: KEYBOARD_SHORTCUT_CONSTANTS.elementName
    })
], KeyboardShortcutComponent);
export { KeyboardShortcutComponent };
