import { r as registerInstance } from './index-419dc51e.js';
import { m as makeTheme } from './makeTheme-efdb2ac2.js';

const Theme = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.theme = null;
  }
  async componentWillRender() {
    if (this.theme) {
      const userConfig = typeof this.theme === "string" ? JSON.parse(this.theme) : this.theme;
      const userTheme = makeTheme(userConfig);
      const existingTag = document.querySelectorAll("head style#corejam-user-style");
      if (userTheme.length > 0) {
        if (existingTag.length > 0) {
          existingTag[0].innerHTML = `
            :root {
              ${userTheme}
            }
          `;
        }
        else {
          const style = document.createElement("style");
          style.id = "corejam-user-style";
          style.innerHTML = `
          :root {
            ${userTheme}
          }
        `;
          document.head.appendChild(style);
        }
      }
    }
  }
};

export { Theme as corejam_ui_theme };
