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 styles from "./toggle-button-vertical-option.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 ObcToggleButtonVerticalOptionType = /* @__PURE__ */ ((ObcToggleButtonVerticalOptionType2) => {
  ObcToggleButtonVerticalOptionType2["flat"] = "flat";
  ObcToggleButtonVerticalOptionType2["regular"] = "regular";
  ObcToggleButtonVerticalOptionType2["normal"] = "normal";
  return ObcToggleButtonVerticalOptionType2;
})(ObcToggleButtonVerticalOptionType || {});
var ObcToggleButtonLabelPlacement = /* @__PURE__ */ ((ObcToggleButtonLabelPlacement2) => {
  ObcToggleButtonLabelPlacement2["inline"] = "inline";
  ObcToggleButtonLabelPlacement2["under"] = "under";
  return ObcToggleButtonLabelPlacement2;
})(ObcToggleButtonLabelPlacement || {});
let ObcToggleButtonVerticalOption = class extends LitElement {
  constructor() {
    super(...arguments);
    this.value = "";
    this.selected = false;
    this.type = "regular";
    this.showDivider = true;
    this.hasIcon = false;
    this.label = "";
    this.disabled = false;
    this.labelPlacement = "inline";
    this._isGroupManaged = false;
  }
  connectedCallback() {
    super.connectedCallback();
    this._isGroupManaged = this.closest("obc-toggle-button-vertical-group") !== null;
  }
  onClick(event) {
    if (this.disabled) {
      event.preventDefault();
      return;
    }
    event.preventDefault();
    if (!this._isGroupManaged) {
      this.selected = !this.selected;
    }
    if (!this.selected) {
      this.dispatchEvent(
        new CustomEvent("selected", {
          detail: { value: this.value },
          bubbles: true,
          composed: true
        })
      );
    }
  }
  render() {
    const labelUnder = this.labelPlacement === "under";
    const hasLabel = this.label.trim().length > 0;
    const labelText = hasLabel ? this.label : " ";
    const classes = classMap({
      wrapper: true,
      selected: this.selected,
      "type-flat": this.type === "flat",
      "type-regular": this.type === "regular",
      "type-normal": this.type === "normal",
      "label-under": labelUnder,
      "label-inline": !labelUnder,
      "has-icon": this.hasIcon,
      disabled: this.disabled
    });
    return html`
      <button
        class=${classes}
        @click=${this.onClick}
        ?disabled=${this.disabled}
        aria-pressed=${this.selected}
        aria-disabled=${this.disabled}
      >
        <div class="visible-wrapper">
          <div class="icon-label-container">
            <div class="icon">
              ${labelUnder && !this.hasIcon ? nothing : this.hasIcon ? html`<slot name="icon"></slot>` : nothing}
            </div>

            ${labelUnder ? html`<div class="label">${labelText}</div>` : hasLabel ? html`<div class="label">${this.label}</div>` : nothing}
          </div>

          ${!this.selected ? html`<div class="bottom-divider"></div>` : nothing}
        </div>
      </button>
    `;
  }
};
ObcToggleButtonVerticalOption.styles = unsafeCSS(styles);
__decorateClass([
  property({ type: String })
], ObcToggleButtonVerticalOption.prototype, "value", 2);
__decorateClass([
  property({ type: Boolean, reflect: true })
], ObcToggleButtonVerticalOption.prototype, "selected", 2);
__decorateClass([
  property({ type: String })
], ObcToggleButtonVerticalOption.prototype, "type", 2);
__decorateClass([
  property({ type: Boolean, reflect: true })
], ObcToggleButtonVerticalOption.prototype, "showDivider", 2);
__decorateClass([
  property({ type: Boolean })
], ObcToggleButtonVerticalOption.prototype, "hasIcon", 2);
__decorateClass([
  property({ type: String })
], ObcToggleButtonVerticalOption.prototype, "label", 2);
__decorateClass([
  property({ type: Boolean, reflect: true })
], ObcToggleButtonVerticalOption.prototype, "disabled", 2);
__decorateClass([
  property({ type: String })
], ObcToggleButtonVerticalOption.prototype, "labelPlacement", 2);
ObcToggleButtonVerticalOption = __decorateClass([
  customElement("obc-toggle-button-vertical-option")
], ObcToggleButtonVerticalOption);
export {
  ObcToggleButtonLabelPlacement,
  ObcToggleButtonVerticalOption,
  ObcToggleButtonVerticalOptionType
};
//# sourceMappingURL=toggle-button-vertical-option.js.map
