'use strict';

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

const index = require('./index-9c866aeb.js');

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

const ScPriceRange = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
  }
  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 index.h(index.Host, null);
    }
    return (index.h(index.Host, null, this.maxPrice.amount == this.minPrice.amount ? (index.h("span", { class: "price-range-display" }, index.h("sc-format-number", { type: "currency", currency: this.maxPrice.currency, value: this.maxPrice.amount }))) : (index.h("span", { class: "price-range-display" }, index.h("sc-format-number", { type: "currency", currency: this.minPrice.currency, value: this.minPrice.amount }), "-", index.h("sc-format-number", { type: "currency", currency: this.maxPrice.currency, value: this.maxPrice.amount })))));
  }
  static get watchers() { return {
    "prices": ["handlePricesChange"]
  }; }
};
ScPriceRange.style = scPriceRangeCss;

exports.sc_price_range = ScPriceRange;
