'use strict';

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

const index$1 = require('./index-140bcbcd.js');
const index$2 = require('./index-3b10efe6.js');
const index = require('./index-d3079b93.js');
require('./_commonjsHelpers-537d719a.js');

const sv = {
  "Top up balance": "Fyll på saldo",
  Cancel: "Avbryt",
  Amount: "Summa",
  "Equalize balance to zero.": "Justera saldot till noll.",
};

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

const styleCss = ".sc-ig-balance-add-h{display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;min-width:15em}[hidden].sc-ig-balance-add-h{display:none}.sc-ig-balance-add-h>form.sc-ig-balance-add>section.sc-ig-balance-add{display:-ms-flexbox;display:flex;width:100%;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center;max-width:15em}.sc-ig-balance-add-h>form.sc-ig-balance-add>section.sc-ig-balance-add:last-of-type{margin-top:.5em}.sc-ig-balance-add-h>form.sc-ig-balance-add>section.sc-ig-balance-add>smoothly-display.sc-ig-balance-add{font-size:xx-large}.sc-ig-balance-add-h>form.sc-ig-balance-add>section.sc-ig-balance-add>smoothly-icon.sc-ig-balance-add{cursor:pointer;padding-left:1em}.sc-ig-balance-add-h>form.sc-ig-balance-add>section.sc-ig-balance-add>smoothly-input.sc-ig-balance-add{border:1px solid rgb(var(--smoothly-medium-color))}.sc-ig-balance-add-h>form.sc-ig-balance-add>section.sc-ig-balance-add>smoothly-submit.sc-ig-balance-add smoothly-icon.sc-ig-balance-add{margin-right:-.4em}.sc-ig-balance-add-h>form.sc-ig-balance-add>section.sc-ig-balance-add>smoothly-trigger.sc-ig-balance-add{padding-left:1em;margin-right:-1em}smoothly-submit.sc-ig-balance-add,smoothly-trigger.sc-ig-balance-add{border:none}";

const IntergiroBalanceAdd = class {
  constructor(hostRef) {
    index$1.registerInstance(this, hostRef);
    this.addFunds = index$1.createEvent(this, "addFunds", 7);
    this.opened = false;
  }
  componentWillLoad() {
    this.t = create(this.element);
  }
  async submit(event) {
    const amount = index$2.dist.parse(event.detail.price, "price", this.customer.currency);
    const order = {
      number: "Manual balance charge.",
      items: {
        name: "Manual balance charge.",
        price: amount,
      },
      currency: this.customer.currency,
      payment: { type: "customer", charge: "balance" },
      customer: this.customer.id,
    };
    this.addFunds.emit(order);
    this.opened = false;
    const form = document.getElementsByTagName("form")[0];
    form.reset();
  }
  render() {
    return [
      index$1.h("form", null, index$1.h("section", null, index$1.h("smoothly-display", { type: "price", value: this.customer.total, currency: this.customer.currency }), this.customer.balance.length > 0 && this.customer.total < 0 ? (index$1.h("smoothly-trigger", { style: { display: this.opened ? "" : "none" } }, index$1.h("smoothly-icon", { toolTip: this.t("Equalize balance to zero."), name: "arrow-up-circle-outline", size: "small", color: "medium", fill: "clear" }))) : ([]), index$1.h("smoothly-icon", { toolTip: this.opened ? this.t("Cancel") : this.t("Top up balance"), color: this.opened ? "medium" : "default", fill: this.opened ? "clear" : "solid", name: this.opened ? "close" : "add-circle", onClick: () => (this.opened = !this.opened) })), index$1.h("section", { style: { display: this.opened ? "" : "none" } }, index$1.h("smoothly-input", { name: "price", type: "price", currency: this.customer.currency }, this.t("Amount")), index$1.h("smoothly-submit", { prevent: true, onSubmit: (event) => this.submit(event) }, index$1.h("smoothly-icon", { toolTip: this.t("Top up balance"), class: "add", color: "success", fill: "clear", name: "add-circle" })))),
    ];
  }
  get element() { return index$1.getElement(this); }
};
IntergiroBalanceAdd.style = styleCss;

exports.ig_balance_add = IntergiroBalanceAdd;
