'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index$1 = require('./index-df541290.js');
const model = require('./model-7d89452f.js');
const index = require('./index-aa81d689.js');
require('./index-bdcc5560.js');
require('./_commonjsHelpers-5bbc2693.js');
require('./index-c277d1ea.js');
require('./index-fe50ed35.js');

const sv = {
  Loading: "Laddar",
  "from server...": "från servern...",
  "There are no": "Det finns inga",
  "to display.": "att visa.",
};

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

const styleCss = ".sc-payfunc-table-h{display:block;width:100%;max-width:90em;margin:auto;border:1px solid rgb(var(--smoothly-medium-color))}[hidden].sc-payfunc-table-h{display:none}.sc-payfunc-table-h>p.sc-payfunc-table{padding-left:1em}.sc-payfunc-table-h>table.sc-payfunc-table{width:100%;table-layout:fixed}.sc-payfunc-table-h>table.sc-payfunc-table>thead.sc-payfunc-table>tr.sc-payfunc-table{display:table-row;font-weight:bold;height:2em}.sc-payfunc-table-h>table.sc-payfunc-table>thead.sc-payfunc-table>tr.sc-payfunc-table>th.sc-payfunc-table{text-transform:capitalize}.sc-payfunc-table-h>table.sc-payfunc-table>thead.sc-payfunc-table>tr.sc-payfunc-table>*.sc-payfunc-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-table-h>table.sc-payfunc-table>thead.sc-payfunc-table>tr.sc-payfunc-table>th.right.sc-payfunc-table{text-align:right;padding-right:5.3em}.sc-payfunc-table-h>table.sc-payfunc-table>td.sc-payfunc-table{text-align:center}th.checkbox.sc-payfunc-table{width:2em}";

const PayfuncTable = class {
  constructor(hostRef) {
    index$1.registerInstance(this, hostRef);
    this.selectedChanged = index$1.createEvent(this, "selectedChanged", 7);
    this.selectable = false;
    this.selected = {};
  }
  componentWillLoad() {
    this.t = create(this.element);
  }
  handleToggle(event) {
    const selected = this.selected;
    if (event.detail.checked)
      selected[event.detail.id] = event.detail.value;
    else
      delete selected[event.detail.id];
    this.selectedChanged.emit((this.selected = selected));
  }
  onChecked(event) {
    this.selectedChanged.emit(event.detail.selected ? { allSelected: true } : {});
  }
  render() {
    const t = this.t;
    return [
      !this.value ? (index$1.h("p", null, t("Loading") + " " + this.name + " " + t("from server..."))) : this.value.length > 0 ? ([
        index$1.h("table", null, index$1.h("thead", null, index$1.h("tr", null, this.selectable && (index$1.h("th", { class: "checkbox", color: "light" }, index$1.h("smoothly-checkbox", { "select-all": true }))), this.header.filter(model.isDefined).map(v => (index$1.h("th", { class: v.align == "right" ? "right" : "", color: "light" }, v.name))))), index$1.h("slot", null)),
      ]) : (index$1.h("p", null, t("There are no") + " " + this.name + " " + t("to display."))),
    ];
  }
  get element() { return index$1.getElement(this); }
};
PayfuncTable.style = styleCss;

exports.payfunc_table = PayfuncTable;
