/**
 * @license
 * Copyright 2023 Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
import { BaseComponentDelegate } from '../core/delegates/base-component-delegate';
import { BUTTON_CONSTANTS } from './button-constants';
export class ButtonComponentDelegate extends BaseComponentDelegate {
    constructor(config) {
        super(config);
    }
    destroy() {
        this._buttonElement = undefined;
    }
    get buttonElement() {
        return this._buttonElement;
    }
    _build() {
        var _a, _b;
        const component = document.createElement(BUTTON_CONSTANTS.elementName);
        this._buttonElement = document.createElement('button');
        this._buttonElement.type = ((_a = this._config.options) === null || _a === void 0 ? void 0 : _a.type) || 'button';
        this._buttonElement.textContent = ((_b = this._config.options) === null || _b === void 0 ? void 0 : _b.text) || '';
        component.appendChild(this._buttonElement);
        return component;
    }
    onClick(listener) {
        var _a;
        (_a = this._buttonElement) === null || _a === void 0 ? void 0 : _a.addEventListener('click', listener);
    }
    onFocus(listener) {
        var _a;
        (_a = this._buttonElement) === null || _a === void 0 ? void 0 : _a.addEventListener('focus', evt => listener(evt));
    }
    onBlur(listener) {
        var _a;
        (_a = this._buttonElement) === null || _a === void 0 ? void 0 : _a.addEventListener('blur', evt => listener(evt));
    }
}
