import { unsafeCSS, LitElement, html } from "lit";
import { customElement } from "../../decorator.js";
import compentStyle from "./communication-table.css.js";
import { property } from "lit/decorators.js";
import { ObcTableCellType } from "../table/table.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 ObcCommunicationTable = class extends LitElement {
  constructor() {
    super(...arguments);
    this.data = [];
    this.showLeadingIcon = true;
    this.showLabel = true;
    this.showActionIcon = true;
    this.largeLeadingIcon = false;
  }
  render() {
    const columns = [];
    if (this.showLeadingIcon) {
      columns.push({
        label: "",
        key: "leadingIcon"
      });
    }
    columns.push({
      label: "Title",
      key: "title"
    });
    if (this.showLabel) {
      columns.push({
        label: "Label",
        key: "label"
      });
    }
    if (this.showActionIcon) {
      columns.push({
        label: "Action",
        key: "actionIcon"
      });
    }
    const data = this.data.map(
      (item) => ({
        selected: item.selected,
        id: item.id,
        leadingIcon: {
          type: ObcTableCellType.Regular,
          largeIcon: this.largeLeadingIcon,
          icon: item.leadingIcon,
          cssPart: "leading-icon" + (item.unread ? " unread" : "") + (item.selected ? " selected" : "")
        },
        title: {
          type: ObcTableCellType.Regular,
          title: item.title,
          text: item.description,
          icon: item.descriptionIcon,
          vertical: true,
          cssPart: "message" + (item.unread ? " unread" : "") + (item.descriptionIcon ? "" : " no-icon") + (item.selected ? " selected" : "")
        },
        label: {
          type: ObcTableCellType.Regular,
          title: item.label1,
          text: item.label2,
          vertical: true,
          cssPart: "label"
        },
        actionIcon: {
          type: ObcTableCellType.Regular,
          icon: item.actionIcon,
          cssPart: "actionIcon"
        }
      })
    );
    return html`<obc-table
      .data=${data}
      .columns=${columns}
      .showHeader=${false}
      rowDivider
      @row-click=${this._handleRowClick}
    ></obc-table>`;
  }
  _handleRowClick(event) {
    this.dispatchEvent(
      new CustomEvent("row-click", {
        detail: { rowId: event.detail.row.id }
      })
    );
  }
};
ObcCommunicationTable.styles = unsafeCSS(compentStyle);
__decorateClass([
  property({ type: Array })
], ObcCommunicationTable.prototype, "data", 2);
__decorateClass([
  property({ type: Boolean, attribute: false })
], ObcCommunicationTable.prototype, "showLeadingIcon", 2);
__decorateClass([
  property({ type: Boolean, attribute: false })
], ObcCommunicationTable.prototype, "showLabel", 2);
__decorateClass([
  property({ type: Boolean, attribute: false })
], ObcCommunicationTable.prototype, "showActionIcon", 2);
__decorateClass([
  property({ type: Boolean })
], ObcCommunicationTable.prototype, "largeLeadingIcon", 2);
ObcCommunicationTable = __decorateClass([
  customElement("obc-communication-table")
], ObcCommunicationTable);
export {
  ObcCommunicationTable
};
//# sourceMappingURL=communication-table.js.map
