import { r as registerInstance, c as createEvent, h, g as getElement } from './index-08b73e9e.js';
import { E as Error } from './unknown-97022c22.js';
import './App-364e27cc.js';
import './Token-ba2c5d5c.js';
import { N as Notice } from './Notice-668f9bc7.js';
import { H as Handler } from './Handler-4f7b3dc8.js';
import { d as dist } from './index-a0a71287.js';
import './index-ff7475d6.js';
import './Item-f4cbd6f4.js';
import './_commonjsHelpers-9943807e.js';
import './index-1f953d81.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 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) {
    registerInstance(this, hostRef);
    this.notice = createEvent(this, "notice", 7);
  }
  componentWillLoad() {
    this.t = create(this.element);
  }
  async retry() {
    this.notice.emit(Notice.execute(this.t("Retrying payment."), async () => {
      let result;
      const response = await Handler.client.customer.retryPayment();
      if (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 [
      h("smoothly-icon", { name: "warning", size: "large" }),
      h("h3", null, this.t("Your payment was declined.")),
      h("p", null, h("b", null, this.t("Please confirm that there are sufficient funds in your account or update your payment method.")), h("br", null), this.t("To update your payment method, add a new card or change your default card by reordering your payment methods."), h("br", null), " ", this.t("Make sure that your preferred card is at the top.")),
      h("smoothly-submit", { prevent: true, color: "dark", onSubmit: () => {
          this.retry();
        } }, this.t("Retry Payment")),
    ];
  }
  get element() { return getElement(this); }
};
CustomerWarning.style = styleCss;

export { CustomerWarning as customer_warning };
