import { Component, h, Prop, State, Watch } from "@stencil/core";
import { Schedule } from "@payfunc/model";
export class PayfuncAccountBalance {
  componentWillLoad() {
    this.filterOrders();
  }
  filterOrders() {
    const orders = this.orders
      ? this.orders.filter(o => o.payment.type == "account" || o.payment.type == "card" ? o.payment.charge == "balance" : false)
      : undefined;
    this.ordersFiltered = orders;
  }
  render() {
    return [
      h("section", null,
        h("main", null,
          h("payfunc-schedule", { schedule: this.account.schedule }),
          this.account.limit ? h("payfunc-limit", { account: this.account }) : []),
        h("payfunc-future-due-dates", { dates: Schedule.calculateDueDates(this.account.schedule, 4) })),
      h("section", null,
        this.account.balance.length > 0 ? h("payfunc-items-list", { items: this.account.balance }) : [],
        this.ordersFiltered && this.ordersFiltered.length > 0 ? (h("payfunc-orders-table", { display: true, orders: this.ordersFiltered })) : ([])),
    ];
  }
  static get is() { return "payfunc-account-balance"; }
  static get encapsulation() { return "scoped"; }
  static get originalStyleUrls() { return {
    "$": ["style.css"]
  }; }
  static get styleUrls() { return {
    "$": ["style.css"]
  }; }
  static get properties() { return {
    "account": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Account",
        "resolved": "Account",
        "references": {
          "Account": {
            "location": "import",
            "path": "@payfunc/model"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "orders": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Order[]",
        "resolved": "Order[] | undefined",
        "references": {
          "Order": {
            "location": "import",
            "path": "@payfunc/model"
          }
        }
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      }
    }
  }; }
  static get states() { return {
    "ordersFiltered": {}
  }; }
  static get watchers() { return [{
      "propName": "orders",
      "methodName": "filterOrders"
    }]; }
}
