import { r as registerInstance, h, g as getElement } from './index-aeac5cad.js';
import './_commonjsHelpers-91fffb88.js';
import { d as dist } from './index-fdd60c34.js';

const sv = {
  Number: "Nummer",
  Amount: "Summa",
  Schedule: "Schema",
  Start: "Påbörjar",
  End: "Upphör",
  Due: "Nästa betalning",
  "There are no subscriptions to display.": "Det finns inga prenummerationer att visa.",
};

function create(language) {
  return dist.create({
    sv,
  }, language);
}

const styleCss = ".sc-payfunc-subscription-table-h{display:block;width:100%;max-width:90em;margin:auto}[hidden].sc-payfunc-subscription-table-h{display:none}.sc-payfunc-subscription-table-h>p.sc-payfunc-subscription-table{padding-left:1em}.sc-payfunc-subscription-table-h>table.sc-payfunc-subscription-table{width:100%}.sc-payfunc-subscription-table-h>table.sc-payfunc-subscription-table>thead.sc-payfunc-subscription-table>tr.sc-payfunc-subscription-table{display:table-row;font-weight:bold;height:2em}.sc-payfunc-subscription-table-h>table.sc-payfunc-subscription-table>thead.sc-payfunc-subscription-table>tr.sc-payfunc-subscription-table>*.sc-payfunc-subscription-table{display:table-cell;padding-right:.5em;padding-left:.3em;vertical-align:middle;position:sticky;top:1.55cm;z-index:1;text-align:left}.sc-payfunc-subscription-table-h>table.sc-payfunc-subscription-table>td.sc-payfunc-subscription-table{text-align:center}";

const PayfuncSubscriptionTable = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.opened = {};
  }
  componentWillLoad() {
    this.t = 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("payfunc-subscription-table-row", { opened: this.opened[s.id], subscription: s }),
            h("payfunc-subscription-details", { opened: (_a = this.opened[s.id]) !== null && _a !== void 0 ? _a : "", subscription: s, account: this.account }),
          ];
        })),
      ]) : (h("p", null, this.t("There are no subscriptions to display."))),
    ];
  }
  get element() { return getElement(this); }
};
PayfuncSubscriptionTable.style = styleCss;

export { PayfuncSubscriptionTable as payfunc_subscription_table };
