import { ICON_SETS as e, getIconSvgInner as t } from "../icons/index.js";
import { configureTheme as n } from "../ui/index.js";
import { o as r } from "../sanitize-uWpY18N9.js";
//#region src/appearance/index.ts
var i = "accent_theme", a = "typography", o = "icon_set", s = "quick_switcher_themes", c = [
	"light",
	"dark",
	"monokai",
	"glass"
], l = [
	"orange",
	"cyan",
	"violet",
	"rose",
	"emerald"
], u = [
	"sora",
	"inter",
	"roboto",
	"system",
	"jetbrains-mono"
], d = [
	"lucide",
	"heroicons",
	"phosphor",
	"material"
], f = "/api/v1/users/me/appearance";
function p(e) {
	return typeof e == "string" && l.includes(e);
}
function m(e) {
	return typeof e == "string" && u.includes(e);
}
function h() {
	let e = localStorage.getItem(i);
	return p(e) ? e : "orange";
}
function g() {
	let e = localStorage.getItem(a);
	return m(e) ? e : "sora";
}
function _(e) {
	e === "orange" ? document.documentElement.removeAttribute("data-accent") : document.documentElement.setAttribute("data-accent", e);
}
function v(e) {
	e === "sora" ? document.documentElement.removeAttribute("data-font") : document.documentElement.setAttribute("data-font", e);
}
function y(e) {
	localStorage.setItem(i, e), _(e);
}
function b(e) {
	localStorage.setItem(a, e), v(e);
}
function x(e) {
	return typeof e == "string" && d.includes(e);
}
function S() {
	let e = localStorage.getItem(o);
	return x(e) ? e : "lucide";
}
function C(e) {
	let n = document.querySelectorAll("[data-icon]");
	for (let i of n) {
		let n = i.getAttribute("data-icon");
		if (n === null || n.length === 0) continue;
		let a = t(e, n);
		a !== void 0 && r(i, a);
	}
	e === "lucide" ? document.documentElement.removeAttribute("data-icon-set") : document.documentElement.setAttribute("data-icon-set", e);
}
function w(e) {
	localStorage.setItem(o, e), C(e);
}
function T() {
	let e = localStorage.getItem(s);
	if (e === null || e.length === 0) return [...c];
	try {
		let t = JSON.parse(e).filter((e) => c.includes(e));
		return t.length > 0 ? t : [...c];
	} catch {
		return [...c];
	}
}
function E(e) {
	localStorage.setItem(s, JSON.stringify(e));
}
function D(e) {
	_(h()), v(g()), C(S());
	let t = T();
	e?.onToggleCycleUpdate && e.onToggleCycleUpdate(t);
}
async function O(e) {
	let t = e?.endpoint ?? f, r = e?.getToken ? e.getToken() : null, i = {};
	r && (i.Authorization = `Bearer ${r}`);
	let a;
	try {
		let e = await fetch(t, { headers: i });
		if (!e.ok) return;
		a = await e.json();
	} catch {
		return;
	}
	if (p(a.accent) && a.accent !== h() && y(a.accent), m(a.font) && a.font !== g() && b(a.font), x(a.icon_set) && a.icon_set !== S() && w(a.icon_set), e?.onToggleCycleUpdate) {
		let t = T();
		n({ themes: t }), e.onToggleCycleUpdate(t);
	}
}
//#endregion
export { e as ICON_SETS, _ as applyAccent, v as applyFont, C as applyIconSet, t as getIconSvgInner, h as getStoredAccent, g as getStoredFont, S as getStoredIconSet, T as getStoredQuickSwitcherThemes, D as initAppearance, p as isValidAccent, m as isValidFont, x as isValidIconSet, y as setAccent, b as setFont, w as setIconSet, E as setQuickSwitcherThemes, O as syncAppearanceFromServer };

//# sourceMappingURL=index.js.map