'use strict';

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

const index$1 = require('./index-0b1e2673.js');
require('./App-1647a125.js');
require('./_commonjsHelpers-937cd5b3.js');
const index$2 = require('./index-1a9e1965.js');
require('./index-451ca284.js');
const index$3 = require('./index-2eb96242.js');
const index = require('./index-36cf3884.js');
const index$4 = require('./index-061d0ccd.js');

const sv = {
  "Failed to update customer information.": "Kunde inte uppdatera kundinformation.",
  "Updated customer information.": "Kundinformation uppdaterad.",
  "Updating customer information...": "Uppdaterar kundinformation...",
};

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

const styleCss = ".sc-payfunc-account-details-h{display:table-row}.sc-payfunc-account-details-h>td.sc-payfunc-account-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:0.5em}payfunc-subscription-table.sc-payfunc-account-details,payfunc-orders-table.sc-payfunc-account-details{margin:auto;width:90%;border:solid 1px rgb(var(--smoothly-medium-shade))}payfunc-account-customer.sc-payfunc-account-details{max-width:70em;margin:auto;padding:1em;padding-left:4.5em}payfunc-account-balance.sc-payfunc-account-details{width:75%;margin:auto}";

const PayfuncAccountDetails = class {
  constructor(hostRef) {
    index$1.registerInstance(this, hostRef);
    this.notice = index$1.createEvent(this, "notice", 7);
    this.updateAccounts = index$1.createEvent(this, "updateAccounts", 7);
    this.opened = "";
  }
  componentWillLoad() {
    this.t = create(this.element);
  }
  async updateCustomer(event) {
    this.notice.emit(index$2.Notice.execute(this.t("Updating customer information..."), async () => {
      let result;
      this.account.customer = event.detail;
      const response = await index$3.Connection.put(`account/${this.account.id}/customer`, this.account.customer);
      if (index$4.dist.Error.is(response))
        result = [false, this.t("Failed to update customer information.")];
      else {
        this.updateAccounts.emit();
        result = [true, this.t("Updated customer information.")];
      }
      return result;
    }));
  }
  render() {
    let result;
    switch (this.opened) {
      case "number":
        result = (index$1.h("payfunc-number-details", { number: this.account.number, identifier: this.account.id, name: "account" }));
        break;
      case "customer":
        result = index$1.h("payfunc-account-customer", { account: this.account });
        break;
      case "order":
        result = index$1.h("payfunc-orders-table", { orders: this.orders, display: true, receipt: this.whitelist });
        break;
      case "subscription":
        result = (index$1.h("payfunc-subscription-table", { subscriptions: this.account.subscription, account: this.account }));
        break;
      case "method":
        result = index$1.h("payfunc-account-method", { account: this.account });
        break;
      case "balance":
        result = index$1.h("payfunc-account-balance", { account: this.account, orders: this.orders });
        break;
      default:
        return "";
    }
    return index$1.h("td", { colSpan: 9 }, result);
  }
  get element() { return index$1.getElement(this); }
};
PayfuncAccountDetails.style = styleCss;

exports.payfunc_account_details = PayfuncAccountDetails;
