import { Component, Element, h, Listen, Prop, State } from "@stencil/core";
import * as translation from "./translation";
export class IntergiroSubscriptionTable {
  constructor() {
    this.opened = {};
  }
  componentWillLoad() {
    this.t = translation.create(this.element);
  }
  toggleColumn(e) {
    const opened = Object.assign({}, this.opened);
    if (e.detail["id"] && opened[e.detail.id] == e.detail.column)
      delete opened[e.detail.id];
    else
      opened[e.detail.id] = e.detail.column;
    this.opened = opened;
  }
  render() {
    return [
      this.subscriptions ? ([
        h("table", null,
          h("thead", null,
            h("tr", null,
              h("th", { color: "light" }, this.t("Number")),
              h("th", { color: "light" }, this.t("Amount")),
              h("th", { color: "light" }, this.t("Schedule")),
              h("th", { color: "light" }, this.t("Start")),
              h("th", { color: "light" }, this.t("End")),
              h("th", { color: "light" }, this.t("Due")))),
          this.subscriptions.map(s => {
            var _a;
            return [
              h("ig-subscription-table-row", { opened: this.opened[s.id], subscription: s }),
              h("ig-subscription-details", { opened: (_a = this.opened[s.id]) !== null && _a !== void 0 ? _a : "", subscription: s, customer: this.customer }),
            ];
          })),
      ]) : (h("p", null, this.t("There are no subscriptions to display."))),
    ];
  }
  static get is() { return "ig-subscription-table"; }
  static get encapsulation() { return "scoped"; }
  static get originalStyleUrls() { return {
    "$": ["style.css"]
  }; }
  static get styleUrls() { return {
    "$": ["style.css"]
  }; }
  static get properties() { return {
    "subscriptions": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Subscription[]",
        "resolved": "Subscription[]",
        "references": {
          "Subscription": {
            "location": "import",
            "path": "@payfunc/model"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "customer": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Customer",
        "resolved": "Customer",
        "references": {
          "Customer": {
            "location": "import",
            "path": "@payfunc/model"
          }
        }
      },
      "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
    }]; }
}
