import { r as registerInstance, h, H as Host } from './index-c269755a.js';

const teliaCounterBadgeCss = ".telia-counter-badge{background-color:#5e0092;border-radius:calc(99.9rem * var(--voca-rem-multiplier));font-family:\"TeliaSans\", Helvetica, Arial, \"Lucida Grande\", sans-serif;font-weight:500;font-size:calc(1.2rem * var(--voca-rem-multiplier));color:#ffffff;display:inline-block;line-height:1;width:calc(1.4rem * var(--voca-rem-multiplier));max-height:calc(1.4rem * var(--voca-rem-multiplier));padding:calc(0.1rem * var(--voca-rem-multiplier)) calc(0.4rem * var(--voca-rem-multiplier));text-align:center}.telia-counter-badge--long{width:auto}.telia-counter-badge--placeholder{display:flex;justify-content:center;align-items:center}";

const TeliaCounterBadge = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    /** The numeric value displayed in the badge. */
    this.value = 0;
    /** Describe unclear button context for better accessibility support */
    this.allyLabel = null;
    /** Tracking id is used to identify and count Component usage */
    this.dataTrackingId = 'telia-counter-badge';
  }
  sanitizeValue(value) {
    const integerValue = Number.parseInt(value);
    if (integerValue > 0) {
      return integerValue;
    }
    else {
      throw Error('Value needs to be a number (1-9)');
    }
  }
  formatValue(value) {
    return value > 999 ? '999+' : value.toString();
  }
  render() {
    return (h(Host, { class: {
        'telia-counter-badge': !!this.value,
        [`telia-counter-badge--long`]: this.value > 9,
      }, "data-testid": this.dataTestid }, h("span", { class: "telia-counter-badge--placeholder", role: "status", "aria-label": this.allyLabel }, this.formatValue(this.sanitizeValue(this.value))), h("telia-vst", { dataTrackingId: this.dataTrackingId })));
  }
};
TeliaCounterBadge.style = teliaCounterBadgeCss;

export { TeliaCounterBadge as telia_counter_badge };
