import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';

const CheckboxGroup = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
  constructor() {
    super();
    this.__registerHost();
    this.onChange = createEvent(this, "change", 7);
    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));
  }
  get el() { return this; }
}, [0, "taro-checkbox-group-core", {
    "name": [8]
  }, [[0, "checkboxchange", "function"]]]);
function defineCustomElement$1() {
  if (typeof customElements === "undefined") {
    return;
  }
  const components = ["taro-checkbox-group-core"];
  components.forEach(tagName => { switch (tagName) {
    case "taro-checkbox-group-core":
      if (!customElements.get(tagName)) {
        customElements.define(tagName, CheckboxGroup);
      }
      break;
  } });
}

const TaroCheckboxGroupCore = CheckboxGroup;
const defineCustomElement = defineCustomElement$1;

export { TaroCheckboxGroupCore, defineCustomElement };

//# sourceMappingURL=taro-checkbox-group-core.js.map