import { unsafeCSS, LitElement, nothing, html } from "lit";
import { property } from "lit/decorators.js";
import { classMap } from "lit/directives/class-map.js";
import componentStyle from "./notification-button.css.js";
import { customElement } from "../../decorator.js";
import "../../icons/icon-notification.js";
import "../../icons/icon-notification-filled.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 NotificationButtonStyle = /* @__PURE__ */ ((NotificationButtonStyle2) => {
  NotificationButtonStyle2["Flat"] = "flat";
  NotificationButtonStyle2["Normal"] = "normal";
  NotificationButtonStyle2["Enhanced"] = "enhanced";
  return NotificationButtonStyle2;
})(NotificationButtonStyle || {});
let ObcNotificationButton = class extends LitElement {
  constructor() {
    super(...arguments);
    this.buttonStyle = "flat";
    this.count = 0;
    this.showCount = false;
    this.isActive = false;
    this.ariaLabel = "Notifications";
  }
  render() {
    const useNormal = this.isActive && this.buttonStyle === "normal";
    const useEnhanced = this.isActive && this.buttonStyle === "enhanced";
    const useFlat = this.buttonStyle === "flat" || !useNormal && !useEnhanced;
    const hasCounter = (useNormal || useEnhanced) && this.showCount;
    const wrapperClasses = {
      wrapper: true,
      "is-active": this.isActive,
      "has-counter": hasCounter,
      flat: useFlat,
      normal: useNormal,
      enhanced: useEnhanced
    };
    const visibleWrapperClasses = {
      "visible-wrapper": true
    };
    return html`
      <button
        class="${classMap(wrapperClasses)}"
        @click="${this.handleClick}"
        aria-label="${this.ariaLabel}${hasCounter ? `, ${this.count} new` : ""}"
        aria-pressed="${this.isActive}"
        role="button"
        type="button"
      >
        <div class="${classMap(visibleWrapperClasses)}">
          <div class="icon-container">
            <slot name="icon"> ${this.renderDefaultIcon()} </slot>
          </div>
          ${hasCounter ? html` <span class="count-label">${this.count}</span> ` : nothing}
        </div>
      </button>
    `;
  }
  renderDefaultIcon() {
    if (this.isActive) {
      return html`<obi-notification-filled></obi-notification-filled>`;
    }
    return html`<obi-notification></obi-notification>`;
  }
  /**
   * Handles click events on the button and dispatches the `obc-click` custom event.
   *
   * @fires obc-click {CustomEvent<NotificationButtonClickEvent>} Fired with the current count and new active state.
   */
  handleClick() {
    const event = new CustomEvent("obc-click", {
      detail: {
        count: this.count,
        isActive: !this.isActive
      },
      composed: true,
      bubbles: true
    });
    this.dispatchEvent(event);
  }
};
ObcNotificationButton.styles = unsafeCSS(componentStyle);
__decorateClass([
  property({ type: String })
], ObcNotificationButton.prototype, "buttonStyle", 2);
__decorateClass([
  property({ type: Number })
], ObcNotificationButton.prototype, "count", 2);
__decorateClass([
  property({ type: Boolean })
], ObcNotificationButton.prototype, "showCount", 2);
__decorateClass([
  property({ type: Boolean })
], ObcNotificationButton.prototype, "isActive", 2);
__decorateClass([
  property({ type: String })
], ObcNotificationButton.prototype, "ariaLabel", 2);
ObcNotificationButton = __decorateClass([
  customElement("obc-notification-button")
], ObcNotificationButton);
export {
  NotificationButtonStyle,
  ObcNotificationButton
};
//# sourceMappingURL=notification-button.js.map
