'use strict';

/**
  Determines correct tag and attrs for components that can be rendered
  as <button> or <a> tags (e.g. bs-pill)
*/
function getButtonOrLink(component, defaultRootTag) {
  const rootTag = getTag(component);
  const buttonOrLinkAttrs = getAttrs(rootTag, component);
  function getProp(comp, key) {
    var _a, _b;
    return comp[key] || ((_a = comp.attrs) === null || _a === void 0 ? void 0 : _a[key]) || ((_b = comp.hostEl) === null || _b === void 0 ? void 0 : _b.getAttribute(key));
  }
  function getTag(comp) {
    const tagsByProp = { href: 'a', onclick: 'button', type: 'button' };
    const foundProp = Object.keys(tagsByProp).find(key => getProp(comp, key));
    return tagsByProp[foundProp] || defaultRootTag;
  }
  function getAttrs(tag, comp) {
    const isLink = tag === 'a';
    const isButton = tag === 'button';
    return Object.assign({ type: isButton
        ? getProp(comp, 'type') || 'button'
        : undefined, disabled: isButton
        ? comp.disabled
        : undefined }, (isLink && comp.disabled && { 'aria-disabled': 'true', tabindex: -1 }));
  }
  return { rootTag, buttonOrLinkAttrs };
}

exports.getButtonOrLink = getButtonOrLink;

//# sourceMappingURL=getButtonOrLink-b46cd381.js.map