// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { h, Host } from '@stencil/core';
export class CheckboxGroup {
  constructor() {
    this.uniqueName = Date.now().toString(36);
    this.name = undefined;
  }
  function(e) {
    e.stopPropagation();
    if (e.target.tagName !== 'TARO-CHECKBOX-CORE')
      return;
    const childList = this.el.querySelectorAll('taro-checkbox-core');
    this.value = this.getValues(childList);
    this.onChange.emit({
      value: this.value
    });
  }
  componentDidLoad() {
    const childList = this.el.querySelectorAll('taro-checkbox-core');
    childList.forEach((element) => {
      element.setAttribute('name', this.name || this.uniqueName);
    });
    Object.defineProperty(this.el, 'value', {
      get: () => {
        if (!this.value) {
          const childList = this.el.querySelectorAll('taro-checkbox-core');
          this.value = this.getValues(childList);
        }
        return this.value;
      },
      configurable: true
    });
  }
  getValues(childList) {
    return Array.from(childList)
      .filter(element => {
      const checkbox = element.querySelector('input');
      return checkbox === null || checkbox === void 0 ? void 0 : checkbox.checked;
    })
      .map(element => element.value);
  }
  render() {
    return (h(Host, null));
  }
  static get is() { return "taro-checkbox-group-core"; }
  static get properties() {
    return {
      "name": {
        "type": "any",
        "mutable": false,
        "complexType": {
          "original": "any",
          "resolved": "any",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "name",
        "reflect": false
      }
    };
  }
  static get events() {
    return [{
        "method": "onChange",
        "name": "change",
        "bubbles": true,
        "cancelable": true,
        "composed": true,
        "docs": {
          "tags": [],
          "text": ""
        },
        "complexType": {
          "original": "any",
          "resolved": "any",
          "references": {}
        }
      }];
  }
  static get elementRef() { return "el"; }
  static get listeners() {
    return [{
        "name": "checkboxchange",
        "method": "function",
        "target": undefined,
        "capture": false,
        "passive": false
      }];
  }
}
//# sourceMappingURL=checkbox-group.js.map
