import { proxyCustomElement, HTMLElement, createEvent, h, Fragment } from '@stencil/core/internal/client';
import { d as defineCustomElement$4 } from './sc-choices2.js';
import { d as defineCustomElement$3 } from './sc-form-control2.js';
import { d as defineCustomElement$2 } from './sc-tooltip2.js';

const scPriceChoicesCss = "sc-price-choices{display:block;position:relative}sc-block-ui{z-index:9}";

const ScPriceChoices$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
  constructor() {
    super();
    this.__registerHost();
    this.scRemoveLineItem = createEvent(this, "scRemoveLineItem", 7);
    this.scUpdateLineItem = createEvent(this, "scUpdateLineItem", 7);
    /** Number of columns */
    this.columns = 1;
    /** Required by default */
    this.required = true;
  }
  handleChange() {
    this.el.querySelectorAll('sc-price-choice').forEach(priceChoice => {
      // get the underlying control
      const choice = priceChoice.querySelector('sc-choice');
      if (!choice.checked) {
        this.scRemoveLineItem.emit({ price_id: priceChoice.priceId, quantity: priceChoice.quantity });
      }
      else {
        this.scUpdateLineItem.emit({ price_id: priceChoice.priceId, quantity: priceChoice.quantity });
      }
    });
  }
  render() {
    return (h(Fragment, null, h("sc-choices", { label: this.label, required: this.required, class: "loaded price-selector", style: { '--columns': this.columns.toString() } }, h("slot", null))));
  }
  get el() { return this; }
  static get style() { return scPriceChoicesCss; }
}, [4, "sc-price-choices", {
    "label": [1],
    "columns": [2],
    "required": [4]
  }, [[0, "scChange", "handleChange"]]]);
function defineCustomElement$1() {
  if (typeof customElements === "undefined") {
    return;
  }
  const components = ["sc-price-choices", "sc-choices", "sc-form-control", "sc-tooltip"];
  components.forEach(tagName => { switch (tagName) {
    case "sc-price-choices":
      if (!customElements.get(tagName)) {
        customElements.define(tagName, ScPriceChoices$1);
      }
      break;
    case "sc-choices":
      if (!customElements.get(tagName)) {
        defineCustomElement$4();
      }
      break;
    case "sc-form-control":
      if (!customElements.get(tagName)) {
        defineCustomElement$3();
      }
      break;
    case "sc-tooltip":
      if (!customElements.get(tagName)) {
        defineCustomElement$2();
      }
      break;
  } });
}
defineCustomElement$1();

const ScPriceChoices = ScPriceChoices$1;
const defineCustomElement = defineCustomElement$1;

export { ScPriceChoices, defineCustomElement };
