"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var React = require("react");
var Utilities_1 = require("../../Utilities");
var KeytipData_1 = require("../../KeytipData");
var getClassNames = Utilities_1.classNamesFunction();
var LinkBase = /** @class */ (function (_super) {
    tslib_1.__extends(LinkBase, _super);
    function LinkBase() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this._link = Utilities_1.createRef();
        _this._onClick = function (ev) {
            var _a = _this.props, onClick = _a.onClick, disabled = _a.disabled;
            if (disabled) {
                ev.preventDefault();
            }
            else if (onClick) {
                onClick(ev);
            }
        };
        return _this;
    }
    LinkBase.prototype.render = function () {
        var _this = this;
        var _a = this.props, disabled = _a.disabled, children = _a.children, className = _a.className, href = _a.href, theme = _a.theme, styles = _a.styles, keytipProps = _a.keytipProps;
        var classNames = getClassNames(styles, {
            className: className,
            isButton: !href,
            isDisabled: disabled,
            theme: theme
        });
        var anchorNativeProps = Utilities_1.getNativeProps(this.props, Utilities_1.anchorProperties);
        var buttonNativeProps = Utilities_1.getNativeProps(this.props, Utilities_1.buttonProperties);
        var anchorElement = (React.createElement(KeytipData_1.KeytipData, { keytipProps: keytipProps, ariaDescribedBy: anchorNativeProps['aria-describedby'], disabled: disabled }, function (keytipAttributes) { return (React.createElement("a", tslib_1.__assign({}, anchorNativeProps, keytipAttributes, { className: classNames.root, onClick: _this._onClick, ref: _this._link, target: _this.props.target, "aria-disabled": disabled }), children)); }));
        var buttonElement = (React.createElement(KeytipData_1.KeytipData, { keytipProps: keytipProps, ariaDescribedBy: buttonNativeProps['aria-describedby'], disabled: disabled }, function (keytipAttributes) { return (React.createElement("button", tslib_1.__assign({}, buttonNativeProps, keytipAttributes, { className: classNames.root, onClick: _this._onClick, ref: _this._link, "aria-disabled": disabled }), children)); }));
        return href ? anchorElement : buttonElement;
    };
    LinkBase.prototype.focus = function () {
        if (this._link.current) {
            this._link.current.focus();
        }
    };
    LinkBase = tslib_1.__decorate([
        Utilities_1.customizable('Link', ['theme', 'getStyles'])
    ], LinkBase);
    return LinkBase;
}(Utilities_1.BaseComponent));
exports.LinkBase = LinkBase;
//# sourceMappingURL=Link.base.js.map