import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';

const BsTab$1 = /*@__PURE__*/ proxyCustomElement(class BsTab extends HTMLElement {
  constructor() {
    super();
    this.__registerHost();
    this.activeTabId = undefined;
    this.hidden = false;
    this.panelId = undefined;
  }
  get isActive() {
    return this.activeTabId && this.activeTabId === this.hostEl.id;
  }
  get panelIdComputed() {
    return this.panelId || `${this.hostEl.id}-panel`;
  }
  validSiblingOrNull(el) {
    var _a, _b;
    return (((_a = el === null || el === void 0 ? void 0 : el.dataset) === null || _a === void 0 ? void 0 : _a.hidden) === '' || ((_b = el === null || el === void 0 ? void 0 : el.dataset) === null || _b === void 0 ? void 0 : _b.hidden) === 'true') ? null : el;
  }
  // avoid unnecessary re-renders
  componentShouldUpdate(newValue, oldValue, propName) {
    if (newValue === oldValue)
      return false;
    if (propName === 'activeTabId') {
      return newValue === this.hostEl.id || oldValue === this.hostEl.id;
    }
  }
  handleKeydown(e) {
    if (e.key === 'Enter' || e.key === ' ') {
      e.preventDefault();
      e.stopPropagation();
      this.hostEl.click();
    }
  }
  render() {
    return (h(Host, { "aria-controls": this.panelIdComputed, "aria-selected": this.isActive ? "true" : "false", "data-hidden": this.hidden || undefined, role: "tab", tabindex: "0" }, h("slot", null)));
  }
  get hostEl() { return this; }
}, [4, "bs-tab", {
    "activeTabId": [1, "active-tab-id"],
    "hidden": [4],
    "panelId": [1, "panel-id"]
  }, [[0, "keydown", "handleKeydown"]]]);
function defineCustomElement$1() {
  if (typeof customElements === "undefined") {
    return;
  }
  const components = ["bs-tab"];
  components.forEach(tagName => { switch (tagName) {
    case "bs-tab":
      if (!customElements.get(tagName)) {
        customElements.define(tagName, BsTab$1);
      }
      break;
  } });
}

const BsTab = BsTab$1;
const defineCustomElement = defineCustomElement$1;

export { BsTab, defineCustomElement };

//# sourceMappingURL=bs-tab.js.map