import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
import { d as defineCustomElement$2 } from './sc-format-number2.js';

const scPriceRangeCss = ":host{display:block}";

const ScPriceRange$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
  constructor() {
    super();
    this.__registerHost();
    this.__attachShadow();
  }
  handlePricesChange() {
    var _a;
    let min, max;
    (_a = this.prices) === null || _a === void 0 ? void 0 : _a.forEach(price => {
      if (!max || price.amount > max.amount) {
        max = price;
      }
      if (!min || price.amount < min.amount) {
        min = price;
      }
    });
    this.minPrice = min;
    this.maxPrice = max;
  }
  componentWillLoad() {
    this.handlePricesChange();
  }
  render() {
    if (!this.maxPrice || !this.minPrice) {
      return h(Host, null);
    }
    return (h(Host, null, this.maxPrice.amount == this.minPrice.amount ? (h("span", { class: "price-range-display" }, h("sc-format-number", { type: "currency", currency: this.maxPrice.currency, value: this.maxPrice.amount }))) : (h("span", { class: "price-range-display" }, h("sc-format-number", { type: "currency", currency: this.minPrice.currency, value: this.minPrice.amount }), "-", h("sc-format-number", { type: "currency", currency: this.maxPrice.currency, value: this.maxPrice.amount })))));
  }
  static get watchers() { return {
    "prices": ["handlePricesChange"]
  }; }
  static get style() { return scPriceRangeCss; }
}, [1, "sc-price-range", {
    "prices": [16],
    "minPrice": [32],
    "maxPrice": [32]
  }]);
function defineCustomElement$1() {
  if (typeof customElements === "undefined") {
    return;
  }
  const components = ["sc-price-range", "sc-format-number"];
  components.forEach(tagName => { switch (tagName) {
    case "sc-price-range":
      if (!customElements.get(tagName)) {
        customElements.define(tagName, ScPriceRange$1);
      }
      break;
    case "sc-format-number":
      if (!customElements.get(tagName)) {
        defineCustomElement$2();
      }
      break;
  } });
}
defineCustomElement$1();

const ScPriceRange = ScPriceRange$1;
const defineCustomElement = defineCustomElement$1;

export { ScPriceRange, defineCustomElement };
