import { getSettings, setSettings, applyDocTheme } from "../common/storage.js";
import { PROVIDERS } from "../ai/providers.js";
import { setLang, resolveLang, applyI18n } from "../common/i18n.js";

const $ = (id) => document.getElementById(id);

(async () => {
  const s = await getSettings();
  applyDocTheme(s.theme);
  setLang(resolveLang(s.language));
  applyI18n();
  $("pp-intercept").checked = s.interceptEnabled !== false;
  const prov = PROVIDERS[s.provider];
  $("pp-provider").textContent = `Провайдер: ${prov?.label || s.provider} · режим: ${s.aiMode}`;

  $("pp-intercept").onchange = () => setSettings({ interceptEnabled: $("pp-intercept").checked });
  $("pp-options").onclick = () => chrome.runtime.openOptionsPage();
})();
