'use strict';

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

const index = require('./index-df541290.js');
const index$1 = require('./index-e4cf4aa6.js');
const index$2 = require('./index-07607ed6.js');
require('./_commonjsHelpers-5bbc2693.js');

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

const IntergiroAccounts = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.updateAccounts = index.createEvent(this, "updateAccounts", 7);
    this.selected = {};
  }
  componentWillLoad() {
    if (!this.accountsFiltered)
      this.filterAccounts();
  }
  handleFilterChanged(event) {
    this.filter = event.detail;
    event.stopPropagation();
  }
  filterAccounts() {
    const result = this.accounts && (this.filter ? index$1.dist.filter(this.filter, this.accounts) : [...this.accounts]);
    this.accountsFiltered = result;
  }
  handleSelectedChanged(event) {
    this.selected = event.detail;
  }
  onCreate(e) {
    this.updateAccounts.emit(e.detail);
  }
  render() {
    return [
      index.h("ig-filter", { template: index$2.Account.template, filter: this.filter }),
      index.h("ig-accounts-actions", { whitelist: this.whitelist, selected: this.selected }),
      index.h("ig-accounts-table", { accounts: this.accountsFiltered, orders: this.orders, selected: this.selected, whitelist: this.whitelist }),
      index.h("ig-account-create-popup", { hidden: true, onCreate: (e) => this.onCreate(e) }),
      index.h("ig-accounts-footer", { accounts: this.accountsFiltered }),
    ];
  }
  static get watchers() { return {
    "accounts": ["filterAccounts"],
    "filter": ["filterAccounts"]
  }; }
};
IntergiroAccounts.style = styleCss;

exports.ig_accounts = IntergiroAccounts;
