'use strict';

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

const index$1 = require('./index-223abef7.js');
const index = require('./index-65f2d9fe.js');
const index$2 = require('./index-b0cd9edb.js');
const index$3 = require('./index-7bb66b0e.js');
require('./App-1795c305.js');
require('./Token-09f9b5d6.js');
const Notice = require('./Notice-e970b490.js');
const unknown = require('./unknown-f63ab5c0.js');

const sv$6 = {
  Edit: "Redigera",
  Delete: "Radera",
  primary: "primär",
  billing: "fakturering",
  delivery: "leverans",
  visit: "besök",
};

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

const styleCss$7 = ".sc-ig-address-h{display:block;position:relative}[hidden].sc-ig-address-h{display:none}smoothly-icon.sc-ig-address{cursor:pointer;margin-top:.3em}label.sc-ig-address{display:inline-block;-webkit-margin-before:.6em;margin-block-start:.6em;-webkit-margin-after:.2em;margin-block-end:.2em;text-transform:capitalize;margin-bottom:.2em}smoothly-popup.sc-ig-address{display:none;position:absolute;right:0}.sc-ig-address-h:hover smoothly-popup.sc-ig-address{display:inline}";

const IntergiroAddress = class {
  constructor(hostRef) {
    index$1.registerInstance(this, hostRef);
    this.edit = index$1.createEvent(this, "edit", 7);
    this.delete = index$1.createEvent(this, "delete", 7);
    this.type = "primary";
    this.mode = "display";
  }
  componentWillLoad() {
    this.t = create$6(this.element);
  }
  onChange(event) {
    event.stopPropagation();
    this.value = event.detail;
    this.mode = "display";
    this.edit.emit(Object.assign({ type: this.type }, this.value));
  }
  onDelete() {
    this.delete.emit(this.type);
  }
  render() {
    const t = this.t;
    return [
      index$1.h("smoothly-popup", null, index$1.h("smoothly-icon", { name: "ellipsis-vertical-outline", size: "small" }), index$1.h("div", { color: "light", slot: "popup" }, index$1.h("smoothly-icon", { size: "small", name: "pencil-outline", toolTip: t("Edit"), onClick: () => (this.mode = "edit") }), index$1.h("smoothly-icon", { size: "small", name: "trash", toolTip: "Delete", onClick: () => this.onDelete() }))),
      this.mode == "edit"
        ? [
          index$1.h("label", null, t(this.type)),
          index$1.h("ig-address-input", { onEdit: (e) => this.onChange(e), value: this.value }),
        ]
        : [index$1.h("label", null, t(this.type)), index$1.h("ig-address-display", { value: this.value })],
    ];
  }
  get element() { return index$1.getElement(this); }
};
IntergiroAddress.style = styleCss$7;

const styleCss$6 = ".sc-ig-address-display-h{display:block;border-top:1px solid rgb(var(--smoothly-medium-color));border-bottom:1px solid rgb(var(--smoothly-medium-color))}";

const IntergiroAddressDisplay = class {
  constructor(hostRef) {
    index$1.registerInstance(this, hostRef);
  }
  render() {
    var _a, _b, _c;
    const value = typeof this.value == "string" ? JSON.parse(this.value) : this.value;
    return value.countryCode == "" ? (index$1.h("address", null, (_a = value.address1) !== null && _a !== void 0 ? _a : "", index$1.h("br", null), (_b = value.address2) !== null && _b !== void 0 ? _b : "", index$1.h("br", null), (_c = value.address3) !== null && _c !== void 0 ? _c : "")) : (index$1.h("address", null, value.street, index$1.h("br", null), value.zipCode, " ", value.city, index$1.h("br", null), index$3.Address.DE.is(value) || (index$3.Address.General.is(value) && value.state) ? value.state + " " : [], index$2.dist.CountryCode.Name.from("en", value.countryCode)));
  }
};
IntergiroAddressDisplay.style = styleCss$6;

const sv$5 = {
  Street: "Gata",
  "Zip code": "Postnummer",
  City: "Ort",
  Country: "Land",
  Save: "Spara",
  Cancel: "Avbryt",
  "Unknown address country": "Okänt adressland",
  primary: "primär",
  billing: "fakturering",
  delivery: "leverans",
  visit: "besök",
  "Please enter a valid address.": "Ange en giltig adress.",
};

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

const styleCss$5 = ".sc-ig-address-input-h{display:block;margin-top:.5em}[hidden].sc-ig-address-input-h{display:none}form.sc-ig-address-input{display:-ms-flexbox;display:flex;-ms-flex-flow:row;flex-flow:row;-ms-flex-wrap:wrap;flex-wrap:wrap;border-collapse:collapse}smoothly-input.sc-ig-address-input{border:1px solid rgb(var(--smoothly-medium-color))}smoothly-input[name=street]#add.sc-ig-address-input,smoothly-input[name=address1]#add.sc-ig-address-input{width:calc(100% - 3.8em - 3px)}smoothly-input[name=street].sc-ig-address-input,smoothly-input[name=address1].sc-ig-address-input{width:100%}smoothly-input[name=zipCode].sc-ig-address-input,smoothly-input[name=address2].sc-ig-address-input{min-width:calc(35% - 2px);-ms-flex-positive:2;flex-grow:2;border-top:none}smoothly-input[name=city].sc-ig-address-input,smoothly-input[name=address3].sc-ig-address-input{min-width:calc(65% - 2px);border-top:none;-ms-flex-positive:1;flex-grow:1}smoothly-input[name=country].sc-ig-address-input{width:100%;border-top:none}form.sc-ig-address-input>div.sc-ig-address-input{width:100%}smoothly-submit.sc-ig-address-input,smoothly-trigger.sc-ig-address-input{width:auto;float:right;background-color:transparent;border:none;cursor:pointer;color:transparent;margin-bottom:.2em}smoothly-select#types.sc-ig-address-input{display:grid;width:100% !important;border:none;padding-bottom:.5em}smoothly-select#countries.sc-ig-address-input{width:3.5em;border-bottom:1px solid rgb(var(--smoothly-medium-color));border-right:none}#states.sc-ig-address-input{width:100% !important;border-top:none}smoothly-select.sc-ig-address-input{border:1px solid rgb(var(--smoothly-medium-color));padding-bottom:.3em;padding-right:.3em;display:grid}";

const IntergiroAddressInput = class {
  constructor(hostRef) {
    index$1.registerInstance(this, hostRef);
    this.edit = index$1.createEvent(this, "edit", 7);
    this.create = index$1.createEvent(this, "create", 7);
    this.close = index$1.createEvent(this, "close", 7);
    this.notice = index$1.createEvent(this, "notice", 7);
    var _a, _b;
    this.types = [];
    this.mode = "edit";
    this.type = this.types[0];
    this.selected = (_b = (_a = this.address) === null || _a === void 0 ? void 0 : _a.countryCode) !== null && _b !== void 0 ? _b : "SE";
    this.countries = ["SE", "FI", "DE", "DK", "NO"];
    this.state = index$3.Address.DE.is(this.address) ? this.address.state : "";
    this.adding = false;
  }
  get address() {
    return typeof this.value == "string" ? JSON.parse(this.value) : this.value;
  }
  componentWillLoad() {
    this.t = create$5(this.element);
    if (!this.value) {
      this.value = index$3.Address.create("SE");
      this.adding = true;
    }
  }
  onTrigger() {
    if (this.adding)
      this.close.emit();
    else
      this.edit.emit(this.address);
  }
  onSelectionChanged(e) {
    if (e.detail.identifier == "types")
      this.type = e.detail.value;
    else if (e.detail.identifier == "countries")
      this.value = index$3.Address.create(e.detail.value);
    else if (e.detail.identifier == "states")
      this.state = e.detail.value;
  }
  onSubmit(e) {
    e.stopPropagation();
    const result = Object.assign(Object.assign({}, e.detail), { countryCode: e.detail.country
        ? index$2.dist.CountryCode.Name.parse(e.detail.country.toLowerCase())
        : this.value.countryCode });
    if (result.countryCode == "DE")
      result.state = this.state;
    if ((index$3.Address.is(result) && !Object.values(result).some(x => x == "")) || result.countryCode == "") {
      this.adding ? this.create.emit({ type: this.type, value: result }) : this.edit.emit(result);
    }
    else
      this.notice.emit(Notice.Notice.failed(this.t("Please enter a valid address.")));
  }
  toUpperCase(value) {
    return value.charAt(0).toUpperCase() + value.slice(1);
  }
  render() {
    var _a;
    const t = this.t;
    let inputFields = [];
    if (this.address.countryCode == "")
      inputFields = [
        index$1.h("smoothly-input", { type: "text", name: "address1", id: this.adding ? "add" : "", value: this.address.address1 }, "Address 1"),
        index$1.h("smoothly-input", { type: "text", name: "address2", value: this.address.address2 }, "Address 2"),
        index$1.h("smoothly-input", { type: "text", name: "address3", value: this.address.address3 }, "Address 3"),
      ];
    else
      inputFields = [
        index$1.h("smoothly-input", { type: "text", name: "street", id: this.adding ? "add" : "", value: this.address.street }, t("Street")),
        index$1.h("smoothly-input", { type: "postal-code", name: "zipCode", value: this.address.zipCode }, t("Zip code")),
        index$1.h("smoothly-input", { type: "text", name: "city", value: this.address.city }, t("City")),
        this.address.countryCode == "DE" ? (index$1.h("smoothly-select", { id: "states", identifier: "states", background: "transparent" }, index$1.h("option", { value: (_a = this.address.state) !== null && _a !== void 0 ? _a : "", selected: true }, this.address.state == "" || !this.address.state ? "State" : this.address.state), index$3.Address.DE.State.types.map(option => (index$1.h("option", { value: option }, option))))) : ([]),
        !this.adding ? (index$1.h("smoothly-input", { type: "text", name: "country", value: this.adding ? "" : index$2.dist.CountryCode.Name.from("en", this.address.countryCode) }, t("Country"))) : ([]),
      ];
    return [
      index$1.h("form", null, this.adding
        ? [
          index$1.h("smoothly-select", { id: "types", identifier: "types", background: "transparent" }, this.types.map(option => this.type == option ? (index$1.h("option", { value: option, selected: true }, this.toUpperCase(t(option)))) : (index$1.h("option", { value: option }, this.toUpperCase(t(option)))))),
          index$1.h("smoothly-select", { id: "countries", identifier: "countries", background: "transparent" }, this.countries.map(country => (index$1.h("option", { value: country, selected: this.selected == country }, country))), index$1.h("option", { value: "" }, "Other")),
        ]
        : [], inputFields, index$1.h("div", null, index$1.h("smoothly-submit", { color: "primary", fill: "clear", prevent: true, onSubmit: (e) => this.onSubmit(e) }, index$1.h("smoothly-icon", { name: "checkmark-circle", toolTip: t("Save"), color: "success", fill: "clear", size: "small" })), index$1.h("smoothly-trigger", { color: "primary", fill: "clear" }, index$1.h("smoothly-icon", { name: "close-circle", toolTip: t("Cancel"), color: "light", fill: "clear", size: "small" })))),
    ];
  }
  get element() { return index$1.getElement(this); }
};
IntergiroAddressInput.style = styleCss$5;

const sv$4 = {
  Add: "Lägg till",
};

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

const styleCss$4 = ".sc-ig-addresses-h{display:block}smoothly-trigger.sc-ig-addresses{display:inline-block;margin:5px}smoothly-icon.sc-ig-addresses{cursor:pointer;float:right;margin-top:-1.5em;padding-bottom:.5em;visibility:hidden}ig-address.sc-ig-addresses{clear:both}.sc-ig-addresses-h:hover smoothly-icon.sc-ig-addresses{visibility:visible}";

const IntergiroAddresses = class {
  constructor(hostRef) {
    index$1.registerInstance(this, hostRef);
    this.changed = index$1.createEvent(this, "changed", 7);
    this.allowed = [];
    this.editing = undefined;
    this.adding = false;
  }
  get allowedArray() {
    if (!this.allowedArrayValue)
      this.allowedArrayValue = Array.isArray(this.allowed)
        ? this.allowed
        : this.allowed.split(" ");
    return this.allowedArrayValue;
  }
  get address() {
    if (typeof this.value == "string")
      this.value = JSON.parse(this.value);
    return this.value;
  }
  get addresses() {
    return index$3.Address.is(this.address) ? { primary: this.address } : Object.assign({}, this.address);
  }
  get types() {
    return index$3.Addresses.types.filter(type => index$3.Addresses.is(this.value) ? !this.value[type] : index$3.Address.is(this.value) ? type != "primary" : type);
  }
  componentWillLoad() {
    this.t = create$4(this.element);
  }
  onChange(e) {
    if (index$3.Address.is(e.detail)) {
      const type = e.detail.type;
      const address = Object.assign({}, e.detail);
      delete address.type;
      let result;
      if (type == "primary" && index$3.Address.is(this.address))
        result = address;
      else {
        result = Object.assign({}, this.addresses);
        result[type] = address;
      }
      this.changed.emit((this.value = result));
    }
  }
  onCreate(e) {
    const type = e.detail.type;
    const value = e.detail.value;
    const result = this.addresses;
    result[type] = value;
    this.changed.emit((this.value = result));
    this.adding = false;
  }
  onTrigger(e) {
    if (e.detail.name == "add" && typeof this.value != "string") {
      const result = this.addresses;
      const added = index$3.Address.create("SE");
      const type = e.detail.value;
      result[type] = added;
      this.value = result;
    }
  }
  onDelete(e) {
    const type = e.detail;
    const result = Object.assign({}, this.addresses);
    delete result[type];
    this.changed.emit((this.value = result));
  }
  render() {
    const allowed = this.allowedArray.filter(type => index$3.Addresses.is(this.address) ? this.address[type] == undefined : type != "primary");
    return [
      this.adding ? (index$1.h("ig-address-input", { onClose: () => (this.adding = false), mode: "add", types: this.types, onCreate: (e) => this.onCreate(e) })) : ([]),
      this.types.length > 0 ? (index$1.h("smoothly-icon", { name: "add-circle", toolTip: this.t("Add"), fill: "clear", size: "medium", color: "success", style: this.adding ? { display: "none" } : {}, onClick: () => (this.adding = true) })) : ([]),
      this.address ? (index$3.Address.is(this.address) ? (index$1.h("ig-address", { mode: this.editing ? "edit" : "display", value: this.address, onEdit: (e) => this.onChange(e), onDelete: (e) => this.onDelete(e) })) : (index$3.Addresses.map(this.address, (type, address) => (index$1.h("ig-address", { mode: this.editing ? "edit" : "display", type: type, value: address, onEdit: (e) => this.onChange(e), onDelete: (e) => this.onDelete(e) }))))) : ([]),
      allowed.map(type => (index$1.h("smoothly-trigger", { color: "primary", fill: "clear", name: "add", value: type }, "+", type))),
    ];
  }
  get element() { return index$1.getElement(this); }
};
IntergiroAddresses.style = styleCss$4;

const sv$3 = {
  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$3(language) {
  return index.dist.create({
    sv: sv$3,
  }, language);
}

const styleCss$3 = ".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:.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:.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:.5s;-webkit-transition-delay:.5s;transition-delay:.5s}";

const IntergiroCustomerLimit = class {
  constructor(hostRef) {
    index$1.registerInstance(this, hostRef);
  }
  componentWillLoad() {
    this.t = create$3(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$3;

const sv$2 = {
  Scheme: "System",
  "Card number": "Kortnummer",
  Expires: "Giltigt t.o.m.",
  Close: "Stäng",
  "Add method": "Lägg till metod",
  "The customer has no payment method.": "Kunden har ingen betalningsmetod.",
};

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

const styleCss$2 = "[hidden].sc-ig-payment-methods-h{display:none}section.sc-ig-payment-methods{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;font-weight:bold}section.sc-ig-payment-methods>*.sc-ig-payment-methods{width:10em}section.sc-ig-payment-methods>*.sc-ig-payment-methods:nth-of-type(2){width:15em}@media only screen and (min-width: 1000px){smoothly-icon.sc-ig-payment-methods{visibility:hidden}smoothly-reorder.sc-ig-payment-methods{float:left}smoothly-reorder.sc-ig-payment-methods>*.sc-ig-payment-methods{margin-top:10px}ig-payment-method-add.sc-ig-payment-methods{position:relative;display:block;visibility:visible;width:50%;float:right}}@media only screen and (max-width: 1000px){smoothly-icon.sc-ig-payment-methods{visibility:visible;position:fixed;right:5%;cursor:pointer}ig-payment-method-add.sc-ig-payment-methods,#desktop.sc-ig-payment-methods{display:none}ig-payment-method-add.sc-ig-payment-methods,#phone.sc-ig-payment-methods{display:block;width:25rem;max-width:90%;margin:0 auto}.sc-ig-payment-methods-h>smoothly-reorder.sc-ig-payment-methods>*.sc-ig-payment-methods,table.sc-ig-payment-methods{max-width:60%;margin:0 auto;margin-top:10px}}";

const IntergiroPaymentMethods = class {
  constructor(hostRef) {
    index$1.registerInstance(this, hostRef);
    this.update = index$1.createEvent(this, "update", 7);
    this.delete = index$1.createEvent(this, "delete", 7);
    this.addable = false;
    this.deletable = false;
    this.mode = "card";
    this.opened = false;
  }
  componentWillLoad() {
    this.t = create$2(this.element);
  }
  renderMethods() {
    this.methods = [...this.methods];
  }
  deleteMethod(index) {
    window.setTimeout(() => {
      this.methods.splice(index, 1);
      this.renderMethods();
      this.delete.emit(this.methods);
    }, 500);
  }
  reorderMethods(event) {
    const fromIndex = event.detail[0];
    const toIndex = event.detail[1];
    const e = this.methods.splice(fromIndex, 1);
    this.methods.splice(toIndex, 0, ...e);
    this.update.emit(this.methods);
  }
  render() {
    return [
      this.addable
        ? [
          index$1.h("smoothly-icon", { name: this.opened ? "close-circle" : "add-circle", toolTip: this.opened ? this.t("Close") : this.t("Add method"), size: "large", onClick: () => (this.opened = !this.opened) }),
          index$1.h("ig-payment-method-add", { id: this.opened ? "phone" : "desktop", customer: this.customer, "api-key": this.apiKey, onAdd: () => this.renderMethods() }),
        ]
        : null,
      this.mode == "table" &&
        (this.methods.length > 0 ? (index$1.h("section", null, index$1.h("label", null, this.t("Scheme")), index$1.h("label", null, this.t("Card number")), index$1.h("label", null, this.t("Expires")))) : (index$1.h("p", null, this.t("The customer has no payment method.")))),
      index$1.h("smoothly-reorder", { onReorder: (event) => this.reorderMethods(event) }, this.methods.map((method, index) => [
        index$1.h("ig-payment-method", { mode: this.mode, method: method, deletable: this.deletable, onDeleteMethod: () => this.deleteMethod(index) }),
      ])),
    ];
  }
  get element() { return index$1.getElement(this); }
};
IntergiroPaymentMethods.style = styleCss$2;

const sv$1 = {
  "Cancelling subscription...": "Avbryter prenumerationen ...",
  "Subscription was cancelled.": "Prenumerationen avbröts.",
  "Failed to cancel subscription.": "Misslyckades med att avbryta prenumerationen.",
  "Updating subscription...": "Uppdaterar prenummeration.",
  "Subscription was updated.": "Prenumerationen uppdaterades.",
  "Failed to update subscription.": "Misslyckades med att uppdatera prenumerationen.",
  "End date": "Slutdatum",
  "Start date": "Startdatum",
  "Cancel subscription": "Avbryt prenumeration",
  ongoing: "pågående",
  Start: "Påbörjar",
  End: "Upphör",
};

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

const styleCss$1 = ".sc-ig-subscription-details-h{display:table-row}.sc-ig-subscription-details-h>td.sc-ig-subscription-details{border-top:solid 1px rgb(var(--smoothly-medium-shade));border-bottom:solid 1px rgb(var(--smoothly-medium-shade));background-color:rgb(var(--smoothly-dark-shade));padding-top:.5em}ig-future-due-dates.sc-ig-subscription-details{width:30%;padding:.5em;margin:auto}ig-schedule.sc-ig-subscription-details{padding:1em;padding-left:4.5em}ig-items-list.sc-ig-subscription-details{padding:.5em;margin:auto;width:50%}ig-items-list.number.sc-ig-subscription-details{width:15%}ig-display-edit.sc-ig-subscription-details{margin-left:4.5em;margin-bottom:1em;width:10em}.sc-ig-subscription-details-h>td.sc-ig-subscription-details>section.sc-ig-subscription-details{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:justify;justify-content:space-between}.sc-ig-subscription-details-h>td.sc-ig-subscription-details>section.sc-ig-subscription-details>smoothly-icon.sc-ig-subscription-details{cursor:pointer;margin-right:1em;margin-top:-.5em}label.sc-ig-subscription-details{font-weight:bold;margin-left:4.5em}";

const IntergiroSubscriptionDetails = class {
  constructor(hostRef) {
    index$1.registerInstance(this, hostRef);
    this.notice = index$1.createEvent(this, "notice", 7);
    this.opened = "";
  }
  componentWillLoad() {
    this.t = create$1(this.element);
  }
  cancel() {
    this.notice.emit(Notice.Notice.execute(this.t("Cancelling subscription..."), async () => {
      const response = await index$3.Connection.delete(`customer/${this.customer.id}/subscription/${this.subscription.id}`);
      return !unknown.Error.is(response)
        ? [true, this.t("Subscription was cancelled.")]
        : [false, this.t("Failed to cancel subscription.")];
    }));
  }
  update(value, property) {
    const update = { [property]: value };
    this.subscription = Object.assign(Object.assign({}, this.subscription), update);
    this.notice.emit(Notice.Notice.execute(this.t("Updating subscription..."), async () => {
      const response = await index$3.Connection.put(`customer/${this.customer.id}/subscription/${this.subscription.id}`, this.subscription);
      return !unknown.Error.is(response)
        ? [true, this.t("Subscription was updated.")]
        : [false, this.t("Failed to update subscription.")];
    }));
  }
  render() {
    var _a;
    let result;
    switch (this.opened) {
      case "number":
        result = (index$1.h("ig-number-details", { number: this.subscription.number, identifier: this.subscription.id, onNumberUpdated: (e) => this.update(e.detail, "number"), name: "subscription" }));
        break;
      case "amount":
        result = (index$1.h("ig-items-list", { onChanged: (e) => this.update(e.detail, "items"), editable: true, class: typeof this.subscription.items == "number" ? "number" : "", items: this.subscription.items, currency: this.subscription.currency }));
        break;
      case "schedule":
        result = index$1.h("ig-schedule", { schedule: this.subscription.schedule });
        break;
      case "end":
        result = [
          index$1.h("label", null, this.t("End")),
          index$1.h("section", null, index$1.h("ig-display-edit", { deletable: false, name: this.t("End date"), onChanged: (e) => this.update(e.detail, "end"), value: (_a = this.subscription.end) !== null && _a !== void 0 ? _a : this.t("ongoing") }), index$1.h("smoothly-icon", { onClick: () => this.cancel(), name: "trash", color: "default", fill: "solid", toolTip: this.t("Cancel subscription") })),
        ];
        break;
      case "start":
        result = [
          index$1.h("label", null, this.t("Start")),
          index$1.h("ig-display-edit", { deletable: false, name: this.t("Start date"), onChanged: (e) => this.update(e.detail, "start"), value: this.subscription.start }),
        ];
        break;
      case "due":
        result = (index$1.h("ig-future-due-dates", { dates: index$3.Schedule.calculateDueDates(this.subscription.schedule, 5, this.subscription.start, this.subscription.end) }));
        break;
      default:
        return "";
    }
    return index$1.h("td", { colSpan: 8 }, result);
  }
  get element() { return index$1.getElement(this); }
};
IntergiroSubscriptionDetails.style = styleCss$1;

const sv = {
  daily: "daglig",
  weekly: "veckovis",
  monthly: "månadsvis",
  quarterly: "kvartalsvis",
  yearly: "årlig",
  ongoing: "pågående",
};

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

const styleCss = ".sc-ig-subscription-table-row-h{display:table-row}[hidden].sc-ig-subscription-table-row-h{display:none}.sc-ig-subscription-table-row-h:hover{border-top:1px solid rgb(var(--smoothly-medium-color));border-bottom:1px solid rgb(var(--smoothly-medium-color));-webkit-box-shadow:var(--smoothly-shadow);box-shadow:var(--smoothly-shadow)}.sc-ig-subscription-table-row-h>td.sc-ig-subscription-table-row>.openable.sc-ig-subscription-table-row{padding:.5em .3em;width:-webkit-max-content;width:-moz-max-content;width:max-content;min-width:3em;display:inline-block}.opened.sc-ig-subscription-table-row,.openable.sc-ig-subscription-table-row{cursor:pointer}.opened.sc-ig-subscription-table-row{border:solid 1px rgb(var(--smoothly-medium-shade));background-color:rgb(var(--smoothly-dark-shade));border-bottom:3px solid rgb(var(--smoothly-dark-shade));border-radius:0 0 2px 2px;margin-bottom:-2px}.sc-ig-subscription-table-row-h>td.sc-ig-subscription-table-row:first-of-type>.opened.sc-ig-subscription-table-row{border-left:none}";

const IntergiroSubscriptionTableRow = class {
  constructor(hostRef) {
    index$1.registerInstance(this, hostRef);
    this.columnClicked = index$1.createEvent(this, "columnClicked", 7);
    this.opened = "";
  }
  componentWillLoad() {
    this.t = create(this.element);
  }
  handleColumnClick(column) {
    this.opened = column;
    this.columnClicked.emit({ id: this.subscription.id, column });
  }
  render() {
    var _a;
    return [
      index$1.h("td", null, index$1.h("section", { class: "openable" + (this.opened == "number" ? " opened" : ""), onClick: () => this.handleColumnClick("number") }, (_a = this.subscription.number) !== null && _a !== void 0 ? _a : this.subscription.id)),
      index$1.h("td", null, index$1.h("smoothly-display-amount", { class: "openable" + (this.opened == "amount" ? " opened" : ""), onClick: () => this.handleColumnClick("amount"), amount: index$3.Item.amount(this.subscription.items), currency: this.subscription.currency })),
      index$1.h("td", null, index$1.h("section", { class: "openable" + (this.opened == "schedule" ? " opened" : ""), onClick: () => this.handleColumnClick("schedule") }, this.t(typeof this.subscription.schedule == "object"
        ? this.subscription.schedule.frequency
        : this.subscription.schedule))),
      index$1.h("td", null, index$1.h("section", { class: "openable" + (this.opened == "start" ? " opened" : ""), onClick: () => this.handleColumnClick("start") }, this.subscription.start)),
      index$1.h("td", null, index$1.h("section", { class: "openable" + (this.opened == "end" ? " opened" : ""), onClick: () => this.handleColumnClick("end") }, this.subscription.end ? this.subscription.end : this.t("ongoing"))),
      index$1.h("td", null, index$1.h("section", { class: "openable" + (this.opened == "due" ? " opened" : ""), onClick: () => this.handleColumnClick("due") }, index$3.Schedule.next(this.subscription.schedule, this.subscription.start))),
    ];
  }
  get element() { return index$1.getElement(this); }
};
IntergiroSubscriptionTableRow.style = styleCss;

exports.ig_address = IntergiroAddress;
exports.ig_address_display = IntergiroAddressDisplay;
exports.ig_address_input = IntergiroAddressInput;
exports.ig_addresses = IntergiroAddresses;
exports.ig_customer_limit = IntergiroCustomerLimit;
exports.ig_payment_methods = IntergiroPaymentMethods;
exports.ig_subscription_details = IntergiroSubscriptionDetails;
exports.ig_subscription_table_row = IntergiroSubscriptionTableRow;
