import { unsafeCSS, LitElement, nothing } from "lit";
import { property } from "lit/decorators.js";
import { classMap } from "lit/directives/class-map.js";
import compentStyle from "./user-button.css.js";
import "../../icons/icon-user.js";
import { literal, html } from "lit/static-html.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;
};
var StyleType = /* @__PURE__ */ ((StyleType2) => {
  StyleType2["flat"] = "flat";
  StyleType2["normal"] = "normal";
  StyleType2["selected"] = "selected";
  return StyleType2;
})(StyleType || {});
var Size = /* @__PURE__ */ ((Size2) => {
  Size2["regular"] = "regular";
  Size2["large"] = "large";
  return Size2;
})(Size || {});
var Variant = /* @__PURE__ */ ((Variant2) => {
  Variant2["icon"] = "icon";
  Variant2["initials"] = "initials";
  return Variant2;
})(Variant || {});
let ObcUserButton = class extends LitElement {
  constructor() {
    super(...arguments);
    this.variant = "icon";
    this.size = "regular";
    this.styleType = "flat";
    this.static = false;
    this.disabled = false;
    this.initials = "";
  }
  get formattedInitials() {
    if (!this.initials) return "";
    const clean = this.initials.replace(/\s+/g, "").toUpperCase();
    const maxInitialsLength = this.size === "large" ? 3 : 2;
    if (clean.length > maxInitialsLength) {
      console.warn(
        `Initials "${this.initials}" are longer than ${maxInitialsLength} characters.`
      );
      return clean.slice(0, maxInitialsLength);
    }
    return clean;
  }
  get shouldShowIcon() {
    return this.variant === "icon";
  }
  render() {
    const styleType = this.size === "large" && this.styleType === "flat" ? "normal" : this.styleType;
    const wrapperClasses = {
      wrapper: true,
      "wrapper-static": this.static,
      [`style-${styleType}`]: true,
      "mode-icon": this.shouldShowIcon,
      "mode-initials": !this.shouldShowIcon,
      "state-static": this.static,
      [`size-${this.size}`]: true
    };
    const tag = this.static ? literal`div` : literal`button`;
    const label = this.label && !this.static ? html`<span class="user-label" part="label">${this.label}</span>` : nothing;
    return html`
        <${tag}
          class=${classMap(wrapperClasses)}
          ?disabled=${this.disabled}
          aria-label=${this.initials || "User button"}
        >
        <div class="content-container" part="content-container">
          <div class="user-button-circle">
            ${this.shouldShowIcon ? html`
                    <div class="icon-container">
                      <slot name="icon">
                        <!-- Fallback to default icon if no slot content -->
                        <obi-user></obi-user>
                      </slot>
                    </div>
                  ` : html`
                    <span class="user-initials">
                      ${this.formattedInitials}
                    </span>
                  `}
          </div>
          ${label}
        </div>
        </${tag}>
      `;
  }
};
ObcUserButton.styles = unsafeCSS(compentStyle);
__decorateClass([
  property({ type: String })
], ObcUserButton.prototype, "variant", 2);
__decorateClass([
  property({ type: String })
], ObcUserButton.prototype, "size", 2);
__decorateClass([
  property({ type: String })
], ObcUserButton.prototype, "styleType", 2);
__decorateClass([
  property({ type: Boolean })
], ObcUserButton.prototype, "static", 2);
__decorateClass([
  property({ type: Boolean })
], ObcUserButton.prototype, "disabled", 2);
__decorateClass([
  property({ type: String })
], ObcUserButton.prototype, "initials", 2);
__decorateClass([
  property({ type: String })
], ObcUserButton.prototype, "label", 2);
ObcUserButton = __decorateClass([
  customElement("obc-user-button")
], ObcUserButton);
export {
  ObcUserButton,
  Size,
  StyleType,
  Variant
};
//# sourceMappingURL=user-button.js.map
