// Shows a faded logo bug on broadcast outputs while the license is in trial.
// Injected by the server into program output pages only; licensed copies render nothing.
(() => {
  const ID = "lrw-trial-watermark";

  async function refresh() {
    try {
      const response = await fetch("/api/license", { cache: "no-store" });
      const license = await response.json();
      const onTrial = Boolean(license && license.status === "trial");
      const existing = document.getElementById(ID);
      if (!onTrial) {
        if (existing) existing.remove();
        return;
      }
      if (existing) return;
      const tag = document.createElement("img");
      tag.id = ID;
      tag.src = "/assets/liberty-raceworks-icon.png";
      tag.alt = "";
      Object.assign(tag.style, {
        position: "fixed",
        right: "20px",
        bottom: "16px",
        width: "110px",
        height: "auto",
        zIndex: "2147483647",
        pointerEvents: "none",
        opacity: "0.45",
        filter: "drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6))",
        userSelect: "none"
      });
      document.body.appendChild(tag);
    } catch (_err) {
      // Keep the last known state if the server is briefly unreachable mid-show.
    }
  }

  refresh();
  setInterval(refresh, 60000);
})();
