import { r as registerInstance, j as createEvent, h } from './index-07845439.js';
import { d as dist } from './index-b6cf748e.js';
import { a as Customer } from './index-e20749b7.js';
import './_commonjsHelpers-8fe71198.js';
import './index-265fba1f.js';
import './index-63517df5.js';

const styleCss = ".sc-ig-customers-h{display:block;width:100%;max-width:90em;margin:auto}ig-customer-create-popup.sc-ig-customers{bottom:3.5em;margin-right:2.5em}";

const IntergiroCustomers = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.updateCustomers = createEvent(this, "updateCustomers", 7);
    this.selected = {};
  }
  componentWillLoad() {
    if (!this.customersFiltered)
      this.filterCustomers();
  }
  handleFilterChanged(event) {
    this.filter = event.detail;
    event.stopPropagation();
  }
  filterCustomers() {
    const result = this.customers && (this.filter ? dist.filter(this.filter, this.customers) : [...this.customers]);
    this.customersFiltered = result;
  }
  handleSelectedChanged(event) {
    this.selected = event.detail;
  }
  onCreate(e) {
    this.updateCustomers.emit(e.detail);
  }
  render() {
    return [
      h("ig-filter", { template: Customer.template, filter: this.filter }),
      h("ig-customer-actions", { whitelist: this.whitelist, selected: this.selected }),
      h("ig-customers-table", { customers: this.customersFiltered, orders: this.orders, selected: this.selected, whitelist: this.whitelist }),
      h("ig-customer-create-popup", { hidden: true, onCreate: (e) => this.onCreate(e) }),
      h("ig-customers-footer", { customers: this.customersFiltered }),
    ];
  }
  static get watchers() { return {
    "customers": ["filterCustomers"],
    "filter": ["filterCustomers"]
  }; }
};
IntergiroCustomers.style = styleCss;

export { IntergiroCustomers as ig_customers };
