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

const sv = {
  Total: "Totalt",
  VAT: "moms",
  Quantity: "Antal",
  Name: "Namn",
  Unit: "Enhet",
  Price: "Pris",
};

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

const styleCss = ".sc-payfunc-items-list-h{display:block}[hidden].sc-payfunc-items-list-h{display:none}.sc-payfunc-items-list-h>li.sc-payfunc-items-list{display:flex;align-items:stretch}.sc-payfunc-items-list-h>li.sc-payfunc-items-list>*.sc-payfunc-items-list:first-child{overflow:hidden;text-overflow:ellipsis}.sc-payfunc-items-list-h>li.sc-payfunc-items-list>*.sc-payfunc-items-list:last-child{margin-left:auto}.sc-payfunc-items-list-h>li.total.sc-payfunc-items-list{border-top:solid 1px rgb(var(--smoothly-color-contrast));margin-top:.2em;padding-top:.2em;font-weight:600}.sc-payfunc-items-list-h>li.vat.sc-payfunc-items-list{font-size:85%}[editable].sc-payfunc-items-list-h>li.total.sc-payfunc-items-list,[editable].sc-payfunc-items-list-h>li.vat.sc-payfunc-items-list{margin-right:1em}";

const PayfuncItemsList = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.changed = createEvent(this, "changed", 7);
    this.editable = false;
  }
  componentWillLoad() {
    this.t = create(this.element);
  }
  edited(e, index) {
    const items = this.items;
    if (index && Array.isArray(items)) {
      items[index] = e.detail;
      this.items = [...items];
    }
    else
      this.items = e.detail;
    this.changed.emit(this.items);
  }
  render() {
    const t = this.t;
    const vat = Item.vat(this.items);
    return [
      Array.isArray(this.items) ? (this.items.map((item, index) => (h("payfunc-item", { onEdit: (e) => this.edited(e, index), editable: this.editable, item: item, currency: this.currency })))) : (h("payfunc-item", { onEdit: (e) => this.edited(e), editable: this.editable, item: this.items, currency: this.currency })),
      h("li", { class: "total" }, h("span", null, t("Total")), h("smoothly-display", { type: "price", value: Item.amount(this.items), currency: this.currency })),
      vat != undefined ? (h("li", { class: "vat" }, h("span", null, t("VAT")), h("smoothly-display", { type: "price", value: vat, currency: this.currency }))) : (""),
    ];
  }
  get element() { return getElement(this); }
};
PayfuncItemsList.style = styleCss;

export { PayfuncItemsList as payfunc_items_list };
