import { Component, h, Prop, State, Watch } from "@stencil/core";
import { Schedule } from "@payfunc/model";
export class IntergiroCustomerBalance {
  componentWillLoad() {
    this.filterOrders();
  }
  filterOrders() {
    const orders = this.orders
      ? this.orders.filter(o => o.payment.type == "customer" || o.payment.type == "card" ? o.payment.charge == "balance" : false)
      : undefined;
    this.ordersFiltered = orders;
  }
  render() {
    return [
      h("section", null,
        h("main", null,
          h("ig-schedule", { schedule: this.customer.schedule }),
          this.customer.limit ? h("ig-customer-limit", { customer: this.customer }) : []),
        h("ig-future-due-dates", { dates: Schedule.calculateDueDates(this.customer.schedule, 4) })),
      h("section", null,
        this.customer.balance.length > 0 ? h("ig-items-list", { items: this.customer.balance }) : [],
        this.ordersFiltered && this.ordersFiltered.length > 0 ? (h("ig-orders-table", { display: true, orders: this.ordersFiltered })) : ([])),
    ];
  }
  static get is() { return "ig-customer-balance"; }
  static get encapsulation() { return "scoped"; }
  static get originalStyleUrls() { return {
    "$": ["style.css"]
  }; }
  static get styleUrls() { return {
    "$": ["style.css"]
  }; }
  static get properties() { return {
    "customer": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Customer",
        "resolved": "Customer",
        "references": {
          "Customer": {
            "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"
    }]; }
}
