const DEFAULTS = {
title: document.title || "OmegaGO",
primaryColor: "#d5890e",
agentId: "agent_5101ka6xdr3cfcnbwjstdc7q0bfj"
};
function buildGradient(c) {
return `radial-gradient(
circle,
hsla(0, 0%, 100%, 1) 0%,
${c} 6%,
hsla(0, 0%, 100%, 1) 21%,
hsla(0, 0%, 100%, 1) 32%,
${c} 44%,
${c} 48%,
hsla(0, 0%, 45%, 1) 52%,
${c} 59%,
hsla(0, 0%, 22%, 1) 74%,
hsla(0, 0%, 100%, 1) 85%,
hsla(0, 0%, 28%, 1) 90%,
hsla(34, 10%, 13%, 1) 100%
)`;
}
function setRippleColor(color) {
const c = color || DEFAULTS.primaryColor;
const bg = buildGradient(c);
document.querySelectorAll(".ripple-effect").forEach(el => el.style.background = bg);
}
function ensureConvai(agentId) {
const id = agentId || DEFAULTS.agentId;
const parent = document.querySelector(".ripple-container") || document.body;
const existing = document.querySelector("elevenlabs-convai");
if (existing) existing.remove();
const el = document.createElement("elevenlabs-convai");
el.setAttribute("agent-id", id);
parent.appendChild(el);
}
function applyConfig(cfg = {}) {
const title = cfg.title ?? DEFAULTS.title;
const color = (cfg.primaryColor || cfg.color) ?? DEFAULTS.primaryColor;
const agentId = cfg.agentId ?? DEFAULTS.agentId;
document.title = title;
setRippleColor(color);
ensureConvai(agentId);
}
function fromQuery() {
const p = new URLSearchParams(location.search);
return {
title: p.get("title") || undefined,
primaryColor: p.get("color") || undefined,
agentId: p.get("agentId") || undefined
};
}
async function loadConfig() {
try {
const res = await fetch("config.json?ts=" + Date.now(), { cache: "no-store" });
if (res.ok) {
const j = await res.json();
applyConfig({ ...j, ...fromQuery() });
return;
}
} catch {}
applyConfig({ ...fromQuery() });
}
document.addEventListener("DOMContentLoaded", loadConfig);