accessibility-plugin-react 2.0.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -28,6 +28,7 @@ __export(index_exports, {
28
28
  AccessibilityPlugin: () => AccessibilityPlugin,
29
29
  BigCursorController: () => BigCursorController,
30
30
  ContrastController: () => ContrastController,
31
+ DEFAULT_PREFERENCES: () => DEFAULT_PREFERENCES,
31
32
  FontSizeController: () => FontSizeController,
32
33
  GrayscaleController: () => GrayscaleController,
33
34
  HideImagesController: () => HideImagesController,
@@ -36,15 +37,50 @@ __export(index_exports, {
36
37
  LetterSpacingController: () => LetterSpacingController,
37
38
  LineHeightController: () => LineHeightController,
38
39
  LinkHighlightController: () => LinkHighlightController,
40
+ PROFILE_DEFINITIONS: () => PROFILE_DEFINITIONS,
39
41
  ReadingGuideController: () => ReadingGuideController,
40
42
  ReadingMaskController: () => ReadingMaskController,
41
43
  ResetController: () => ResetController,
42
44
  SaturationController: () => SaturationController,
43
45
  TextAlignController: () => TextAlignController,
46
+ createInitialPreferencesState: () => createInitialPreferencesState,
47
+ enLocale: () => enLocale,
48
+ isRtlLocale: () => isRtlLocale,
49
+ normalizePreferenceValue: () => normalizePreferenceValue,
50
+ normalizePreferences: () => normalizePreferences,
51
+ preferencesReducer: () => preferencesReducer,
52
+ registerLocale: () => registerLocale,
53
+ resolveEffectivePreferences: () => resolveEffectivePreferences,
54
+ resolveLocaleStrings: () => resolveLocaleStrings,
44
55
  useAccessibility: () => useAccessibility
45
56
  });
46
57
  module.exports = __toCommonJS(index_exports);
47
58
 
59
+ // #style-inject:#style-inject
60
+ function styleInject(css, { insertAt } = {}) {
61
+ if (!css || typeof document === "undefined") return;
62
+ const head = document.head || document.getElementsByTagName("head")[0];
63
+ const style = document.createElement("style");
64
+ style.type = "text/css";
65
+ if (insertAt === "top") {
66
+ if (head.firstChild) {
67
+ head.insertBefore(style, head.firstChild);
68
+ } else {
69
+ head.appendChild(style);
70
+ }
71
+ } else {
72
+ head.appendChild(style);
73
+ }
74
+ if (style.styleSheet) {
75
+ style.styleSheet.cssText = css;
76
+ } else {
77
+ style.appendChild(document.createTextNode(css));
78
+ }
79
+ }
80
+
81
+ // src/styles/tailwind.css
82
+ styleInject('.arap-root {\n --arap-surface: #fff;\n --arap-text: #111827;\n --arap-muted: #475569;\n --arap-border: #cbd5e1;\n --arap-divider: #e2e8f0;\n --arap-accent: #1d4ed8;\n --arap-accent-hover: #1e40af;\n --arap-selected: #eff6ff;\n --arap-control: #f8fafc;\n color-scheme: light;\n font: 15px/1.5 system-ui, sans-serif;\n color: var(--arap-text);\n text-align: left;\n letter-spacing: normal;\n}\n.arap-root *,\n.arap-root *::before,\n.arap-root *::after {\n box-sizing: border-box;\n}\n.arap-root button {\n font: inherit;\n cursor: pointer;\n color: inherit;\n text-transform: none;\n letter-spacing: normal;\n transition: background-color 0.15s, border-color 0.15s;\n}\n.arap-root button:disabled {\n opacity: 0.45;\n cursor: not-allowed;\n}\n.arap-root button:focus-visible,\n.arap-panel:focus-visible {\n outline: 3px solid var(--arap-accent);\n outline-offset: 3px;\n}\n.arap-root .arap-btn {\n position: fixed;\n z-index: 2147483001;\n bottom: max(16px, env(safe-area-inset-bottom));\n right: max(16px, env(safe-area-inset-right));\n width: 56px;\n height: 56px;\n padding: 12px;\n display: flex;\n align-items: center;\n justify-content: center;\n border: 2px solid var(--arap-surface);\n border-radius: 50%;\n background: var(--arap-accent);\n color: #fff;\n box-shadow: 0 4px 12px #0f172a26, 0 10px 24px #0f172a14;\n}\n.arap-root .arap-btn:hover {\n background: var(--arap-accent-hover);\n}\n.arap-root .arap-btn[data-position=left] {\n right: auto;\n left: max(16px, env(safe-area-inset-left));\n}\n.arap-root .arap-btn[data-position=top] {\n bottom: auto;\n top: max(16px, env(safe-area-inset-top));\n}\n.arap-root .arap-panel {\n position: fixed;\n z-index: 2147483000;\n bottom: max(88px, calc(env(safe-area-inset-bottom) + 72px));\n right: max(16px, env(safe-area-inset-right));\n width: min(400px, calc(100vw - 32px));\n max-height: calc(100vh - 120px);\n max-height: calc(100dvh - 120px - env(safe-area-inset-bottom));\n overflow: auto;\n overscroll-behavior: contain;\n scrollbar-width: thin;\n scrollbar-color: var(--arap-border) transparent;\n padding: 20px;\n border: 1px solid var(--arap-divider);\n border-radius: 16px;\n background: var(--arap-surface);\n box-shadow: 0 8px 16px #0f172a0d, 0 20px 48px #0f172a1a;\n}\n.arap-root .arap-panel[hidden] {\n display: none !important;\n}\n.arap-root .arap-panel[data-position=left] {\n right: auto;\n left: max(16px, env(safe-area-inset-left));\n}\n.arap-root .arap-panel[data-position=top] {\n bottom: auto;\n top: max(88px, calc(env(safe-area-inset-top) + 72px));\n}\n.arap-heading {\n display: flex;\n justify-content: space-between;\n align-items: flex-start;\n gap: 8px;\n padding-bottom: 18px;\n border-bottom: 1px solid var(--arap-divider);\n}\n.arap-heading-copy {\n min-width: 0;\n}\n.arap-heading h2 {\n margin: 0;\n font: 700 22px/1.3 system-ui, sans-serif;\n letter-spacing: -0.025em;\n color: var(--arap-text);\n overflow-wrap: anywhere;\n}\n.arap-description {\n margin: 6px 0 0;\n color: var(--arap-muted);\n font: 14px/1.5 system-ui, sans-serif;\n overflow-wrap: anywhere;\n}\n.arap-heading button {\n flex: none;\n width: 44px;\n height: 44px;\n margin-top: -6px;\n border: 1px solid transparent;\n border-radius: 8px;\n background: transparent;\n color: var(--arap-muted);\n font-size: 28px;\n line-height: 1;\n}\n.arap-heading button:hover {\n background: var(--arap-control);\n border-color: var(--arap-border);\n}\n.arap-feature {\n display: grid;\n grid-template-columns: minmax(0, 1fr) auto;\n align-items: center;\n gap: 10px 12px;\n padding: 18px 0;\n border-bottom: 1px solid var(--arap-divider);\n}\n.arap-feature:last-child {\n border: 0;\n padding-bottom: 0;\n}\n.arap-label {\n display: flex;\n align-items: center;\n gap: 10px;\n font-weight: 500;\n min-width: 0;\n overflow-wrap: anywhere;\n}\n.arap-icon {\n flex: none;\n width: 22px;\n height: 22px;\n display: inline-block;\n vertical-align: middle;\n}\n.arap-controls {\n display: flex;\n align-items: stretch;\n border: 1px solid var(--arap-border);\n border-radius: 9px;\n overflow: hidden;\n background: var(--arap-control);\n}\n.arap-root .arap-btn-sm {\n flex: none;\n width: 44px;\n height: 44px;\n border: 0;\n border-radius: 0;\n background: transparent;\n font-size: 22px;\n}\n.arap-root .arap-btn-sm:hover:not(:disabled) {\n background: var(--arap-selected);\n color: var(--arap-accent);\n}\n.arap-root .arap-controls button:focus-visible {\n outline-offset: -4px;\n}\n.arap-value {\n display: flex;\n align-items: center;\n justify-content: center;\n min-width: 56px;\n padding: 0 6px;\n text-align: center;\n font-weight: 600;\n border-inline: 1px solid var(--arap-divider);\n background: var(--arap-surface);\n}\n.arap-segmented {\n grid-column: 1 / -1;\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n min-width: 0;\n}\n.arap-root .arap-segment {\n flex: 1 1 auto;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 5px;\n min-width: 44px;\n min-height: 44px;\n padding: 8px 10px;\n border: 1px solid var(--arap-border);\n border-radius: 8px;\n background: var(--arap-control);\n color: var(--arap-muted);\n overflow-wrap: anywhere;\n}\n.arap-root .arap-segment:hover {\n background: var(--arap-selected);\n border-color: var(--arap-accent);\n}\n.arap-root .arap-segment-active {\n background: var(--arap-accent);\n color: #fff;\n border-color: var(--arap-accent);\n font-weight: 600;\n}\n.arap-root .arap-segment-active:hover {\n background: var(--arap-accent-hover);\n color: #fff;\n}\n.arap-check {\n flex: none;\n font-size: 15px;\n line-height: 1;\n}\n.arap-root .arap-toggle {\n position: relative;\n width: 56px;\n height: 44px;\n padding: 0;\n border: 0;\n border-radius: 10px;\n background: transparent;\n}\n.arap-toggle::before {\n content: "";\n position: absolute;\n inset: 6px 0;\n border: 2px solid #64748b;\n border-radius: 20px;\n background: #e2e8f0;\n}\n.arap-toggle-knob {\n position: absolute;\n top: 10px;\n left: 4px;\n width: 24px;\n height: 24px;\n border-radius: 50%;\n background: #475569;\n pointer-events: none;\n transition: transform 0.15s;\n}\n.arap-toggle-active::before {\n background: var(--arap-accent);\n border-color: var(--arap-accent);\n}\n.arap-toggle-active .arap-toggle-knob {\n transform: translateX(24px);\n background: #fff;\n}\n.arap-toggle-active .arap-toggle-knob::after {\n content: "\\2713";\n display: block;\n color: var(--arap-accent);\n font-size: 16px;\n font-weight: 700;\n line-height: 24px;\n text-align: center;\n}\n.arap-root .arap-toggle:hover::before {\n border-color: var(--arap-accent);\n}\n.arap-feature-reset {\n display: block;\n}\n.arap-root .arap-reset-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 10px;\n width: 100%;\n min-height: 48px;\n padding: 10px;\n border: 1px solid var(--arap-border);\n border-radius: 10px;\n background: var(--arap-control);\n color: var(--arap-accent);\n font-weight: 600;\n}\n.arap-root .arap-reset-btn:hover {\n background: var(--arap-selected);\n border-color: var(--arap-accent);\n}\n@media (max-width: 380px) {\n .arap-root .arap-panel {\n padding: 16px;\n }\n .arap-heading h2 {\n font-size: 20px;\n }\n .arap-feature-stepper {\n grid-template-columns: minmax(0, 1fr);\n }\n .arap-controls {\n width: 100%;\n }\n .arap-value {\n flex: 1;\n }\n}\n@media (prefers-reduced-motion: reduce) {\n .arap-root *,\n .arap-root *::before,\n .arap-root *::after {\n transition: none !important;\n animation: none !important;\n }\n}\n@media (forced-colors: active) {\n .arap-root {\n --arap-surface: Canvas;\n --arap-text: CanvasText;\n --arap-muted: CanvasText;\n --arap-border: ButtonText;\n --arap-divider: ButtonText;\n --arap-accent: Highlight;\n --arap-control: Canvas;\n --arap-selected: Canvas;\n }\n .arap-root button[aria-pressed=true] {\n outline: 2px solid Highlight;\n outline-offset: -4px;\n }\n .arap-root .arap-segment-active {\n color: HighlightText;\n background: Highlight;\n }\n .arap-toggle::before {\n border-color: ButtonText;\n background: Canvas;\n }\n .arap-toggle-knob {\n background: ButtonText;\n }\n .arap-toggle-active .arap-toggle-knob {\n background: Highlight;\n }\n .arap-toggle-active .arap-toggle-knob::after {\n color: HighlightText;\n }\n}\n.arap-root .arap-panel {\n display: flex;\n flex-direction: column;\n overflow: visible;\n}\n.arap-heading {\n flex: none;\n}\n.arap-tools {\n flex: 1 1 auto;\n min-height: 0;\n overflow: auto;\n overscroll-behavior: contain;\n scrollbar-width: thin;\n scrollbar-color: var(--arap-border) transparent;\n padding: 0 3px;\n margin: 0 -3px;\n}\n.arap-tools:focus-visible {\n outline: 3px solid var(--arap-accent);\n outline-offset: -3px;\n}\n.arap-quick-actions {\n position: relative;\n flex: none;\n display: flex;\n align-items: center;\n gap: 8px;\n padding-top: 14px;\n margin-top: 8px;\n border-top: 1px solid var(--arap-divider);\n}\n.arap-actions {\n flex: 1;\n min-width: 0;\n}\n.arap-actions:empty {\n display: none;\n}\n.arap-actions .arap-feature-reset {\n padding: 0;\n margin: 0;\n border: 0;\n}\n.arap-root .arap-position-button,\n.arap-root .arap-position-default,\n.arap-root .arap-position-arrows button {\n min-width: 44px;\n min-height: 44px;\n padding: 8px 10px;\n border: 1px solid var(--arap-border);\n border-radius: 8px;\n background: var(--arap-control);\n color: var(--arap-accent);\n}\n.arap-root .arap-position-button:hover,\n.arap-root .arap-position-default:hover,\n.arap-root .arap-position-arrows button:hover {\n background: var(--arap-selected);\n border-color: var(--arap-accent);\n}\n.arap-position-popover {\n position: absolute;\n z-index: 1;\n bottom: calc(100% + 8px);\n left: 0;\n width: 100%;\n max-height: calc(100dvh - 160px);\n overflow: auto;\n padding: 14px;\n border: 1px solid var(--arap-border);\n border-radius: 12px;\n background: var(--arap-surface);\n box-shadow: 0 8px 24px #0f172a26;\n}\n.arap-position-popover[hidden] {\n display: none !important;\n}\n.arap-position-label {\n display: block;\n margin-bottom: 6px;\n font-weight: 600;\n}\n.arap-position-popover select {\n width: 100%;\n min-height: 44px;\n padding: 8px;\n border: 1px solid var(--arap-border);\n border-radius: 8px;\n font: inherit;\n color: var(--arap-text);\n background: var(--arap-surface);\n}\n.arap-position-popover select:focus-visible {\n outline: 3px solid var(--arap-accent);\n outline-offset: 2px;\n}\n.arap-position-arrows {\n display: flex;\n justify-content: space-between;\n gap: 6px;\n margin-top: 10px;\n}\n.arap-position-default {\n width: 100%;\n margin-top: 8px;\n}\n.arap-root .arap-btn[data-draggable=true] {\n touch-action: none;\n user-select: none;\n cursor: grab;\n}\n.arap-root .arap-btn[data-dragging=true] {\n cursor: grabbing;\n}\n.arap-root .arap-btn[data-corner$=left],\n.arap-root .arap-panel[data-corner$=left] {\n right: auto;\n left: max(16px, env(safe-area-inset-left));\n}\n.arap-root .arap-btn[data-corner$=right],\n.arap-root .arap-panel[data-corner$=right] {\n left: auto;\n right: max(16px, env(safe-area-inset-right));\n}\n.arap-root .arap-btn[data-corner^=top] {\n bottom: auto;\n top: max(16px, env(safe-area-inset-top));\n}\n.arap-root .arap-btn[data-corner^=bottom] {\n top: auto;\n bottom: max(16px, env(safe-area-inset-bottom));\n}\n.arap-root .arap-panel[data-corner^=top] {\n bottom: auto;\n top: max(88px, calc(env(safe-area-inset-top) + 72px));\n}\n.arap-root .arap-panel[data-corner^=bottom] {\n top: auto;\n bottom: max(88px, calc(env(safe-area-inset-bottom) + 72px));\n}\n.arap-sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n border: 0;\n}\n.arap-root .arap-skip-actions {\n position: absolute;\n top: 12px;\n left: 20px;\n width: 44px;\n height: 44px;\n clip-path: inset(50%);\n overflow: hidden;\n pointer-events: none;\n}\n.arap-root .arap-skip-actions:focus-visible {\n right: 20px;\n width: auto;\n height: auto;\n min-height: 44px;\n clip-path: none;\n pointer-events: auto;\n z-index: 2;\n padding: 8px;\n border: 1px solid var(--arap-accent);\n border-radius: 8px;\n background: var(--arap-surface);\n color: var(--arap-accent);\n}\n@media (max-height: 480px) {\n .arap-root .arap-panel {\n top: max(16px, env(safe-area-inset-top)) !important;\n bottom: max(16px, env(safe-area-inset-bottom)) !important;\n max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;\n padding: 8px;\n }\n .arap-heading {\n padding-bottom: 8px;\n }\n .arap-heading h2 {\n font-size: 18px;\n }\n .arap-heading button {\n margin-top: 0;\n }\n .arap-description {\n display: none;\n }\n .arap-quick-actions {\n padding-top: 8px;\n margin-top: 0;\n }\n .arap-root .arap-reset-btn {\n min-height: 44px;\n }\n .arap-root .arap-btn[data-open=true] {\n visibility: hidden;\n }\n .arap-position-popover {\n max-height: calc(100dvh - 96px);\n }\n}\n.arap-statement {\n flex: none;\n padding-top: 10px;\n text-align: center;\n}\n.arap-statement-link {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-height: 44px;\n padding: 6px 12px;\n color: var(--arap-accent);\n text-decoration: underline;\n text-underline-offset: 4px;\n font-size: 14px;\n font-weight: 500;\n border-radius: 8px;\n}\n.arap-statement-link:hover {\n color: var(--arap-accent-hover);\n background: var(--arap-selected);\n}\n.arap-statement-link:focus-visible {\n outline: 3px solid var(--arap-accent);\n outline-offset: 2px;\n}\n.arap-root .arap-btn[data-large-controls=true] {\n width: 64px;\n height: 64px;\n min-width: 48px;\n min-height: 48px;\n}\n.arap-root .arap-panel[data-large-controls=true] {\n width: min(440px, calc(100vw - 32px));\n}\n.arap-root .arap-panel[data-large-controls=true] .arap-heading button {\n width: 48px;\n height: 48px;\n min-width: 48px;\n min-height: 48px;\n font-size: 32px;\n}\n.arap-root .arap-panel[data-large-controls=true] .arap-btn-sm {\n width: 48px;\n height: 48px;\n min-width: 48px;\n min-height: 48px;\n font-size: 24px;\n}\n.arap-root .arap-panel[data-large-controls=true] .arap-value {\n min-width: 64px;\n font-size: 16px;\n}\n.arap-root .arap-panel[data-large-controls=true] .arap-segment {\n min-width: 48px;\n min-height: 48px;\n padding: 10px 14px;\n font-size: 15px;\n}\n.arap-root .arap-panel[data-large-controls=true] .arap-toggle {\n width: 64px;\n height: 48px;\n}\n.arap-root .arap-panel[data-large-controls=true] .arap-toggle::before {\n inset: 8px 0;\n}\n.arap-root .arap-panel[data-large-controls=true] .arap-toggle-knob {\n top: 12px;\n}\n.arap-root .arap-panel[data-large-controls=true] .arap-toggle-active .arap-toggle-knob {\n transform: translateX(28px);\n}\n.arap-root .arap-panel[data-large-controls=true] .arap-reset-btn {\n min-height: 52px;\n font-size: 16px;\n padding: 12px;\n}\n.arap-root .arap-panel[data-large-controls=true] .arap-position-button,\n.arap-root .arap-panel[data-large-controls=true] .arap-position-default,\n.arap-root .arap-panel[data-large-controls=true] .arap-position-arrows button {\n min-width: 48px;\n min-height: 48px;\n font-size: 15px;\n}\n.arap-root .arap-panel[data-large-controls=true] .arap-position-popover select {\n min-height: 48px;\n font-size: 15px;\n}\n.arap-root .arap-panel[data-large-controls=true] .arap-statement-link {\n min-height: 48px;\n font-size: 15px;\n padding: 10px 16px;\n}\n.arap-root .arap-panel[data-large-controls=true] .arap-skip-actions {\n min-width: 48px;\n min-height: 48px;\n}\n');
83
+
48
84
  // src/core/AccessibilityPlugin.tsx
49
85
  var import_react4 = require("react");
50
86
 
@@ -150,9 +186,19 @@ function validKey(key) {
150
186
  function isRecord(value) {
151
187
  return !!value && typeof value === "object" && !Array.isArray(value);
152
188
  }
153
- function loadState(key = DEFAULT_STORAGE_KEY) {
189
+ function getStorage(mode = "local") {
190
+ if (mode === "none" || typeof window === "undefined") return null;
191
+ try {
192
+ return mode === "session" ? window.sessionStorage : window.localStorage;
193
+ } catch {
194
+ return null;
195
+ }
196
+ }
197
+ function loadState(key = DEFAULT_STORAGE_KEY, mode = "local") {
198
+ const storage = getStorage(mode);
199
+ if (!storage) return null;
154
200
  try {
155
- const raw = JSON.parse(localStorage.getItem(key) || "null");
201
+ const raw = JSON.parse(storage.getItem(key) || "null");
156
202
  if (!isRecord(raw)) return null;
157
203
  const features = "version" in raw ? raw.version === 1 ? raw.features : null : raw;
158
204
  if (!isRecord(features)) return null;
@@ -163,19 +209,23 @@ function loadState(key = DEFAULT_STORAGE_KEY) {
163
209
  return null;
164
210
  }
165
211
  }
166
- function saveState(state, key = DEFAULT_STORAGE_KEY) {
212
+ function saveState(state, key = DEFAULT_STORAGE_KEY, mode = "local") {
213
+ const storage = getStorage(mode);
214
+ if (!storage) return;
167
215
  try {
168
- localStorage.setItem(key, JSON.stringify({ version: 1, features: state }));
216
+ storage.setItem(key, JSON.stringify({ version: 1, features: state }));
169
217
  } catch {
170
218
  }
171
219
  }
172
- function clearState(key = DEFAULT_STORAGE_KEY) {
220
+ function clearState(key = DEFAULT_STORAGE_KEY, mode = "local") {
221
+ const storage = getStorage(mode);
222
+ if (!storage) return;
173
223
  try {
174
- localStorage.removeItem(key);
224
+ storage.removeItem(key);
175
225
  } catch {
176
226
  }
177
227
  }
178
- function createStorageWriter(key = DEFAULT_STORAGE_KEY) {
228
+ function createStorageWriter(key = DEFAULT_STORAGE_KEY, mode = "local") {
179
229
  let timer;
180
230
  let pending;
181
231
  const cancel = () => {
@@ -186,7 +236,7 @@ function createStorageWriter(key = DEFAULT_STORAGE_KEY) {
186
236
  const flush = () => {
187
237
  const next = pending;
188
238
  cancel();
189
- if (next) saveState(next, key);
239
+ if (next) saveState(next, key, mode);
190
240
  };
191
241
  return {
192
242
  schedule(state) {
@@ -196,7 +246,7 @@ function createStorageWriter(key = DEFAULT_STORAGE_KEY) {
196
246
  },
197
247
  clear() {
198
248
  cancel();
199
- clearState(key);
249
+ clearState(key, mode);
200
250
  },
201
251
  cancel,
202
252
  flush
@@ -204,13 +254,14 @@ function createStorageWriter(key = DEFAULT_STORAGE_KEY) {
204
254
  }
205
255
 
206
256
  // src/core/preferenceStore.ts
207
- function createPreferenceStore(key, persist) {
208
- const writer = createStorageWriter(key);
257
+ function createPreferenceStore(key, persist, storageMode) {
258
+ const resolvedMode = storageMode ?? (persist ? "local" : "none");
259
+ const writer = createStorageWriter(key, resolvedMode);
209
260
  const empty = {};
210
261
  let snapshot2;
211
262
  const listeners = /* @__PURE__ */ new Set();
212
263
  const getSnapshot = () => {
213
- snapshot2 ?? (snapshot2 = persist ? loadState(key) ?? {} : {});
264
+ snapshot2 ?? (snapshot2 = resolvedMode !== "none" ? loadState(key, resolvedMode) ?? {} : {});
214
265
  return snapshot2;
215
266
  };
216
267
  return {
@@ -224,7 +275,7 @@ function createPreferenceStore(key, persist) {
224
275
  },
225
276
  update(update) {
226
277
  snapshot2 = update(getSnapshot());
227
- if (persist) {
278
+ if (resolvedMode !== "none") {
228
279
  if (Object.keys(snapshot2).length) writer.schedule(snapshot2);
229
280
  else writer.clear();
230
281
  }
@@ -475,11 +526,15 @@ function AccessibilityPlugin({
475
526
  children,
476
527
  position = "right",
477
528
  persistenceKey,
478
- persist = true
529
+ persist = true,
530
+ storage,
531
+ locale,
532
+ statementUrl,
533
+ largeControls
479
534
  }) {
480
535
  const [isOpen, setIsOpen] = (0, import_react4.useState)(false);
481
536
  const [store] = (0, import_react4.useState)(
482
- () => createPreferenceStore(persistenceKey, persist)
537
+ () => createPreferenceStore(persistenceKey, persist, storage)
483
538
  );
484
539
  const features = (0, import_react4.useSyncExternalStore)(
485
540
  store.subscribe,
@@ -593,7 +648,10 @@ function AccessibilityPlugin({
593
648
  registerFeature,
594
649
  resetAll,
595
650
  registerReset,
596
- unregisterReset
651
+ unregisterReset,
652
+ locale,
653
+ statementUrl,
654
+ largeControls
597
655
  }),
598
656
  [
599
657
  isOpen,
@@ -609,7 +667,10 @@ function AccessibilityPlugin({
609
667
  registerFeature,
610
668
  resetAll,
611
669
  registerReset,
612
- unregisterReset
670
+ unregisterReset,
671
+ locale,
672
+ statementUrl,
673
+ largeControls
613
674
  ]
614
675
  );
615
676
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(AccessibilityContext.Provider, { value, children: [
@@ -648,21 +709,93 @@ function WidgetPortal({ children }) {
648
709
  ) : null;
649
710
  }
650
711
 
712
+ // src/core/i18n/en.ts
713
+ var enLocale = Object.freeze({
714
+ title: "Accessibility settings",
715
+ description: "Adjust your reading experience",
716
+ closeLabel: "Close accessibility settings",
717
+ skipToActions: "Jump to quick actions",
718
+ toolsLabel: "Accessibility tools",
719
+ quickActionsLabel: "Quick actions",
720
+ resetLabel: "Reset all accessibility settings",
721
+ resetAll: "Reset All",
722
+ statementLink: "Accessibility Statement",
723
+ openInNewTab: "opens in a new tab",
724
+ buttonTitle: "Accessibility",
725
+ dragHelp: "Drag to move, or use Alt and arrow keys. The Move button menu offers click and keyboard controls.",
726
+ positionLabel: "Button position",
727
+ moveButton: "Move button",
728
+ moveButtonLabel: "Move accessibility button",
729
+ buttonPositionSelectLabel: "Accessibility button position",
730
+ customPosition: "Custom position",
731
+ resetPosition: "Reset button position",
732
+ doneMoving: "Done moving",
733
+ moveLeft: "Move accessibility button left",
734
+ moveUp: "Move accessibility button up",
735
+ moveDown: "Move accessibility button down",
736
+ moveRight: "Move accessibility button right",
737
+ largeControlsLabel: "Oversized widget controls",
738
+ formatPointPosition: (x, y) => `Button position: ${Math.round(x * 100)}% horizontally, ${Math.round(y * 100)}% vertically.`,
739
+ formatCornerPosition: (corner) => `Button position: ${corner.split("-").join(" ")}.`
740
+ });
741
+
742
+ // src/core/i18n/index.ts
743
+ var dictionaries = {
744
+ en: enLocale
745
+ };
746
+ var RTL_LOCALES = /* @__PURE__ */ new Set([
747
+ "ar",
748
+ "arc",
749
+ "dv",
750
+ "fa",
751
+ "ha",
752
+ "he",
753
+ "khw",
754
+ "ks",
755
+ "ku",
756
+ "ps",
757
+ "ur",
758
+ "yi"
759
+ ]);
760
+ function registerLocale(code, strings) {
761
+ dictionaries[code.toLowerCase()] = strings;
762
+ }
763
+ function isRtlLocale(localeProp) {
764
+ if (!localeProp) return false;
765
+ const base = localeProp.toLowerCase().split("-")[0];
766
+ return RTL_LOCALES.has(base);
767
+ }
768
+ function resolveLocaleStrings(localeProp) {
769
+ const normalized = (localeProp || (typeof document !== "undefined" ? document.documentElement.lang : "en") || "en").trim().toLowerCase();
770
+ if (dictionaries[normalized]) {
771
+ return dictionaries[normalized];
772
+ }
773
+ const base = normalized.split("-")[0];
774
+ if (dictionaries[base]) {
775
+ return dictionaries[base];
776
+ }
777
+ return enLocale;
778
+ }
779
+
651
780
  // src/core/AccessibilityButton.tsx
652
781
  var import_jsx_runtime3 = require("react/jsx-runtime");
653
782
  function AccessibilityButton({
654
783
  icon,
655
784
  draggable = true,
656
- title = "Accessibility",
785
+ title,
657
786
  description,
658
787
  className = "",
659
- style
788
+ style,
789
+ largeControls
660
790
  }) {
661
791
  const ctx = (0, import_react6.useContext)(AccessibilityContext);
662
792
  if (!ctx)
663
793
  throw new Error(
664
794
  "AccessibilityButton must be used within an <AccessibilityPlugin> provider."
665
795
  );
796
+ const strings = resolveLocaleStrings(ctx.locale);
797
+ const buttonTitle = title ?? strings.buttonTitle;
798
+ const isLarge = largeControls ?? ctx.largeControls ?? false;
666
799
  const viewport = useViewport();
667
800
  const triggerSize = useTriggerSize(`${ctx.panelId}-trigger`);
668
801
  const [preview, setPreview] = (0, import_react6.useState)(null);
@@ -683,6 +816,7 @@ function AccessibilityButton({
683
816
  "data-dragging": !!preview,
684
817
  "data-open": ctx.isOpen,
685
818
  "data-position": ctx.position,
819
+ "data-large-controls": isLarge,
686
820
  onPointerDown: (event) => {
687
821
  suppressClick.current = false;
688
822
  if (!draggable || !event.isPrimary || event.button !== 0) return;
@@ -762,7 +896,7 @@ function AccessibilityButton({
762
896
  );
763
897
  }
764
898
  },
765
- "aria-label": title,
899
+ "aria-label": buttonTitle,
766
900
  "aria-keyshortcuts": draggable ? "Alt+ArrowUp Alt+ArrowDown Alt+ArrowLeft Alt+ArrowRight" : void 0,
767
901
  "aria-describedby": description || draggable ? `${ctx.panelId}-trigger-description` : void 0,
768
902
  "aria-expanded": ctx.isOpen,
@@ -784,14 +918,16 @@ function AccessibilityButton({
784
918
  }
785
919
  ) }),
786
920
  (description || draggable) && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { id: `${ctx.panelId}-trigger-description`, hidden: true, children: [
787
- description,
788
- " ",
789
- draggable && "Drag to move, or use Alt and arrow keys. The Move button menu offers click and keyboard controls."
921
+ description ? `${description} ` : "",
922
+ draggable && strings.dragHelp
790
923
  ] })
791
924
  ]
792
925
  }
793
926
  ),
794
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "arap-sr-only", role: "status", children: ctx.widgetPlacement?.kind === "point" ? `Button position: ${Math.round(ctx.widgetPlacement.x * 100)}% horizontally, ${Math.round(ctx.widgetPlacement.y * 100)}% vertically.` : `Button position: ${corner.split("-").join(" ")}.` })
927
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "arap-sr-only", role: "status", children: ctx.widgetPlacement?.kind === "point" ? strings.formatPointPosition ? strings.formatPointPosition(
928
+ ctx.widgetPlacement.x,
929
+ ctx.widgetPlacement.y
930
+ ) : `Button position: ${Math.round(ctx.widgetPlacement.x * 100)}% horizontally, ${Math.round(ctx.widgetPlacement.y * 100)}% vertically.` : strings.formatCornerPosition ? strings.formatCornerPosition(corner) : `Button position: ${corner.split("-").join(" ")}.` })
795
931
  ] });
796
932
  }
797
933
 
@@ -807,6 +943,7 @@ var import_react8 = require("react");
807
943
  var import_jsx_runtime4 = require("react/jsx-runtime");
808
944
  function PositionControls() {
809
945
  const ctx = (0, import_react8.useContext)(AccessibilityContext);
946
+ const strings = resolveLocaleStrings(ctx.locale);
810
947
  const [open, setOpen] = (0, import_react8.useState)(false);
811
948
  const select = (0, import_react8.useRef)(null);
812
949
  const opener = (0, import_react8.useRef)(null);
@@ -838,7 +975,7 @@ function PositionControls() {
838
975
  event.currentTarget.focus();
839
976
  setOpen(!open);
840
977
  },
841
- children: "Move button"
978
+ children: strings.moveButton
842
979
  }
843
980
  ),
844
981
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
@@ -848,7 +985,7 @@ function PositionControls() {
848
985
  className: "arap-position-popover",
849
986
  hidden: !open,
850
987
  role: "group",
851
- "aria-label": "Move accessibility button",
988
+ "aria-label": strings.moveButtonLabel,
852
989
  onKeyDown: (event) => {
853
990
  if (event.key === "Escape") {
854
991
  event.stopPropagation();
@@ -861,7 +998,7 @@ function PositionControls() {
861
998
  {
862
999
  className: "arap-position-label",
863
1000
  htmlFor: `${ctx.panelId}-corner`,
864
- children: "Button position"
1001
+ children: strings.positionLabel
865
1002
  }
866
1003
  ),
867
1004
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
@@ -869,33 +1006,33 @@ function PositionControls() {
869
1006
  {
870
1007
  ref: select,
871
1008
  id: `${ctx.panelId}-corner`,
872
- "aria-label": "Accessibility button position",
1009
+ "aria-label": strings.buttonPositionSelectLabel,
873
1010
  value: ctx.widgetPlacement?.kind === "point" ? "custom" : ctx.widgetPlacement?.corner ?? defaultCorner(ctx.position),
874
1011
  onChange: (event) => ctx.setWidgetPlacement({
875
1012
  kind: "corner",
876
1013
  corner: event.target.value
877
1014
  }),
878
1015
  children: [
879
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "custom", disabled: true, children: "Custom position" }),
1016
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "custom", disabled: true, children: strings.customPosition }),
880
1017
  corners.map((corner) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: corner, children: corner.split("-").join(" ") }, corner))
881
1018
  ]
882
1019
  }
883
1020
  ),
884
1021
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "arap-position-arrows", children: [
885
- ["left", -20, 0, "\u2190"],
886
- ["up", 0, -20, "\u2191"],
887
- ["down", 0, 20, "\u2193"],
888
- ["right", 20, 0, "\u2192"]
889
- ].map(([direction, dx, dy, label]) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1022
+ ["left", -20, 0, "\u2190", strings.moveLeft],
1023
+ ["up", 0, -20, "\u2191", strings.moveUp],
1024
+ ["down", 0, 20, "\u2193", strings.moveDown],
1025
+ ["right", 20, 0, "\u2192", strings.moveRight]
1026
+ ].map(([direction, dx, dy, arrowChar, label]) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
890
1027
  "button",
891
1028
  {
892
1029
  type: "button",
893
- "aria-label": `Move accessibility button ${direction}`,
1030
+ "aria-label": label,
894
1031
  onClick: (event) => {
895
1032
  event.currentTarget.focus();
896
1033
  move(dx, dy);
897
1034
  },
898
- children: label
1035
+ children: arrowChar
899
1036
  },
900
1037
  direction
901
1038
  )) }),
@@ -908,10 +1045,10 @@ function PositionControls() {
908
1045
  event.currentTarget.focus();
909
1046
  ctx.setWidgetPlacement(null);
910
1047
  },
911
- children: "Reset button position"
1048
+ children: strings.resetPosition
912
1049
  }
913
1050
  ),
914
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { className: "arap-position-default", type: "button", onClick: close, children: "Done moving" })
1051
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { className: "arap-position-default", type: "button", onClick: close, children: strings.doneMoving })
915
1052
  ]
916
1053
  }
917
1054
  )
@@ -925,11 +1062,22 @@ function Panel({
925
1062
  footer,
926
1063
  className = "",
927
1064
  style,
928
- title = "Accessibility settings",
929
- description = "Adjust your reading experience",
930
- closeLabel = "Close accessibility settings"
1065
+ title,
1066
+ description,
1067
+ closeLabel,
1068
+ statementUrl,
1069
+ largeControls,
1070
+ locale
931
1071
  }) {
932
1072
  const ctx = (0, import_react9.useContext)(AccessibilityContext);
1073
+ const effectiveLocale = locale ?? ctx.locale;
1074
+ const strings = resolveLocaleStrings(effectiveLocale);
1075
+ const panelTitle = title ?? strings.title;
1076
+ const panelDescription = description === void 0 ? strings.description : description;
1077
+ const panelCloseLabel = closeLabel ?? strings.closeLabel;
1078
+ const effectiveStatementUrl = statementUrl ?? ctx.statementUrl;
1079
+ const isLarge = largeControls ?? ctx.largeControls ?? false;
1080
+ const isRtl = isRtlLocale(effectiveLocale);
933
1081
  const panel = (0, import_react9.useRef)(null);
934
1082
  const [actions, setActions] = (0, import_react9.useState)(null);
935
1083
  const viewport = useViewport();
@@ -963,10 +1111,14 @@ function Panel({
963
1111
  },
964
1112
  "data-corner": corner,
965
1113
  "data-position": ctx.position,
1114
+ "data-large-controls": isLarge,
1115
+ lang: effectiveLocale ?? "en",
1116
+ dir: isRtl ? "rtl" : "ltr",
1117
+ translate: "no",
966
1118
  hidden: !ctx.isOpen,
967
1119
  role: "region",
968
- "aria-label": title,
969
- "aria-describedby": description ? `${ctx.panelId}-description` : void 0,
1120
+ "aria-label": panelTitle,
1121
+ "aria-describedby": panelDescription ? `${ctx.panelId}-description` : void 0,
970
1122
  tabIndex: -1,
971
1123
  onKeyDown: (event) => {
972
1124
  if (event.key === "Escape" && !event.defaultPrevented) {
@@ -977,10 +1129,18 @@ function Panel({
977
1129
  children: [
978
1130
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "arap-heading", children: [
979
1131
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "arap-heading-copy", children: [
980
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h2", { children: title }),
981
- description && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { id: `${ctx.panelId}-description`, className: "arap-description", children: description })
1132
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h2", { children: panelTitle }),
1133
+ panelDescription && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { id: `${ctx.panelId}-description`, className: "arap-description", children: panelDescription })
982
1134
  ] }),
983
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", "aria-label": closeLabel, onClick: ctx.closeMenu, children: "\xD7" })
1135
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1136
+ "button",
1137
+ {
1138
+ type: "button",
1139
+ "aria-label": panelCloseLabel,
1140
+ onClick: ctx.closeMenu,
1141
+ children: "\xD7"
1142
+ }
1143
+ )
984
1144
  ] }),
985
1145
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
986
1146
  "button",
@@ -993,7 +1153,7 @@ function Panel({
993
1153
  );
994
1154
  target?.focus();
995
1155
  },
996
- children: "Jump to quick actions"
1156
+ children: strings.skipToActions
997
1157
  }
998
1158
  ),
999
1159
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PanelActionsContext.Provider, { value: actions, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
@@ -1002,7 +1162,7 @@ function Panel({
1002
1162
  className: "arap-tools",
1003
1163
  role: "group",
1004
1164
  tabIndex: 0,
1005
- "aria-label": "Accessibility tools",
1165
+ "aria-label": strings.toolsLabel,
1006
1166
  children
1007
1167
  }
1008
1168
  ) }),
@@ -1011,13 +1171,30 @@ function Panel({
1011
1171
  {
1012
1172
  className: "arap-quick-actions",
1013
1173
  role: "group",
1014
- "aria-label": "Quick actions",
1174
+ "aria-label": strings.quickActionsLabel,
1015
1175
  children: [
1016
1176
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PositionControls, {}, ctx.isOpen ? "open" : "closed"),
1017
1177
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "arap-actions", ref: setActions, children: footer })
1018
1178
  ]
1019
1179
  }
1020
- )
1180
+ ),
1181
+ effectiveStatementUrl && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "arap-statement", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1182
+ "a",
1183
+ {
1184
+ href: effectiveStatementUrl,
1185
+ className: "arap-statement-link",
1186
+ target: "_blank",
1187
+ rel: "noopener noreferrer",
1188
+ children: [
1189
+ strings.statementLink,
1190
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "arap-sr-only", children: [
1191
+ " (",
1192
+ strings.openInNewTab,
1193
+ ")"
1194
+ ] })
1195
+ ]
1196
+ }
1197
+ ) })
1021
1198
  ]
1022
1199
  }
1023
1200
  );
@@ -1069,6 +1246,304 @@ function useAccessibility(featureKey, defaultValue, options) {
1069
1246
  return { value, setValue, reset };
1070
1247
  }
1071
1248
 
1249
+ // src/core/preferences/defaults.ts
1250
+ var DEFAULT_PREFERENCES = Object.freeze({
1251
+ fontScale: 1,
1252
+ lineHeight: null,
1253
+ letterSpacingEm: null,
1254
+ wordSpacingEm: null,
1255
+ paragraphSpacingEm: null,
1256
+ textAlign: "original",
1257
+ contrastMode: "off",
1258
+ highlightLinks: false,
1259
+ highlightFocus: false,
1260
+ reduceMotion: false,
1261
+ hideDecorativeImages: false,
1262
+ fontFamily: "original",
1263
+ cursorSize: "original",
1264
+ readerMode: "off",
1265
+ saturation: "original",
1266
+ tooltips: false
1267
+ });
1268
+ var PROFILE_DEFINITIONS = {
1269
+ motor: {
1270
+ id: "motor",
1271
+ label: "Motor Impaired",
1272
+ description: "Enhanced focus rings, richer tooltips, and reduced motion.",
1273
+ settings: {
1274
+ reduceMotion: true,
1275
+ highlightFocus: true,
1276
+ tooltips: true
1277
+ }
1278
+ },
1279
+ blind: {
1280
+ id: "blind",
1281
+ label: "Blind & Screen Reader",
1282
+ description: "Semantic assistance and accessible authored descriptions.",
1283
+ settings: {
1284
+ tooltips: true
1285
+ }
1286
+ },
1287
+ "color-blind": {
1288
+ id: "color-blind",
1289
+ label: "Color Blind",
1290
+ description: "High contrast accents and non-color-only link indicators.",
1291
+ settings: {
1292
+ contrastMode: "high",
1293
+ highlightLinks: true
1294
+ }
1295
+ },
1296
+ dyslexia: {
1297
+ id: "dyslexia",
1298
+ label: "Dyslexia Friendly",
1299
+ description: "Legible typeface, reading guide line, and reduced motion.",
1300
+ settings: {
1301
+ fontFamily: "dyslexia-option",
1302
+ readerMode: "guide",
1303
+ reduceMotion: true
1304
+ }
1305
+ },
1306
+ "low-vision": {
1307
+ id: "low-vision",
1308
+ label: "Low Vision",
1309
+ description: "Enlarged text, large cursor pointer, and high-visibility focus.",
1310
+ settings: {
1311
+ fontScale: 1.25,
1312
+ cursorSize: "large",
1313
+ highlightFocus: true,
1314
+ tooltips: true
1315
+ }
1316
+ },
1317
+ cognitive: {
1318
+ id: "cognitive",
1319
+ label: "Cognitive & Learning",
1320
+ description: "Mild text scaling, reading guide line, and distraction reduction.",
1321
+ settings: {
1322
+ fontScale: 1.125,
1323
+ readerMode: "guide",
1324
+ reduceMotion: true,
1325
+ tooltips: true
1326
+ }
1327
+ },
1328
+ seizure: {
1329
+ id: "seizure",
1330
+ label: "Seizure & Epileptic",
1331
+ description: "Pauses nonessential motion and reduces transition flashes.",
1332
+ settings: {
1333
+ reduceMotion: true
1334
+ }
1335
+ },
1336
+ adhd: {
1337
+ id: "adhd",
1338
+ label: "ADHD / Focus",
1339
+ description: "Reading mask spotlight and reduced animation distraction.",
1340
+ settings: {
1341
+ readerMode: "mask",
1342
+ reduceMotion: true
1343
+ }
1344
+ }
1345
+ };
1346
+
1347
+ // src/core/preferences/registry.ts
1348
+ var VALID_CONTRAST_MODES = /* @__PURE__ */ new Set([
1349
+ "off",
1350
+ "light",
1351
+ "dark",
1352
+ "high",
1353
+ "invert"
1354
+ ]);
1355
+ var VALID_READER_MODES = /* @__PURE__ */ new Set([
1356
+ "off",
1357
+ "guide",
1358
+ "mask"
1359
+ ]);
1360
+ var VALID_TEXT_ALIGNS = /* @__PURE__ */ new Set([
1361
+ "original",
1362
+ "left",
1363
+ "right",
1364
+ "center",
1365
+ "justify"
1366
+ ]);
1367
+ var VALID_FONT_FAMILIES = /* @__PURE__ */ new Set([
1368
+ "original",
1369
+ "legible",
1370
+ "dyslexia-option"
1371
+ ]);
1372
+ var VALID_CURSOR_SIZES = /* @__PURE__ */ new Set([
1373
+ "original",
1374
+ "large"
1375
+ ]);
1376
+ var VALID_SATURATIONS = /* @__PURE__ */ new Set([
1377
+ "original",
1378
+ "low",
1379
+ "high",
1380
+ "grayscale"
1381
+ ]);
1382
+ function clamp(value, min, max) {
1383
+ if (Number.isNaN(value) || !Number.isFinite(value)) return min;
1384
+ return Math.min(Math.max(value, min), max);
1385
+ }
1386
+ function normalizePreferenceValue(key, value) {
1387
+ switch (key) {
1388
+ case "fontScale":
1389
+ return typeof value === "number" ? clamp(value, 0.5, 2) : 1;
1390
+ case "lineHeight":
1391
+ if (value === null || value === void 0)
1392
+ return null;
1393
+ return typeof value === "number" ? clamp(value, 0.5, 2) : null;
1394
+ case "letterSpacingEm":
1395
+ if (value === null || value === void 0)
1396
+ return null;
1397
+ return typeof value === "number" ? clamp(value, 0, 0.5) : null;
1398
+ case "wordSpacingEm":
1399
+ if (value === null || value === void 0)
1400
+ return null;
1401
+ return typeof value === "number" ? clamp(value, 0, 0.5) : null;
1402
+ case "paragraphSpacingEm":
1403
+ if (value === null || value === void 0)
1404
+ return null;
1405
+ return typeof value === "number" ? clamp(value, 0, 1) : null;
1406
+ case "textAlign":
1407
+ return typeof value === "string" && VALID_TEXT_ALIGNS.has(value) ? value : "original";
1408
+ case "contrastMode":
1409
+ return typeof value === "string" && VALID_CONTRAST_MODES.has(value) ? value : "off";
1410
+ case "fontFamily":
1411
+ return typeof value === "string" && VALID_FONT_FAMILIES.has(value) ? value : "original";
1412
+ case "cursorSize":
1413
+ return typeof value === "string" && VALID_CURSOR_SIZES.has(value) ? value : "original";
1414
+ case "readerMode":
1415
+ return typeof value === "string" && VALID_READER_MODES.has(value) ? value : "off";
1416
+ case "saturation":
1417
+ return typeof value === "string" && VALID_SATURATIONS.has(value) ? value : "original";
1418
+ case "highlightLinks":
1419
+ case "highlightFocus":
1420
+ case "reduceMotion":
1421
+ case "hideDecorativeImages":
1422
+ case "tooltips":
1423
+ return Boolean(value);
1424
+ default:
1425
+ return value;
1426
+ }
1427
+ }
1428
+ function normalizePreferences(input) {
1429
+ const result = { ...DEFAULT_PREFERENCES };
1430
+ if (!input || typeof input !== "object") return result;
1431
+ for (const k of Object.keys(DEFAULT_PREFERENCES)) {
1432
+ if (k in input && input[k] !== void 0) {
1433
+ result[k] = normalizePreferenceValue(k, input[k]);
1434
+ }
1435
+ }
1436
+ return result;
1437
+ }
1438
+ function resolveEffectivePreferences(base, profileSnapshot, overrides) {
1439
+ const merged = {
1440
+ ...DEFAULT_PREFERENCES,
1441
+ ...base,
1442
+ ...profileSnapshot ?? {},
1443
+ ...overrides
1444
+ };
1445
+ return normalizePreferences(merged);
1446
+ }
1447
+
1448
+ // src/core/preferences/reducer.ts
1449
+ function createInitialPreferencesState(initial) {
1450
+ const base = normalizePreferences(initial);
1451
+ return {
1452
+ base,
1453
+ activeProfileId: null,
1454
+ profileSnapshot: null,
1455
+ overrides: {},
1456
+ effective: { ...base }
1457
+ };
1458
+ }
1459
+ function preferencesReducer(state, action) {
1460
+ switch (action.type) {
1461
+ case "SET_PREFERENCE": {
1462
+ const normalizedValue = normalizePreferenceValue(
1463
+ action.key,
1464
+ action.value
1465
+ );
1466
+ if (state.activeProfileId) {
1467
+ const nextOverrides = {
1468
+ ...state.overrides,
1469
+ [action.key]: normalizedValue
1470
+ };
1471
+ return {
1472
+ ...state,
1473
+ overrides: nextOverrides,
1474
+ effective: resolveEffectivePreferences(
1475
+ state.base,
1476
+ state.profileSnapshot,
1477
+ nextOverrides
1478
+ )
1479
+ };
1480
+ }
1481
+ const nextBase = {
1482
+ ...state.base,
1483
+ [action.key]: normalizedValue
1484
+ };
1485
+ return {
1486
+ ...state,
1487
+ base: nextBase,
1488
+ effective: resolveEffectivePreferences(nextBase, null, state.overrides)
1489
+ };
1490
+ }
1491
+ case "APPLY_PROFILE": {
1492
+ const profile = PROFILE_DEFINITIONS[action.profileId];
1493
+ const settings = action.settings || profile?.settings || {};
1494
+ const profileSnapshot = { ...settings };
1495
+ const nextOverrides = {};
1496
+ return {
1497
+ ...state,
1498
+ activeProfileId: action.profileId,
1499
+ profileSnapshot,
1500
+ overrides: nextOverrides,
1501
+ effective: resolveEffectivePreferences(
1502
+ state.base,
1503
+ profileSnapshot,
1504
+ nextOverrides
1505
+ )
1506
+ };
1507
+ }
1508
+ case "CLEAR_PROFILE": {
1509
+ const nextBase = {
1510
+ ...state.base,
1511
+ ...state.overrides
1512
+ };
1513
+ return {
1514
+ ...state,
1515
+ activeProfileId: null,
1516
+ profileSnapshot: null,
1517
+ overrides: {},
1518
+ effective: normalizePreferences(nextBase),
1519
+ base: nextBase
1520
+ };
1521
+ }
1522
+ case "RESET_ALL": {
1523
+ const cleanBase = { ...DEFAULT_PREFERENCES };
1524
+ return {
1525
+ base: cleanBase,
1526
+ activeProfileId: null,
1527
+ profileSnapshot: null,
1528
+ overrides: {},
1529
+ effective: cleanBase
1530
+ };
1531
+ }
1532
+ case "IMPORT_PREFERENCES": {
1533
+ const cleanBase = normalizePreferences(action.preferences);
1534
+ return {
1535
+ base: cleanBase,
1536
+ activeProfileId: null,
1537
+ profileSnapshot: null,
1538
+ overrides: {},
1539
+ effective: cleanBase
1540
+ };
1541
+ }
1542
+ default:
1543
+ return state;
1544
+ }
1545
+ }
1546
+
1072
1547
  // src/core/FeatureIcon.tsx
1073
1548
  var import_jsx_runtime6 = require("react/jsx-runtime");
1074
1549
  var drawings = {
@@ -1662,9 +2137,10 @@ function ResetController() {
1662
2137
  }
1663
2138
  const actionHost = (0, import_react11.useContext)(PanelActionsContext);
1664
2139
  const { resetAll } = ctx;
2140
+ const strings = resolveLocaleStrings(ctx.locale);
1665
2141
  const button = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "arap-feature arap-feature-reset", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("button", { className: "arap-reset-btn", onClick: resetAll, type: "button", children: [
1666
2142
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(FeatureIcon, { name: "reset" }),
1667
- "Reset All"
2143
+ strings.resetAll
1668
2144
  ] }) });
1669
2145
  return actionHost ? (0, import_react_dom2.createPortal)(button, actionHost) : button;
1670
2146
  }
@@ -1676,6 +2152,7 @@ function ResetController() {
1676
2152
  AccessibilityPlugin,
1677
2153
  BigCursorController,
1678
2154
  ContrastController,
2155
+ DEFAULT_PREFERENCES,
1679
2156
  FontSizeController,
1680
2157
  GrayscaleController,
1681
2158
  HideImagesController,
@@ -1684,11 +2161,21 @@ function ResetController() {
1684
2161
  LetterSpacingController,
1685
2162
  LineHeightController,
1686
2163
  LinkHighlightController,
2164
+ PROFILE_DEFINITIONS,
1687
2165
  ReadingGuideController,
1688
2166
  ReadingMaskController,
1689
2167
  ResetController,
1690
2168
  SaturationController,
1691
2169
  TextAlignController,
2170
+ createInitialPreferencesState,
2171
+ enLocale,
2172
+ isRtlLocale,
2173
+ normalizePreferenceValue,
2174
+ normalizePreferences,
2175
+ preferencesReducer,
2176
+ registerLocale,
2177
+ resolveEffectivePreferences,
2178
+ resolveLocaleStrings,
1692
2179
  useAccessibility
1693
2180
  });
1694
2181
  //# sourceMappingURL=index.js.map