import { Component, Element, h, Listen, Prop, State } from "@stencil/core";
import * as translation from "../../../translation";
export class IntergiroEntryTable {
  constructor() {
    this.opened = {};
  }
  componentWillLoad() {
    this.t = translation.create(this.element);
  }
  toggleColumn(e) {
    const opened = Object.assign({}, this.opened);
    if (opened[e.detail.index] == e.detail.column)
      delete opened[e.detail.index];
    else
      opened[e.detail.index] = e.detail.column;
    this.opened = opened;
    e.stopPropagation();
  }
  render() {
    return [
      this.entries.length > 0 ? ([
        h("table", null,
          h("thead", null,
            h("tr", null,
              h("th", { color: "light" }, this.t("level")),
              h("th", { color: "light" }, this.t("point")),
              h("th", { color: "light" }, this.t("data")))),
          this.entries.map(e => {
            const index = this.entries.indexOf(e);
            return [
              h("ig-entry-table-row", { entry: e, opened: this.opened[index], index: index }),
              h("ig-entry-details", { entry: e, opened: this.opened[index] }),
            ];
          })),
      ]) : (h("p", null, this.t("There are no entries to display."))),
    ];
  }
  static get is() { return "ig-entry-table"; }
  static get encapsulation() { return "scoped"; }
  static get originalStyleUrls() { return {
    "$": ["style.css"]
  }; }
  static get styleUrls() { return {
    "$": ["style.css"]
  }; }
  static get properties() { return {
    "entries": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Log.Entry[]",
        "resolved": "Entry[]",
        "references": {
          "Log": {
            "location": "import",
            "path": "@payfunc/model-log"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    }
  }; }
  static get states() { return {
    "t": {},
    "opened": {}
  }; }
  static get elementRef() { return "element"; }
  static get listeners() { return [{
      "name": "columnClicked",
      "method": "toggleColumn",
      "target": undefined,
      "capture": false,
      "passive": false
    }]; }
}
