"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/ThemeToggle/ThemeToggle.tsx
var ThemeToggle_exports = {};
__export(ThemeToggle_exports, {
  ThemeToggle: () => ThemeToggle
});
module.exports = __toCommonJS(ThemeToggle_exports);
var import_phosphor_react = require("phosphor-react");
var import_react3 = require("react");

// src/components/SelectionButton/SelectionButton.tsx
var import_react = require("react");

// src/utils/utils.ts
var import_clsx = require("clsx");
var import_tailwind_merge = require("tailwind-merge");
function cn(...inputs) {
  return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
}

// src/components/SelectionButton/SelectionButton.tsx
var import_jsx_runtime = require("react/jsx-runtime");
var SelectionButton = (0, import_react.forwardRef)(
  ({ icon, label, selected = false, className = "", disabled, ...props }, ref) => {
    const baseClasses = [
      "inline-flex",
      "items-center",
      "justify-start",
      "gap-2",
      "p-4",
      "rounded-xl",
      "cursor-pointer",
      "border",
      "border-border-50",
      "bg-background",
      "text-sm",
      "text-text-700",
      "font-bold",
      "shadow-soft-shadow-1",
      "hover:bg-background-100",
      "focus-visible:outline-none",
      "focus-visible:ring-2",
      "focus-visible:ring-indicator-info",
      "focus-visible:ring-offset-0",
      "focus-visible:shadow-none",
      "active:ring-2",
      "active:ring-primary-950",
      "active:ring-offset-0",
      "active:shadow-none",
      "disabled:opacity-50",
      "disabled:cursor-not-allowed"
    ];
    const stateClasses = selected ? ["ring-primary-950", "ring-2", "ring-offset-0", "shadow-none"] : [];
    const allClasses = [...baseClasses, ...stateClasses].join(" ");
    return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
      "button",
      {
        ref,
        type: "button",
        className: cn(allClasses, className),
        disabled,
        "aria-pressed": selected,
        ...props,
        children: [
          icon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "flex items-center justify-center w-6 h-6", children: icon }),
          /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: label })
        ]
      }
    );
  }
);
SelectionButton.displayName = "SelectionButton";
var SelectionButton_default = SelectionButton;

// src/hooks/useTheme.ts
var import_react2 = require("react");

// src/store/themeStore.ts
var import_zustand = require("zustand");
var import_middleware = require("zustand/middleware");
var DARK_THEME_MAP = {
  "base-light": "base-dark",
  "enem-parana-light": "enem-parana-dark",
  "enem-paraiba-light": "enem-paraiba-dark",
  "analytica-light": "analytica-dark"
};
var resolveDarkTheme = (originalTheme) => {
  if (!originalTheme) return "base-dark";
  return DARK_THEME_MAP[originalTheme] ?? "base-dark";
};
var applyThemeToDOM = (mode) => {
  const htmlElement = document.documentElement;
  const originalTheme = htmlElement.dataset.originalTheme;
  if (mode === "dark") {
    htmlElement.dataset.theme = resolveDarkTheme(originalTheme);
    return true;
  } else if (mode === "light") {
    if (originalTheme) {
      htmlElement.dataset.theme = originalTheme;
    }
    return false;
  } else if (mode === "system") {
    const isSystemDark = window.matchMedia(
      "(prefers-color-scheme: dark)"
    ).matches;
    if (isSystemDark) {
      htmlElement.dataset.theme = resolveDarkTheme(originalTheme);
      return true;
    } else if (originalTheme) {
      htmlElement.dataset.theme = originalTheme;
      return false;
    }
  }
  return false;
};
var saveOriginalTheme = () => {
  const htmlElement = document.documentElement;
  const currentTheme = htmlElement.dataset.theme || document.querySelector('meta[name="theme"]')?.getAttribute("content");
  if (currentTheme && !htmlElement.dataset.originalTheme) {
    htmlElement.dataset.originalTheme = currentTheme;
  }
};
var useThemeStore = (0, import_zustand.create)()(
  (0, import_middleware.devtools)(
    (0, import_middleware.persist)(
      (set, get) => ({
        // Initial state
        themeMode: "system",
        isDark: false,
        // Actions
        applyTheme: (mode) => {
          const isDark = applyThemeToDOM(mode);
          set({ isDark });
        },
        toggleTheme: () => {
          const { themeMode, applyTheme } = get();
          let newMode;
          if (themeMode === "light") {
            newMode = "dark";
          } else if (themeMode === "dark") {
            newMode = "light";
          } else {
            newMode = "dark";
          }
          set({ themeMode: newMode });
          applyTheme(newMode);
        },
        setTheme: (mode) => {
          const { applyTheme } = get();
          set({ themeMode: mode });
          applyTheme(mode);
        },
        setWhiteLabelTheme: (theme) => {
          const htmlElement = document.documentElement;
          if (theme) {
            htmlElement.dataset.originalTheme = theme;
            const { themeMode, applyTheme } = get();
            if (themeMode === "light" || themeMode === "system") {
              htmlElement.dataset.theme = theme;
            }
            applyTheme(themeMode);
          }
        },
        clearWhiteLabelTheme: () => {
          const htmlElement = document.documentElement;
          delete htmlElement.dataset.originalTheme;
          delete htmlElement.dataset.theme;
          saveOriginalTheme();
          const { themeMode, applyTheme } = get();
          applyTheme(themeMode);
        },
        initializeTheme: () => {
          const { themeMode, applyTheme } = get();
          saveOriginalTheme();
          applyTheme(themeMode);
        },
        handleSystemThemeChange: () => {
          const { themeMode, applyTheme } = get();
          if (themeMode === "system") {
            applyTheme("system");
          }
        }
      }),
      {
        name: "theme-store",
        // Nome da chave no localStorage
        partialize: (state) => ({
          themeMode: state.themeMode
        })
        // Só persiste o themeMode, não o isDark
      }
    ),
    {
      name: "theme-store"
    }
  )
);

// src/hooks/useTheme.ts
var useTheme = () => {
  const {
    themeMode,
    isDark,
    toggleTheme,
    setTheme,
    initializeTheme,
    handleSystemThemeChange
  } = useThemeStore();
  const branding = (0, import_react2.useMemo)(() => {
    if (typeof document === "undefined") {
      return {
        theme: null,
        favicon: null,
        icon: null,
        mainLogo: null,
        internalLogo: null,
        loginImage: null
      };
    }
    return {
      theme: document.querySelector('meta[name="theme"]')?.getAttribute("content") ?? null,
      favicon: document.querySelector('link[rel="icon"]')?.getAttribute("href") ?? null,
      icon: document.querySelector('link[rel="apple-touch-icon"]')?.getAttribute("href") ?? null,
      mainLogo: document.querySelector('meta[name="main-logo"]')?.getAttribute("content") ?? null,
      internalLogo: document.querySelector('meta[name="internal-logo"]')?.getAttribute("content") ?? null,
      loginImage: document.querySelector('meta[name="login-image"]')?.getAttribute("content") ?? null
    };
  }, []);
  (0, import_react2.useEffect)(() => {
    initializeTheme();
    const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
    mediaQuery.addEventListener("change", handleSystemThemeChange);
    return () => {
      mediaQuery.removeEventListener("change", handleSystemThemeChange);
    };
  }, [initializeTheme, handleSystemThemeChange]);
  return {
    themeMode,
    isDark,
    toggleTheme,
    setTheme,
    branding
  };
};

// src/components/ThemeToggle/ThemeToggle.tsx
var import_jsx_runtime2 = require("react/jsx-runtime");
var ThemeToggle = ({
  variant = "default",
  onToggle
}) => {
  const { themeMode, setTheme } = useTheme();
  const [tempTheme, setTempTheme] = (0, import_react3.useState)(themeMode);
  (0, import_react3.useEffect)(() => {
    setTempTheme(themeMode);
  }, [themeMode]);
  const problemTypes = [
    {
      id: "light",
      title: "Claro",
      icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_phosphor_react.Sun, { size: 24 })
    },
    {
      id: "dark",
      title: "Escuro",
      icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_phosphor_react.Moon, { size: 24 })
    },
    {
      id: "system",
      title: "Sistema",
      icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
        "svg",
        {
          width: "25",
          height: "25",
          viewBox: "0 0 25 25",
          fill: "none",
          xmlns: "http://www.w3.org/2000/svg",
          children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
            "path",
            {
              d: "M12.5 2.75C15.085 2.75276 17.5637 3.78054 19.3916 5.6084C21.2195 7.43628 22.2473 9.915 22.25 12.5C22.25 14.4284 21.6778 16.3136 20.6064 17.917C19.5352 19.5201 18.0128 20.7699 16.2314 21.5078C14.4499 22.2458 12.489 22.4387 10.5977 22.0625C8.70642 21.6863 6.96899 20.758 5.60547 19.3945C4.24197 18.031 3.31374 16.2936 2.9375 14.4023C2.56129 12.511 2.75423 10.5501 3.49219 8.76855C4.23012 6.98718 5.47982 5.46483 7.08301 4.39355C8.68639 3.32221 10.5716 2.75 12.5 2.75ZM11.75 4.28516C9.70145 4.47452 7.7973 5.42115 6.41016 6.94043C5.02299 8.4599 4.25247 10.4426 4.25 12.5C4.25247 14.5574 5.02299 16.5401 6.41016 18.0596C7.7973 19.5789 9.70145 20.5255 11.75 20.7148V4.28516Z",
              fill: "#525252"
            }
          )
        }
      )
    }
  ];
  const handleThemeSelect = (selectedTheme) => {
    if (variant === "with-save") {
      setTempTheme(selectedTheme);
    } else {
      setTheme(selectedTheme);
    }
    if (onToggle) {
      onToggle(selectedTheme);
    }
  };
  const currentTheme = variant === "with-save" ? tempTheme : themeMode;
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex flex-row gap-2 sm:gap-4 py-2", children: problemTypes.map((type) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
    SelectionButton_default,
    {
      icon: type.icon,
      label: type.title,
      selected: currentTheme === type.id,
      onClick: () => handleThemeSelect(type.id),
      className: "w-full p-2 sm:p-4"
    },
    type.id
  )) });
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  ThemeToggle
});
//# sourceMappingURL=index.js.map