"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/hooks/useA11yPreferences.ts
var useA11yPreferences_exports = {};
__export(useA11yPreferences_exports, {
  __testing: () => __testing,
  useA11yPreferences: () => useA11yPreferences
});
module.exports = __toCommonJS(useA11yPreferences_exports);
var import_react = require("react");

// src/store/accessibilityStore.ts
var import_zustand = require("zustand");
var import_middleware = require("zustand/middleware");
var COLOR_BLIND_PREFIX = "a11y-cb-";
var getColorBlindClass = (mode) => mode === "none" /* None */ ? null : `${COLOR_BLIND_PREFIX}${mode}`;
var DEFAULT_ACCESSIBILITY_PREFERENCES = {
  contrastMode: "normal",
  saturationMode: "normal",
  fontSize: 0,
  letterSpacing: 0,
  lineSpacing: 0,
  highlightLinks: false,
  pauseAnimations: false,
  bigCursor: false,
  dyslexiaFont: false,
  readingAid: "none",
  keyboardShortcut: true,
  colorBlindMode: "none" /* None */,
  ttsMode: "off",
  ttsRate: 1,
  ttsVoiceId: null,
  librasEnabled: false
};
var useAccessibilityStore = (0, import_zustand.create)()(
  (0, import_middleware.devtools)(
    (0, import_middleware.persist)(
      (set) => ({
        ...DEFAULT_ACCESSIBILITY_PREFERENCES,
        isPanelOpen: false,
        ttsStatus: "idle",
        setContrastMode: (contrastMode) => set({ contrastMode }),
        setSaturationMode: (saturationMode) => set({ saturationMode }),
        setFontSize: (fontSize) => set({ fontSize }),
        setLetterSpacing: (letterSpacing) => set({ letterSpacing }),
        setLineSpacing: (lineSpacing) => set({ lineSpacing }),
        setHighlightLinks: (highlightLinks) => set({ highlightLinks }),
        setPauseAnimations: (pauseAnimations) => set({ pauseAnimations }),
        setBigCursor: (bigCursor) => set({ bigCursor }),
        setDyslexiaFont: (dyslexiaFont) => set({ dyslexiaFont }),
        setReadingAid: (readingAid) => set({ readingAid }),
        setKeyboardShortcut: (keyboardShortcut) => set({ keyboardShortcut }),
        setColorBlindMode: (colorBlindMode) => set({ colorBlindMode }),
        setTTSMode: (ttsMode) => set({ ttsMode }),
        setTTSRate: (ttsRate) => set({ ttsRate }),
        setTTSVoiceId: (ttsVoiceId) => set({ ttsVoiceId }),
        setTTSStatus: (ttsStatus) => set({ ttsStatus }),
        setLibrasEnabled: (librasEnabled) => set({ librasEnabled }),
        resetPreferences: () => set({ ...DEFAULT_ACCESSIBILITY_PREFERENCES }),
        openPanel: () => set({ isPanelOpen: true }),
        closePanel: () => set({ isPanelOpen: false }),
        togglePanel: () => set((state) => ({ isPanelOpen: !state.isPanelOpen }))
      }),
      {
        name: "accessibility-store",
        // version 1: removeu `librasEnabled` da persistência (era custoso
        // recarregar VLibras a cada refresh). A migração limpa esse valor
        // de localStorages antigos para evitar auto-load surpresa.
        version: 1,
        // eslint-disable-next-line @typescript-eslint/no-explicit-any -- migrate works with arbitrary persisted shapes from older versions
        migrate: (persistedState) => {
          if (persistedState && typeof persistedState === "object" && "librasEnabled" in persistedState) {
            delete persistedState.librasEnabled;
          }
          return persistedState;
        },
        partialize: (state) => ({
          contrastMode: state.contrastMode,
          saturationMode: state.saturationMode,
          fontSize: state.fontSize,
          letterSpacing: state.letterSpacing,
          lineSpacing: state.lineSpacing,
          highlightLinks: state.highlightLinks,
          pauseAnimations: state.pauseAnimations,
          bigCursor: state.bigCursor,
          dyslexiaFont: state.dyslexiaFont,
          readingAid: state.readingAid,
          keyboardShortcut: state.keyboardShortcut,
          colorBlindMode: state.colorBlindMode,
          ttsRate: state.ttsRate,
          ttsVoiceId: state.ttsVoiceId
          // ttsMode e librasEnabled NÃO são persistidos:
          // - ttsMode: o leitor sempre começa desligado ao recarregar
          //   a página para evitar comportamento confuso
          // - librasEnabled: o VLibras é pesado (~MBs de assets); auto-
          //   carregar a cada refresh seria custoso e surpreendente. O
          //   usuário ativa explicitamente quando precisa.
        })
      }
    ),
    { name: "accessibility-store" }
  )
);

// src/hooks/useA11yPreferences.ts
var CONTRAST_CLASS = {
  normal: null,
  high: "a11y-contrast-high",
  inverted: "a11y-contrast-inverted"
};
var SATURATION_CLASS = {
  normal: null,
  grayscale: "a11y-saturation-grayscale",
  low: "a11y-saturation-low"
};
var LEVEL_PREFIX = {
  fontSize: "a11y-font-",
  letterSpacing: "a11y-letter-spacing-",
  lineSpacing: "a11y-line-spacing-"
};
var ALL_A11Y_CLASSES = [
  "a11y-contrast-high",
  "a11y-contrast-inverted",
  "a11y-saturation-grayscale",
  "a11y-saturation-low",
  "a11y-font-1",
  "a11y-font-2",
  "a11y-font-3",
  "a11y-letter-spacing-1",
  "a11y-letter-spacing-2",
  "a11y-letter-spacing-3",
  "a11y-line-spacing-1",
  "a11y-line-spacing-2",
  "a11y-line-spacing-3",
  "a11y-highlight-links",
  "a11y-no-animations",
  "a11y-big-cursor",
  "a11y-dyslexia-font",
  "a11y-cb-protanopia",
  "a11y-cb-deuteranopia",
  "a11y-cb-tritanopia"
];
var buildLevelClass = (prefix, level) => {
  if (level === 0) return null;
  return `${prefix}${level}`;
};
var buildClassMap = (prefs) => ({
  contrastMode: CONTRAST_CLASS[prefs.contrastMode] ?? void 0,
  saturationMode: SATURATION_CLASS[prefs.saturationMode] ?? void 0,
  fontSize: buildLevelClass(LEVEL_PREFIX.fontSize, prefs.fontSize) ?? void 0,
  letterSpacing: buildLevelClass(LEVEL_PREFIX.letterSpacing, prefs.letterSpacing) ?? void 0,
  lineSpacing: buildLevelClass(LEVEL_PREFIX.lineSpacing, prefs.lineSpacing) ?? void 0,
  highlightLinks: prefs.highlightLinks ? "a11y-highlight-links" : void 0,
  pauseAnimations: prefs.pauseAnimations ? "a11y-no-animations" : void 0,
  bigCursor: prefs.bigCursor ? "a11y-big-cursor" : void 0,
  dyslexiaFont: prefs.dyslexiaFont ? "a11y-dyslexia-font" : void 0,
  colorBlindMode: getColorBlindClass(prefs.colorBlindMode) ?? void 0
});
var syncDom = (prefs) => {
  if (typeof document === "undefined") return;
  const root = document.documentElement;
  ALL_A11Y_CLASSES.forEach((cls) => root.classList.remove(cls));
  const classMap = buildClassMap(prefs);
  Object.values(classMap).forEach((cls) => {
    if (cls) root.classList.add(cls);
  });
};
var useA11yPreferences = () => {
  const contrastMode = useAccessibilityStore((s) => s.contrastMode);
  const saturationMode = useAccessibilityStore((s) => s.saturationMode);
  const fontSize = useAccessibilityStore((s) => s.fontSize);
  const letterSpacing = useAccessibilityStore((s) => s.letterSpacing);
  const lineSpacing = useAccessibilityStore((s) => s.lineSpacing);
  const highlightLinks = useAccessibilityStore((s) => s.highlightLinks);
  const pauseAnimations = useAccessibilityStore((s) => s.pauseAnimations);
  const bigCursor = useAccessibilityStore((s) => s.bigCursor);
  const dyslexiaFont = useAccessibilityStore((s) => s.dyslexiaFont);
  const readingAid = useAccessibilityStore((s) => s.readingAid);
  const keyboardShortcut = useAccessibilityStore((s) => s.keyboardShortcut);
  const colorBlindMode = useAccessibilityStore((s) => s.colorBlindMode);
  const ttsMode = useAccessibilityStore((s) => s.ttsMode);
  const ttsRate = useAccessibilityStore((s) => s.ttsRate);
  const ttsVoiceId = useAccessibilityStore((s) => s.ttsVoiceId);
  const librasEnabled = useAccessibilityStore((s) => s.librasEnabled);
  (0, import_react.useEffect)(() => {
    syncDom({
      contrastMode,
      saturationMode,
      fontSize,
      letterSpacing,
      lineSpacing,
      highlightLinks,
      pauseAnimations,
      bigCursor,
      dyslexiaFont,
      readingAid,
      keyboardShortcut,
      colorBlindMode,
      ttsMode,
      ttsRate,
      ttsVoiceId,
      librasEnabled
    });
  }, [
    contrastMode,
    saturationMode,
    fontSize,
    letterSpacing,
    lineSpacing,
    highlightLinks,
    pauseAnimations,
    bigCursor,
    dyslexiaFont,
    colorBlindMode
  ]);
};
var __testing = {
  buildClassMap,
  syncDom,
  ALL_A11Y_CLASSES
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  __testing,
  useA11yPreferences
});
//# sourceMappingURL=index.js.map