import { r as registerInstance, h, H as Host, g as getElement } from './index-345463dd.js';

const klevuIconCss = ":host{display:inline-block}span{font-family:\"Material Symbols Rounded\";font-variation-settings:\"FILL\" 0, \"wght\" 600, \"GRAD\" 0, \"opsz\" 20}div svg{width:100%;height:100%}";

const KlevuIcon = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.name = undefined;
    this.iconURL = undefined;
    this.iconURLSvg = undefined;
    this.svgStyle = undefined;
  }
  async connectedCallback() {
    var _a, _b;
    const url = (_b = (_a = window["klevu_ui_settings"]) === null || _a === void 0 ? void 0 : _a.icons) === null || _b === void 0 ? void 0 : _b[this.name];
    if (url === null || url === void 0 ? void 0 : url.endsWith(".svg")) {
      try {
        const data = await window.fetch(url);
        this.iconURLSvg = await data.text();
        const fontSize = getComputedStyle(this.el).fontSize;
        this.svgStyle = {
          fill: getComputedStyle(this.el).color,
          height: fontSize,
          width: fontSize,
        };
      }
      catch (e) { }
    }
    else if (url) {
      this.iconURL = url;
    }
    if (!this.iconURL && !this.iconURLSvg) {
      // Inject material fonts to project
      const fontCssUrl = "https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20,600,0,0";
      let element = document.querySelector(`link[href="${fontCssUrl}"]`);
      // Only inject the element if it's not yet present
      if (!element) {
        element = document.createElement("link");
        element.setAttribute("rel", "stylesheet");
        element.setAttribute("href", fontCssUrl);
        document.head.appendChild(element);
      }
    }
  }
  render() {
    return (h(Host, null, this.iconURLSvg ? (h("div", { style: this.svgStyle, innerHTML: this.iconURLSvg })) : this.iconURL ? (h("img", { src: this.iconURL })) : (h("span", null, this.name))));
  }
  get el() { return getElement(this); }
};
KlevuIcon.style = klevuIconCss;

const klevuTypographyCss = ":host{--klevu-typography-color:inherit;display:block}span{display:inline-block}.variant-h1{font-size:var(--klevu-typography-font-size, var(--klevu-h1-size));font-weight:var(--klevu-h1-weight);line-height:var(--klevu-h1-line-height);color:var(--klevu-typography-color, var(--klevu-color-neutral-8))}.variant-h2{font-size:var(--klevu-typography-font-size, var(--klevu-h2-size));font-weight:var(--klevu-h2-weight);line-height:var(--klevu-h2-line-height);color:var(--klevu-typography-color, var(--klevu-color-neutral-8))}.variant-h3{font-size:var(--klevu-typography-font-size, var(--klevu-h3-size));font-weight:var(--klevu-h3-weight);line-height:var(--klevu-h3-line-height);color:var(--klevu-typography-color, var(--klevu-color-neutral-8))}.variant-h4{font-size:var(--klevu-typography-font-size, var(--klevu-h4-size));font-weight:var(--klevu-h4-weight);line-height:var(--klevu-h4-line-height);color:var(--klevu-typography-color, var(--klevu-color-neutral-8))}.variant-body-l,.variant-body-l-bold{font-size:var(--klevu-typography-font-size, var(--klevu-body-l-size));line-height:var(--klevu-body-l-line-height);color:var(--klevu-typography-color, var(--klevu-color-neutral-8))}.variant-body-m,.variant-body-m-bold{font-size:var(--klevu-typography-font-size, var(--klevu-body-m-size));line-height:var(--klevu-body-m-line-height);color:var(--klevu-typography-color, var(--klevu-color-neutral-8))}.variant-body-s,.variant-body-s-bold{font-size:var(--klevu-typography-font-size, var(--klevu-body-s-size));line-height:var(--klevu-body-s-line-height);color:var(--klevu-typography-color, var(--klevu-color-neutral-8))}.variant-body-xs,.variant-body-xs-bold{font-size:var(--klevu-typography-font-size, var(--klevu-body-xs-size));line-height:var(--klevu-body-xs-line-height);color:var(--klevu-typography-color, var(--klevu-color-neutral-8))}.variant-body-l,.variant-body-m,.variant-body-s,.variant-body-xs{font-weight:var(--klevu-typography-font-weight, 400)}.variant-body-l-bold,.variant-body-m-bold,.variant-body-s-bold,.variant-body-xs-bold{font-weight:var(--klevu-typography-font-weight, 600)}";

const KlevuTypography = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.variant = undefined;
    this.fullWidth = undefined;
  }
  render() {
    let style = {};
    if (this.fullWidth) {
      style.width = "100%";
    }
    return (h("span", { class: `variant-${this.variant}`, style: style }, h("slot", null)));
  }
};
KlevuTypography.style = klevuTypographyCss;

export { KlevuIcon as klevu_icon, KlevuTypography as klevu_typography };

//# sourceMappingURL=klevu-icon_2.entry.js.map