'use strict';

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

const index$1 = require('./index-140bcbcd.js');
const index = require('./index-d3079b93.js');
require('./index-4ba31f38.js');
require('./Item-00ce8c24.js');
const index$2 = require('./index-ac98852d.js');
require('./Credentials-8e4749ab.js');
require('./Token-8c5ba5d9.js');
require('./_commonjsHelpers-537d719a.js');
require('./unknown-38d3748c.js');
require('./index-bddf9814.js');
require('./index-3b10efe6.js');
require('./App-0b3e3f31.js');
require('./Notice-e970b490.js');
require('./index-2d6d8231.js');
require('./index-dc498c54.js');
require('./index-09251373.js');
require('./TextDecoder-753156f3.js');

const sv$2 = {
  Limit: "Gräns",
  "Soft limit": "Mjuk gräns",
  Margin: "Marginal",
  "Credit limit": "Kreditgräns",
  "Automatic charge limit.": "Gräns för automatisk debitering.",
  "Automatic charge margin.": "Marginal för automatisk debitering.",
};

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

const styleCss$2 = ".sc-ig-customer-limit-h{width:100%;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:distribute;justify-content:space-around}[hidden].sc-ig-customer-limit-h{display:none}.sc-ig-customer-limit-h>section.sc-ig-customer-limit{width:100%}.sc-ig-customer-limit-h>section.sc-ig-customer-limit>label.sc-ig-customer-limit{font-weight:bold;text-align:left;padding-bottom:0.2em}.sc-ig-customer-limit-h>section.sc-ig-customer-limit>smoothly-display.sc-ig-customer-limit{width:10em;max-width:10em;text-transform:capitalize;-ms-flex-item-align:start;align-self:flex-start}.sc-ig-customer-limit-h>section.sc-ig-customer-limit>span.sc-ig-customer-limit{background:rgba(0, 0, 0, 0.5);text-align:center;border-radius:6px;padding:0.6em;position:absolute;z-index:1;visibility:hidden}.sc-ig-customer-limit-h>section.sc-ig-customer-limit:hover>span.sc-ig-customer-limit{visibility:visible;-moz-transition-delay:0.5s;-webkit-transition-delay:0.5s;transition-delay:0.5s}";

const IntergiroCustomerLimit = class {
  constructor(hostRef) {
    index$1.registerInstance(this, hostRef);
  }
  componentWillLoad() {
    this.t = create$2(this.element);
  }
  render() {
    const limit = typeof this.customer.limit == "number" ? this.customer.limit : undefined;
    const hard = typeof this.customer.limit == "object" && this.customer.limit.hard ? this.customer.limit.hard : undefined;
    const soft = typeof this.customer.limit == "object" && this.customer.limit.soft ? this.customer.limit.soft : undefined;
    const margin = typeof this.customer.limit == "object" && this.customer.limit.margin ? this.customer.limit.margin : undefined;
    return limit ? (index$1.h("section", null, index$1.h("label", null, this.t("Credit limit")), index$1.h("smoothly-display", null, limit + " " + this.customer.currency))) : ([
      hard && (index$1.h("section", null, index$1.h("label", null, this.t("Credit limit")), index$1.h("smoothly-display", null, hard + " " + this.customer.currency))),
      soft && (index$1.h("section", null, index$1.h("label", null, this.t("Soft limit")), index$1.h("smoothly-display", null, soft + " " + this.customer.currency), index$1.h("span", null, this.t("Automatic charge limit.")))),
      margin && (index$1.h("section", null, index$1.h("label", null, this.t("Margin")), index$1.h("smoothly-display", null, margin + " " + this.customer.currency), index$1.h("span", null, this.t("Automatic charge margin.")))),
    ]);
  }
  get element() { return index$1.getElement(this); }
};
IntergiroCustomerLimit.style = styleCss$2;

const sv$1 = {
  "Loading orders from server.": "Laddar ordrar från servern.",
  "There are no orders to display.": "Det finns inga ordrar att visa.",
  "Order number": "Ordernummer",
  Contact: "Kontakt",
  Amount: "Summa",
  Receipt: "Kvitto",
  Payment: "Betalning",
  Created: "Skapad",
  Status: "Status",
  "Select all orders": "Markera alla ordrar",
  "Deselect all orders": "Avmarkera alla ordrar",
  "Download order report": "Ladda ner orderrapport",
  "Load more orders": "Ladda in fler ordrar",
};

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

const styleCss$1 = ".sc-ig-orders-table-h{display:block;width:100%;max-width:90em;margin:auto}[hidden].sc-ig-orders-table-h{display:none}.sc-ig-orders-table-h>table.sc-ig-orders-table{width:100%}.sc-ig-orders-table-h>p.sc-ig-orders-table{padding-left:0.5em}[id].sc-ig-orders-table{scroll-margin-top:calc(1.6cm + 2em)}thead.sc-ig-orders-table>tr.sc-ig-orders-table{display:table-row;font-weight:bold;height:2em;border-top:solid 1px rgb(var(--smoothly-dark-shadow));border-bottom:solid 1px rgb(var(--smoothly-dark-shadow))}thead.sc-ig-orders-table>tr.sc-ig-orders-table>*.sc-ig-orders-table{display:table-cell;padding-right:0.5em;padding-left:0.3em;vertical-align:middle;position:-webkit-sticky;position:sticky;top:1.55cm;z-index:1;text-align:left}[embedded].sc-ig-orders-table-h thead.sc-ig-orders-table>tr.sc-ig-orders-table>*.sc-ig-orders-table{top:0}thead.sc-ig-orders-table>tr.sc-ig-orders-table>*.sc-ig-orders-table>smoothly-icon.sc-ig-orders-table{vertical-align:-50%;margin-left:0.1em}.sc-ig-orders-table-h .loadMore.sc-ig-orders-table{text-align:center}.sc-ig-orders-table-h>table.sc-ig-orders-table>td.sc-ig-orders-table>button.sc-ig-orders-table:focus{outline:none}ig-orders-table-row.sc-ig-orders-table{display:table-row-group;border-top:1px solid transparent}ig-orders-table-row.sc-ig-orders-table:last-of-type{border-bottom:1px solid transparent}ig-orders-table-row[hidden].sc-ig-orders-table{display:none}";

const IntergiroOrdersTable = class {
  constructor(hostRef) {
    index$1.registerInstance(this, hostRef);
    this.selectedChanged = index$1.createEvent(this, "selectedChanged", 7);
    this.selected = {};
    this.display = false;
    this.opened = {};
    this.count = 100;
    this.hash = false;
  }
  componentWillLoad() {
    this.t = create$1(this.element);
  }
  componentDidRender() {
    var _a;
    if (window.location.hash && !this.hash) {
      const element = document.getElementById(window.location.hash.substring(1));
      if (element) {
        element.scrollIntoView();
        const order = (_a = this.orders) === null || _a === void 0 ? void 0 : _a.find(order => { var _a; return ((_a = order.number) === null || _a === void 0 ? void 0 : _a.replace(/\s/g, "").toLowerCase()) == window.location.hash.substring(1); });
        if (order) {
          const opened = Object.assign({}, this.opened);
          opened[order.id] = "number";
          this.opened = opened;
        }
        this.hash = true;
      }
    }
  }
  toggleColumn(e) {
    const opened = Object.assign({}, this.opened);
    if (Object.prototype.hasOwnProperty.call(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;
  }
  handleToggle(event) {
    const orders = Object.assign({}, this.selected);
    if (event.detail.checked)
      orders[event.detail.order.id] = event.detail.order;
    else
      delete orders[event.detail.order.id];
    this.selectedChanged.emit((this.selected = orders));
  }
  onChecked(event) {
    this.selected = {};
    if (event.detail.selected && this.orders)
      for (const order of this.orders)
        this.selected[order.id] = order;
    this.selectedChanged.emit(this.selected);
    event.stopPropagation();
    event.preventDefault();
  }
  render() {
    const t = this.t;
    let result;
    if (!this.orders)
      result = index$1.h("p", null, t("Loading orders from server."));
    else if (this.orders.length <= 0)
      result = index$1.h("p", null, t("There are no orders to display."));
    else {
      const amountOrders = this.orders.length;
      result = (index$1.h("table", null, index$1.h("thead", null, index$1.h("tr", null, !this.display ? (index$1.h("th", { style: { width: "5%" }, color: "light" }, index$1.h("smoothly-checkbox", { "select-all": true }))) : (""), index$1.h("th", { color: "light" }, t("Order number")), !this.display ? index$1.h("th", { color: "light" }, t("Contact")) : "", index$1.h("th", { color: "light" }, t("Amount")), this.receipt ? index$1.h("th", { color: "light" }, t("Receipt")) : "", index$1.h("th", { color: "light" }, t("Payment")), index$1.h("th", { color: "light" }, t("Created")), index$1.h("th", { color: "light" }, t("Status")))), this.orders
        .slice(0, this.count)
        .map(order => {
        var _a;
        return [
          index$1.h("ig-orders-table-row", { id: (_a = order.number) === null || _a === void 0 ? void 0 : _a.replace(/\s/g, "").toLowerCase(), selected: this.selected.hasOwnProperty.call(this.selected, order.id), order: order, display: this.display, opened: this.opened.hasOwnProperty.call(this.opened, order.id) ? this.opened[order.id] : "", receipt: this.receipt }),
          index$1.h("ig-orders-table-details", { order: order, opened: this.opened.hasOwnProperty.call(this.opened, order.id) ? this.opened[order.id] : "" }),
        ];
      }), index$1.h("td", { class: "loadMore", colSpan: 7 }, this.count < amountOrders ? (index$1.h("button", { onClick: () => (this.count += 100) }, index$1.h("smoothly-icon", { name: "chevron-down-circle", size: "large", toolTip: t("Load more orders") }))) : ("")), index$1.h("td", null)));
    }
    return result;
  }
  get element() { return index$1.getElement(this); }
};
IntergiroOrdersTable.style = styleCss$1;

const en = {
  "-2": "third to last",
  "-1": "second to last",
  "0": "last",
};

const sv = {
  frequency: "frekvens",
  offset: "offset",
  daily: "daglig",
  weekly: "veckovis",
  monthly: "månadsvis",
  quarterly: "kvartalsvis",
  yearly: "årlig",
  date: "datum",
  month: "månad",
  weekday: "veckodag",
  monday: "måndag",
  tuesday: "tisdag",
  wednesday: "onsdag",
  thursday: "torsdag",
  friday: "fredag",
  saturday: "lördag",
  sunday: "söndag",
  january: "januari",
  february: "februari",
  march: "mars",
  may: "maj",
  june: "juni",
  july: "juli",
  august: "augusti",
  october: "oktober",
  first: "första",
  second: "andra",
  third: "tredje",
  "-2": "tredje sista dagen",
  "-1": "andra sista dagen",
  "0": "sista dagen",
};

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

const styleCss = ".sc-ig-schedule-h{width:100%;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:distribute;justify-content:space-around}[hidden].sc-ig-schedule-h{display:none}.sc-ig-schedule-h>section.sc-ig-schedule{width:100%}.sc-ig-schedule-h>section.sc-ig-schedule>label.sc-ig-schedule{font-weight:bold;text-align:left;padding-bottom:0.2em;text-transform:capitalize}.sc-ig-schedule-h>section.sc-ig-schedule>smoothly-display.sc-ig-schedule{width:10em;max-width:10em;text-transform:capitalize;-ms-flex-item-align:start;align-self:flex-start}";

const IntergiroSchedule = class {
  constructor(hostRef) {
    index$1.registerInstance(this, hostRef);
    this.notice = index$1.createEvent(this, "notice", 7);
    this.advanced = false;
  }
  componentWillLoad() {
    this.t = create(this.element);
    this.frequency = typeof this.schedule == "object" ? this.schedule.frequency : this.schedule;
    this.offset = index$2.Schedule.is(this.schedule) && this.schedule.frequency != "daily" ? this.schedule.offset : undefined;
    this.divisor = index$2.Schedule.is(this.schedule) ? this.schedule.divisor : undefined;
  }
  render() {
    return [
      index$1.h("section", null, index$1.h("label", null, this.t("frequency")), index$1.h("smoothly-display", { type: "text", value: this.t(this.frequency) })),
      (this.frequency == "quarterly" || this.frequency == "yearly") && this.offset != undefined ? (index$1.h("section", null, index$1.h("label", null, this.t("month")), index$1.h("smoothly-display", { type: "text", value: this.t(Array.isArray(this.offset) ? index$2.Schedule.months[this.offset[0]] : index$2.Schedule.months[this.offset]) }))) : ([]),
      (this.frequency == "monthly" ||
        ((this.frequency == "yearly" || this.frequency == "quarterly") && Array.isArray(this.offset))) &&
        this.offset != undefined ? (index$1.h("section", null, index$1.h("label", null, this.t("date")), index$1.h("smoothly-display", { type: "text", value: this.t(Array.isArray(this.offset) ? (this.offset[1] + 1).toString() : (this.offset + 1).toString()) }))) : ([]),
      this.frequency == "weekly" && !Array.isArray(this.offset) && this.offset != undefined ? (index$1.h("section", null, index$1.h("label", null, this.t("weekday")), index$1.h("smoothly-display", { type: "text", value: this.t(index$2.Schedule.weekdays[this.offset - 1]) }))) : ([]),
      this.divisor != undefined ? (index$1.h("section", null, index$1.h("label", null, this.t("divisor")), index$1.h("smoothly-display", { type: "text", value: Array.isArray(this.divisor)
          ? this.divisor[0].toString() + " / " + this.divisor[1].toString()
          : this.divisor.toString() }))) : ([]),
    ];
  }
  get element() { return index$1.getElement(this); }
};
IntergiroSchedule.style = styleCss;

exports.ig_customer_limit = IntergiroCustomerLimit;
exports.ig_orders_table = IntergiroOrdersTable;
exports.ig_schedule = IntergiroSchedule;
