import { r as registerInstance, j as createEvent, h, g as getElement } from './index-07845439.js';
import { i as isDefined } from './model-6cd0f9d5.js';
import { d as dist } from './index-3cc80977.js';
import './index-ea5ab071.js';
import './_commonjsHelpers-9bc404fc.js';
import './index-614b6d2f.js';
import './index-0a60c67f.js';

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

function create(language) {
  return 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) {
    registerInstance(this, hostRef);
    this.selectedChanged = 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 ? (h("p", null, t("Loading") + " " + this.name + " " + t("from server..."))) : this.value.length > 0 ? ([
        h("table", null, h("thead", null, h("tr", null, this.selectable && (h("th", { class: "checkbox", color: "light" }, h("smoothly-checkbox", { "select-all": true }))), this.header.filter(isDefined).map(v => (h("th", { class: v.align == "right" ? "right" : "", color: "light" }, v.name))))), h("slot", null)),
      ]) : (h("p", null, t("There are no") + " " + this.name + " " + t("to display."))),
    ];
  }
  get element() { return getElement(this); }
};
PayfuncTable.style = styleCss;

export { PayfuncTable as payfunc_table };
