import { proxyCustomElement, HTMLElement } from '@stencil/core/internal/client';
import { m as maybeConvertAmount } from './utils.js';

const ScFormatNumber = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
  constructor() {
    super();
    this.__registerHost();
    /** The number to format. */
    this.value = 0;
    /** The formatting style to use. */
    this.type = 'decimal';
    /** Turns off grouping separators. */
    this.noGrouping = false;
    /** The currency to use when formatting. Must be an ISO 4217 currency code such as `USD` or `EUR`. */
    this.currency = 'USD';
    /** How to display the currency. */
    this.currencyDisplay = 'symbol';
  }
  render() {
    var _a;
    if (isNaN(this.value)) {
      return '';
    }
    const lang = navigator.language || ((_a = navigator) === null || _a === void 0 ? void 0 : _a.browserLanguage) || (navigator.languages || ['en'])[0];
    return new Intl.NumberFormat(this.locale || lang, {
      style: this.type,
      currency: this.currency.toUpperCase(),
      currencyDisplay: this.currencyDisplay,
      useGrouping: !this.noGrouping,
      minimumIntegerDigits: this.minimumIntegerDigits,
      minimumFractionDigits: this.minimumFractionDigits,
      maximumFractionDigits: this.maximumFractionDigits,
      minimumSignificantDigits: this.minimumSignificantDigits,
      maximumSignificantDigits: this.maximumSignificantDigits,
    }).format(this.noConvert ? this.value : maybeConvertAmount(this.value, this.currency.toUpperCase()));
  }
}, [0, "sc-format-number", {
    "value": [2],
    "locale": [1025],
    "type": [1],
    "noGrouping": [4, "no-grouping"],
    "currency": [1],
    "currencyDisplay": [1, "currency-display"],
    "minimumIntegerDigits": [2, "minimum-integer-digits"],
    "minimumFractionDigits": [2, "minimum-fraction-digits"],
    "maximumFractionDigits": [2, "maximum-fraction-digits"],
    "minimumSignificantDigits": [2, "minimum-significant-digits"],
    "maximumSignificantDigits": [2, "maximum-significant-digits"],
    "noConvert": [4, "no-convert"]
  }]);
function defineCustomElement() {
  if (typeof customElements === "undefined") {
    return;
  }
  const components = ["sc-format-number"];
  components.forEach(tagName => { switch (tagName) {
    case "sc-format-number":
      if (!customElements.get(tagName)) {
        customElements.define(tagName, ScFormatNumber);
      }
      break;
  } });
}
defineCustomElement();

export { ScFormatNumber as S, defineCustomElement as d };
