import { r as registerInstance, h, g as getElement, c as createEvent } from './index-08b73e9e.js';
import { d as dist } from './index-3cf720d3.js';
import './Item-f4cbd6f4.js';
import { A as Authorization } from './index-2d6441ea.js';
import './ok-c9833bf3.js';
import './Token-ba2c5d5c.js';
import { M as Merchant } from './index-c2c33860.js';
import './index-8e333ab5.js';
import { c as create$1 } from './index-f9034522.js';
import { d as dist$1 } from './index-a0a71287.js';
import './App-364e27cc.js';
import { N as Notice } from './Notice-668f9bc7.js';
import { h as hasValue } from './model-12e84827.js';
import { E as Error } from './unknown-97022c22.js';
import { M as Merchant$1, K as Key } from './index-3299c1c0.js';
import './Credentials-b84c0c5f.js';
import { I as IntergiroMonitor } from './index-abd4e34b.js';
import './_commonjsHelpers-9943807e.js';
import './index-1f953d81.js';
import './index-714bb39b.js';
import './index-063af7ee.js';
import './TextDecoder-357ac2ce.js';
import './index-f77ff597.js';
import './index-26d778c4.js';
import './Handler-40406565.js';

const styleCss$6 = ".sc-ig-merchant-account-table-h{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;width:100%;max-width:60em;margin:auto}[hidden].sc-ig-merchant-account-table-h{display:none}.sc-ig-merchant-account-table-h>table.sc-ig-merchant-account-table{width:100%;border:1px solid rgb(var(--smoothly-medium-color));background-color:rgb(var(--smoothly-default-color));margin-top:1em}.sc-ig-merchant-account-table-h>table.sc-ig-merchant-account-table>th.sc-ig-merchant-account-table{position:-webkit-sticky;position:sticky;width:5em;text-align:left;padding:0.2em 0.5em;text-transform:capitalize}.sc-ig-merchant-account-table-h>table.sc-ig-merchant-account-table>th.sc-ig-merchant-account-table:not(:first-of-type){text-transform:uppercase}.sc-ig-merchant-account-table-h>table.sc-ig-merchant-account-table tr.sc-ig-merchant-account-table{display:table-row}.sc-ig-merchant-account-table-h td.sc-ig-merchant-account-table{padding-left:.3em}tr.sc-ig-merchant-account-table>*.sc-ig-merchant-account-table{display:table-cell;text-align:left;padding:0.2em .5em;min-width:-webkit-min-content;min-width:-moz-min-content;min-width:min-content;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;text-transform:capitalize}";

const IntergiroMerchantAccountTable = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.accounts = [];
  }
  componentWillLoad() {
    this.t = create$1(this.element);
    this.getAccountList();
  }
  addAccount(account, currency) {
    var _a;
    this.accounts.push({
      currency: (_a = currency !== null && currency !== void 0 ? currency : this.currency) !== null && _a !== void 0 ? _a : "default",
      iban: typeof account == "string" ? account : "iban" in account ? account.iban : "-",
      bic: typeof account != "string" && "bic" in account ? account.bic : "-",
    });
  }
  getAccountList() {
    Merchant.Reconciliation.Account.is(this.account)
      ? this.addAccount(this.account)
      : Object.entries(this.account).forEach(a => (dist.Currency.is(a[0]) || a[0] == "default") &&
        Merchant.Reconciliation.Account.is(a[1]) &&
        this.addAccount(a[1], a[0]));
  }
  render() {
    return [
      h("table", null, h("th", { color: "light" }, this.t("currency")), h("th", { color: "light" }, this.t("iban")), h("th", { color: "light" }, this.t("bic")), this.accounts.map(account => {
        var _a;
        return (h("tr", null, h("td", null, account.currency), h("td", null, account.iban), h("td", null, (_a = account.bic) !== null && _a !== void 0 ? _a : "-")));
      })),
    ];
  }
  get element() { return getElement(this); }
};
IntergiroMerchantAccountTable.style = styleCss$6;

const styleCss$5 = ".sc-ig-merchant-fee-table-h{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;width:100%;max-width:60em;margin:auto}[hidden].sc-ig-merchant-fee-table-h{display:none}.sc-ig-merchant-fee-table-h>table.sc-ig-merchant-fee-table{width:100%;border:1px solid rgb(var(--smoothly-medium-color));background-color:rgb(var(--smoothly-default-color));margin-top:1em}.sc-ig-merchant-fee-table-h>table.sc-ig-merchant-fee-table>th.sc-ig-merchant-fee-table{position:-webkit-sticky;position:sticky;width:5em;text-align:left;padding:0.2em 0.5em;text-transform:capitalize}.sc-ig-merchant-fee-table-h>table.sc-ig-merchant-fee-table tr.sc-ig-merchant-fee-table{display:table-row}.sc-ig-merchant-fee-table-h td.sc-ig-merchant-fee-table{padding-left:.3em}tr.sc-ig-merchant-fee-table>*.sc-ig-merchant-fee-table{display:table-cell;text-align:left;padding:0.2em .5em;min-width:-webkit-min-content;min-width:-moz-min-content;min-width:min-content;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;text-transform:capitalize}";

const IntergiroMerchantFeeTable = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
  }
  componentWillLoad() {
    this.t = create$1(this.element);
    this.batchFees();
  }
  getCountryName(value) {
    var _a;
    return value == "eea"
      ? this.t("european economic area")
      : dist.CountryCode.Alpha2.is(value)
        ? dist.CountryCode.Name.from((_a = dist$1.getLanguage(this.element)) !== null && _a !== void 0 ? _a : "en", value)
        : this.t("default");
  }
  batchFees() {
    var _a, _b, _c, _d, _e, _f;
    const fees = this.fees.filter(f => f[0] == "eea" || f[0] == "other" || dist.CountryCode.Alpha2.is(f[0]));
    this.values = [];
    for (const fee of fees) {
      const schemes = typeof fee[1] == "object" ? Object.entries(fee[1]) : [];
      for (const scheme of schemes) {
        const fees = scheme[1] && Object.entries(scheme[1]);
        const debitFee = fees && fees.find(s => s[0] == "debit");
        const debit = debitFee && Object.values(debitFee[1]);
        const creditFee = fees && fees.find(s => s[0] == "credit");
        const credit = creditFee && Object.values(creditFee[1]);
        const percentage = fees && ((_a = fees.find(s => s[0] == "percentage")) === null || _a === void 0 ? void 0 : _a[1]);
        const minimum = fees && ((_b = fees.find(s => s[0] == "minimum")) === null || _b === void 0 ? void 0 : _b[1]);
        const value = {
          country: this.getCountryName(fee[0]),
          scheme: [scheme[0]],
          debit: { percentage: (_c = debit === null || debit === void 0 ? void 0 : debit[0]) !== null && _c !== void 0 ? _c : percentage, minimum: (_d = debit === null || debit === void 0 ? void 0 : debit[1]) !== null && _d !== void 0 ? _d : minimum },
          credit: { percentage: (_e = credit === null || credit === void 0 ? void 0 : credit[0]) !== null && _e !== void 0 ? _e : percentage, minimum: (_f = credit === null || credit === void 0 ? void 0 : credit[1]) !== null && _f !== void 0 ? _f : minimum },
        };
        let existingFee;
        if ((existingFee = this.values.find(v => v.country == value.country &&
          JSON.stringify(v.credit) == JSON.stringify(value.credit) &&
          JSON.stringify(v.debit) == JSON.stringify(value.debit))))
          existingFee.scheme = existingFee.scheme.concat(value.scheme);
        else
          this.values.push(value);
      }
    }
  }
  render() {
    return [
      this.values.length > 0 && (h("table", null, h("th", { color: "light" }, this.t("Country")), h("th", { color: "light" }, this.t("Scheme")), h("th", { color: "light" }, this.t("Debit")), h("th", { color: "light" }, this.t("Credit")), this.values.map(f => (h("tr", null, h("td", null, f.country), h("td", null, f.scheme.map((s, i) => s + (i != f.scheme.length - 1 ? ", " : ""))), h("td", null, f.debit.percentage + " %", f.debit.minimum ? " Min " + f.debit.minimum + " " + this.currency : ""), h("td", null, f.credit.percentage + " %", f.credit.minimum ? " Min " + f.credit.minimum + " " + this.currency : "")))))),
    ];
  }
  get element() { return getElement(this); }
  static get watchers() { return {
    "fees": ["batchFees"]
  }; }
};
IntergiroMerchantFeeTable.style = styleCss$5;

const styleCss$4 = ".sc-ig-merchant-information-h{display:-ms-flexbox;display:flex;-ms-flex-pack:start;justify-content:flex-start;padding:1em;padding-left:4.5em}.sc-ig-merchant-information-h>section.sc-ig-merchant-information>*.sc-ig-merchant-information:first-child{font-weight:bold;text-transform:capitalize}smoothly-display.sc-ig-merchant-information{text-align:left;margin:0;padding:.1em}.sc-ig-merchant-information-h>section.sc-ig-merchant-information{width:50%}";

const IntergiroMerchantInformation = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
  }
  componentWillLoad() {
    this.t = create$1(this.element);
  }
  render() {
    return [
      h("section", null, h("smoothly-display", null, this.t("name")), h("smoothly-display", null, this.merchant.name)),
      this.merchant.descriptor && (h("section", null, h("smoothly-display", null, this.t("descriptor")), h("smoothly-display", null, this.merchant.descriptor))),
      h("section", null, h("smoothly-display", null, this.t("country")), h("smoothly-display", null, this.merchant.country
        .toUpperCase()
        .replace(/./g, char => String.fromCodePoint(char.charCodeAt(0) + 127397)) +
        " " +
        this.merchant.country)),
      h("section", null, h("smoothly-display", null, this.t("category code")), h("smoothly-display", null, this.merchant.categoryCode)),
    ];
  }
  get element() { return getElement(this); }
};
IntergiroMerchantInformation.style = styleCss$4;

const sv = {
  " by ": " av ",
  Acquirer: "Inlösare",
  Merchant: "Handlare",
  Other: "Annan",
  rules: "regler",
  "Edit rule": "Redigera regel",
  "Rule by": "Regel av",
  "Enter rule": "Ange regel",
  "Invalid input": "Ogiltigt värde",
  "Add rule": "Lägg till regel",
  Save: "Spara",
  Cancel: "Avbryt",
  Edit: "Redigera",
  Delete: "Ta bort",
  "Deleting rule...": "Tar bort regel...",
  "Successfully deleted rule.": "Regel borttagen.",
  "Failed to update rule.": "Misslyckades med att ta bort regel.",
  "Editing rule...": "Redigerar regel...",
  "Successfully edited rule.": "Regel redigerad.",
  "Failed to edit rule.": "Misslyckades med att redigera regel.",
  "Adding rule...": "Lägger till regel...",
  "Successfully added rule.": "Regel tillagd.",
  "Failed to add rules.": "Misslyckades med att lägga till regel.",
  acquirer: "inlösare",
};

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

const styleCss$3 = ".sc-ig-merchant-rule-h{width:100%;border-bottom:1px solid rgb(var(--smoothly-default-color))}[mode=\"display\"].sc-ig-merchant-rule-h{margin-bottom:.5em;padding-bottom:.1em}.sc-ig-merchant-rule-h:hover>smoothly-popup.sc-ig-merchant-rule{visibility:visible}.sc-ig-merchant-rule-h>smoothly-popup.sc-ig-merchant-rule{display:block;margin:0;float:right;visibility:hidden}smoothly-icon.sc-ig-merchant-rule{cursor:pointer}[mode=\"display\"].sc-ig-merchant-rule-h:hover{border-bottom-color:rgba(0, 0, 0, 0.1)}ig-merchant-rule-input.sc-ig-merchant-rule{margin-bottom:.5em}";

const IntergiroMerchantRule = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.delete = createEvent(this, "delete", 7);
    this.edit = createEvent(this, "edit", 7);
    this.mode = "display";
    this.editable = true;
  }
  componentWillLoad() {
    this.t = create(this.element);
  }
  handleCancel(event) {
    this.mode = "display";
    event.stopPropagation();
  }
  handleRuleChanged(event) {
    this.edit.emit({ key: this.type, oldValue: this.value, newValue: event === null || event === void 0 ? void 0 : event.detail.value });
    this.value = event.detail.value;
    this.mode = "display";
    event === null || event === void 0 ? void 0 : event.stopPropagation();
  }
  render() {
    var _a;
    const rule = this.value ? Merchant.Rule.parse(this.value) : undefined;
    return (this.value &&
      this.value.length > 0 && [
      this.mode == "display" ? ([
        this.editable && (h("smoothly-popup", null, h("smoothly-icon", { name: "ellipsis-vertical-outline", size: "small" }), h("div", { color: "light", slot: "popup" }, h("smoothly-icon", { size: "small", name: "pencil-outline", toolTip: this.t("Edit"), onClick: () => (this.mode = "input") }), h("smoothly-icon", { size: "small", name: "trash", toolTip: this.t("Delete"), onClick: () => this.delete.emit({ key: this.type, value: this.value }) })))),
        h("smoothly-display", { type: "text", value: this.value }),
      ]) : (h("ig-merchant-rule-input", { action: rule === null || rule === void 0 ? void 0 : rule.action, event: rule === null || rule === void 0 ? void 0 : rule.operation, value: (_a = rule === null || rule === void 0 ? void 0 : rule.condition) === null || _a === void 0 ? void 0 : _a.toString() })),
    ]);
  }
  get element() { return getElement(this); }
};
IntergiroMerchantRule.style = styleCss$3;

const styleCss$2 = ".sc-ig-merchant-rule-input-h{display:block;width:100%}[hidden].sc-ig-merchant-rule-input-h{display:none}.sc-ig-merchant-rule-input-h>form.sc-ig-merchant-rule-input{display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-align:center;align-items:center;border-collapse:collapse}.sc-ig-merchant-rule-input-h>form.sc-ig-merchant-rule-input>smoothly-input.sc-ig-merchant-rule-input,.sc-ig-merchant-rule-input-h>form.sc-ig-merchant-rule-input>smoothly-select.sc-ig-merchant-rule-input{border-collapse:collapse;background-color:rgb(var(--smoothly-default-color));border:solid 1px rgb(var(--smoothly-medium-shade))}.sc-ig-merchant-rule-input-h>form.sc-ig-merchant-rule-input>smoothly-input.sc-ig-merchant-rule-input:last-of-type{min-width:25em;-ms-flex-positive:40;flex-grow:40;-ms-flex-negative:2;flex-shrink:2;border-left:none}.sc-ig-merchant-rule-input-h>form.sc-ig-merchant-rule-input>smoothly-select.sc-ig-merchant-rule-input{-ms-flex-positive:1;flex-grow:1;-ms-flex-negative:2;flex-shrink:2;display:grid;cursor:pointer;padding:0.3em 0}.sc-ig-merchant-rule-input-h>form.sc-ig-merchant-rule-input>section.sc-ig-merchant-rule-input{width:100%;border:solid 1px rgb(var(--smoothly-medium-shade));background-color:rgb(var(--smoothly-default-color));display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;margin:0.2em 0 0.5em 0;min-height:2em}.sc-ig-merchant-rule-input-h>form.sc-ig-merchant-rule-input>section.sc-ig-merchant-rule-input>ig-autocomplete-input.sc-ig-merchant-rule-input{width:calc(100% - 80px);display:inline-block;margin-left:0.5em;margin-top:-0.4em;margin-bottom:0.4em}.sc-ig-merchant-rule-input-h>form.sc-ig-merchant-rule-input>section.sc-ig-merchant-rule-input>smoothly-submit.sc-ig-merchant-rule-input{z-index:1}";

const IntergiroMerchantRuleInput = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.updated = createEvent(this, "updated", 7);
    this.cancel = createEvent(this, "cancel", 7);
    this.notice = createEvent(this, "notice", 7);
    this.add = false;
    this.action = "reject";
    this.event = "authorization";
    this.textEntered = false;
    this.actions = ["reject"];
    this.events = ["authorization", "refund", "capture", "void"];
  }
  componentWillLoad() {
    this.t = create(this.element);
    this.setType();
  }
  setType() {
    var _a;
    if (!this.type)
      this.type = ((_a = this.values) === null || _a === void 0 ? void 0 : _a.includes("master")) ? "acquirer" : "agent";
  }
  onSubmit(e) {
    var _a;
    const key = (_a = e.detail.key) !== null && _a !== void 0 ? _a : (this.type == "acquirer" ? "master" : this.type);
    const rule = this.action + " " + this.event + " if " + this.ruleElement.value;
    if (key && Merchant.Rule.parse(rule)) {
      this.updated.emit({
        key,
        value: rule,
      });
      this.reset();
    }
    else
      this.notice.emit(Notice.failed(this.t("Invalid input")));
  }
  onCancel(e) {
    this.cancel.emit(e);
    this.reset();
  }
  onSelectionChanged(e) {
    if (e.detail.identifier == "type")
      this.type = e.detail.value;
    else if (e.detail.identifier == "action")
      this.action = e.detail.value;
    else if (e.detail.identifier == "event")
      this.event = e.detail.value;
    if (!this.add)
      this.textEntered = true;
  }
  checkTextEntered() {
    if (hasValue(this.ruleElement))
      this.textEntered = this.ruleElement.value != "";
  }
  reset() {
    if (this.ruleElement && hasValue(this.ruleElement))
      this.ruleElement.value = "";
    this.textEntered = false;
    this.setType();
  }
  render() {
    var _a, _b, _c;
    return (h("form", null, this.add && [
      h("smoothly-select", { identifier: "type", background: "transparent" }, (_a = this.values) === null || _a === void 0 ? void 0 : _a.map(v => (h("option", { value: v, selected: this.type == v }, this.t(v == "master" ? "Acquirer" : v.charAt(0).toUpperCase() + v.slice(1)))))),
      this.type == "other" && (h("smoothly-input", { id: "type", name: "key" }, this.t("Rule by"))),
    ], h("section", null, h("smoothly-select", { identifier: "action", background: "transparent" }, (_b = this.actions) === null || _b === void 0 ? void 0 : _b.map(a => (h("option", { value: a, selected: this.action == a }, a)))), h("span", null, "-"), h("smoothly-select", { identifier: "event", background: "transparent" }, (_c = this.events) === null || _c === void 0 ? void 0 : _c.map(e => (h("option", { value: e, selected: this.event == e, id: this.event == e ? "selected" : "" }, e)))), h("span", null, "if"), h("ig-autocomplete-input", { id: "rule", name: "value", template: Authorization.template, value: this.value, ref: (element) => (this.ruleElement = element), onKeyDown: this.checkTextEntered.bind(this) }), h("smoothly-submit", { fill: "clear", prevent: true, onSubmit: (e) => this.onSubmit(e), style: { visibility: this.textEntered ? "visible" : "hidden" } }, h("smoothly-icon", { toolTip: this.t("Add rule"), name: "checkmark-circle", size: "small" })), h("smoothly-submit", { fill: "clear", prevent: true, onClick: (e) => this.onCancel(e) }, h("smoothly-icon", { toolTip: this.t("Cancel"), size: "small", name: "close-circle" })))));
  }
  get element() { return getElement(this); }
};
IntergiroMerchantRuleInput.style = styleCss$2;

const styleCss$1 = ".sc-ig-merchant-rules-h{display:block}.sc-ig-merchant-rules-h>section.sc-ig-merchant-rules{padding-bottom:1em;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:start;align-items:flex-start;-ms-flex-positive:1;flex-grow:1;text-overflow:ellipsis;background-color:rgb(var(--smoothly-default-color));border:solid 1px rgb(var(--smoothly-medium-shade))}.sc-ig-merchant-rules-h>section.sc-ig-merchant-rules>label.sc-ig-merchant-rules{font-weight:bold;padding:0.3em 0.5em;width:100%;margin-left:-0.5em}.sc-ig-merchant-rules-h>section.sc-ig-merchant-rules{padding:0 0.5em}.sc-ig-merchant-rules-h>section.sc-ig-merchant-rules>label.sc-ig-merchant-rules::first-letter{text-transform:capitalize}.sc-ig-merchant-rules-h>section.sc-ig-merchant-rules smoothly-icon.sc-ig-merchant-rules{cursor:pointer;float:right}[state=\"add\"].sc-ig-merchant-rules-h>section.sc-ig-merchant-rules smoothly-icon.sc-ig-merchant-rules{visibility:hidden}[state=\"view\"].sc-ig-merchant-rules-h>ig-merchant-rule-input.sc-ig-merchant-rules{display:none}[state=\"add\"].sc-ig-merchant-rules-h>ig-merchant-rule-input.sc-ig-merchant-rules{display:block;margin-bottom:0.5em}";

const IntergiroMerchantRules = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.notice = createEvent(this, "notice", 7);
    this.merchantUpdated = createEvent(this, "merchantUpdated", 7);
    this.state = "view";
    this.master = false;
  }
  async componentWillLoad() {
    var _a;
    this.t = create(this.element);
    const user = (_a = IntergiroMonitor.client) === null || _a === void 0 ? void 0 : _a.me.user;
    if (user && Merchant$1.is(user.merchant)) {
      const key = await Key.unpack(user.merchant.key.private, "agent");
      this.master = Key.is(key) && key.sub == "master";
    }
  }
  handleCanceled() {
    this.state = "view";
  }
  async updateMerchant(rule, message) {
    this.notice.emit(Notice.execute(this.t(message.execute), async () => {
      var _a;
      let result;
      const response = await ((_a = IntergiroMonitor.client) === null || _a === void 0 ? void 0 : _a.merchant.connection.patch(`merchant/${this.merchant.id}/rule`, rule));
      if (response && !Error.is(response)) {
        result = [true, this.t(message.success)];
        this.state = "view";
        this.merchantUpdated.emit();
        this.merchant = Object.assign({}, this.merchant);
      }
      else
        result = [false, this.t(message.fail)];
      return result;
    }));
  }
  async handleDeleted(event) {
    var _a;
    const rules = Object.assign({}, this.merchant.rules);
    rules[event.detail.key] = (_a = rules[event.detail.key]) === null || _a === void 0 ? void 0 : _a.filter(v => v != event.detail.value);
    this.merchant.rules[event.detail.key] = rules[event.detail.key];
    this.updateMerchant({ [event.detail.key]: rules[event.detail.key] }, { execute: "Deleting rule...", success: "Successfully deleted rule.", fail: "Failed to delete rule." });
    event === null || event === void 0 ? void 0 : event.stopPropagation();
  }
  async handleEdit(event) {
    var _a;
    const rules = Object.assign({}, this.merchant.rules);
    rules[event.detail.key] = (_a = rules[event.detail.key]) === null || _a === void 0 ? void 0 : _a.map(v => v == event.detail.oldValue ? (v = event.detail.newValue) : v);
    this.updateMerchant({ [event.detail.key]: rules[event.detail.key] }, { execute: "Editing rule...", success: "Successfully edited rule.", fail: "Failed to edit rule." });
    event === null || event === void 0 ? void 0 : event.stopPropagation();
  }
  handleAdd(event) {
    var _a;
    const key = event === null || event === void 0 ? void 0 : event.detail.key;
    const value = event === null || event === void 0 ? void 0 : event.detail.value;
    this.merchant.rules[key] ? (_a = this.merchant.rules[key]) === null || _a === void 0 ? void 0 : _a.push(value) : (this.merchant.rules[key] = [value]);
    this.updateMerchant({ [key]: this.merchant.rules[key] }, { execute: "Adding rule...", success: "Successfully added rule.", fail: "Failed to add rule." });
    event === null || event === void 0 ? void 0 : event.stopPropagation();
  }
  render() {
    const values = ["merchant", "agent", "other", ...Object.keys(this.merchant.rules)].reduce((r, v) => (r.includes(v) ? r : [...r, v]), []);
    if (!this.master)
      values.splice(values.indexOf("master"), 1);
    if (this.audience == "private")
      values.splice(values.indexOf("agent"), 1);
    const rules = Object.entries(this.merchant.rules);
    return [
      h("ig-merchant-rule-input", { add: true, values: values }),
      rules.map((r, index) => {
        var _a;
        return (r[1] && [
          h("section", null, h("label", { color: "light" }, this.t("rules") +
            (r[1].length > 0
              ? this.t(" by ") +
                this.t(r[0] == "master" ? this.t("acquirer") : r[0]) +
                " (" +
                this.merchant.currency +
                ")"
              : ""), index == 0 && (h("smoothly-icon", { name: "add", toolTip: this.t("Add rule"), size: "medium", fill: "clear", color: "dark", onClick: () => (this.state = "add") }))), (_a = r[1]) === null || _a === void 0 ? void 0 :
            _a.map((rule, index) => [
              h("ig-merchant-rule", { style: index == 0 ? { "margin-top": "0.5em" } : {}, editable: this.master || index != 0, type: r[0], value: rule }),
            ])),
        ]);
      }),
    ];
  }
  get element() { return getElement(this); }
};
IntergiroMerchantRules.style = styleCss$1;

const styleCss = ".sc-ig-merchant-settlement-h{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}[view=\"multiple\"].sc-ig-merchant-settlement-h{padding:1em;padding-left:4.5em}[view=\"single\"].sc-ig-merchant-settlement-h>label.sc-ig-merchant-settlement{font-weight:bold;padding:.5em 0.5em;width:100%;margin-bottom:.5em;text-transform:capitalize}[view=\"single\"].sc-ig-merchant-settlement-h{border:1px solid rgb(var(--smoothly-medium-color));padding-bottom:1em;overflow:hidden;margin-top:2em;margin-bottom:2em}.sc-ig-merchant-settlement-h>main.sc-ig-merchant-settlement{display:-ms-flexbox;display:flex;-ms-flex-item-align:center;align-self:center;padding-bottom:1em;width:60em;margin:0}smoothly-display.sc-ig-merchant-settlement{text-align:left;margin:0;width:-webkit-min-content;width:-moz-min-content;width:min-content;white-space:nowrap}.sc-ig-merchant-settlement-h>main.sc-ig-merchant-settlement>section.sc-ig-merchant-settlement{width:30%}.sc-ig-merchant-settlement-h>main.sc-ig-merchant-settlement>section.sc-ig-merchant-settlement>*.sc-ig-merchant-settlement:first-child{font-weight:bold;padding:.1em}.sc-ig-merchant-settlement-h>main.sc-ig-merchant-settlement>section.sc-ig-merchant-settlement>*.sc-ig-merchant-settlement::first-letter{text-transform:capitalize}";

const IntergiroMerchantsettlement = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.view = "multiple";
    this.operation = ["authorization", "capture", "refund", "void", "all"];
  }
  componentWillLoad() {
    this.t = create$1(this.element);
  }
  render() {
    const settlement = this.merchant.reconciliation;
    const fees = settlement.fees && Object.entries(settlement.fees);
    return [
      this.view == "single" && h("label", { color: "light" }, this.t("settlement information")),
      h("main", null, settlement.costPlus && (h("section", null, h("smoothly-display", null, this.t("cost plus")), h("smoothly-display", null, this.t("yes")))), settlement.reserves && (h("section", null, h("smoothly-display", null, this.t("reserves")), h("smoothly-display", null, settlement.reserves.percentage +
        "%" +
        (settlement.reserves.days ? " " + this.t("for") + " " + settlement.reserves.days + " " + "days." : "")))), this.operation.map(o => {
        const fee = fees.find(f => f[0] == o);
        return (fee && [
          h("section", null, h("smoothly-display", null, this.t(o)), h("smoothly-display-amount", { amount: typeof fee[1] == "number" ? fee[1] : undefined, currency: this.merchant.currency })),
        ]);
      })),
      h("ig-merchant-account-table", { account: this.merchant.reconciliation.account, currency: this.merchant.currency }),
      h("ig-merchant-fee-table", { currency: this.merchant.currency, fees: fees }),
    ];
  }
  get element() { return getElement(this); }
};
IntergiroMerchantsettlement.style = styleCss;

export { IntergiroMerchantAccountTable as ig_merchant_account_table, IntergiroMerchantFeeTable as ig_merchant_fee_table, IntergiroMerchantInformation as ig_merchant_information, IntergiroMerchantRule as ig_merchant_rule, IntergiroMerchantRuleInput as ig_merchant_rule_input, IntergiroMerchantRules as ig_merchant_rules, IntergiroMerchantsettlement as ig_merchant_settlement };
