import { unsafeCSS, LitElement, nothing, html } from "lit";
import { customElement } from "../../decorator.js";
import { property } from "lit/decorators.js";
import { classMap } from "lit/directives/class-map.js";
import compentStyle from "./pivot-item.css.js";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __decorateClass = (decorators, target, key, kind) => {
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
    if (decorator = decorators[i])
      result = (kind ? decorator(target, key, result) : decorator(result)) || result;
  if (kind && result) __defProp(target, key, result);
  return result;
};
var ObcPivotItemDirection = /* @__PURE__ */ ((ObcPivotItemDirection2) => {
  ObcPivotItemDirection2["horizontal"] = "horizontal";
  ObcPivotItemDirection2["vertical"] = "vertical";
  return ObcPivotItemDirection2;
})(ObcPivotItemDirection || {});
let ObcPivotItem = class extends LitElement {
  constructor() {
    super(...arguments);
    this.value = "";
    this.selected = false;
    this.direction = "horizontal";
    this.hasLeadingIcon = false;
    this.hasLabel = false;
    this.label = "";
    this.disabled = false;
  }
  /**
   * Handles click events. Emits `selected` when the item is not disabled or already selected.
   *
   * @fires selected {CustomEvent<{value: string}>} When the item is clicked and becomes selected
   */
  onClick() {
    if (this.disabled || this.selected) {
      return;
    }
    this.dispatchEvent(
      new CustomEvent("selected", {
        detail: { value: this.value },
        bubbles: true,
        composed: true
      })
    );
  }
  render() {
    const isVertical = this.direction === "vertical";
    const shouldShowLabel = this.hasLabel && this.label.trim().length > 0;
    const classes = classMap({
      wrapper: true,
      selected: this.selected,
      "direction-vertical": isVertical,
      "direction-horizontal": !isVertical,
      "has-leading-icon": this.hasLeadingIcon,
      "has-label": this.hasLabel,
      disabled: this.disabled
    });
    return html`
      <button
        class=${classes}
        @click=${this.onClick}
        ?disabled=${this.disabled}
        aria-pressed=${this.selected}
      >
        <div class="visible-wrapper">
          <div class="placeholder">
            <div class="icon-label-container">
              ${this.hasLeadingIcon ? html`<div class="icon">
                    <slot name="icon"></slot>
                  </div>` : nothing}
              ${shouldShowLabel ? html`<div class="label">${this.label}</div>` : nothing}
            </div>
          </div>
        </div>

        <div class="selected-container">
          <div class="active-tab-stroke"></div>
        </div>
      </button>
    `;
  }
};
ObcPivotItem.styles = unsafeCSS(compentStyle);
__decorateClass([
  property({ type: String })
], ObcPivotItem.prototype, "value", 2);
__decorateClass([
  property({ type: Boolean, reflect: true })
], ObcPivotItem.prototype, "selected", 2);
__decorateClass([
  property({ type: String })
], ObcPivotItem.prototype, "direction", 2);
__decorateClass([
  property({ type: Boolean })
], ObcPivotItem.prototype, "hasLeadingIcon", 2);
__decorateClass([
  property({ type: Boolean })
], ObcPivotItem.prototype, "hasLabel", 2);
__decorateClass([
  property({ type: String })
], ObcPivotItem.prototype, "label", 2);
__decorateClass([
  property({ type: Boolean })
], ObcPivotItem.prototype, "disabled", 2);
ObcPivotItem = __decorateClass([
  customElement("obc-pivot-item")
], ObcPivotItem);
export {
  ObcPivotItem,
  ObcPivotItemDirection
};
//# sourceMappingURL=pivot-item.js.map
