import { unsafeCSS, LitElement, nothing, html } from "lit";
import { property } from "lit/decorators.js";
import { customElement } from "../../decorator.js";
import { classMap } from "lit/directives/class-map.js";
import componentStyle from "./attachment-list-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;
};
let ObcAttachmentListItem = class extends LitElement {
  constructor() {
    super(...arguments);
    this.label = "File name";
    this.index = "";
    this.hasIndex = false;
    this.hasLeadingIcon = false;
    this.hasTag = false;
    this.hasTimeDate = false;
    this.date = "";
    this.time = "";
    this.hasTrailingAction = false;
    this.showDivider = false;
    this.amplified = false;
    this.disabled = false;
  }
  updated(changedProperties) {
    if (changedProperties.has("disabled")) {
      this._updateTrailingActionDisabled();
    }
  }
  _updateTrailingActionDisabled() {
    const slot = this.shadowRoot?.querySelector(
      'slot[name="trailing-action"]'
    );
    if (!slot) return;
    for (const node of slot.assignedElements()) {
      if (this.disabled) {
        node.setAttribute("disabled", "");
      } else {
        node.removeAttribute("disabled");
      }
    }
  }
  _handleTrailingActionSlotChange() {
    this._updateTrailingActionDisabled();
  }
  _handleClick() {
    if (this.disabled) return;
    this.dispatchEvent(
      new CustomEvent("attachment-item-click", {
        bubbles: true,
        composed: true,
        detail: { label: this.label }
      })
    );
  }
  render() {
    return html`
      <button
        type="button"
        class=${classMap({
      wrapper: true,
      amplified: this.amplified,
      disabled: this.disabled
    })}
        ?disabled=${this.disabled}
        @click=${this._handleClick}
      >
        ${this.showDivider ? html`<div class="divider"></div>` : nothing}
        <div class="content-container">
          <div class="label-group">
            ${this.hasIndex ? html`<span class="index-label">${this.index}</span>` : nothing}
            ${this.hasLeadingIcon ? html`<div class="leading-icon">
                  <slot name="leading-icon"></slot>
                </div>` : nothing}
            <div class="file-name-container">
              <span class="file-name">${this.label}</span>
            </div>
          </div>
          ${this.hasTag ? html`<div class="tag-container">
                <slot name="tag"></slot>
              </div>` : nothing}
          <div class="trailing-group">
            ${this.hasTimeDate ? html`<div class="time-date-container">
                  <span class="date-label">${this.date}</span>
                  <span class="time-label">${this.time}</span>
                </div>` : nothing}
            ${this.hasTrailingAction ? html`<div class="trailing-action">
                  <slot
                    name="trailing-action"
                    @slotchange=${this._handleTrailingActionSlotChange}
                  ></slot>
                </div>` : nothing}
          </div>
        </div>
      </button>
    `;
  }
};
ObcAttachmentListItem.styles = unsafeCSS(componentStyle);
__decorateClass([
  property({ type: String })
], ObcAttachmentListItem.prototype, "label", 2);
__decorateClass([
  property({ type: String })
], ObcAttachmentListItem.prototype, "index", 2);
__decorateClass([
  property({ type: Boolean })
], ObcAttachmentListItem.prototype, "hasIndex", 2);
__decorateClass([
  property({ type: Boolean })
], ObcAttachmentListItem.prototype, "hasLeadingIcon", 2);
__decorateClass([
  property({ type: Boolean })
], ObcAttachmentListItem.prototype, "hasTag", 2);
__decorateClass([
  property({ type: Boolean })
], ObcAttachmentListItem.prototype, "hasTimeDate", 2);
__decorateClass([
  property({ type: String })
], ObcAttachmentListItem.prototype, "date", 2);
__decorateClass([
  property({ type: String })
], ObcAttachmentListItem.prototype, "time", 2);
__decorateClass([
  property({ type: Boolean })
], ObcAttachmentListItem.prototype, "hasTrailingAction", 2);
__decorateClass([
  property({ type: Boolean })
], ObcAttachmentListItem.prototype, "showDivider", 2);
__decorateClass([
  property({ type: Boolean })
], ObcAttachmentListItem.prototype, "amplified", 2);
__decorateClass([
  property({ type: Boolean })
], ObcAttachmentListItem.prototype, "disabled", 2);
ObcAttachmentListItem = __decorateClass([
  customElement("obc-attachment-list-item")
], ObcAttachmentListItem);
export {
  ObcAttachmentListItem
};
//# sourceMappingURL=attachment-list-item.js.map
