import { Component, Element, h, Prop, State } from "@stencil/core";
import { Currency } from "isoly";
import { Merchant } from "@payfunc/model-acquirer";
import * as translation from "../../../../translation";
export class IntergiroMerchantAccountTable {
  constructor() {
    this.accounts = [];
  }
  componentWillLoad() {
    this.t = translation.create(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 => (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 : "-")));
        })),
    ];
  }
  static get is() { return "ig-merchant-account-table"; }
  static get encapsulation() { return "scoped"; }
  static get originalStyleUrls() { return {
    "$": ["style.css"]
  }; }
  static get styleUrls() { return {
    "$": ["style.css"]
  }; }
  static get properties() { return {
    "currency": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "Currency",
        "resolved": "Currency | undefined",
        "references": {
          "Currency": {
            "location": "import",
            "path": "isoly"
          }
        }
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "currency",
      "reflect": false
    },
    "account": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "| Merchant.Reconciliation.Account\n\t\t| {\n\t\t\t\t[currency in Currency | \"default\"]?: Merchant.Reconciliation.Account\n\t\t  }",
        "resolved": "string | { AED?: Account | undefined; AFN?: Account | undefined; ALL?: Account | undefined; AMD?: Account | undefined; ANG?: Account | undefined; AOA?: Account | undefined; ARS?: Account | undefined; AUD?: Account | undefined; AWG?: Account | undefined; AZN?: Account | undefined; BAM?: Account | undefined; BBD?: Account | undefined; BDT?: Account | undefined; BGN?: Account | undefined; BHD?: Account | undefined; BIF?: Account | undefined; BMD?: Account | undefined; BND?: Account | undefined; BOB?: Account | undefined; BOV?: Account | undefined; BRL?: Account | undefined; BSD?: Account | undefined; BTN?: Account | undefined; BWP?: Account | undefined; BYN?: Account | undefined; BZD?: Account | undefined; CAD?: Account | undefined; CDF?: Account | undefined; CHE?: Account | undefined; CHF?: Account | undefined; CHW?: Account | undefined; CLF?: Account | undefined; CLP?: Account | undefined; CNY?: Account | undefined; COP?: Account | undefined; COU?: Account | undefined; CRC?: Account | undefined; CUC?: Account | undefined; CUP?: Account | undefined; CVE?: Account | undefined; CZK?: Account | undefined; DJF?: Account | undefined; DKK?: Account | undefined; DOP?: Account | undefined; DZD?: Account | undefined; EGP?: Account | undefined; ERN?: Account | undefined; ETB?: Account | undefined; EUR?: Account | undefined; FJD?: Account | undefined; FKP?: Account | undefined; GBP?: Account | undefined; GEL?: Account | undefined; GHS?: Account | undefined; GIP?: Account | undefined; GMD?: Account | undefined; GNF?: Account | undefined; GTQ?: Account | undefined; GYD?: Account | undefined; HKD?: Account | undefined; HNL?: Account | undefined; HRK?: Account | undefined; HTG?: Account | undefined; HUF?: Account | undefined; IDR?: Account | undefined; ILS?: Account | undefined; INR?: Account | undefined; IQD?: Account | undefined; IRR?: Account | undefined; ISK?: Account | undefined; JMD?: Account | undefined; JOD?: Account | undefined; JPY?: Account | undefined; KES?: Account | undefined; KGS?: Account | undefined; KHR?: Account | undefined; KMF?: Account | undefined; KPW?: Account | undefined; KRW?: Account | undefined; KWD?: Account | undefined; KYD?: Account | undefined; KZT?: Account | undefined; LAK?: Account | undefined; LBP?: Account | undefined; LKR?: Account | undefined; LRD?: Account | undefined; LSL?: Account | undefined; LYD?: Account | undefined; MAD?: Account | undefined; MDL?: Account | undefined; MGA?: Account | undefined; MKD?: Account | undefined; MMK?: Account | undefined; MNT?: Account | undefined; MOP?: Account | undefined; MRU?: Account | undefined; MUR?: Account | undefined; MVR?: Account | undefined; MWK?: Account | undefined; MXN?: Account | undefined; MXV?: Account | undefined; MYR?: Account | undefined; MZN?: Account | undefined; NAD?: Account | undefined; NGN?: Account | undefined; NIO?: Account | undefined; NOK?: Account | undefined; NPR?: Account | undefined; NZD?: Account | undefined; OMR?: Account | undefined; PAB?: Account | undefined; PEN?: Account | undefined; PGK?: Account | undefined; PHP?: Account | undefined; PKR?: Account | undefined; PLN?: Account | undefined; PYG?: Account | undefined; QAR?: Account | undefined; RON?: Account | undefined; RSD?: Account | undefined; RUB?: Account | undefined; RWF?: Account | undefined; SAR?: Account | undefined; SBD?: Account | undefined; SCR?: Account | undefined; SDG?: Account | undefined; SEK?: Account | undefined; SGD?: Account | undefined; SHP?: Account | undefined; SLL?: Account | undefined; SOS?: Account | undefined; SRD?: Account | undefined; SSP?: Account | undefined; STN?: Account | undefined; SVC?: Account | undefined; SYP?: Account | undefined; SZL?: Account | undefined; THB?: Account | undefined; TJS?: Account | undefined; TMT?: Account | undefined; TND?: Account | undefined; TOP?: Account | undefined; TRY?: Account | undefined; TTD?: Account | undefined; TWD?: Account | undefined; TZS?: Account | undefined; UAH?: Account | undefined; UGX?: Account | undefined; USD?: Account | undefined; USN?: Account | undefined; UYI?: Account | undefined; UYU?: Account | undefined; UYW?: Account | undefined; UZS?: Account | undefined; VES?: Account | undefined; VND?: Account | undefined; VUV?: Account | undefined; WST?: Account | undefined; XAF?: Account | undefined; XAG?: Account | undefined; XAU?: Account | undefined; XBA?: Account | undefined; XBB?: Account | undefined; XBC?: Account | undefined; XBD?: Account | undefined; XCD?: Account | undefined; XDR?: Account | undefined; XOF?: Account | undefined; XPD?: Account | undefined; XPF?: Account | undefined; XPT?: Account | undefined; XSU?: Account | undefined; XTS?: Account | undefined; XUA?: Account | undefined; XXX?: Account | undefined; YER?: Account | undefined; ZAR?: Account | undefined; ZMW?: Account | undefined; ZWL?: Account | undefined; default?: Account | undefined; } | { bic: string; iban: string; }",
        "references": {
          "Merchant": {
            "location": "import",
            "path": "@payfunc/model-acquirer"
          },
          "Currency": {
            "location": "import",
            "path": "isoly"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "account",
      "reflect": false
    }
  }; }
  static get states() { return {
    "t": {}
  }; }
  static get elementRef() { return "element"; }
}
