'use strict';

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

const index$1 = require('./index-0b1e2673.js');
require('./_commonjsHelpers-937cd5b3.js');
const index$2 = require('./index-2eb96242.js');
const index = require('./index-36cf3884.js');

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

function create(language) {
  return index.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) {
    index$1.registerInstance(this, hostRef);
    this.changed = index$1.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 = index$2.Item.vat(this.items);
    return [
      Array.isArray(this.items) ? (this.items.map((item, index) => (index$1.h("payfunc-item", { onEdit: (e) => this.edited(e, index), editable: this.editable, item: item, currency: this.currency })))) : (index$1.h("payfunc-item", { onEdit: (e) => this.edited(e), editable: this.editable, item: this.items, currency: this.currency })),
      index$1.h("li", { class: "total" }, index$1.h("span", null, t("Total")), index$1.h("smoothly-display", { type: "price", value: index$2.Item.amount(this.items), currency: this.currency })),
      vat != undefined ? (index$1.h("li", { class: "vat" }, index$1.h("span", null, t("VAT")), index$1.h("smoothly-display", { type: "price", value: vat, currency: this.currency }))) : (""),
    ];
  }
  get element() { return index$1.getElement(this); }
};
PayfuncItemsList.style = styleCss;

exports.payfunc_items_list = PayfuncItemsList;
