import { unsafeCSS, LitElement, html } from "lit";
import { property } from "lit/decorators.js";
import componentStyles from "./icon-check-button.css.js";
import { classMap } from "lit/directives/class-map.js";
import { customElement } from "../../decorator.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;
};
let ObcIconCheckButton = class extends LitElement {
  constructor() {
    super(...arguments);
    this.checked = false;
    this.disabled = false;
    this.hasLabel = false;
    this.label = "";
    this.hasAlert = false;
    this.externalControl = false;
  }
  handleClick() {
    if (this.disabled) {
      return;
    }
    this.dispatchEvent(
      new CustomEvent("icon-check-button-click", {
        detail: {
          checked: !this.checked
        },
        bubbles: true,
        composed: true
      })
    );
    if (!this.externalControl) {
      this.checked = !this.checked;
    }
  }
  render() {
    return html`
      <button
        class=${classMap({
      wrapper: true,
      "state-checked": this.checked,
      "state-unchecked": !this.checked,
      disabled: this.disabled,
      "has-alert": this.hasAlert
    })}
        @click=${this.handleClick}
        ?disabled=${this.disabled}
        aria-pressed=${this.checked ? "true" : "false"}
        aria-disabled=${this.disabled ? "true" : "false"}
      >
        <div class="visible-wrapper">
          <div class="icon">
            <slot name="icon"></slot>
          </div>
        </div>
        ${this.hasLabel ? html`<div class="label-container">
              <div class="label">${this.label}</div>
            </div>` : ""}
      </button>
    `;
  }
};
ObcIconCheckButton.styles = unsafeCSS(componentStyles);
__decorateClass([
  property({ type: Boolean, reflect: true })
], ObcIconCheckButton.prototype, "checked", 2);
__decorateClass([
  property({ type: Boolean, reflect: true })
], ObcIconCheckButton.prototype, "disabled", 2);
__decorateClass([
  property({ type: Boolean })
], ObcIconCheckButton.prototype, "hasLabel", 2);
__decorateClass([
  property({ type: String })
], ObcIconCheckButton.prototype, "label", 2);
__decorateClass([
  property({ type: Boolean })
], ObcIconCheckButton.prototype, "hasAlert", 2);
__decorateClass([
  property({ type: Boolean })
], ObcIconCheckButton.prototype, "externalControl", 2);
ObcIconCheckButton = __decorateClass([
  customElement("obc-icon-check-button")
], ObcIconCheckButton);
export {
  ObcIconCheckButton
};
//# sourceMappingURL=icon-check-button.js.map
