'use strict';

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

const index$1 = require('./index-140bcbcd.js');
const unknown = require('./unknown-38d3748c.js');
require('./App-0b3e3f31.js');
require('./Token-8c5ba5d9.js');
const Notice = require('./Notice-e970b490.js');
const Handler = require('./Handler-51fdca63.js');
const index = require('./index-d3079b93.js');
require('./index-dc498c54.js');
require('./Item-00ce8c24.js');
require('./_commonjsHelpers-537d719a.js');
require('./index-09251373.js');

const sv = {
  "Retrying payment.": "Försöker betalning igen.",
  "Your payment was declined.": "Din betalning misslyckades.",
  "Payment succeeded.": "Betalningen lyckades.",
  "Please confirm that there are sufficient funds in your account or update your payment method.": "Bekräfta att det finns tillräckligt med pengar på ditt konto eller uppdatera din betalningsmetod.",
  "To update your payment method, add a new card or change your default card by reordering your payment methods.": "För att uppdatera din betalningsmetod, lägg till ett nytt kort eller ändra ditt standardkort genom att ändra ordning på dina betalningsmetoder.",
  "Make sure that your preferred card is at the top.": "Se till att kortet du vill använda är högst upp.",
  "Retry Payment": "Försök igen",
};

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

const styleCss = ".sc-customer-warning-h{display:-ms-flexbox;display:flex;-ms-flex-line-pack:center;align-content:center;max-width:90em;min-height:7em;border-radius:1em;margin-bottom:1em;margin-top:1em;padding:0.5em;padding-right:2em}smoothly-icon.sc-customer-warning{margin-top:0.5em;margin-left:2em}h3.sc-customer-warning{margin-left:0.5em;-ms-flex-negative:0;flex-shrink:0}p.sc-customer-warning{width:80%;margin-top:3.4em;margin-left:-16.2em;-ms-flex-positive:2;flex-grow:2}smoothly-submit.sc-customer-warning{height:-webkit-max-content;height:-moz-max-content;height:max-content;padding:0.3em;border-radius:0.5em;text-transform:uppercase;width:8.5em;text-align:center;margin-top:3em;-ms-flex-item-align:baseline;align-self:baseline;cursor:pointer;font-size:1em}";

const CustomerWarning = class {
  constructor(hostRef) {
    index$1.registerInstance(this, hostRef);
    this.notice = index$1.createEvent(this, "notice", 7);
  }
  componentWillLoad() {
    this.t = create(this.element);
  }
  async retry() {
    this.notice.emit(Notice.Notice.execute(this.t("Retrying payment."), async () => {
      let result;
      const response = await Handler.Handler.client.customer.retryPayment();
      if (unknown.Error.is(response) || typeof response == "string" || response.errors > 0 || response.unpaid > 0)
        result = [false, this.t("Your payment was declined.")];
      else
        result = [true, this.t("Payment succeeded.")];
      return result;
    }));
  }
  render() {
    return [
      index$1.h("smoothly-icon", { name: "warning", size: "large" }),
      index$1.h("h3", null, this.t("Your payment was declined.")),
      index$1.h("p", null, index$1.h("b", null, this.t("Please confirm that there are sufficient funds in your account or update your payment method.")), index$1.h("br", null), this.t("To update your payment method, add a new card or change your default card by reordering your payment methods."), index$1.h("br", null), " ", this.t("Make sure that your preferred card is at the top.")),
      index$1.h("smoothly-submit", { prevent: true, color: "dark", onSubmit: () => {
          this.retry();
        } }, this.t("Retry Payment")),
    ];
  }
  get element() { return index$1.getElement(this); }
};
CustomerWarning.style = styleCss;

exports.customer_warning = CustomerWarning;
