'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-df541290.js');
const index$1 = require('./index-0b6f1dd9.js');
const index$2 = require('./index-c12b8888.js');
require('./_commonjsHelpers-10109b76.js');
require('./index-fe328b96.js');
require('./index-b7493032.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) {
    index.registerInstance(this, hostRef);
    this.updateCustomers = index.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 ? index$1.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 [
      index.h("ig-filter", { template: index$2.Customer.template, filter: this.filter }),
      index.h("ig-customer-actions", { whitelist: this.whitelist, selected: this.selected }),
      index.h("ig-customers-table", { customers: this.customersFiltered, orders: this.orders, selected: this.selected, whitelist: this.whitelist }),
      index.h("ig-customer-create-popup", { hidden: true, onCreate: (e) => this.onCreate(e) }),
      index.h("ig-customers-footer", { customers: this.customersFiltered }),
    ];
  }
  static get watchers() { return {
    "customers": ["filterCustomers"],
    "filter": ["filterCustomers"]
  }; }
};
IntergiroCustomers.style = styleCss;

exports.ig_customers = IntergiroCustomers;
