@nice2dev/ui-core 1.2.2 → 1.3.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +445 -0
  2. package/dist/core/NiceUserPreferences.d.ts +9 -2
  3. package/dist/core/a11y.d.ts +42 -5
  4. package/dist/core/hooks.d.ts +4 -0
  5. package/dist/core/spatialNav.d.ts +31 -8
  6. package/dist/core/useGamepad.d.ts +17 -4
  7. package/dist/index.cjs +21 -21
  8. package/dist/index.d.ts +1 -0
  9. package/dist/index.mjs +3965 -4756
  10. package/dist/input/bindings.d.ts +35 -0
  11. package/dist/input/elements.d.ts +71 -0
  12. package/dist/input/engine.d.ts +153 -0
  13. package/dist/input/focus/candidates.d.ts +18 -0
  14. package/dist/input/focus/navigator.d.ts +24 -0
  15. package/dist/input/focus/scopes.d.ts +44 -0
  16. package/dist/input/focus/spatial.d.ts +13 -0
  17. package/dist/input/gamepadFamily.d.ts +30 -0
  18. package/dist/input/gamepadPoller.d.ts +57 -0
  19. package/dist/input/index.d.ts +33 -0
  20. package/dist/input/osk/editing.d.ts +15 -0
  21. package/dist/input/osk/layouts.d.ts +47 -0
  22. package/dist/input/prompts/NiceButtonPrompt.d.ts +35 -0
  23. package/dist/input/prompts/NiceControlHint.d.ts +21 -0
  24. package/dist/input/prompts/NiceInputHintBar.d.ts +31 -0
  25. package/dist/input/prompts/NiceKeyCap.d.ts +18 -0
  26. package/dist/input/prompts/keys.d.ts +23 -0
  27. package/dist/input/react/NiceFocusScope.d.ts +14 -0
  28. package/dist/input/react/NiceInputProvider.d.ts +42 -0
  29. package/dist/input/react/actions.d.ts +48 -0
  30. package/dist/input/react/hints.d.ts +34 -0
  31. package/dist/input/react/hooks.d.ts +52 -0
  32. package/dist/input/react/useElementEffect.d.ts +7 -0
  33. package/dist/input/react/useGridFocus.d.ts +26 -0
  34. package/dist/input/react/useMenuButton.d.ts +29 -0
  35. package/dist/input/react/useOverlayFocus.d.ts +33 -0
  36. package/dist/input/react/useRovingFocus.d.ts +46 -0
  37. package/dist/input/react/useTreeFocus.d.ts +30 -0
  38. package/dist/input/tabEscape.d.ts +20 -0
  39. package/dist/input/types.d.ts +98 -0
  40. package/dist/input-layer-Hyi3G0IM.js +3911 -0
  41. package/dist/input-layer-Kez0PkmN.cjs +1 -0
  42. package/dist/input.cjs +1 -0
  43. package/dist/input.mjs +94 -0
  44. package/package.json +8 -2
@@ -0,0 +1,3911 @@
1
+ import { useNiceTranslation as Z } from "@nice2dev/i18n";
2
+ import { jsx as C, jsxs as F, Fragment as _t } from "react/jsx-runtime";
3
+ import Ne, { useContext as re, useCallback as O, createContext as Te, useRef as R, useEffect as V, useLayoutEffect as Bt, useState as K, useMemo as ve, useSyncExternalStore as Mt, forwardRef as Kt, useImperativeHandle as jt } from "react";
4
+ const gt = /* @__PURE__ */ new Set([
5
+ "",
6
+ "text",
7
+ "search",
8
+ "email",
9
+ "url",
10
+ "tel",
11
+ "password"
12
+ ]), Pe = /* @__PURE__ */ new Set([
13
+ "number",
14
+ "range",
15
+ "date",
16
+ "time",
17
+ "datetime-local",
18
+ "month",
19
+ "week"
20
+ ]), Ut = /* @__PURE__ */ new Set([
21
+ "checkbox",
22
+ "radio",
23
+ "button",
24
+ "submit",
25
+ "reset",
26
+ "file",
27
+ "image",
28
+ "color"
29
+ ]), Gt = /* @__PURE__ */ new Set([
30
+ "button",
31
+ "link",
32
+ "checkbox",
33
+ "radio",
34
+ "switch",
35
+ "tab",
36
+ "menuitem",
37
+ "menuitemcheckbox",
38
+ "menuitemradio",
39
+ "option",
40
+ "treeitem"
41
+ ]), bt = (n) => n instanceof HTMLInputElement && gt.has(n.type), De = (n) => n instanceof HTMLTextAreaElement, yt = (n) => n instanceof HTMLElement && n.isContentEditable;
42
+ function qt(n, e) {
43
+ const { intent: t, direction: a } = e;
44
+ return bt(n) ? t === "navigate" ? a === "left" || a === "right" : t === "first" || t === "last" || t === "activate" || t === "toggleHints" : De(n) || yt(n) ? t !== "back" && t !== "view" && t !== "menu" && t !== "secondary" : n instanceof HTMLSelectElement ? t !== "back" && t !== "view" && t !== "menu" : n instanceof HTMLInputElement ? Pe.has(n.type) ? t === "navigate" || t === "first" || t === "last" || t === "pagePrev" || t === "pageNext" : n.type === "radio" && t === "navigate" : !1;
45
+ }
46
+ function wt(n) {
47
+ if (n instanceof HTMLButtonElement || n.tagName === "SUMMARY")
48
+ return !0;
49
+ if (n instanceof HTMLAnchorElement)
50
+ return n.hasAttribute("href");
51
+ if (n instanceof HTMLInputElement)
52
+ return Ut.has(n.type);
53
+ const e = n.getAttribute("role");
54
+ return e !== null && Gt.has(e);
55
+ }
56
+ function $t(n) {
57
+ if (typeof n.click == "function") {
58
+ n.click();
59
+ return;
60
+ }
61
+ const e = n.ownerDocument.defaultView;
62
+ n.dispatchEvent(
63
+ new ((e == null ? void 0 : e.MouseEvent) ?? MouseEvent)("click", {
64
+ bubbles: !0,
65
+ cancelable: !0,
66
+ composed: !0
67
+ })
68
+ );
69
+ }
70
+ function Et(n) {
71
+ if (n.defaultPrevented || n.repeat || n.target !== n.currentTarget || n.key !== "Enter" && n.key !== " " && n.key !== "Spacebar")
72
+ return;
73
+ const e = n.currentTarget;
74
+ if (!e || typeof e.dispatchEvent != "function")
75
+ return;
76
+ n.preventDefault();
77
+ const t = e.ownerDocument.defaultView;
78
+ e.dispatchEvent(
79
+ new ((t == null ? void 0 : t.MouseEvent) ?? MouseEvent)("click", {
80
+ bubbles: !0,
81
+ cancelable: !0,
82
+ composed: !0,
83
+ ctrlKey: !!n.ctrlKey,
84
+ shiftKey: !!n.shiftKey,
85
+ altKey: !!n.altKey,
86
+ metaKey: !!n.metaKey
87
+ })
88
+ );
89
+ }
90
+ function me(n) {
91
+ const e = n.getAttribute("data-nice-engage");
92
+ if (e === "value" || e === "text" || e === "popup" || e === "canvas")
93
+ return e;
94
+ if (e === "none")
95
+ return null;
96
+ const t = n.getAttribute("role");
97
+ return t === "combobox" ? "popup" : t === "slider" || t === "spinbutton" || n instanceof HTMLSelectElement ? "value" : n instanceof HTMLInputElement ? gt.has(n.type) ? n.readOnly ? null : "text" : Pe.has(n.type) && !n.readOnly ? "value" : null : De(n) ? n.readOnly ? null : "text" : yt(n) ? "text" : null;
98
+ }
99
+ function kt(n, e) {
100
+ return e === "popup" ? n.getAttribute("aria-expanded") === "true" : n.hasAttribute("data-nice-engaged");
101
+ }
102
+ function ce(n) {
103
+ return n instanceof HTMLSelectElement || n instanceof HTMLInputElement && Pe.has(n.type);
104
+ }
105
+ function Me(n) {
106
+ n.dispatchEvent(new Event("input", { bubbles: !0 })), n.dispatchEvent(new Event("change", { bubbles: !0 }));
107
+ }
108
+ function Ie(n, e) {
109
+ var r;
110
+ const t = Object.getPrototypeOf(n), a = (r = Object.getOwnPropertyDescriptor(t, "value")) == null ? void 0 : r.set;
111
+ a ? a.call(n, e) : n.value = e;
112
+ }
113
+ const ge = "data-nice-engage-restore", be = (n) => n instanceof HTMLInputElement && n.type === "number";
114
+ function Yt(n) {
115
+ return be(n) || n.hasAttribute(ge);
116
+ }
117
+ function Ha(n, e, t) {
118
+ if (n.value !== e && (Ie(n, e), n.dispatchEvent(new Event("input", { bubbles: !0 }))), t !== void 0)
119
+ try {
120
+ n.setSelectionRange(t, t);
121
+ } catch {
122
+ }
123
+ }
124
+ function Wt(n, e) {
125
+ n.value !== e && (Ie(n, e), Me(n));
126
+ }
127
+ function le(n, e, t = "step") {
128
+ const a = e === "up" || e === "right";
129
+ if (n instanceof HTMLSelectElement) {
130
+ const s = n.selectedIndex, o = n.options.length - 1;
131
+ if (t === "edge")
132
+ n.selectedIndex = a ? o : 0;
133
+ else {
134
+ const i = t === "big" ? 10 : 1;
135
+ n.selectedIndex = Math.max(0, Math.min(o, s + (a ? i : -i)));
136
+ }
137
+ return n.selectedIndex !== s ? (Me(n), !0) : !1;
138
+ }
139
+ const r = n.value;
140
+ try {
141
+ if (t === "edge" && (n.min !== "" || n.max !== ""))
142
+ Ie(n, a ? n.max || n.value : n.min || n.value);
143
+ else {
144
+ const s = t === "big" ? 10 : 1;
145
+ a ? n.stepUp(s) : n.stepDown(s);
146
+ }
147
+ } catch {
148
+ return !1;
149
+ }
150
+ return n.value !== r ? (Me(n), !0) : !1;
151
+ }
152
+ function Xt(n, e) {
153
+ if (!(bt(n) || De(n)) || n.selectionStart === null || e !== "left" && e !== "right")
154
+ return !1;
155
+ const t = n.selectionStart + (e === "right" ? 1 : -1), a = Math.max(0, Math.min(n.value.length, t));
156
+ return n.setSelectionRange(a, a), !0;
157
+ }
158
+ const xt = {
159
+ // Navigation
160
+ "chevron-down": "M6 9l6 6 6-6",
161
+ "chevron-up": "M18 15l-6-6-6 6",
162
+ "chevron-left": "M15 18l-6-6 6-6",
163
+ "chevron-right": "M9 6l6 6-6 6",
164
+ "arrow-left": "M19 12H5m0 0l7 7m-7-7l7-7",
165
+ "arrow-right": "M5 12h14m0 0l-7-7m7 7l-7 7",
166
+ "arrow-up": "M12 19V5m0 0l-7 7m7-7l7 7",
167
+ "arrow-down": "M12 5v14m0 0l7-7m-7 7l-7-7",
168
+ // Actions
169
+ close: "M18 6L6 18M6 6l12 12",
170
+ plus: "M12 5v14m-7-7h14",
171
+ minus: "M5 12h14",
172
+ check: "M5 13l4 4L19 7",
173
+ edit: "M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7M18.5 2.5a2.121 2.121 0 113 3L12 15l-4 1 1-4 9.5-9.5z",
174
+ trash: "M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16",
175
+ copy: "M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z",
176
+ download: "M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4",
177
+ upload: "M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12",
178
+ refresh: "M4 4v5h5M20 20v-5h-5M20.49 9A9 9 0 005.64 5.64L1 10m22 4l-4.64 4.36A9 9 0 013.51 15",
179
+ // UI
180
+ search: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z",
181
+ filter: "M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z",
182
+ "sort-asc": "M3 4h13M3 8h9m-9 4h6m4 0l4-4m0 0l4 4m-4-4v12",
183
+ "sort-desc": "M3 4h13M3 8h9m-9 4h9m5-4v12m0 0l-4-4m4 4l4-4",
184
+ // Neutral "sortable" indicator: a small up-chevron over a down-chevron.
185
+ sort: "M6 10l6-6 6 6M6 14l6 6 6-6",
186
+ menu: "M4 6h16M4 12h16M4 18h16",
187
+ "more-vertical": "M12 5v.01M12 12v.01M12 19v.01",
188
+ "more-horizontal": "M5 12h.01M12 12h.01M19 12h.01",
189
+ settings: "M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z M15 12a3 3 0 11-6 0 3 3 0 016 0z",
190
+ eye: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z M15 12a3 3 0 11-6 0 3 3 0 016 0z",
191
+ "eye-off": "M17.94 17.94A10.07 10.07 0 0112 20c-7 0-11-8-11-8a18.45 18.45 0 015.06-5.94M9.9 4.24A9.12 9.12 0 0112 4c7 0 11 8 11 8a18.5 18.5 0 01-2.16 3.19m-6.72-1.07a3 3 0 11-4.24-4.24 M1 1l22 22",
192
+ lock: "M19 11H5a2 2 0 00-2 2v7a2 2 0 002 2h14a2 2 0 002-2v-7a2 2 0 00-2-2zm-3-4a4 4 0 10-8 0v4h8V7z",
193
+ // Status
194
+ info: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",
195
+ warning: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z",
196
+ error: "M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z",
197
+ success: "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z",
198
+ help: "M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",
199
+ // Content
200
+ calendar: "M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z",
201
+ clock: "M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z",
202
+ file: "M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z",
203
+ folder: "M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z",
204
+ image: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z",
205
+ link: "M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1",
206
+ mail: "M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z",
207
+ phone: "M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z",
208
+ // the device, as `phone` is the handset
209
+ smartphone: "M7 2h10a2 2 0 012 2v16a2 2 0 01-2 2H7a2 2 0 01-2-2V4a2 2 0 012-2z M11 18h2",
210
+ user: "M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z",
211
+ users: "M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z",
212
+ home: "M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6",
213
+ star: "M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z",
214
+ heart: "M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z",
215
+ bell: "M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9",
216
+ grip: "M4 6h2m4 0h2m4 0h2M4 12h2m4 0h2m4 0h2M4 18h2m4 0h2m4 0h2",
217
+ hash: "M4 9h16M4 15h16M10 3L8 21M16 3l-2 18",
218
+ list: "M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01",
219
+ circle: "M12 21a9 9 0 100-18 9 9 0 000 18z",
220
+ // UI component / element types (palettes, builders)
221
+ box: "M21 8a2 2 0 00-1-1.73l-7-4a2 2 0 00-2 0l-7 4A2 2 0 003 8v8a2 2 0 001 1.73l7 4a2 2 0 002 0l7-4A2 2 0 0021 16V8z M3.27 6.96L12 12.01l8.73-5.05 M12 22.08V12",
222
+ tabs: "M3 9h18v10H3z M7 9V5h6v4",
223
+ columns: "M4 4h7v16H4z M13 4h7v16h-7z",
224
+ grid: "M3 3h7v7H3z M14 3h7v7h-7z M14 14h7v7h-7z M3 14h7v7H3z",
225
+ table: "M3 5h18v14H3z M3 10h18M3 15h18M9 5v14M15 5v14",
226
+ heading: "M6 4v16M18 4v16M6 12h12",
227
+ type: "M4 7V4h16v3M9 20h6M12 4v16",
228
+ "align-left": "M3 6h18M3 12h12M3 18h15",
229
+ input: "M4 9h16a1 1 0 011 1v4a1 1 0 01-1 1H4a1 1 0 01-1-1v-4a1 1 0 011-1z M7 12h5",
230
+ button: "M5 9h14a2 2 0 012 2v2a2 2 0 01-2 2H5a2 2 0 01-2-2v-2a2 2 0 012-2z",
231
+ select: "M4 6h16a1 1 0 011 1v10a1 1 0 01-1 1H4a1 1 0 01-1-1V7a1 1 0 011-1z M15 11l-3 3-3-3",
232
+ "check-square": "M9 11l3 3L22 4 M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11",
233
+ video: "M23 7l-7 5 7 5V7z M16 5H3a2 2 0 00-2 2v10a2 2 0 002 2h13a2 2 0 002-2V7a2 2 0 00-2-2z",
234
+ card: "M3 5h18a1 1 0 011 1v12a1 1 0 01-1 1H3a1 1 0 01-1-1V6a1 1 0 011-1z M3 10h18",
235
+ // App / infra / media concepts
236
+ "bar-chart": "M6 20v-6M12 20V4M18 20v-10",
237
+ "line-chart": "M3 3v18h18 M7 15l4-4 3 3 5-6",
238
+ "area-chart": "M3 3v18h18 M7 17v-3l4-4 3 3 5-6v10z",
239
+ "pie-chart": "M21.21 15.89A10 10 0 118 2.83 M22 12A10 10 0 0012 2v10z",
240
+ "donut-chart": "M12 3a9 9 0 100 18 9 9 0 000-18z M12 8a4 4 0 100 8 4 4 0 000-8z",
241
+ "scatter-chart": "M3 3v18h18 M8 16h.01 M11 11h.01 M15 14h.01 M18 8h.01",
242
+ "bars-vertical": "M6 5v14M12 5v14M18 5v14",
243
+ globe: "M12 3a9 9 0 100 18 9 9 0 000-18z M3 12h18 M12 3a14 14 0 010 18 M12 3a14 14 0 000 18",
244
+ monitor: "M3 4h18a1 1 0 011 1v11a1 1 0 01-1 1H3a1 1 0 01-1-1V5a1 1 0 011-1z M8 21h8 M12 17v4",
245
+ camera: "M23 19a2 2 0 01-2 2H3a2 2 0 01-2-2V8a2 2 0 012-2h3l2-3h6l2 3h3a2 2 0 012 2z M12 17a4 4 0 100-8 4 4 0 000 8z",
246
+ plug: "M9 2v5 M15 2v5 M7 7h10v3a5 5 0 01-10 0V7z M12 15v7",
247
+ save: "M19 21H5a2 2 0 01-2-2V5a2 2 0 012-2h11l5 5v11a2 2 0 01-2 2z M17 21v-8H7v8 M7 3v5h8",
248
+ tag: "M20.59 13.41l-7.17 7.17a2 2 0 01-2.83 0L2 12V2h10l8.59 8.59a2 2 0 010 2.82z M7 7h.01",
249
+ palette: "M12 2a10 10 0 000 20 2 2 0 002-2c0-.5-.2-1-.5-1.3a2 2 0 01-.5-1.2 2 2 0 012-2H17a5 5 0 005-5c0-5-4.5-9-10-9z M6.5 11.5h.01 M9.5 7.5h.01 M14.5 7.5h.01",
250
+ book: "M4 19.5A2.5 2.5 0 016.5 17H20 M6.5 2H20v20H6.5A2.5 2.5 0 014 19.5v-15A2.5 2.5 0 016.5 2z",
251
+ cloud: "M18 10h-1.26A8 8 0 109 20h9a5 5 0 000-10z",
252
+ target: "M12 3a9 9 0 100 18 9 9 0 000-18z M12 7a5 5 0 100 10 5 5 0 000-10z M12 11a1 1 0 100 2 1 1 0 000-2z",
253
+ message: "M21 11.5a8.5 8.5 0 01-8.5 8.5 8.4 8.4 0 01-3.8-.9L3 21l1.9-5.7a8.4 8.4 0 01-.9-3.8A8.5 8.5 0 0112.5 3 8.5 8.5 0 0121 11.5z",
254
+ flask: "M9 2h6 M10 2v6.5L4.5 19a1 1 0 00.9 1.5h13.2a1 1 0 00.9-1.5L14 8.5V2 M7 15h10",
255
+ rocket: "M12 15l-3-3a22 22 0 012-3.95A12.88 12.88 0 0122 2c0 2.72-.78 7.5-6 11a22 22 0 01-3.95 2z M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0 M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5 M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 00-2.91-.09z",
256
+ music: "M9 18V5l12-2v13 M9 18a3 3 0 11-6 0 3 3 0 016 0z M21 16a3 3 0 11-6 0 3 3 0 016 0z",
257
+ wifi: "M5 12.55a11 11 0 0114 0 M8.5 16.11a6 6 0 017 0 M12 20h.01 M2 8.82a15 15 0 0120 0",
258
+ database: "M12 8c4.97 0 9-1.34 9-3s-4.03-3-9-3-9 1.34-9 3 4.03 3 9 3z M21 5v6c0 1.66-4.03 3-9 3s-9-1.34-9-3V5 M21 11v6c0 1.66-4.03 3-9 3s-9-1.34-9-3v-6",
259
+ slash: "M12 3a9 9 0 100 18 9 9 0 000-18z M5.6 5.6l12.8 12.8",
260
+ puzzle: "M19.4 13.6a1.6 1.6 0 10.2-3.2H19V7a2 2 0 00-2-2h-3.4v-.4a1.6 1.6 0 10-3.2 0V5H7a2 2 0 00-2 2v3.4h.4a1.6 1.6 0 100 3.2H5V17a2 2 0 002 2h3.4v.4a1.6 1.6 0 103.2 0V19H17a2 2 0 002-2v-3.4z",
261
+ dollar: "M12 1v22 M17 5H9.5a3.5 3.5 0 000 7h5a3.5 3.5 0 010 7H6",
262
+ printer: "M6 9V2h12v7 M6 18H4a2 2 0 01-2-2v-5a2 2 0 012-2h16a2 2 0 012 2v5a2 2 0 01-2 2h-2 M6 14h12v8H6z",
263
+ scale: "M12 3v18 M5 21h14 M5 7l7-2 7 2 M2 13a3 3 0 006 0L5 7zm14 0a3 3 0 006 0L19 7z",
264
+ accessibility: "M12 3a9 9 0 100 18 9 9 0 000-18z M12 9a1.5 1.5 0 100-3 1.5 1.5 0 000 3z M7.5 10.5l4.5 1 4.5-1 M12 11.5v3.5l-2 3.5 M12 15l2 3.5",
265
+ window: "M3 4h18a1 1 0 011 1v14a1 1 0 01-1 1H3a1 1 0 01-1-1V5a1 1 0 011-1z M2 9h20 M6 6.5h.01 M9 6.5h.01",
266
+ "map-pin": "M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0118 0z M12 13a3 3 0 100-6 3 3 0 000 6z",
267
+ cursor: "M5 3l14 7-6 2-2 6-6-15z",
268
+ shuffle: "M16 3h5v5 M4 20L21 3 M21 16v5h-5 M15 15l6 6 M4 4l5 5",
269
+ lightbulb: "M9 18h6 M10 22h4 M12 2a7 7 0 00-4 12.7c.6.5 1 1.3 1 2.1V18h6v-1.2c0-.8.4-1.6 1-2.1A7 7 0 0012 2z",
270
+ server: "M3 4h18a1 1 0 011 1v4a1 1 0 01-1 1H3a1 1 0 01-1-1V5a1 1 0 011-1z M3 14h18a1 1 0 011 1v4a1 1 0 01-1 1H3a1 1 0 01-1-1v-4a1 1 0 011-1z M7 7h.01 M7 17h.01",
271
+ terminal: "M4 17l6-6-6-6 M12 19h8",
272
+ "git-branch": "M6 3v12 M18 9a3 3 0 100-6 3 3 0 000 6z M6 21a3 3 0 100-6 3 3 0 000 6z M18 9a9 9 0 01-9 9",
273
+ send: "M22 2L11 13 M22 2l-7 20-4-9-9-4 20-7z",
274
+ // Media
275
+ play: "M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z M21 12a9 9 0 11-18 0 9 9 0 0118 0z",
276
+ pause: "M10 9v6m4-6v6m7-3a9 9 0 11-18 0 9 9 0 0118 0z",
277
+ stop: "M21 12a9 9 0 11-18 0 9 9 0 0118 0z M9 10a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 01-1-1v-4z",
278
+ mic: "M12 1a3 3 0 00-3 3v8a3 3 0 006 0V4a3 3 0 00-3-3zM19 10v2a7 7 0 01-14 0v-2M12 19v4M8 23h8",
279
+ volume: "M11 5L6 9H2v6h4l5 4V5z M15.54 8.46a5 5 0 010 7.07 M19.07 4.93a10 10 0 010 14.14",
280
+ "volume-off": "M11 5L6 9H2v6h4l5 4V5z M23 9l-6 6 M17 9l6 6",
281
+ "skip-back": "M19 20L9 12l10-8v16z M5 19V5",
282
+ // Toggle
283
+ expand: "M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4",
284
+ collapse: "M9 9V5m0 4H5m4 0L4 4m11 5h4m-4 0V5m0 4l5-5M9 15v4m0-4H5m4 0l-5 5m15-5h-4m4 0v4m0-4l-5 5",
285
+ "external-link": "M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14",
286
+ // Extended set (entities, gamification, status)
287
+ briefcase: "M20 7H4a2 2 0 00-2 2v9a2 2 0 002 2h16a2 2 0 002-2V9a2 2 0 00-2-2zM16 7V5a2 2 0 00-2-2h-4a2 2 0 00-2 2v2M2 12h20",
288
+ building: "M4 22V4a2 2 0 012-2h12a2 2 0 012 2v18M4 22h16M9 22v-4h6v4M9 6h.01M15 6h.01M9 10h.01M15 10h.01M9 14h.01M15 14h.01",
289
+ medal: "M15.477 12.89L17 22l-5-3-5 3 1.523-9.11M12 15a6 6 0 100-12 6 6 0 000 12z",
290
+ clipboard: "M9 2h6a1 1 0 011 1v1a1 1 0 01-1 1H9a1 1 0 01-1-1V3a1 1 0 011-1zM16 4h2a2 2 0 012 2v14a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2h2",
291
+ "skip-forward": "M5 4l10 8-10 8V4zM19 5v14",
292
+ "at-sign": "M12 16a4 4 0 100-8 4 4 0 000 8zM16 12v1.5a2.5 2.5 0 005 0V12a9 9 0 10-3.5 7.14",
293
+ gift: "M20 12v10H4V12M2 7h20v5H2zM12 22V7M12 7H7.5a2.5 2.5 0 010-5C11 2 12 7 12 7zM12 7h4.5a2.5 2.5 0 000-5C13 2 12 7 12 7z",
294
+ archive: "M21 8v13H3V8M1 3h22v5H1zM10 12h4",
295
+ reply: "M9 17l-5-5 5-5M4 12h11a4 4 0 014 4v2",
296
+ forward: "M15 17l5-5-5-5M20 12H9a4 4 0 00-4 4v2",
297
+ paperclip: "M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48",
298
+ zap: "M13 2L3 14h9l-1 8 10-12h-9l1-8z",
299
+ // Graphics / drawing tools (vector / pixel / photo / game editors)
300
+ square: "M4 4h16v16H4z",
301
+ triangle: "M12 4L3 20h18z",
302
+ hexagon: "M7.5 3h9l4.5 9-4.5 9h-9L3 12z",
303
+ diamond: "M12 2l10 10-10 10L2 12z",
304
+ line: "M5 19L19 5",
305
+ pen: "M12 19l7-7 3 3-7 7-3-3z M18 13l-1.5-7.5L2 2l3.5 14.5L13 18l5-5z M11 11a2 2 0 100-4 2 2 0 000 4z",
306
+ brush: "M9.06 11.9l8.07-8.06a2.85 2.85 0 114.03 4.03l-8.06 8.08 M7.07 14.94c-1.66 0-3 1.35-3 3.02 0 1.33-2.5 1.52-2 2.02 1.08 1.1 2.49 2.02 4 2.02 2.2 0 4-1.8 4-4.04a3.01 3.01 0 00-3-3.02z",
307
+ droplet: "M12 2.69l5.66 5.66a8 8 0 11-11.31 0z",
308
+ bucket: "M5 8h14l-1.5 11a2 2 0 01-2 1.8H8.5a2 2 0 01-2-1.8L5 8z M5 8l2-4h10l2 4",
309
+ scissors: "M6 9a3 3 0 100-6 3 3 0 000 6z M6 21a3 3 0 100-6 3 3 0 000 6z M20 4L8.12 15.88 M14.47 14.48L20 20 M8.12 8.12L12 12",
310
+ layers: "M12 2l9 5-9 5-9-5 9-5z M3 12l9 5 9-5 M3 17l9 5 9-5",
311
+ crop: "M6 2v14a2 2 0 002 2h14 M2 6h14a2 2 0 012 2v14",
312
+ eyedropper: "M2 22l1-1h3l9-9 M3 21v-3l9-9 M15 6l3.5-3.5a2.12 2.12 0 013 3L18 9l-3-3z",
313
+ ruler: "M21.3 8.7l-6-6a1 1 0 00-1.4 0L2.7 13.9a1 1 0 000 1.4l6 6a1 1 0 001.4 0L21.3 10.1a1 1 0 000-1.4z M7.5 10.5l2 2 M11 7l2 2 M14.5 3.5l2 2",
314
+ wand: "M15 4V2 M15 16v-2 M8 9h2 M20 9h2 M3 21l9-9 M12.2 6.2L11 5 M17.8 6.2L19 5 M17.8 11.8L19 13",
315
+ move: "M5 9l-3 3 3 3 M9 5l3-3 3 3 M15 19l-3 3-3-3 M19 9l3 3-3 3 M2 12h20 M12 2v20",
316
+ gamepad: "M6 12h4 M8 10v4 M15 13h.01 M18 11h.01 M2 12a4 4 0 014-4h12a4 4 0 014 4l-1.5 6a2 2 0 01-2 1.5H5.5a2 2 0 01-2-1.5L2 12z",
317
+ eraser: "M7 21l-4.3-4.3a1 1 0 010-1.4l9.6-9.6a2 2 0 012.8 0l4.6 4.6a2 2 0 010 2.8L13 21H7z M22 21H7 M5 12l5 5",
318
+ // Buildings / interior / fixtures (spatial / floor-plan / smart-home / real-estate editors)
319
+ thermometer: "M14 14.76V3.5a2.5 2.5 0 00-5 0v11.26a4.5 4.5 0 105 0z",
320
+ door: "M18 20V5a1 1 0 00-1-1H7a1 1 0 00-1 1v15 M3 20h18 M13 11.5h.01",
321
+ stairs: "M3 20h3v-3h3v-3h3v-3h3v-3h3",
322
+ elevator: "M5 3h14a1 1 0 011 1v16a1 1 0 01-1 1H5a1 1 0 01-1-1V4a1 1 0 011-1z M9.5 9L12 6.5 14.5 9 M9.5 15l2.5 2.5 2.5-2.5",
323
+ bed: "M2 4v16 M2 8h18a2 2 0 012 2v10 M22 17H2 M6 8v4 M2 12h4",
324
+ sofa: "M3 9V7a2 2 0 012-2h14a2 2 0 012 2v2 M21 9a2 2 0 00-2 2v3H5v-3a2 2 0 00-2-2 2 2 0 00-2 2v4a1 1 0 001 1h18a1 1 0 001-1v-4a2 2 0 00-2-2 M5 18v2 M19 18v2",
325
+ chair: "M6 11V5a2 2 0 012-2h8a2 2 0 012 2v6 M5 11h14 M6 11l-1 8h14l-1-8 M6 19v2 M18 19v2",
326
+ utensils: "M3 2v7a2 2 0 002 2 2 2 0 002-2V2 M5 2v20 M21 2v9c0 1-1 1.8-2 1.8h-1V20 M18 2v9",
327
+ mountain: "M8 3l4 8 5-5 5 15H2L8 3z",
328
+ tree: "M12 2L7 11h10L12 2z M9 11l3 5 3-5 M12 16v6",
329
+ sun: "M12 17a5 5 0 100-10 5 5 0 000 10z M12 1v2 M12 21v2 M4.22 4.22l1.42 1.42 M18.36 18.36l1.42 1.42 M1 12h2 M21 12h2 M4.22 19.78l1.42-1.42 M18.36 5.64l1.42-1.42",
330
+ moon: "M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z",
331
+ // Rich-text editing (NiceHtmlEditor toolbar, document editors)
332
+ "list-ordered": "M10 6h11M10 12h11M10 18h11M4 6h1v4M4 10h2M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",
333
+ unlink: "M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07L11 5.78M3 3l18 18M9 15l3-3M14 11l3 3M14 21l-1.72-1.72a5 5 0 0 1-7.07-7.07L7 10.49",
334
+ code: "M16 18l6-6-6-6M8 6l-6 6 6 6",
335
+ quote: "M3 21c3-3 3-9 0-12M21 21c-3-3-3-9 0-12M9 7h6v6H9zM15 7h6v6h-6z",
336
+ indent: "M3 8l4 4-4 4M7 6h14M7 12h14M3 18h18",
337
+ outdent: "M7 8l-4 4 4 4M21 6H3M21 12H7M21 18H3",
338
+ "align-center": "M3 6h18M6 12h12M3 18h18",
339
+ "align-right": "M3 6h18M9 12h12M3 18h18",
340
+ "align-justify": "M3 6h18M3 12h18M3 18h18",
341
+ "align-top": "M4 4h16M9 8v12M15 8v7",
342
+ "align-middle": "M4 12h16M9 5v14M15 8v8",
343
+ "align-bottom": "M4 20h16M9 4v12M15 9v7",
344
+ "distribute-h": "M4 4v16M20 4v16M10 7h4v10h-4z",
345
+ "distribute-v": "M4 4h16M4 20h16M7 10h10v4H7z",
346
+ parallelogram: "M7 5h14l-4 14H3z",
347
+ barcode: "M4 5v14M6.5 5v14M10 5v14M13 5v14M15.5 5v14M19 5v14M20.5 5v14",
348
+ "qr-code": "M4 4h6v6H4z M14 4h6v6h-6z M4 14h6v6H4z M14 14h2v2h-2z M18 14h2v2h-2z M14 18h2v2h-2z M18 18h2v2h-2z",
349
+ smile: "M12 22a10 10 0 1 1 0-20 10 10 0 0 1 0 20zM8 14s1.5 2 4 2 4-2 4-2M9 9h.01M15 9h.01",
350
+ undo: "M9 14L4 9l5-5M4 9h10.5a5.5 5.5 0 010 11H11",
351
+ redo: "M15 14l5-5-5-5M20 9H9.5a5.5 5.5 0 000 11H13",
352
+ unlock: "M19 11H5a2 2 0 00-2 2v7a2 2 0 002 2h14a2 2 0 002-2v-7a2 2 0 00-2-2z M7 11V7a5 5 0 019.9-1",
353
+ keyboard: "M4 6h16a2 2 0 012 2v8a2 2 0 01-2 2H4a2 2 0 01-2-2V8a2 2 0 012-2z M6 10h.01 M10 10h.01 M14 10h.01 M18 10h.01 M8 14h8",
354
+ "page-break": "M6 3v5h12V3 M6 21v-5h12v5 M2 12h3 M8 12h3 M13 12h3 M19 12h3",
355
+ shield: "M12 2l8 3v6c0 5-3.4 9.4-8 11-4.6-1.6-8-6-8-11V5z",
356
+ repeat: "M17 2l4 4-4 4 M3 11V9a4 4 0 014-4h14 M7 22l-4-4 4-4 M21 13v2a4 4 0 01-4 4H3",
357
+ // 1.2.1: for the controls that drew these as inline <svg>
358
+ pin: "M12 17v5 M5 17h14l-1.5-3V8a2 2 0 00-2-2h-7a2 2 0 00-2 2v6z",
359
+ "mic-off": "M1 1l22 22 M9 9v3a3 3 0 005.12 2.12 M15 9.34V4a3 3 0 00-5.94-.6 M17 16.95A7 7 0 015 12v-2 M19 10v2a7 7 0 01-.11 1.23 M12 19v4 M8 23h8",
360
+ "log-out": "M9 21H5a2 2 0 01-2-2V5a2 2 0 012-2h4 M16 17l5-5-5-5 M21 12H9",
361
+ "chevrons-left": "M11 17l-5-5 5-5 M18 17l-5-5 5-5",
362
+ "chevrons-right": "M13 17l5-5-5-5 M6 17l5-5-5-5",
363
+ "zoom-in": "M11 4a7 7 0 100 14 7 7 0 000-14z M21 21l-4.35-4.35 M11 8v6 M8 11h6",
364
+ "zoom-out": "M11 4a7 7 0 100 14 7 7 0 000-14z M21 21l-4.35-4.35 M8 11h6",
365
+ navigation: "M12 2l7 19-7-4-7 4z",
366
+ "refresh-ccw": "M1 4v6h6 M23 20v-6h-6 M20.49 9A9 9 0 005.64 5.64L1 10 M3.51 15a9 9 0 0014.85 3.36L23 14",
367
+ minimize: "M4 14h6v6 M20 10h-6V4 M14 10l7-7 M3 21l7-7",
368
+ // 1.2.2: geometry tools and object grouping, drawn as glyphs before (Ntd* of the same names in icons)
369
+ point: "M12 8a4 4 0 1 0 0 8a4 4 0 1 0 0-8z M12 12h.01",
370
+ segment: "M6.5 17.5L17.5 6.5 M3 19a2 2 0 1 0 4 0a2 2 0 1 0-4 0 M17 5a2 2 0 1 0 4 0a2 2 0 1 0-4 0",
371
+ perpendicular: "M3 20h18 M12 20V4 M12 15h5v5",
372
+ parallel: "M4 16L14 6 M10 20L20 10",
373
+ midpoint: "M3 12h6 M15 12h6 M3 9v6 M21 9v6 M12 9a3 3 0 1 0 0 6a3 3 0 1 0 0-6z",
374
+ "angle-bisector": "M4 20h17 M4 20L16 5 M4 20l14.4-6.9 M10 20a6 6 0 0 0-2.25-4.68",
375
+ group: "M3 7V3h4 M17 3h4v4 M21 17v4h-4 M7 21H3v-4 M7 7h5v5H7z M12 12h5v5h-5z",
376
+ ungroup: "M3 3h8v8H3z M13 13h8v8h-8z",
377
+ // 1.3.0: button and key glyphs of the input prompts (ADR-005 § 8, decision 0.8). Outline here;
378
+ // the filled, coloured Ntd* of @nice2dev/icons carry the same names in its resolver.
379
+ "pad-xbox-a": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M9.25 16l2.75-8 2.75 8 M10.2 13.25h3.6",
380
+ "pad-xbox-b": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M9.75 8v8 M9.75 8h2.5a2 2 0 0 1 0 4h-2.5 M9.75 12h3a2 2 0 0 1 0 4h-3",
381
+ "pad-xbox-x": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M9.5 8l5 8 M14.5 8l-5 8",
382
+ "pad-xbox-y": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M9.5 8l2.5 4 2.5-4 M12 12v4",
383
+ "pad-nintendo-a": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M9.25 16l2.75-8 2.75 8 M10.2 13.25h3.6",
384
+ "pad-nintendo-b": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M9.75 8v8 M9.75 8h2.5a2 2 0 0 1 0 4h-2.5 M9.75 12h3a2 2 0 0 1 0 4h-3",
385
+ "pad-nintendo-x": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M9.5 8l5 8 M14.5 8l-5 8",
386
+ "pad-nintendo-y": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M9.5 8l2.5 4 2.5-4 M12 12v4",
387
+ "pad-playstation-cross": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M9 9l6 6 M15 9l-6 6",
388
+ "pad-playstation-circle": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M12 8.25a3.75 3.75 0 1 0 0 7.5a3.75 3.75 0 1 0 0 -7.5z",
389
+ "pad-playstation-square": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M8.5 8.5h7v7h-7z",
390
+ "pad-playstation-triangle": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M12 8l4.5 7.5h-9z",
391
+ "pad-generic-north": "M12 3a3 3 0 1 0 0 6a3 3 0 1 0 0 -6z M12 6h.01 M18 10.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z M6 10.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z M12 16.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z",
392
+ "pad-generic-east": "M12 4.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z M18 9a3 3 0 1 0 0 6a3 3 0 1 0 0 -6z M18 12h.01 M6 10.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z M12 16.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z",
393
+ "pad-generic-west": "M12 4.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z M18 10.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z M6 9a3 3 0 1 0 0 6a3 3 0 1 0 0 -6z M6 12h.01 M12 16.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z",
394
+ "pad-generic-south": "M12 4.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z M18 10.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z M6 10.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z M12 15a3 3 0 1 0 0 6a3 3 0 1 0 0 -6z M12 18h.01",
395
+ "pad-lb": "M6 9h12a3 3 0 0 1 0 6H6a3 3 0 0 1 0-6z M7.5 12h.01",
396
+ "pad-rb": "M6 9h12a3 3 0 0 1 0 6H6a3 3 0 0 1 0-6z M16.5 12h.01",
397
+ "pad-lt": "M9 3h6a3 3 0 0 1 3 3v7a6 6 0 0 1-12 0V6a3 3 0 0 1 3-3z M9.5 7h.01",
398
+ "pad-rt": "M9 3h6a3 3 0 0 1 3 3v7a6 6 0 0 1-12 0V6a3 3 0 0 1 3-3z M14.5 7h.01",
399
+ "pad-start": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M8.5 8.75h7 M8.5 12h7 M8.5 15.25h7",
400
+ "pad-select": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M7.75 7.75h5.5v5.5h-5.5z M10.75 16.25h5.5v-5.5",
401
+ "pad-home": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M7.95 12L12 8.6l4.05 3.4v4H7.95z",
402
+ "pad-dpad": "M9 3h6v6h6v6h-6v6H9v-6H3V9h6z",
403
+ "pad-dpad-up": "M9 3h6v6h6v6h-6v6H9v-6H3V9h6z M12 5.6l1.15 1.5h-2.3z",
404
+ "pad-dpad-down": "M9 3h6v6h6v6h-6v6H9v-6H3V9h6z M12 18.4l1.15-1.5h-2.3z",
405
+ "pad-dpad-left": "M9 3h6v6h6v6h-6v6H9v-6H3V9h6z M5.6 12l1.5-1.15v2.3z",
406
+ "pad-dpad-right": "M9 3h6v6h6v6h-6v6H9v-6H3V9h6z M18.4 12l-1.5-1.15v2.3z",
407
+ "pad-stick-left": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M12 7.5a4.5 4.5 0 1 0 0 9a4.5 4.5 0 1 0 0 -9z M4.5 12h1",
408
+ "pad-stick-right": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M12 7.5a4.5 4.5 0 1 0 0 9a4.5 4.5 0 1 0 0 -9z M18.5 12h1",
409
+ "pad-stick-left-press": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M12 7.5a4.5 4.5 0 1 0 0 9a4.5 4.5 0 1 0 0 -9z M12 12h.01 M4.5 12h1",
410
+ "pad-stick-right-press": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M12 7.5a4.5 4.5 0 1 0 0 9a4.5 4.5 0 1 0 0 -9z M12 12h.01 M18.5 12h1",
411
+ "remote-ok": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M12 8.5a3.5 3.5 0 1 0 0 7a3.5 3.5 0 1 0 0 -7z",
412
+ "remote-back": "M9 14l-4-4 4-4 M5 10h9a5 5 0 0 1 0 10h-2",
413
+ "remote-menu": "M4 6h16v12H4z M8 10h8 M8 14h8",
414
+ "key-command": "M9 9V6.5A2.5 2.5 0 1 0 6.5 9H9z M9 9h6 M9 9v6 M15 9V6.5A2.5 2.5 0 1 1 17.5 9H15z M15 9v6 M15 15H9 M15 15v2.5a2.5 2.5 0 1 0 2.5-2.5H15z M9 15H6.5A2.5 2.5 0 1 0 9 17.5V15z",
415
+ "key-option": "M4 6h5l6 12h5 M14 6h6",
416
+ "key-shift": "M12 4l-8 8h4v8h8v-8h4z",
417
+ "key-control": "M7 14l5-5 5 5",
418
+ "key-enter": "M20 5v7a3 3 0 0 1-3 3H5 M9 11l-4 4 4 4",
419
+ "key-tab": "M4 12h14 M14 8l4 4-4 4 M20 6v12",
420
+ // on-screen keyboard (1.3.0 H1)
421
+ "key-backspace": "M21 5H9l-6 7 6 7h12a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1z M17 9l-6 6 M11 9l6 6",
422
+ "key-space": "M4 10v4h16v-4",
423
+ "key-caps": "M12 4l-7 7h4v5h6v-5h4z M8 20h8"
424
+ }, Jt = {
425
+ xs: 12,
426
+ sm: 16,
427
+ md: 20,
428
+ lg: 24,
429
+ xl: 32
430
+ }, Oe = /* @__PURE__ */ Te({}), Na = ({ resolver: n, children: e }) => Ne.createElement(Oe.Provider, { value: { resolver: n } }, e);
431
+ function Zt({
432
+ path: n,
433
+ size: e,
434
+ className: t,
435
+ style: a,
436
+ color: r,
437
+ title: s,
438
+ onClick: o
439
+ }) {
440
+ return /* @__PURE__ */ F(
441
+ "svg",
442
+ {
443
+ xmlns: "http://www.w3.org/2000/svg",
444
+ width: e,
445
+ height: e,
446
+ viewBox: "0 0 24 24",
447
+ fill: "none",
448
+ stroke: r || "currentColor",
449
+ strokeWidth: 2,
450
+ strokeLinecap: "round",
451
+ strokeLinejoin: "round",
452
+ className: `nice-icon ${t || ""}`,
453
+ style: a,
454
+ role: o ? "button" : s ? "img" : "presentation",
455
+ tabIndex: o ? 0 : void 0,
456
+ onKeyDown: o ? Et : void 0,
457
+ "aria-label": s,
458
+ "aria-hidden": o ? void 0 : !s,
459
+ onClick: o,
460
+ children: [
461
+ s && /* @__PURE__ */ C("title", { children: s }),
462
+ /* @__PURE__ */ C("path", { d: n })
463
+ ]
464
+ }
465
+ );
466
+ }
467
+ const te = ({
468
+ name: n,
469
+ size: e = "md",
470
+ className: t,
471
+ style: a,
472
+ color: r,
473
+ title: s,
474
+ onClick: o
475
+ }) => {
476
+ const { resolver: i } = re(Oe), c = typeof e == "number" ? e : Jt[e];
477
+ if (i) {
478
+ const u = i(n, c);
479
+ if (u)
480
+ return /* @__PURE__ */ C(
481
+ "span",
482
+ {
483
+ role: o ? "button" : void 0,
484
+ tabIndex: o ? 0 : void 0,
485
+ onKeyDown: o ? Et : void 0,
486
+ className: `nice-icon-wrap ${t || ""}`,
487
+ style: a,
488
+ onClick: o,
489
+ children: u
490
+ }
491
+ );
492
+ }
493
+ const d = xt[n];
494
+ return d ? /* @__PURE__ */ C(
495
+ Zt,
496
+ {
497
+ path: d,
498
+ size: c,
499
+ className: t,
500
+ style: a,
501
+ color: r,
502
+ title: s,
503
+ onClick: o
504
+ }
505
+ ) : null;
506
+ };
507
+ function Ta() {
508
+ const { resolver: n } = re(Oe);
509
+ return { renderIcon: O(
510
+ (t, a = "md") => t == null ? null : typeof t != "string" ? t : Ne.createElement(te, { name: t, size: a }),
511
+ [n]
512
+ ) };
513
+ }
514
+ const Pa = /* @__PURE__ */ Object.keys(xt), zt = [
515
+ "a[href]",
516
+ "area[href]",
517
+ "button",
518
+ 'input:not([type="hidden"])',
519
+ "select",
520
+ "textarea",
521
+ "summary",
522
+ "iframe",
523
+ "audio[controls]",
524
+ "video[controls]",
525
+ '[contenteditable]:not([contenteditable="false"])',
526
+ "[tabindex]",
527
+ "[data-nice-focusable]"
528
+ ].join(",");
529
+ function J(n) {
530
+ const e = n.getBoundingClientRect();
531
+ return {
532
+ left: e.left,
533
+ top: e.top,
534
+ right: e.right,
535
+ bottom: e.bottom,
536
+ width: e.width,
537
+ height: e.height
538
+ };
539
+ }
540
+ const _e = (n) => n instanceof HTMLButtonElement || n instanceof HTMLInputElement || n instanceof HTMLSelectElement || n instanceof HTMLTextAreaElement;
541
+ function Qt(n) {
542
+ if (_e(n) && n.disabled || n.getAttribute("aria-disabled") === "true" && !n.hasAttribute("data-nice-focusable"))
543
+ return !0;
544
+ const e = n.closest("fieldset[disabled]");
545
+ if (e && _e(n)) {
546
+ const t = e.querySelector(":scope > legend");
547
+ return !(t && t.contains(n));
548
+ }
549
+ return !1;
550
+ }
551
+ function en(n) {
552
+ var a;
553
+ if (n.closest("[hidden]"))
554
+ return !1;
555
+ const e = n.getBoundingClientRect();
556
+ if (e.width === 0 && e.height === 0) {
557
+ const r = n.ownerDocument.documentElement.getBoundingClientRect();
558
+ if (r.width !== 0 || r.height !== 0)
559
+ return !1;
560
+ }
561
+ const t = (a = n.ownerDocument.defaultView) == null ? void 0 : a.getComputedStyle(n);
562
+ return !t || t.display !== "none" && t.visibility !== "hidden" && t.visibility !== "collapse";
563
+ }
564
+ function tn(n) {
565
+ if (!(n instanceof HTMLInputElement) || n.type !== "radio" || !n.name || n.checked)
566
+ return !0;
567
+ const t = [...(n.form ?? n.ownerDocument).querySelectorAll('input[type="radio"]')].filter(
568
+ (a) => a.name === n.name
569
+ );
570
+ return !t.some((a) => a.checked) && t[0] === n;
571
+ }
572
+ function ne(n) {
573
+ if (!(n instanceof HTMLElement) || !n.matches(zt))
574
+ return !1;
575
+ if (!n.hasAttribute("data-nice-focusable")) {
576
+ const e = n.getAttribute("tabindex");
577
+ if (e !== null && Number(e) < 0 || n instanceof HTMLAnchorElement && !n.hasAttribute("href") && e === null)
578
+ return !1;
579
+ }
580
+ return n.closest('[inert],[aria-hidden="true"]') || Qt(n) ? !1 : en(n) && tn(n);
581
+ }
582
+ function U(n, e = []) {
583
+ const t = [];
584
+ for (const a of n.querySelectorAll(zt))
585
+ e.some((r) => r && r.contains(a)) || ne(a) && t.push(a);
586
+ return t;
587
+ }
588
+ const Be = typeof window > "u" ? V : Bt;
589
+ function _(n, e, t) {
590
+ const a = R({ el: null, deps: [] }), r = R(e);
591
+ r.current = e, Be(() => {
592
+ const s = (n == null ? void 0 : n.current) ?? null, o = a.current;
593
+ s === o.el && t.length === o.deps.length && t.every((c, d) => Object.is(c, o.deps[d])) || (typeof o.cleanup == "function" && o.cleanup(), o.el = s, o.deps = [...t], o.cleanup = s ? r.current(s) : void 0);
594
+ }), Be(
595
+ () => () => {
596
+ const s = a.current;
597
+ typeof s.cleanup == "function" && s.cleanup(), a.current = { el: null, deps: [] };
598
+ },
599
+ []
600
+ );
601
+ }
602
+ const ee = /* @__PURE__ */ new Map(), ue = /* @__PURE__ */ new WeakMap(), ye = /* @__PURE__ */ new Set();
603
+ function Ke() {
604
+ ye.forEach((n) => n());
605
+ }
606
+ function At(n, e, t = !1) {
607
+ const a = { hints: e, fallback: t };
608
+ let r = ee.get(n);
609
+ return r || (r = /* @__PURE__ */ new Set(), ee.set(n, r)), r.add(a), Ke(), () => {
610
+ const s = ee.get(n);
611
+ s != null && s.delete(a) && (s.size === 0 && ee.delete(n), Ke());
612
+ };
613
+ }
614
+ function Da(n, e) {
615
+ const t = ue.get(n);
616
+ ue.delete(n), e && e.length > 0 && ue.set(n, At(n, e)), t == null || t();
617
+ }
618
+ function nn(n, e) {
619
+ const t = [], a = /* @__PURE__ */ new Set(), r = (s) => {
620
+ const o = [...ee.get(s) ?? []], i = [...o.filter((c) => !c.fallback), ...o.filter((c) => c.fallback)];
621
+ for (const c of i.flatMap((d) => d.hints)) {
622
+ const d = `${c.intent}:${c.direction ?? ""}`;
623
+ a.has(d) || (a.add(d), t.push(c));
624
+ }
625
+ };
626
+ for (let s = n; s; s = s.parentElement)
627
+ r(s);
628
+ return r(e), t;
629
+ }
630
+ function St(n, e, t = {}) {
631
+ const { enabled: a = !0, fallback: r = !1 } = t, s = JSON.stringify(e), o = (i) => {
632
+ const c = JSON.parse(s);
633
+ return c.length > 0 ? At(i, c, r) : void 0;
634
+ };
635
+ _(n, (i) => a ? o(i) : void 0, [s, a, r]), V(() => {
636
+ if (!(n || !a))
637
+ return o(document);
638
+ }, [n, s, a, r]);
639
+ }
640
+ function an() {
641
+ const [n, e] = K(null), [, t] = K(0);
642
+ return V(() => {
643
+ const a = document, r = () => e(a.activeElement), s = () => t((o) => o + 1);
644
+ return r(), a.addEventListener("focusin", r), a.addEventListener("focusout", r), ye.add(s), () => {
645
+ a.removeEventListener("focusin", r), a.removeEventListener("focusout", r), ye.delete(s);
646
+ };
647
+ }, []), n;
648
+ }
649
+ class rn {
650
+ constructor(e = "ntd-user-preferences") {
651
+ this.key = e;
652
+ }
653
+ async load() {
654
+ try {
655
+ const e = localStorage.getItem(this.key);
656
+ return e ? JSON.parse(e) : null;
657
+ } catch {
658
+ return null;
659
+ }
660
+ }
661
+ async save(e) {
662
+ localStorage.setItem(this.key, JSON.stringify(e));
663
+ }
664
+ async clear() {
665
+ localStorage.removeItem(this.key);
666
+ }
667
+ }
668
+ class Ia {
669
+ constructor(e = "ntd-preferences", t = "preferences") {
670
+ this.db = null, this.dbName = e, this.storeName = t;
671
+ }
672
+ async getDB() {
673
+ return this.db ? this.db : new Promise((e, t) => {
674
+ const a = indexedDB.open(this.dbName, 1);
675
+ a.onerror = () => t(a.error), a.onsuccess = () => {
676
+ this.db = a.result, e(this.db);
677
+ }, a.onupgradeneeded = (r) => {
678
+ const s = r.target.result;
679
+ s.objectStoreNames.contains(this.storeName) || s.createObjectStore(this.storeName, { keyPath: "id" });
680
+ };
681
+ });
682
+ }
683
+ async load() {
684
+ const e = await this.getDB();
685
+ return new Promise((t, a) => {
686
+ const o = e.transaction(this.storeName, "readonly").objectStore(this.storeName).get("user-preferences");
687
+ o.onerror = () => a(o.error), o.onsuccess = () => {
688
+ var i;
689
+ return t(((i = o.result) == null ? void 0 : i.data) || null);
690
+ };
691
+ });
692
+ }
693
+ async save(e) {
694
+ const t = await this.getDB();
695
+ return new Promise((a, r) => {
696
+ const i = t.transaction(this.storeName, "readwrite").objectStore(this.storeName).put({ id: "user-preferences", data: e });
697
+ i.onerror = () => r(i.error), i.onsuccess = () => a();
698
+ });
699
+ }
700
+ async clear() {
701
+ const e = await this.getDB();
702
+ return new Promise((t, a) => {
703
+ const o = e.transaction(this.storeName, "readwrite").objectStore(this.storeName).delete("user-preferences");
704
+ o.onerror = () => a(o.error), o.onsuccess = () => t();
705
+ });
706
+ }
707
+ }
708
+ class Oa {
709
+ constructor(e, t) {
710
+ this.baseUrl = e, this.getAuthHeaders = t;
711
+ }
712
+ getHeaders() {
713
+ var e;
714
+ return {
715
+ "Content-Type": "application/json",
716
+ ...((e = this.getAuthHeaders) == null ? void 0 : e.call(this)) || {}
717
+ };
718
+ }
719
+ async fetch() {
720
+ const e = await fetch(`${this.baseUrl}/preferences`, {
721
+ method: "GET",
722
+ headers: this.getHeaders()
723
+ });
724
+ if (!e.ok) {
725
+ if (e.status === 404)
726
+ return null;
727
+ throw new Error(`Failed to fetch preferences: ${e.statusText}`);
728
+ }
729
+ return e.json();
730
+ }
731
+ async push(e) {
732
+ const t = await fetch(`${this.baseUrl}/preferences`, {
733
+ method: "PUT",
734
+ headers: this.getHeaders(),
735
+ body: JSON.stringify(e)
736
+ });
737
+ if (!t.ok)
738
+ throw new Error(`Failed to save preferences: ${t.statusText}`);
739
+ }
740
+ async getServerTimestamp() {
741
+ const e = await fetch(`${this.baseUrl}/preferences/timestamp`, {
742
+ method: "GET",
743
+ headers: this.getHeaders()
744
+ });
745
+ return e.ok && (await e.json()).timestamp || 0;
746
+ }
747
+ }
748
+ const Re = /* @__PURE__ */ Te(
749
+ null
750
+ );
751
+ function Lt() {
752
+ const n = re(Re);
753
+ if (!n)
754
+ throw new Error("useUserPreferences must be used within NiceUserPreferencesProvider");
755
+ return n;
756
+ }
757
+ function sn() {
758
+ return re(Re);
759
+ }
760
+ function Ct(n, e) {
761
+ const { getControlPreferences: t, setControlPreferences: a, updateControlPreferences: r } = Lt(), s = t(n, e), o = O(
762
+ (c) => a(n, e, c),
763
+ [n, e, a]
764
+ ), i = O(
765
+ (c) => r(n, e, c),
766
+ [n, e, r]
767
+ );
768
+ return [s, o, i];
769
+ }
770
+ function Ra(n) {
771
+ return Ct(n, "grid");
772
+ }
773
+ function Va(n) {
774
+ return Ct(n, "chart");
775
+ }
776
+ const je = {
777
+ version: 1,
778
+ global: {},
779
+ controls: {}
780
+ };
781
+ function Fa({
782
+ storage: n = new rn(),
783
+ syncAdapter: e,
784
+ autoSyncInterval: t = 0,
785
+ saveDebounce: a = 500,
786
+ children: r
787
+ }) {
788
+ const [s, o] = K(je), [i, c] = K(!0), [d, u] = K(!1), [p, l] = K(null), v = R(void 0), y = R(void 0);
789
+ V(() => {
790
+ let h = !0;
791
+ return (async () => {
792
+ try {
793
+ const m = await n.load();
794
+ h && m && o(m);
795
+ } catch (m) {
796
+ h && l(m instanceof Error ? m : new Error("Failed to load preferences"));
797
+ } finally {
798
+ h && c(!1);
799
+ }
800
+ })(), () => {
801
+ h = !1;
802
+ };
803
+ }, [n]);
804
+ const k = O(
805
+ (h) => {
806
+ v.current && clearTimeout(v.current), v.current = setTimeout(async () => {
807
+ try {
808
+ await n.save(h);
809
+ } catch (A) {
810
+ l(A instanceof Error ? A : new Error("Failed to save preferences"));
811
+ }
812
+ }, a);
813
+ },
814
+ [n, a]
815
+ );
816
+ V(() => {
817
+ i || k(s);
818
+ }, [s, i, k]);
819
+ const E = R(async () => {
820
+ });
821
+ V(() => {
822
+ if (e && t > 0)
823
+ return y.current = setInterval(() => {
824
+ E.current();
825
+ }, t), () => {
826
+ y.current && clearInterval(y.current);
827
+ };
828
+ }, [e, t]), V(() => () => {
829
+ v.current && clearTimeout(v.current), y.current && clearInterval(y.current);
830
+ }, []);
831
+ const H = O(
832
+ (h, A) => {
833
+ var m;
834
+ return (m = s.controls[h]) == null ? void 0 : m[A];
835
+ },
836
+ [s]
837
+ ), x = O(
838
+ (h, A, m) => {
839
+ o((D) => ({
840
+ ...D,
841
+ controls: {
842
+ ...D.controls,
843
+ [h]: {
844
+ ...D.controls[h],
845
+ [A]: m,
846
+ lastModified: Date.now()
847
+ }
848
+ }
849
+ }));
850
+ },
851
+ []
852
+ ), M = O(
853
+ (h, A, m) => {
854
+ o((D) => {
855
+ var I;
856
+ const L = (I = D.controls[h]) == null ? void 0 : I[A], P = typeof L == "object" && L !== null ? { ...L, ...m } : m;
857
+ return {
858
+ ...D,
859
+ controls: {
860
+ ...D.controls,
861
+ [h]: {
862
+ ...D.controls[h],
863
+ [A]: P,
864
+ lastModified: Date.now()
865
+ }
866
+ }
867
+ };
868
+ });
869
+ },
870
+ []
871
+ ), z = O(
872
+ (h, A) => {
873
+ o((m) => {
874
+ if (A) {
875
+ const { [A]: P, ...I } = m.controls[h] || {};
876
+ return {
877
+ ...m,
878
+ controls: {
879
+ ...m.controls,
880
+ [h]: I
881
+ }
882
+ };
883
+ }
884
+ const { [h]: D, ...L } = m.controls;
885
+ return {
886
+ ...m,
887
+ controls: L
888
+ };
889
+ });
890
+ },
891
+ []
892
+ ), g = O(
893
+ (h) => s.global[h],
894
+ [s]
895
+ ), S = O(
896
+ (h, A) => {
897
+ o((m) => ({
898
+ ...m,
899
+ global: {
900
+ ...m.global,
901
+ [h]: A
902
+ }
903
+ }));
904
+ },
905
+ []
906
+ ), N = O(async () => {
907
+ if (e) {
908
+ u(!0), l(null);
909
+ try {
910
+ const h = await e.getServerTimestamp(), A = s.lastSync || 0;
911
+ if (h > A) {
912
+ const m = await e.fetch();
913
+ m && (o({
914
+ ...m,
915
+ lastSync: Date.now()
916
+ }), await n.save(m));
917
+ } else {
918
+ const m = { ...s, lastSync: Date.now() };
919
+ await e.push(m), o(m);
920
+ }
921
+ } catch (h) {
922
+ l(h instanceof Error ? h : new Error("Sync failed"));
923
+ } finally {
924
+ u(!1);
925
+ }
926
+ }
927
+ }, [e, s, n]);
928
+ E.current = N;
929
+ const w = O(() => JSON.stringify(s, null, 2), [s]), b = O((h) => {
930
+ try {
931
+ const A = JSON.parse(h);
932
+ if (typeof A.version != "number" || !A.controls)
933
+ throw new Error("Invalid preferences format");
934
+ o(A);
935
+ } catch (A) {
936
+ l(A instanceof Error ? A : new Error("Import failed"));
937
+ }
938
+ }, []), T = O(() => {
939
+ o(je), n.clear();
940
+ }, [n]), f = ve(
941
+ () => ({
942
+ preferences: s,
943
+ isLoading: i,
944
+ isSyncing: d,
945
+ error: p,
946
+ getControlPreferences: H,
947
+ setControlPreferences: x,
948
+ updateControlPreferences: M,
949
+ clearControlPreferences: z,
950
+ getGlobalPreferences: g,
951
+ setGlobalPreferences: S,
952
+ sync: N,
953
+ exportPreferences: w,
954
+ importPreferences: b,
955
+ resetAllPreferences: T
956
+ }),
957
+ [
958
+ s,
959
+ i,
960
+ d,
961
+ p,
962
+ H,
963
+ x,
964
+ M,
965
+ z,
966
+ g,
967
+ S,
968
+ N,
969
+ w,
970
+ b,
971
+ T
972
+ ]
973
+ );
974
+ return /* @__PURE__ */ C(Re.Provider, { value: f, children: r });
975
+ }
976
+ function _a({
977
+ showGlobal: n = !0,
978
+ showControls: e = !0,
979
+ showExportImport: t = !0,
980
+ showSync: a = !0,
981
+ className: r,
982
+ style: s
983
+ }) {
984
+ var g, S, N, w;
985
+ const { t: o } = Z(), {
986
+ preferences: i,
987
+ isLoading: c,
988
+ isSyncing: d,
989
+ error: u,
990
+ sync: p,
991
+ exportPreferences: l,
992
+ importPreferences: v,
993
+ resetAllPreferences: y,
994
+ setGlobalPreferences: k,
995
+ clearControlPreferences: E
996
+ } = Lt(), H = R(null), x = () => {
997
+ const b = l(), T = new Blob([b], { type: "application/json" }), f = URL.createObjectURL(T), h = document.createElement("a");
998
+ h.href = f, h.download = "nice2dev-preferences.json", h.click(), URL.revokeObjectURL(f);
999
+ }, M = (b) => {
1000
+ var h;
1001
+ const T = (h = b.target.files) == null ? void 0 : h[0];
1002
+ if (!T)
1003
+ return;
1004
+ const f = new FileReader();
1005
+ f.onload = () => {
1006
+ v(f.result);
1007
+ }, f.readAsText(T);
1008
+ };
1009
+ if (c)
1010
+ return /* @__PURE__ */ C("div", { className: r, style: s, children: o("userPreferences.loadingPreferences", "Loading preferences...") });
1011
+ const z = Object.keys(i.controls);
1012
+ return /* @__PURE__ */ F(
1013
+ "div",
1014
+ {
1015
+ className: `ntd-preferences-panel ${r || ""}`,
1016
+ style: {
1017
+ fontFamily: "system-ui, sans-serif",
1018
+ fontSize: "14px",
1019
+ padding: "16px",
1020
+ ...s
1021
+ },
1022
+ children: [
1023
+ u && /* @__PURE__ */ C(
1024
+ "div",
1025
+ {
1026
+ style: {
1027
+ padding: "12px",
1028
+ marginBottom: "16px",
1029
+ background: "var(--nice-danger-bg, #fef2f2)",
1030
+ border: "1px solid var(--nice-danger-bg, #fecaca)",
1031
+ borderRadius: "6px",
1032
+ color: "var(--nice-color-error, #dc2626)"
1033
+ },
1034
+ children: u.message
1035
+ }
1036
+ ),
1037
+ /* @__PURE__ */ F("div", { style: { display: "flex", gap: "8px", marginBottom: "20px", flexWrap: "wrap" }, children: [
1038
+ a && /* @__PURE__ */ C(
1039
+ "button",
1040
+ {
1041
+ onClick: p,
1042
+ disabled: d,
1043
+ style: {
1044
+ padding: "8px 16px",
1045
+ border: "1px solid var(--nice-border-color, #e5e7eb)",
1046
+ borderRadius: "6px",
1047
+ background: "var(--nice-bg-primary, #fff)",
1048
+ cursor: d ? "wait" : "pointer"
1049
+ },
1050
+ children: d ? o("userPreferences.syncing", "Syncing...") : o("userPreferences.sync", "Sync")
1051
+ }
1052
+ ),
1053
+ t && /* @__PURE__ */ F(_t, { children: [
1054
+ /* @__PURE__ */ C(
1055
+ "button",
1056
+ {
1057
+ onClick: x,
1058
+ style: {
1059
+ padding: "8px 16px",
1060
+ border: "1px solid var(--nice-border-color, #e5e7eb)",
1061
+ borderRadius: "6px",
1062
+ background: "var(--nice-bg-primary, #fff)",
1063
+ cursor: "pointer"
1064
+ },
1065
+ children: o("userPreferences.export", "Export")
1066
+ }
1067
+ ),
1068
+ /* @__PURE__ */ C(
1069
+ "button",
1070
+ {
1071
+ onClick: () => {
1072
+ var b;
1073
+ return (b = H.current) == null ? void 0 : b.click();
1074
+ },
1075
+ style: {
1076
+ padding: "8px 16px",
1077
+ border: "1px solid var(--nice-border-color, #e5e7eb)",
1078
+ borderRadius: "6px",
1079
+ background: "var(--nice-bg-primary, #fff)",
1080
+ cursor: "pointer"
1081
+ },
1082
+ children: o("userPreferences.import", "Import")
1083
+ }
1084
+ ),
1085
+ /* @__PURE__ */ C(
1086
+ "input",
1087
+ {
1088
+ ref: H,
1089
+ type: "file",
1090
+ accept: ".json",
1091
+ onChange: M,
1092
+ style: { display: "none" }
1093
+ }
1094
+ )
1095
+ ] }),
1096
+ /* @__PURE__ */ C(
1097
+ "button",
1098
+ {
1099
+ onClick: y,
1100
+ style: {
1101
+ padding: "8px 16px",
1102
+ border: "1px solid var(--nice-danger-dark, #dc2626)",
1103
+ borderRadius: "6px",
1104
+ background: "var(--nice-danger-bg, #fef2f2)",
1105
+ color: "var(--nice-color-error, #dc2626)",
1106
+ cursor: "pointer",
1107
+ marginLeft: "auto"
1108
+ },
1109
+ children: o("userPreferences.resetAll", "Reset All")
1110
+ }
1111
+ )
1112
+ ] }),
1113
+ n && /* @__PURE__ */ F("div", { style: { marginBottom: "24px" }, children: [
1114
+ /* @__PURE__ */ C("h3", { style: { margin: "0 0 12px", fontSize: "16px", fontWeight: 600 }, children: o("userPreferences.globalPreferences", "Global Preferences") }),
1115
+ /* @__PURE__ */ F("div", { style: { display: "grid", gap: "12px" }, children: [
1116
+ /* @__PURE__ */ F("label", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
1117
+ /* @__PURE__ */ C(
1118
+ "input",
1119
+ {
1120
+ type: "checkbox",
1121
+ checked: ((g = i.global.display) == null ? void 0 : g.reducedMotion) || !1,
1122
+ onChange: (b) => k("display", {
1123
+ ...i.global.display,
1124
+ reducedMotion: b.target.checked
1125
+ })
1126
+ }
1127
+ ),
1128
+ o("userPreferences.reducedMotion", "Reduced motion")
1129
+ ] }),
1130
+ /* @__PURE__ */ F("label", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
1131
+ /* @__PURE__ */ C(
1132
+ "input",
1133
+ {
1134
+ type: "checkbox",
1135
+ checked: ((S = i.global.display) == null ? void 0 : S.highContrast) || !1,
1136
+ onChange: (b) => k("display", {
1137
+ ...i.global.display,
1138
+ highContrast: b.target.checked
1139
+ })
1140
+ }
1141
+ ),
1142
+ o("userPreferences.highContrast", "High contrast")
1143
+ ] }),
1144
+ /* @__PURE__ */ F("label", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
1145
+ o("userPreferences.fontScale", "Font scale:"),
1146
+ /* @__PURE__ */ C(
1147
+ "input",
1148
+ {
1149
+ type: "range",
1150
+ min: "0.8",
1151
+ max: "1.5",
1152
+ step: "0.1",
1153
+ value: ((N = i.global.display) == null ? void 0 : N.fontScale) || 1,
1154
+ onChange: (b) => k("display", {
1155
+ ...i.global.display,
1156
+ fontScale: parseFloat(b.target.value)
1157
+ }),
1158
+ style: { flex: 1 }
1159
+ }
1160
+ ),
1161
+ /* @__PURE__ */ F("span", { children: [
1162
+ ((((w = i.global.display) == null ? void 0 : w.fontScale) || 1) * 100).toFixed(0),
1163
+ "%"
1164
+ ] })
1165
+ ] })
1166
+ ] })
1167
+ ] }),
1168
+ e && z.length > 0 && /* @__PURE__ */ F("div", { children: [
1169
+ /* @__PURE__ */ C("h3", { style: { margin: "0 0 12px", fontSize: "16px", fontWeight: 600 }, children: o("userPreferences.controlPreferences", "Control Preferences ({controlIds})").replace(
1170
+ "{controlIds}",
1171
+ String(z.length)
1172
+ ) }),
1173
+ /* @__PURE__ */ C("div", { style: { display: "grid", gap: "8px" }, children: z.map((b) => {
1174
+ const T = i.controls[b], f = Object.keys(T).filter((h) => h !== "lastModified");
1175
+ return /* @__PURE__ */ F(
1176
+ "div",
1177
+ {
1178
+ style: {
1179
+ display: "flex",
1180
+ alignItems: "center",
1181
+ justifyContent: "space-between",
1182
+ padding: "10px 12px",
1183
+ background: "var(--nice-bg-secondary, #f9fafb)",
1184
+ borderRadius: "6px"
1185
+ },
1186
+ children: [
1187
+ /* @__PURE__ */ F("div", { children: [
1188
+ /* @__PURE__ */ C("div", { style: { fontWeight: 500 }, children: b }),
1189
+ /* @__PURE__ */ C("div", { style: { fontSize: "12px", color: "var(--nice-text-muted, #6b7280)" }, children: f.join(", ") })
1190
+ ] }),
1191
+ /* @__PURE__ */ C(
1192
+ "button",
1193
+ {
1194
+ onClick: () => E(b),
1195
+ style: {
1196
+ padding: "4px 8px",
1197
+ border: "none",
1198
+ borderRadius: "4px",
1199
+ background: "var(--nice-border-color, #e5e7eb)",
1200
+ cursor: "pointer",
1201
+ fontSize: "12px"
1202
+ },
1203
+ children: o("userPreferences.clear", "Clear")
1204
+ }
1205
+ )
1206
+ ]
1207
+ },
1208
+ b
1209
+ );
1210
+ }) })
1211
+ ] }),
1212
+ e && z.length === 0 && /* @__PURE__ */ C("div", { style: { color: "var(--nice-text-muted, #6b7280)", fontStyle: "italic" }, children: o("userPreferences.noControlPreferencesSavedYet", "No control preferences saved yet.") })
1213
+ ]
1214
+ }
1215
+ );
1216
+ }
1217
+ const Ue = {
1218
+ "045e": "xbox",
1219
+ "054c": "playstation",
1220
+ "057e": "nintendo",
1221
+ "28de": "steam"
1222
+ };
1223
+ function on(n) {
1224
+ var a, r, s;
1225
+ const e = n.toLowerCase(), t = ((a = /vendor:\s*([0-9a-f]{4})/.exec(e)) == null ? void 0 : a[1]) ?? ((s = (r = /^([0-9a-f]{1,4})-[0-9a-f]{1,4}-/.exec(e)) == null ? void 0 : r[1]) == null ? void 0 : s.padStart(4, "0"));
1226
+ return t && Ue[t] ? Ue[t] : /xbox|xinput|x-box/.test(e) ? "xbox" : /dualsense|dualshock|playstation/.test(e) ? "playstation" : /nintendo|pro controller|joy-con|switch/.test(e) ? "nintendo" : /steam|valve/.test(e) ? "steam" : "generic";
1227
+ }
1228
+ function cn(n, e) {
1229
+ return e !== "auto" ? e : n === "nintendo" ? "east" : "south";
1230
+ }
1231
+ const ln = {
1232
+ A: "south",
1233
+ B: "east",
1234
+ X: "west",
1235
+ Y: "north",
1236
+ LB: "leftBumper",
1237
+ RB: "rightBumper",
1238
+ LT: "leftTrigger",
1239
+ RT: "rightTrigger",
1240
+ View: "select",
1241
+ Menu: "start",
1242
+ LS: "leftStick",
1243
+ RS: "rightStick"
1244
+ };
1245
+ function un(n) {
1246
+ return ln[n] ?? n;
1247
+ }
1248
+ const we = {
1249
+ xbox: { south: ["A"], east: ["B"], west: ["X"], north: ["Y"] },
1250
+ playstation: {
1251
+ south: ["Cross", "input.pad.cross"],
1252
+ east: ["Circle", "input.pad.circle"],
1253
+ west: ["Square", "input.pad.square"],
1254
+ north: ["Triangle", "input.pad.triangle"]
1255
+ },
1256
+ nintendo: { south: ["B"], east: ["A"], west: ["Y"], north: ["X"] },
1257
+ steam: { south: ["A"], east: ["B"], west: ["X"], north: ["Y"] },
1258
+ generic: {
1259
+ south: ["Bottom button", "input.pad.bottomButton"],
1260
+ east: ["Right button", "input.pad.rightButton"],
1261
+ west: ["Left button", "input.pad.leftButton"],
1262
+ north: ["Top button", "input.pad.topButton"]
1263
+ }
1264
+ }, Ge = ["Left stick", "input.pad.leftStick"], qe = ["Right stick", "input.pad.rightStick"], dn = {
1265
+ xbox: [["LB"], ["RB"], ["LT"], ["RT"], ["View"], ["Menu"], ["LS"], ["RS"]],
1266
+ playstation: [["L1"], ["R1"], ["L2"], ["R2"], ["Create"], ["Options"], ["L3"], ["R3"]],
1267
+ nintendo: [
1268
+ ["L"],
1269
+ ["R"],
1270
+ ["ZL"],
1271
+ ["ZR"],
1272
+ ["Minus", "input.pad.minus"],
1273
+ ["Plus", "input.pad.plus"],
1274
+ Ge,
1275
+ qe
1276
+ ],
1277
+ steam: [["L1"], ["R1"], ["L2"], ["R2"], ["View"], ["Menu"], ["L3"], ["R3"]],
1278
+ generic: [
1279
+ ["Left bumper", "input.pad.leftBumper"],
1280
+ ["Right bumper", "input.pad.rightBumper"],
1281
+ ["Left trigger", "input.pad.leftTrigger"],
1282
+ ["Right trigger", "input.pad.rightTrigger"],
1283
+ ["Select"],
1284
+ ["Start"],
1285
+ Ge,
1286
+ qe
1287
+ ]
1288
+ }, hn = {
1289
+ leftBumper: 0,
1290
+ rightBumper: 1,
1291
+ leftTrigger: 2,
1292
+ rightTrigger: 3,
1293
+ select: 4,
1294
+ start: 5,
1295
+ leftStick: 6,
1296
+ rightStick: 7
1297
+ }, fn = {
1298
+ dpadUp: ["D-pad up", "input.pad.dpadUp"],
1299
+ dpadDown: ["D-pad down", "input.pad.dpadDown"],
1300
+ dpadLeft: ["D-pad left", "input.pad.dpadLeft"],
1301
+ dpadRight: ["D-pad right", "input.pad.dpadRight"],
1302
+ home: ["Home"]
1303
+ };
1304
+ function pn(n, e) {
1305
+ if (e in we[n])
1306
+ return we[n][e];
1307
+ const t = hn[e];
1308
+ return t === void 0 ? fn[e] ?? [e] : dn[n][t];
1309
+ }
1310
+ function vn(n, e) {
1311
+ const [t, a] = pn(n, e);
1312
+ return a ? { label: t, key: a } : { label: t };
1313
+ }
1314
+ function mn(n, e) {
1315
+ switch (e) {
1316
+ case "south":
1317
+ case "east":
1318
+ case "west":
1319
+ case "north": {
1320
+ if (n === "generic")
1321
+ return `pad-generic-${e}`;
1322
+ const t = n === "steam" ? "xbox" : n;
1323
+ return `pad-${t}-${we[t][e][0].toLowerCase()}`;
1324
+ }
1325
+ case "leftBumper":
1326
+ return "pad-lb";
1327
+ case "rightBumper":
1328
+ return "pad-rb";
1329
+ case "leftTrigger":
1330
+ return "pad-lt";
1331
+ case "rightTrigger":
1332
+ return "pad-rt";
1333
+ case "leftStick":
1334
+ return "pad-stick-left-press";
1335
+ case "rightStick":
1336
+ return "pad-stick-right-press";
1337
+ case "dpadUp":
1338
+ return "pad-dpad-up";
1339
+ case "dpadDown":
1340
+ return "pad-dpad-down";
1341
+ case "dpadLeft":
1342
+ return "pad-dpad-left";
1343
+ case "dpadRight":
1344
+ return "pad-dpad-right";
1345
+ default:
1346
+ return `pad-${e}`;
1347
+ }
1348
+ }
1349
+ const Ht = ["up", "down", "left", "right"], Ee = {
1350
+ navigate: ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"],
1351
+ activate: ["Enter", "Space"],
1352
+ back: ["Escape"],
1353
+ secondary: ["ContextMenu", "Shift+F10"],
1354
+ tertiary: [],
1355
+ menu: ["Ctrl+K"],
1356
+ view: ["F6", "Shift+F6"],
1357
+ sectionPrev: ["Ctrl+PageUp"],
1358
+ sectionNext: ["Ctrl+PageDown"],
1359
+ pagePrev: ["PageUp"],
1360
+ pageNext: ["PageDown"],
1361
+ first: ["Home"],
1362
+ last: ["End"],
1363
+ scroll: [],
1364
+ toggleHints: ["Shift+?"]
1365
+ }, $e = {
1366
+ navigate: ["dpadUp", "dpadDown", "dpadLeft", "dpadRight"],
1367
+ activate: ["south"],
1368
+ back: ["east"],
1369
+ secondary: ["west"],
1370
+ tertiary: ["north"],
1371
+ menu: ["start"],
1372
+ view: ["select"],
1373
+ sectionPrev: ["leftBumper"],
1374
+ sectionNext: ["rightBumper"],
1375
+ pagePrev: ["leftTrigger"],
1376
+ pageNext: ["rightTrigger"],
1377
+ first: [],
1378
+ last: [],
1379
+ scroll: [],
1380
+ toggleHints: ["leftStick"]
1381
+ }, Mn = {
1382
+ " ": "Space",
1383
+ Spacebar: "Space",
1384
+ Esc: "Escape",
1385
+ Apps: "ContextMenu",
1386
+ Up: "ArrowUp",
1387
+ Down: "ArrowDown",
1388
+ Left: "ArrowLeft",
1389
+ Right: "ArrowRight"
1390
+ };
1391
+ function Ve(n) {
1392
+ return Mn[n] ?? n;
1393
+ }
1394
+ function Nt(n) {
1395
+ const e = n.endsWith("++") ? [...n.slice(0, -2).split("+"), "+"] : n.split("+"), t = e.pop() ?? "", a = new Set(e.map((r) => r.toLowerCase()));
1396
+ return {
1397
+ key: Ve(t),
1398
+ primary: a.has("ctrl") || a.has("cmd") || a.has("meta") || a.has("mod"),
1399
+ alt: a.has("alt") || a.has("option"),
1400
+ shift: a.has("shift")
1401
+ };
1402
+ }
1403
+ const gn = (n) => n.length === 1 && n.toLowerCase() === n.toUpperCase();
1404
+ function Tt(n, e) {
1405
+ const t = Ve(e.key);
1406
+ return !(t.length === 1 ? t.toLowerCase() === n.key.toLowerCase() : t === n.key) || n.primary !== (e.ctrlKey || e.metaKey) || n.alt !== e.altKey ? !1 : gn(n.key) || n.shift === e.shiftKey;
1407
+ }
1408
+ function Ye(n) {
1409
+ const e = {};
1410
+ for (const t of Object.keys(Ee)) {
1411
+ const a = n.keyboardBindings[t] ?? Ee[t];
1412
+ e[t] = a.map(Nt);
1413
+ }
1414
+ return e;
1415
+ }
1416
+ function bn(n, e) {
1417
+ for (const t of Object.keys(e)) {
1418
+ const a = e[t];
1419
+ for (let r = 0; r < a.length; r++)
1420
+ if (Tt(a[r], n))
1421
+ return t === "navigate" ? { intent: t, direction: Ht[r] } : t === "view" ? { intent: t, direction: a[r].shift ? "up" : "down" } : { intent: t };
1422
+ }
1423
+ return null;
1424
+ }
1425
+ const yn = /* @__PURE__ */ new Set(["GoBack", "BrowserBack", "XF86Back"]), wn = /* @__PURE__ */ new Set([461, 10009]);
1426
+ function En(n) {
1427
+ return yn.has(n.key) || wn.has(n.keyCode) ? { intent: "back" } : n.key === "ChannelUp" ? { intent: "sectionNext" } : n.key === "ChannelDown" ? { intent: "sectionPrev" } : null;
1428
+ }
1429
+ function ke(n, e) {
1430
+ const t = cn(e, n.confirmButton), a = t === "south" ? "east" : "south", r = {};
1431
+ for (const s of Object.keys($e)) {
1432
+ const o = n.gamepadBindings[s];
1433
+ o ? r[s] = [...o] : s === "activate" ? r[s] = [t] : s === "back" ? r[s] = [a] : r[s] = [...$e[s]];
1434
+ }
1435
+ return r;
1436
+ }
1437
+ function kn(n) {
1438
+ const e = /* @__PURE__ */ new Map();
1439
+ for (const t of Object.keys(n))
1440
+ n[t].forEach((a, r) => {
1441
+ e.has(a) || e.set(a, t === "navigate" ? { intent: t, direction: Ht[r] } : { intent: t });
1442
+ });
1443
+ return e;
1444
+ }
1445
+ const se = "data-nice-focus-scope", xe = `[${se}]`;
1446
+ function xn(n, e) {
1447
+ const t = {
1448
+ [se]: e.nav ?? "spatial",
1449
+ "data-nice-scope-wrap": e.wrap ? "" : null,
1450
+ "data-nice-scope-trap": e.trap ? "" : null,
1451
+ "data-nice-scope-enter": e.enter && e.enter !== "last" ? e.enter : null,
1452
+ "data-nice-arrows": e.arrows ?? null,
1453
+ "data-nice-region": e.region ?? null
1454
+ }, a = {};
1455
+ for (const [r, s] of Object.entries(t))
1456
+ a[r] = n.getAttribute(r), s === null ? n.removeAttribute(r) : n.setAttribute(r, s);
1457
+ return () => {
1458
+ for (const [r, s] of Object.entries(a))
1459
+ s === null ? n.removeAttribute(r) : n.setAttribute(r, s);
1460
+ };
1461
+ }
1462
+ function Pt(n) {
1463
+ const e = n.getAttribute(se), t = n.getAttribute("data-nice-scope-enter");
1464
+ return {
1465
+ nav: e === "vertical" || e === "horizontal" || e === "grid" || e === "none" ? e : "spatial",
1466
+ wrap: n.hasAttribute("data-nice-scope-wrap"),
1467
+ trap: n.hasAttribute("data-nice-scope-trap"),
1468
+ enter: t === "selected" || t === "first" ? t : "last"
1469
+ };
1470
+ }
1471
+ function We(n, e) {
1472
+ var a;
1473
+ const t = (a = n.parentElement) == null ? void 0 : a.closest(xe);
1474
+ return t && e.contains(t) && t !== e ? t : e;
1475
+ }
1476
+ function zn(n) {
1477
+ var t, a;
1478
+ const e = [];
1479
+ for (let r = (t = n.parentElement) == null ? void 0 : t.closest(xe); r; r = (a = r.parentElement) == null ? void 0 : a.closest(xe))
1480
+ e.push(r);
1481
+ return e;
1482
+ }
1483
+ function An(n) {
1484
+ var t;
1485
+ const e = (t = n.closest("[data-nice-arrows]")) == null ? void 0 : t.getAttribute("data-nice-arrows");
1486
+ return e === "spatial" || e === "native" ? e : null;
1487
+ }
1488
+ const Xe = { horizontal: 30, vertical: 2 }, G = 1, Je = (n) => n === "left" || n === "right", Ze = (n, e, t, a) => Math.max(0, Math.max(n, t) - Math.min(e, a));
1489
+ function Sn(n, e, t) {
1490
+ switch (t) {
1491
+ case "right":
1492
+ return e.left >= n.right - G;
1493
+ case "left":
1494
+ return e.right <= n.left + G;
1495
+ case "down":
1496
+ return e.top >= n.bottom - G;
1497
+ default:
1498
+ return e.bottom <= n.top + G;
1499
+ }
1500
+ }
1501
+ function Ln(n, e, t) {
1502
+ const a = n.left + n.width / 2, r = n.top + n.height / 2, s = e.left + e.width / 2, o = e.top + e.height / 2;
1503
+ switch (t) {
1504
+ case "right":
1505
+ return s > a + G;
1506
+ case "left":
1507
+ return s < a - G;
1508
+ case "down":
1509
+ return o > r + G;
1510
+ default:
1511
+ return o < r - G;
1512
+ }
1513
+ }
1514
+ function Cn(n, e, t) {
1515
+ let a, r, s;
1516
+ Je(t) ? (a = t === "right" ? e.left - n.right : n.left - e.right, r = Ze(n.top, n.bottom, e.top, e.bottom), s = Math.abs(e.top + e.height / 2 - (n.top + n.height / 2))) : (a = t === "down" ? e.top - n.bottom : n.top - e.bottom, r = Ze(n.left, n.right, e.left, e.right), s = Math.abs(e.left + e.width / 2 - (n.left + n.width / 2)));
1517
+ const o = Je(t) ? Xe.horizontal : Xe.vertical;
1518
+ return Math.max(0, a) + r * o + s * 0.01;
1519
+ }
1520
+ function Dt(n, e, t, a) {
1521
+ const r = e.map(t);
1522
+ for (const s of [Sn, Ln]) {
1523
+ let o = -1, i = 1 / 0;
1524
+ for (let c = 0; c < r.length; c++) {
1525
+ if (!s(n, r[c], a))
1526
+ continue;
1527
+ const d = Cn(n, r[c], a);
1528
+ d < i && (i = d, o = c);
1529
+ }
1530
+ if (o >= 0)
1531
+ return e[o];
1532
+ }
1533
+ return null;
1534
+ }
1535
+ const de = (n) => n === "left" || n === "right", Hn = (n) => {
1536
+ var e;
1537
+ return ((e = n.ownerDocument.defaultView) == null ? void 0 : e.getComputedStyle(n).direction) === "rtl";
1538
+ };
1539
+ function Nn(n, e, t, a) {
1540
+ if (n.length === 0)
1541
+ return null;
1542
+ const r = (s) => !!(e.compareDocumentPosition(s) & Node.DOCUMENT_POSITION_FOLLOWING);
1543
+ if (t)
1544
+ return n.find(r) ?? (a ? n[0] : null);
1545
+ for (let s = n.length - 1; s >= 0; s--)
1546
+ if (!r(n[s]))
1547
+ return n[s];
1548
+ return a ? n[n.length - 1] : null;
1549
+ }
1550
+ const Tn = '[aria-selected="true"],[aria-checked="true"],[aria-current]:not([aria-current="false"]),:checked';
1551
+ function Pn(n, e, t) {
1552
+ let a = null;
1553
+ for (let s = n.parentElement; s && !s.contains(e); s = s.parentElement)
1554
+ s.hasAttribute(se) && (a = s);
1555
+ if (!a)
1556
+ return n;
1557
+ const r = Pt(a).enter;
1558
+ if (r === "last") {
1559
+ const s = t.get(a);
1560
+ return s && s.isConnected && a.contains(s) && ne(s) ? s : n;
1561
+ }
1562
+ return r === "selected" ? [...a.querySelectorAll(Tn)].find(ne) ?? n : U(a)[0] ?? n;
1563
+ }
1564
+ function Dn(n, e, t) {
1565
+ const a = J(n);
1566
+ let r = We(n, t.root), s = null;
1567
+ for (; ; ) {
1568
+ const o = Pt(r);
1569
+ if (o.nav === "spatial" || o.nav === "grid" || o.nav === "vertical" && !de(e) || o.nav === "horizontal" && de(e)) {
1570
+ const c = U(r, [n, s]);
1571
+ let d;
1572
+ if (o.nav === "vertical" || o.nav === "horizontal") {
1573
+ let u = e === "down" || e === "right";
1574
+ de(e) && Hn(r) && (u = !u), d = Nn(c, n, u, o.wrap);
1575
+ } else
1576
+ d = Dt(a, c, J, e);
1577
+ if (d)
1578
+ return Pn(d, n, t.memory);
1579
+ }
1580
+ if (r === t.root || o.trap)
1581
+ return null;
1582
+ s = r, r = We(r, t.root);
1583
+ }
1584
+ }
1585
+ function Qe(n, e) {
1586
+ const t = e.left + e.width / 2, a = e.top + e.height / 2;
1587
+ let r = null, s = 1 / 0;
1588
+ for (const o of U(n)) {
1589
+ const i = J(o), c = Math.hypot(i.left + i.width / 2 - t, i.top + i.height / 2 - a);
1590
+ c < s && (s = c, r = o);
1591
+ }
1592
+ return r;
1593
+ }
1594
+ const It = [
1595
+ "[data-nice-region]",
1596
+ "header",
1597
+ "nav",
1598
+ "main",
1599
+ "aside",
1600
+ "footer",
1601
+ '[role="banner"]',
1602
+ '[role="navigation"]',
1603
+ '[role="main"]',
1604
+ '[role="complementary"]',
1605
+ '[role="contentinfo"]',
1606
+ '[role="search"]',
1607
+ '[role="region"][aria-label]',
1608
+ '[role="region"][aria-labelledby]'
1609
+ ].join(",");
1610
+ function In(n, e, t) {
1611
+ const a = [...t.root.querySelectorAll(It)], r = a.filter(
1612
+ (u) => !a.some((p) => p !== u && p.contains(u)) && U(u).length > 0
1613
+ );
1614
+ if (r.length === 0)
1615
+ return null;
1616
+ const s = r.findIndex((u) => u.contains(n)), o = e === "up" || e === "left" ? -1 : 1, i = s < 0 ? o > 0 ? -1 : 0 : s, c = r[(i + o + r.length) % r.length];
1617
+ if (c === r[s])
1618
+ return null;
1619
+ const d = t.memory.get(c);
1620
+ return d && d.isConnected && c.contains(d) && ne(d) ? d : U(c)[0];
1621
+ }
1622
+ const Ba = [
1623
+ "navigate",
1624
+ "activate",
1625
+ "back",
1626
+ "secondary",
1627
+ "tertiary",
1628
+ "menu",
1629
+ "view",
1630
+ "sectionPrev",
1631
+ "sectionNext",
1632
+ "pagePrev",
1633
+ "pageNext",
1634
+ "first",
1635
+ "last",
1636
+ "scroll",
1637
+ "toggleHints"
1638
+ ], he = [
1639
+ "south",
1640
+ "east",
1641
+ "west",
1642
+ "north",
1643
+ "leftBumper",
1644
+ "rightBumper",
1645
+ "leftTrigger",
1646
+ "rightTrigger",
1647
+ "select",
1648
+ "start",
1649
+ "leftStick",
1650
+ "rightStick",
1651
+ "dpadUp",
1652
+ "dpadDown",
1653
+ "dpadLeft",
1654
+ "dpadRight",
1655
+ "home"
1656
+ ], ze = "nice-intent", ae = "nice-engagechange", W = {
1657
+ confirmButton: "auto",
1658
+ gamepadBindings: {},
1659
+ keyboardBindings: {},
1660
+ stickThreshold: 0.5,
1661
+ stickDeadzone: 0.2,
1662
+ invertScroll: !1,
1663
+ repeatDelay: 400,
1664
+ repeatInterval: 110,
1665
+ repeatIntervalMin: 50,
1666
+ hints: "auto",
1667
+ hintDensity: "bar",
1668
+ glyphFamily: "auto",
1669
+ vibration: !1,
1670
+ arrowNavigation: "auto",
1671
+ onScreenKeyboard: "auto"
1672
+ }, On = /* @__PURE__ */ new Set([4, 5, 6, 7, 12, 13, 14, 15]), Rn = 0.85;
1673
+ function Vn(n, e) {
1674
+ return Math.abs(n) > Math.abs(e) ? n > 0 ? "right" : "left" : e > 0 ? "down" : "up";
1675
+ }
1676
+ class Fn {
1677
+ constructor(e, t) {
1678
+ this.states = /* @__PURE__ */ new Map(), this.connected = /* @__PURE__ */ new Set(), this.warned = /* @__PURE__ */ new Set(), this.started = !1, this.frameId = 0, this.onConnected = (a) => {
1679
+ const r = a.gamepad;
1680
+ r && this.connected.add(r.index), this.schedule();
1681
+ }, this.onDisconnected = (a) => {
1682
+ var s, o;
1683
+ const r = a.gamepad;
1684
+ r && (this.connected.delete(r.index), this.states.delete(r.index) && ((o = (s = this.opts).onPadsChange) == null || o.call(s, this.pads))), this.connected.size === 0 && this.cancel();
1685
+ }, this.onVisibility = () => {
1686
+ this.win.document.hidden ? this.cancel() : this.schedule();
1687
+ }, this.frame = (a) => {
1688
+ this.frameId = 0, this.poll(a), this.schedule();
1689
+ }, this.win = e, this.opts = t;
1690
+ }
1691
+ /** Whether an animation frame is scheduled (false without a pad or on a hidden page). */
1692
+ get running() {
1693
+ return this.frameId !== 0;
1694
+ }
1695
+ get pads() {
1696
+ return [...this.states.values()].map((e) => e.info);
1697
+ }
1698
+ start() {
1699
+ if (!this.started) {
1700
+ this.started = !0, this.win.addEventListener("gamepadconnected", this.onConnected), this.win.addEventListener("gamepaddisconnected", this.onDisconnected), this.win.document.addEventListener("visibilitychange", this.onVisibility);
1701
+ for (const e of this.read())
1702
+ this.connected.add(e.index);
1703
+ this.schedule();
1704
+ }
1705
+ }
1706
+ stop() {
1707
+ this.started && (this.started = !1, this.win.removeEventListener("gamepadconnected", this.onConnected), this.win.removeEventListener("gamepaddisconnected", this.onDisconnected), this.win.document.removeEventListener("visibilitychange", this.onVisibility), this.cancel(), this.connected.clear(), this.states.clear());
1708
+ }
1709
+ /** Read every pad once; public so tests can drive a frame. */
1710
+ poll(e) {
1711
+ var o, i, c, d, u, p;
1712
+ const t = this.opts.timing(), a = /* @__PURE__ */ new Set(), r = this.read();
1713
+ for (const l of r) {
1714
+ a.add(l.index);
1715
+ let v = this.states.get(l.index);
1716
+ (!v || v.info.id !== l.id) && (v = {
1717
+ info: {
1718
+ index: l.index,
1719
+ id: l.id,
1720
+ family: on(l.id),
1721
+ mapping: l.mapping
1722
+ },
1723
+ pressed: [],
1724
+ stick: null,
1725
+ holds: /* @__PURE__ */ new Map()
1726
+ }, this.states.set(l.index, v), this.warnMapping(l), (i = (o = this.opts).onPadsChange) == null || i.call(o, this.pads)), this.readButtons(v, l, e, t), this.readSticks(v, l, e, t);
1727
+ }
1728
+ let s = !1;
1729
+ for (const l of [...this.states.keys()])
1730
+ a.has(l) || (this.states.delete(l), s = !0);
1731
+ s && ((d = (c = this.opts).onPadsChange) == null || d.call(c, this.pads)), (p = (u = this.opts).onFrame) == null || p.call(u, r, e);
1732
+ }
1733
+ readButtons(e, t, a, r) {
1734
+ for (let s = 0; s < he.length; s++) {
1735
+ const o = t.buttons[s], i = !!(o && (o.pressed || o.value > 0.5)), c = `b${s}`;
1736
+ i !== !!e.pressed[s] ? (e.pressed[s] = i, i && On.has(s) ? e.holds.set(c, { since: a, last: a, count: 0 }) : e.holds.delete(c), this.opts.onButton({
1737
+ pad: e.info,
1738
+ button: he[s],
1739
+ pressed: i,
1740
+ repeat: !1
1741
+ })) : i && this.repeats(e, c, a, r) && this.opts.onButton({
1742
+ pad: e.info,
1743
+ button: he[s],
1744
+ pressed: i,
1745
+ repeat: !0
1746
+ });
1747
+ }
1748
+ }
1749
+ readSticks(e, t, a, r) {
1750
+ const s = t.axes[0] ?? 0, o = t.axes[1] ?? 0, i = Math.hypot(s, o);
1751
+ if (i >= r.stickThreshold) {
1752
+ const p = Vn(s, o);
1753
+ p !== e.stick ? (e.stick = p, e.holds.set("stick", { since: a, last: a, count: 0 }), this.opts.onStick({ pad: e.info, direction: p, repeat: !1 })) : this.repeats(e, "stick", a, r) && this.opts.onStick({ pad: e.info, direction: p, repeat: !0 });
1754
+ } else e.stick && i < r.stickThreshold * 0.7 && (e.stick = null, e.holds.delete("stick"));
1755
+ const c = t.axes[2] ?? 0, d = t.axes[3] ?? 0, u = Math.hypot(c, d);
1756
+ if (u > r.stickDeadzone) {
1757
+ const p = (u - r.stickDeadzone) / (1 - r.stickDeadzone) / u;
1758
+ this.opts.onScroll({ pad: e.info, x: c * p, y: d * p });
1759
+ }
1760
+ }
1761
+ repeats(e, t, a, r) {
1762
+ const s = e.holds.get(t);
1763
+ if (!s || a - s.since < r.repeatDelay)
1764
+ return !1;
1765
+ const o = Math.max(
1766
+ r.repeatIntervalMin,
1767
+ r.repeatInterval * Rn ** s.count
1768
+ );
1769
+ return a - s.last < o ? !1 : (s.last = a, s.count++, !0);
1770
+ }
1771
+ read() {
1772
+ var a, r;
1773
+ const e = ((r = (a = this.win.navigator).getGamepads) == null ? void 0 : r.call(a)) ?? [], t = [];
1774
+ for (const s of e)
1775
+ s && s.connected !== !1 && t.push(s);
1776
+ return t;
1777
+ }
1778
+ warnMapping(e) {
1779
+ e.mapping === "standard" || this.warned.has(e.id) || (this.warned.add(e.id), process.env.NODE_ENV !== "production" && console.warn(
1780
+ `[nice2dev/input] "${e.id}" has no standard mapping; its buttons are read by standard positions and may be off.`
1781
+ ));
1782
+ }
1783
+ schedule() {
1784
+ this.frameId === 0 && this.started && this.connected.size > 0 && !this.win.document.hidden && typeof this.win.requestAnimationFrame == "function" && (this.frameId = this.win.requestAnimationFrame(this.frame));
1785
+ }
1786
+ cancel() {
1787
+ this.frameId !== 0 && (this.win.cancelAnimationFrame(this.frameId), this.frameId = 0);
1788
+ }
1789
+ }
1790
+ const _n = {
1791
+ up: "ArrowUp",
1792
+ down: "ArrowDown",
1793
+ left: "ArrowLeft",
1794
+ right: "ArrowRight"
1795
+ }, et = {
1796
+ ArrowUp: 38,
1797
+ ArrowDown: 40,
1798
+ ArrowLeft: 37,
1799
+ ArrowRight: 39,
1800
+ Enter: 13,
1801
+ Escape: 27,
1802
+ Home: 36,
1803
+ End: 35,
1804
+ PageUp: 33,
1805
+ PageDown: 34
1806
+ }, tt = /* @__PURE__ */ new Set(["Shift", "Control", "Alt", "Meta", "AltGraph", "OS"]), Bn = /Web0S|webOS|Tizen|SMART-TV|SmartTV|HbbTV|NetCast|Android TV|AFT|BRAVIA|CrKey/i, nt = 18, at = (n) => n === "keyboard" || n === "gamepad" || n === "remote";
1807
+ class Kn {
1808
+ constructor(e) {
1809
+ this.started = !1, this.listeners = /* @__PURE__ */ new Set(), this.frameListeners = /* @__PURE__ */ new Set(), this.padMaps = /* @__PURE__ */ new Map(), this.memory = /* @__PURE__ */ new WeakMap(), this.engagedValues = /* @__PURE__ */ new WeakMap(), this.overlays = [], this.hintsToggled = !1, this.activePad = null, this.lastFocus = null, this.observer = null, this.live = null, this.snapshot = [], this.capture = null, this.translate = (t, a) => a, this.onKeyDown = (t) => {
1810
+ if (t.niceSource)
1811
+ return;
1812
+ const a = En(t), r = this.tv || a ? "remote" : "keyboard";
1813
+ if (tt.has(t.key) || this.setMethod(r), this.capture && !tt.has(t.key)) {
1814
+ t.preventDefault();
1815
+ const c = [
1816
+ t.ctrlKey || t.metaKey ? "Ctrl" : "",
1817
+ t.altKey ? "Alt" : "",
1818
+ t.shiftKey ? "Shift" : ""
1819
+ ], d = Ve(t.key);
1820
+ this.capture({
1821
+ keys: [...c, d.length === 1 ? d.toUpperCase() : d].filter(Boolean).join("+")
1822
+ });
1823
+ return;
1824
+ }
1825
+ if (t.defaultPrevented || t.isComposing)
1826
+ return;
1827
+ const s = a ?? bn(t, this.keyTable);
1828
+ if (!s)
1829
+ return;
1830
+ const o = this.targetOf(t);
1831
+ if (qt(o, s))
1832
+ return;
1833
+ const i = {
1834
+ intent: s.intent,
1835
+ direction: s.direction,
1836
+ source: r,
1837
+ repeat: t.repeat,
1838
+ keyEvent: t
1839
+ };
1840
+ (this.dispatchIntent(i, o) || this.keyDefault(i, o)) && t.preventDefault();
1841
+ }, this.onPadButton = (t) => {
1842
+ if (this.activePad = t.pad, this.setMethod("gamepad", t.pad.family), !t.pressed)
1843
+ return;
1844
+ if (this.capture) {
1845
+ t.repeat || this.capture({ button: t.button });
1846
+ return;
1847
+ }
1848
+ const a = this.padMap(t.pad.family).get(t.button);
1849
+ a && this.deviceIntent({ ...a, source: "gamepad", repeat: t.repeat, gamepad: t.pad });
1850
+ }, this.onPadStick = (t) => {
1851
+ this.activePad = t.pad, this.setMethod("gamepad", t.pad.family), !this.capture && this.deviceIntent({
1852
+ intent: "navigate",
1853
+ direction: t.direction,
1854
+ source: "gamepad",
1855
+ repeat: t.repeat,
1856
+ gamepad: t.pad
1857
+ });
1858
+ }, this.onPadScroll = (t) => {
1859
+ this.activePad = t.pad, this.setMethod("gamepad", t.pad.family);
1860
+ const a = this.state.preferences.invertScroll ? -1 : 1, r = t.x * a, s = t.y * a, o = this.focused(), i = {
1861
+ intent: "scroll",
1862
+ direction: Math.abs(r) > Math.abs(s) ? r > 0 ? "right" : "left" : s > 0 ? "down" : "up",
1863
+ amount: Math.min(1, Math.hypot(r, s)),
1864
+ source: "gamepad",
1865
+ repeat: !0,
1866
+ gamepad: t.pad
1867
+ };
1868
+ this.dispatchIntent(i, o) || rt(st(o, r, s), r * nt, s * nt);
1869
+ }, this.onPointerDown = (t) => {
1870
+ this.setMethod(t.pointerType === "touch" ? "touch" : "pointer");
1871
+ }, this.onFocusIn = (t) => {
1872
+ const a = t.target;
1873
+ if (a instanceof HTMLElement) {
1874
+ for (let r = a.parentElement; r; r = r.parentElement)
1875
+ (r.hasAttribute(se) || r.matches(It) || r === this.doc.body) && this.memory.set(r, a);
1876
+ this.lastFocus = { el: a, rect: J(a), scope: zn(a)[0] ?? null };
1877
+ }
1878
+ }, this.onFocusOut = (t) => {
1879
+ const a = t.target;
1880
+ a instanceof HTMLElement && a.hasAttribute("data-nice-engaged") && this.release(a, this.state.method === "gamepad" ? "gamepad" : "keyboard", !1);
1881
+ }, this.recover = () => {
1882
+ const t = this.lastFocus;
1883
+ if (!t || t.el.isConnected)
1884
+ return;
1885
+ this.lastFocus = null;
1886
+ const a = this.doc.activeElement;
1887
+ if (a && a !== this.doc.body)
1888
+ return;
1889
+ const r = this.navigationRoot(), s = t.scope && t.scope.isConnected && r.contains(t.scope) ? t.scope : r, o = Qe(s, t.rect) ?? (s !== r ? Qe(r, t.rect) : null);
1890
+ o && this.focusElement(o);
1891
+ }, this.win = e, this.doc = e.document, this.tv = Bn.test(e.navigator.userAgent), this.keyTable = Ye(W), this.state = {
1892
+ method: "pointer",
1893
+ family: null,
1894
+ pads: [],
1895
+ preferences: W,
1896
+ hintsVisible: W.hints === "always"
1897
+ }, this.poller = new Fn(e, {
1898
+ timing: () => this.state.preferences,
1899
+ onButton: this.onPadButton,
1900
+ onStick: this.onPadStick,
1901
+ onScroll: this.onPadScroll,
1902
+ onPadsChange: (t) => {
1903
+ t.length === 0 && (this.snapshot = []), this.update({ pads: t });
1904
+ },
1905
+ onFrame: (t, a) => {
1906
+ this.snapshot = t, this.frameListeners.forEach((r) => r(t, a));
1907
+ }
1908
+ });
1909
+ }
1910
+ /* ── Lifecycle ───────────────────────────────────────────────── */
1911
+ get isStarted() {
1912
+ return this.started;
1913
+ }
1914
+ /** Whether the page runs in a TV browser (webOS, Tizen, Android TV, …): remote and 10-foot. */
1915
+ get isTv() {
1916
+ return this.tv;
1917
+ }
1918
+ start() {
1919
+ this.started || (this.started = !0, this.tv && !this.doc.documentElement.hasAttribute("data-nice-tv") && this.doc.documentElement.setAttribute("data-nice-tv", "auto"), this.win.addEventListener("keydown", this.onKeyDown), this.win.addEventListener("pointerdown", this.onPointerDown, { capture: !0, passive: !0 }), this.doc.addEventListener("focusin", this.onFocusIn), this.doc.addEventListener("focusout", this.onFocusOut), this.poller.start());
1920
+ }
1921
+ stop() {
1922
+ this.started && (this.started = !1, this.win.removeEventListener("keydown", this.onKeyDown), this.win.removeEventListener("pointerdown", this.onPointerDown, { capture: !0 }), this.doc.removeEventListener("focusin", this.onFocusIn), this.doc.removeEventListener("focusout", this.onFocusOut), this.poller.stop(), this.watchRecovery(!1));
1923
+ }
1924
+ /** Whether the gamepad loop is scheduled (false without a pad). */
1925
+ get polling() {
1926
+ return this.poller.running;
1927
+ }
1928
+ /* ── State ───────────────────────────────────────────────────── */
1929
+ /** Same object until something changes (fit for `useSyncExternalStore`). */
1930
+ getState() {
1931
+ return this.state;
1932
+ }
1933
+ subscribe(e) {
1934
+ return this.listeners.add(e), () => this.listeners.delete(e);
1935
+ }
1936
+ setPreferences(e) {
1937
+ const t = { ...this.state.preferences, ...e };
1938
+ this.keyTable = Ye(t), this.padMaps.clear(), this.update({ preferences: t });
1939
+ }
1940
+ /** Words of announcements and labels; the React provider passes the app's translator. */
1941
+ setTranslator(e) {
1942
+ this.translate = e;
1943
+ }
1944
+ /** Pad family of the prompts: the preference, else the pad used last. */
1945
+ get glyphFamily() {
1946
+ const e = this.state.preferences.glyphFamily;
1947
+ return e !== "auto" ? e : this.state.family ?? "xbox";
1948
+ }
1949
+ /** The buttons bound to an intent on a pad of the family (for prompts). */
1950
+ gamepadBinding(e, t = this.glyphFamily) {
1951
+ return ke(this.state.preferences, t)[e];
1952
+ }
1953
+ /** The keys bound to an intent (for prompts), as written in the preferences. */
1954
+ keyboardBinding(e) {
1955
+ return this.keyTable[e];
1956
+ }
1957
+ toggleHints() {
1958
+ this.hintsToggled = !this.hintsToggled, this.update({});
1959
+ }
1960
+ /**
1961
+ * Hands the next pad button or key press to `onInput` instead of acting on it (a bindings
1962
+ * screen); returns what cancels the capture.
1963
+ */
1964
+ captureNextInput(e) {
1965
+ const t = (a) => {
1966
+ this.capture = null, e(a);
1967
+ };
1968
+ return this.capture = t, () => {
1969
+ this.capture === t && (this.capture = null);
1970
+ };
1971
+ }
1972
+ update(e) {
1973
+ const t = { ...this.state, ...e }, { hints: a } = t.preferences;
1974
+ let r = a === "always" ? !0 : a === "never" ? !1 : at(t.method);
1975
+ this.hintsToggled && (r = !r), t.hintsVisible = r, this.state = t, this.listeners.forEach((s) => s());
1976
+ }
1977
+ setMethod(e, t) {
1978
+ const a = this.doc.documentElement;
1979
+ t && a.getAttribute("data-nice-gamepad") !== t && a.setAttribute("data-nice-gamepad", t), !(e === this.state.method && (t === void 0 || t === this.state.family)) && (a.setAttribute("data-nice-input", e), this.watchRecovery(at(e)), this.update(t ? { method: e, family: t } : { method: e }));
1980
+ }
1981
+ /* ── Gamepad frames (games, device testers) ──────────────────── */
1982
+ /** Raw pads every polled frame while a pad is connected. */
1983
+ subscribeGamepadFrames(e) {
1984
+ return this.frameListeners.add(e), () => this.frameListeners.delete(e);
1985
+ }
1986
+ /**
1987
+ * The pads as read in the last polled frame — empty without a pad. For code that runs its own
1988
+ * animation loop (games, particle effects) instead of a second `getGamepads()` reader.
1989
+ */
1990
+ get gamepadSnapshot() {
1991
+ return this.snapshot;
1992
+ }
1993
+ /** Feedback rumble on the pad used last, when the user allows vibration. */
1994
+ vibrate(e, t = 0.5) {
1995
+ this.state.preferences.vibration && this.activePad && this.rumble(this.activePad.index, e, t, t);
1996
+ }
1997
+ /** Rumble a given pad regardless of the preference (a game's own effect). */
1998
+ rumble(e, t, a = 0.5, r = 0.5) {
1999
+ var i, c, d;
2000
+ const s = (c = (i = this.win.navigator).getGamepads) == null ? void 0 : c.call(i)[e], o = s == null ? void 0 : s.vibrationActuator;
2001
+ (d = o == null ? void 0 : o.playEffect) == null || d.call(o, "dual-rumble", {
2002
+ startDelay: 0,
2003
+ duration: t,
2004
+ weakMagnitude: a,
2005
+ strongMagnitude: r
2006
+ });
2007
+ }
2008
+ /* ── Overlays ────────────────────────────────────────────────── */
2009
+ /** Puts an overlay on the stack; returns what takes it off. */
2010
+ pushOverlay(e) {
2011
+ return this.overlays.push(e), () => {
2012
+ const t = this.overlays.lastIndexOf(e);
2013
+ t >= 0 && this.overlays.splice(t, 1);
2014
+ };
2015
+ }
2016
+ topOverlay() {
2017
+ return this.overlays[this.overlays.length - 1];
2018
+ }
2019
+ /** Closes the top overlay that can be closed; returns whether one was. */
2020
+ closeTopOverlay(e) {
2021
+ for (let t = this.overlays.length - 1; t >= 0; t--) {
2022
+ const a = this.overlays[t];
2023
+ if (a.onClose)
2024
+ return a.onClose(e), !0;
2025
+ if (a.modal)
2026
+ return !1;
2027
+ }
2028
+ return !1;
2029
+ }
2030
+ /* ── Intents ─────────────────────────────────────────────────── */
2031
+ /** Dispatches `nice-intent` on the target; returns whether a handler consumed it. */
2032
+ dispatchIntent(e, t = this.focused()) {
2033
+ const a = new CustomEvent(ze, {
2034
+ detail: e,
2035
+ bubbles: !0,
2036
+ cancelable: !0,
2037
+ composed: !0
2038
+ });
2039
+ return t.dispatchEvent(a), a.defaultPrevented;
2040
+ }
2041
+ /** Moves focus in a direction through the scope tree; returns whether it moved. */
2042
+ moveFocus(e, t = this.focused()) {
2043
+ const a = this.navigationRoot();
2044
+ if (t === this.doc.body || !a.contains(t))
2045
+ return this.focusInitial(a);
2046
+ const r = Dn(t, e, { root: a, memory: this.memory });
2047
+ return r ? (this.focusElement(r), !0) : !1;
2048
+ }
2049
+ /** The `view` intent: next (`down`) or previous (`up`) region. */
2050
+ focusRegion(e, t = this.focused()) {
2051
+ const a = In(t, e, {
2052
+ root: this.navigationRoot(),
2053
+ memory: this.memory
2054
+ });
2055
+ return a ? (this.focusElement(a), !0) : !1;
2056
+ }
2057
+ /** Focuses the element and brings it into view (scroll-padding respected). */
2058
+ focusElement(e) {
2059
+ var t;
2060
+ e.focus({ preventScroll: !0, focusVisible: !0 }), (t = e.scrollIntoView) == null || t.call(e, { block: "nearest", inline: "nearest" });
2061
+ }
2062
+ /** Engages a control (ADR-005 § 6); popup controls open instead. */
2063
+ engage(e, t, a = me(e)) {
2064
+ if (a) {
2065
+ if (a === "popup") {
2066
+ this.emulateKey(e, "ArrowDown", t);
2067
+ return;
2068
+ }
2069
+ e.setAttribute("data-nice-engaged", ""), be(e) && this.engagedValues.set(e, e.value), this.fireEngage(e, { engaged: !0, cancelled: !1, source: t }), this.announce(this.translate("input.engaged", "Editing"));
2070
+ }
2071
+ }
2072
+ /**
2073
+ * Releases an engaged control; `cancelled` when left with `back`. A native number field gets
2074
+ * its value from before back; custom controls do that in `useEngage`'s `onRelease`.
2075
+ */
2076
+ release(e, t, a) {
2077
+ if (!e.hasAttribute("data-nice-engaged"))
2078
+ return;
2079
+ e.removeAttribute("data-nice-engaged");
2080
+ const r = this.engagedValues.get(e);
2081
+ this.engagedValues.delete(e), a && r !== void 0 && be(e) && Wt(e, r), this.fireEngage(e, { engaged: !1, cancelled: a, source: t }), this.announce(this.translate("input.released", "Done editing"));
2082
+ }
2083
+ /** Defaults of trusted keys: the browser already clicks, types and scrolls. */
2084
+ keyDefault(e, t) {
2085
+ switch (e.intent) {
2086
+ case "navigate":
2087
+ return this.arrowPolicy(t, e.source) === "spatial" ? this.moveFocus(e.direction ?? "down", t) : !1;
2088
+ case "view":
2089
+ return this.focusRegion(e.direction ?? "down", t);
2090
+ case "back":
2091
+ return this.closeTopOverlay(e.source);
2092
+ case "toggleHints":
2093
+ return this.toggleHints(), !0;
2094
+ default:
2095
+ return !1;
2096
+ }
2097
+ }
2098
+ arrowPolicy(e, t) {
2099
+ if (t !== "keyboard")
2100
+ return "spatial";
2101
+ const a = this.state.preferences.arrowNavigation;
2102
+ return a !== "auto" ? a : An(e) ?? "native";
2103
+ }
2104
+ /* ── Gamepad ─────────────────────────────────────────────────── */
2105
+ padMap(e) {
2106
+ let t = this.padMaps.get(e);
2107
+ return t || (t = kn(ke(this.state.preferences, e)), this.padMaps.set(e, t)), t;
2108
+ }
2109
+ /** A pad intent: the intent event, then engage rules, key emulation and the default action. */
2110
+ deviceIntent(e) {
2111
+ const t = this.focused();
2112
+ if (this.dispatchIntent(e, t))
2113
+ return;
2114
+ const a = t === this.doc.body ? null : me(t), r = a !== null && kt(t, a), s = t, o = e.source;
2115
+ switch (e.intent) {
2116
+ case "navigate": {
2117
+ const i = e.direction ?? "down";
2118
+ a && !r ? this.moveFocus(i, t) : r && ce(t) ? le(t, i) : r && a === "text" ? Xt(t, i) : this.emulateKey(t, _n[i], o) || this.moveFocus(i, t);
2119
+ return;
2120
+ }
2121
+ case "activate":
2122
+ a && !r ? this.engage(s, o, a) : r && a === "popup" ? this.emulateKey(t, "Enter", o) : r && (a === "value" || a === "canvas") ? this.release(s, o, !1) : r || (wt(t) ? $t(t) : this.emulateKey(t, "Enter", o));
2123
+ return;
2124
+ case "back":
2125
+ r && a === "popup" ? this.emulateKey(t, "Escape", o) : r ? this.release(s, o, !0) : this.emulateKey(t, "Escape", o) || this.closeTopOverlay(o);
2126
+ return;
2127
+ case "sectionPrev":
2128
+ case "sectionNext":
2129
+ if (r && a === "value") {
2130
+ const i = e.intent === "sectionNext";
2131
+ ce(t) ? le(t, i ? "up" : "down", "big") : this.emulateKey(t, i ? "PageUp" : "PageDown", o);
2132
+ }
2133
+ return;
2134
+ case "pagePrev":
2135
+ case "pageNext": {
2136
+ const i = e.intent === "pageNext";
2137
+ if (r && a === "value")
2138
+ ce(t) ? le(t, i ? "up" : "down", "edge") : this.emulateKey(t, i ? "End" : "Home", o);
2139
+ else if (!this.emulateKey(t, i ? "PageDown" : "PageUp", o)) {
2140
+ const c = st(t, 0, i ? 1 : -1);
2141
+ rt(c, 0, (i ? 1 : -1) * ((c == null ? void 0 : c.clientHeight) ?? 0) * 0.9);
2142
+ }
2143
+ return;
2144
+ }
2145
+ case "first":
2146
+ case "last":
2147
+ this.emulateKey(t, e.intent === "first" ? "Home" : "End", o);
2148
+ return;
2149
+ case "secondary":
2150
+ this.contextMenu(t);
2151
+ return;
2152
+ case "menu":
2153
+ r && a === "text" && (this.release(s, o, !1), this.emulateKey(t, "Enter", o));
2154
+ return;
2155
+ case "view":
2156
+ this.focusRegion(e.direction ?? "down", t);
2157
+ return;
2158
+ case "toggleHints":
2159
+ this.toggleHints();
2160
+ return;
2161
+ default:
2162
+ return;
2163
+ }
2164
+ }
2165
+ /** A synthetic key on the element; returns whether a handler consumed it. */
2166
+ emulateKey(e, t, a) {
2167
+ const r = (o) => {
2168
+ const i = new KeyboardEvent(o, {
2169
+ key: t,
2170
+ code: t,
2171
+ bubbles: !0,
2172
+ cancelable: !0,
2173
+ composed: !0
2174
+ });
2175
+ return Object.defineProperty(i, "niceSource", { value: a }), Object.defineProperty(i, "keyCode", { value: et[t] ?? 0 }), Object.defineProperty(i, "which", { value: et[t] ?? 0 }), i;
2176
+ }, s = r("keydown");
2177
+ return e.dispatchEvent(s), e.dispatchEvent(r("keyup")), s.defaultPrevented;
2178
+ }
2179
+ /** `secondary` on a pad: the context menu of the element, as a right click would open it. */
2180
+ contextMenu(e) {
2181
+ const t = e.getBoundingClientRect();
2182
+ e.dispatchEvent(
2183
+ new MouseEvent("contextmenu", {
2184
+ bubbles: !0,
2185
+ cancelable: !0,
2186
+ button: 2,
2187
+ clientX: t.left + t.width / 2,
2188
+ clientY: t.top + t.height / 2
2189
+ })
2190
+ );
2191
+ }
2192
+ watchRecovery(e) {
2193
+ e && !this.observer && typeof MutationObserver < "u" && this.doc.body ? (this.observer = new MutationObserver(this.recover), this.observer.observe(this.doc.body, { childList: !0, subtree: !0 })) : !e && this.observer && (this.observer.disconnect(), this.observer = null);
2194
+ }
2195
+ /* ── Helpers ─────────────────────────────────────────────────── */
2196
+ focused() {
2197
+ const e = this.doc.activeElement;
2198
+ return e && e !== this.doc.documentElement ? e : this.doc.body;
2199
+ }
2200
+ targetOf(e) {
2201
+ var a;
2202
+ const t = (a = e.composedPath) == null ? void 0 : a.call(e)[0];
2203
+ return t instanceof Element ? t : e.target instanceof Element ? e.target : this.focused();
2204
+ }
2205
+ /** Moves stay inside the top modal overlay. */
2206
+ navigationRoot() {
2207
+ for (let e = this.overlays.length - 1; e >= 0; e--)
2208
+ if (this.overlays[e].modal && this.overlays[e].element.isConnected)
2209
+ return this.overlays[e].element;
2210
+ return this.doc.body;
2211
+ }
2212
+ /** Nothing focused yet: the remembered element, else the first one of the main region. */
2213
+ focusInitial(e) {
2214
+ const t = this.memory.get(e), a = e.querySelector('main,[role="main"]'), r = (t && t.isConnected && e.contains(t) && ne(t) ? t : null) ?? (a ? U(a)[0] : void 0) ?? U(e)[0];
2215
+ return r ? (this.focusElement(r), !0) : !1;
2216
+ }
2217
+ fireEngage(e, t) {
2218
+ e.dispatchEvent(new CustomEvent(ae, { detail: t, bubbles: !0 }));
2219
+ }
2220
+ /** Polite announcement through the engine's own live region. */
2221
+ announce(e) {
2222
+ if (!this.live || !this.live.isConnected) {
2223
+ const t = this.doc.createElement("div");
2224
+ t.setAttribute("role", "status"), t.setAttribute("aria-live", "polite"), t.setAttribute("data-nice-input-live", ""), t.style.cssText = "position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0", this.doc.body.appendChild(t), this.live = t;
2225
+ }
2226
+ this.live.textContent = e;
2227
+ }
2228
+ }
2229
+ function rt(n, e, t) {
2230
+ n && (typeof n.scrollBy == "function" ? n.scrollBy({ left: e, top: t }) : (n.scrollLeft += e, n.scrollTop += t));
2231
+ }
2232
+ function st(n, e, t) {
2233
+ const a = n.ownerDocument, r = a.defaultView;
2234
+ for (let s = n; s && s !== a.body; s = s.parentElement) {
2235
+ if (!(s instanceof HTMLElement) || !r)
2236
+ continue;
2237
+ const o = r.getComputedStyle(s), i = /(auto|scroll)/.test(o.overflowY) && s.scrollHeight > s.clientHeight, c = /(auto|scroll)/.test(o.overflowX) && s.scrollWidth > s.clientWidth;
2238
+ if (t !== 0 && i || e !== 0 && c)
2239
+ return s;
2240
+ }
2241
+ return a.scrollingElement ?? a.documentElement;
2242
+ }
2243
+ const ot = /* @__PURE__ */ new WeakMap();
2244
+ function jn(n = window, e = !0) {
2245
+ let t = ot.get(n);
2246
+ return t || (t = new Kn(n), ot.set(n, t)), e && t.start(), t;
2247
+ }
2248
+ const it = {
2249
+ method: "pointer",
2250
+ family: null,
2251
+ pads: [],
2252
+ preferences: W,
2253
+ hintsVisible: !1
2254
+ }, Un = () => {
2255
+ }, Ot = /* @__PURE__ */ Te(null);
2256
+ function B() {
2257
+ const [n] = K(
2258
+ () => typeof window > "u" ? null : jn(window, !1)
2259
+ );
2260
+ return V(() => {
2261
+ n == null || n.start();
2262
+ }, [n]), n;
2263
+ }
2264
+ function Q(n) {
2265
+ const e = B(), t = O(
2266
+ (a) => e ? (e.start(), e.subscribe(a)) : Un,
2267
+ [e]
2268
+ );
2269
+ return Mt(
2270
+ t,
2271
+ () => n(e ? e.getState() : it),
2272
+ () => n(it)
2273
+ );
2274
+ }
2275
+ function Rt() {
2276
+ return Q((n) => n);
2277
+ }
2278
+ function Ka() {
2279
+ return Q((n) => n.method);
2280
+ }
2281
+ function ja() {
2282
+ return Q((n) => n.family);
2283
+ }
2284
+ function Ua() {
2285
+ return Q((n) => n.pads);
2286
+ }
2287
+ function Gn() {
2288
+ return Q((n) => n.hintsVisible);
2289
+ }
2290
+ function qn() {
2291
+ const n = Q((r) => r.preferences), e = re(Ot), t = B(), a = O(
2292
+ (r) => {
2293
+ e ? e.setPreferences(r) : t == null || t.setPreferences(r);
2294
+ },
2295
+ [e, t]
2296
+ );
2297
+ return [n, a];
2298
+ }
2299
+ function Ga({
2300
+ preferences: n,
2301
+ defaultPreferences: e,
2302
+ onPreferencesChange: t,
2303
+ persist: a = !0,
2304
+ children: r
2305
+ }) {
2306
+ const s = B(), { t: o } = Z(), i = sn(), c = a ? i == null ? void 0 : i.preferences.global.input : void 0, [d, u] = K({}), p = JSON.stringify([e, c, d, n]), l = ve(
2307
+ () => ({ ...W, ...e, ...c, ...d, ...n }),
2308
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- keyed by content: callers pass inline objects
2309
+ [p]
2310
+ );
2311
+ V(() => {
2312
+ s == null || s.setPreferences(l);
2313
+ }, [s, l]), V(() => () => s == null ? void 0 : s.setPreferences(W), [s]), V(() => {
2314
+ s == null || s.setTranslator(o);
2315
+ }, [s, o]);
2316
+ const v = O(
2317
+ (k) => {
2318
+ const E = { ...d, ...k };
2319
+ u(E), a && i && i.setGlobalPreferences("input", { ...i.preferences.global.input, ...k }), t == null || t({ ...l, ...k });
2320
+ },
2321
+ [d, a, i, t, l]
2322
+ ), y = ve(() => ({ setPreferences: v }), [v]);
2323
+ return /* @__PURE__ */ C(Ot.Provider, { value: y, children: r });
2324
+ }
2325
+ function ct(n, e) {
2326
+ return e === "none" ? null : e && typeof e == "object" ? e.current ?? n : typeof e == "string" && e !== "first" && e !== "container" ? n.querySelector(e) ?? n : e === "container" ? n : n.querySelector("[autofocus],[data-autofocus]") ?? U(n)[0] ?? n;
2327
+ }
2328
+ const $n = '[role="listbox"],[role="menu"],[role="dialog"],[role="alertdialog"],[role="grid"],[role="tree"],[data-nice-popup]', lt = /* @__PURE__ */ new WeakMap();
2329
+ function ut(n) {
2330
+ let e = lt.get(n);
2331
+ if (!e) {
2332
+ const t = { current: n.activeElement, previous: null };
2333
+ n.addEventListener(
2334
+ "focusin",
2335
+ (a) => {
2336
+ a.target !== t.current && (t.previous = t.current, t.current = a.target);
2337
+ },
2338
+ !0
2339
+ ), lt.set(n, t), e = t;
2340
+ }
2341
+ return e;
2342
+ }
2343
+ function dt(n) {
2344
+ var t;
2345
+ let e = n;
2346
+ for (; e.parentNode && e.parentNode !== ((t = e.ownerDocument) == null ? void 0 : t.body); )
2347
+ e = e.parentNode;
2348
+ return e;
2349
+ }
2350
+ function Yn(n, e) {
2351
+ return n.compareDocumentPosition(e) & Node.DOCUMENT_POSITION_FOLLOWING ? dt(e) !== dt(n) || e instanceof Element && e.closest($n) !== null : !1;
2352
+ }
2353
+ function ht(n) {
2354
+ !n.hasAttribute("tabindex") && n.tabIndex < 0 && n.setAttribute("tabindex", "-1"), n.focus({ preventScroll: !0 });
2355
+ }
2356
+ function Wn(n, e) {
2357
+ const { open: t, modal: a = !0, restoreFocus: r = !0, closeHint: s } = e, o = R(e);
2358
+ o.current = e;
2359
+ const i = B(), { t: c } = Z();
2360
+ V(() => {
2361
+ typeof document < "u" && ut(document);
2362
+ }, []);
2363
+ const d = !!e.onClose && e.closeOnEscape !== !1;
2364
+ St(
2365
+ n,
2366
+ t && d && s !== !1 ? [{ intent: "back", label: s ?? c("input.hint.close", "Close") }] : [],
2367
+ { fallback: !0 }
2368
+ ), _(
2369
+ n,
2370
+ (u) => {
2371
+ if (!t || !i)
2372
+ return;
2373
+ const p = u.ownerDocument, l = p.activeElement, v = ut(p), y = (w) => w instanceof HTMLElement && w !== p.body && !u.contains(w);
2374
+ let k = null;
2375
+ y(l) ? k = l : l && u.contains(l) ? k = y(v.previous) ? v.previous : null : y(v.current) && (k = v.current);
2376
+ const E = (w) => {
2377
+ const { onClose: b, closeOnEscape: T } = o.current;
2378
+ b && T !== !1 && b(w);
2379
+ }, H = {
2380
+ element: u,
2381
+ modal: a,
2382
+ onClose: o.current.onClose && o.current.closeOnEscape !== !1 ? E : void 0
2383
+ }, x = i.pushOverlay(H), M = ["data-nice-focus-scope", "data-nice-scope-trap"], z = M.map((w) => u.getAttribute(w));
2384
+ if (u.setAttribute("data-nice-focus-scope", "spatial"), a && u.setAttribute("data-nice-scope-trap", ""), !u.contains(p.activeElement)) {
2385
+ const w = ct(u, o.current.initialFocus);
2386
+ w && ht(w);
2387
+ }
2388
+ const g = (w) => {
2389
+ if (w.defaultPrevented)
2390
+ return;
2391
+ if (w.key === "Escape" || w.key === "Esc") {
2392
+ i.topOverlay() === H && H.onClose && (w.preventDefault(), H.onClose(w.niceSource ?? "keyboard"));
2393
+ return;
2394
+ }
2395
+ if (w.key !== "Tab" || !a)
2396
+ return;
2397
+ const b = U(u);
2398
+ if (b.length === 0) {
2399
+ w.preventDefault();
2400
+ return;
2401
+ }
2402
+ const T = b[0], f = b[b.length - 1], h = p.activeElement;
2403
+ w.shiftKey && (h === T || h === u) ? (w.preventDefault(), f.focus()) : !w.shiftKey && h === f && (w.preventDefault(), T.focus());
2404
+ };
2405
+ u.addEventListener("keydown", g);
2406
+ let S = u.contains(p.activeElement);
2407
+ const N = (w) => {
2408
+ const b = w.target;
2409
+ S = !!b && u.contains(b), !(!a || !b || u.contains(b) || i.topOverlay() !== H) && (Yn(u, b) || ht(ct(u, o.current.initialFocus) ?? u));
2410
+ };
2411
+ return p.addEventListener("focusin", N), () => {
2412
+ u.removeEventListener("keydown", g), p.removeEventListener("focusin", N), x(), M.forEach((T, f) => {
2413
+ const h = z[f];
2414
+ h === null ? u.removeAttribute(T) : u.setAttribute(T, h);
2415
+ });
2416
+ const w = p.activeElement, b = u.contains(w) || (!w || w === p.body) && S;
2417
+ r && k && k.isConnected && b && k.focus({ preventScroll: !0 });
2418
+ };
2419
+ },
2420
+ [t, a, r, i]
2421
+ );
2422
+ }
2423
+ const Xn = {
2424
+ Enter: ["Enter", "input.key.enter"],
2425
+ Escape: ["Esc", "input.key.escape"],
2426
+ Space: ["Space", "input.key.space"],
2427
+ Tab: ["Tab", "input.key.tab"],
2428
+ PageUp: ["Page Up", "input.key.pageUp"],
2429
+ PageDown: ["Page Down", "input.key.pageDown"],
2430
+ Home: ["Home", "input.key.home"],
2431
+ End: ["End", "input.key.end"],
2432
+ Backspace: ["Backspace", "input.key.backspace"],
2433
+ Delete: ["Delete", "input.key.delete"],
2434
+ ContextMenu: ["Menu key", "input.key.contextMenu"],
2435
+ Ctrl: ["Ctrl", "input.key.ctrl"],
2436
+ Alt: ["Alt", "input.key.alt"],
2437
+ Shift: ["Shift", "input.key.shift"]
2438
+ }, Jn = {
2439
+ ArrowUp: ["arrow-up", "Up arrow", "input.key.arrowUp"],
2440
+ ArrowDown: ["arrow-down", "Down arrow", "input.key.arrowDown"],
2441
+ ArrowLeft: ["arrow-left", "Left arrow", "input.key.arrowLeft"],
2442
+ ArrowRight: ["arrow-right", "Right arrow", "input.key.arrowRight"]
2443
+ }, Zn = {
2444
+ Ctrl: ["key-command", "Command", "input.key.command"],
2445
+ Alt: ["key-option", "Option", "input.key.option"],
2446
+ Shift: ["key-shift", "Shift", "input.key.shift"]
2447
+ }, Vt = {
2448
+ Cmd: "Ctrl",
2449
+ Meta: "Ctrl",
2450
+ Mod: "Ctrl",
2451
+ Control: "Ctrl",
2452
+ Option: "Alt",
2453
+ Esc: "Escape",
2454
+ " ": "Space"
2455
+ };
2456
+ function Qn() {
2457
+ var t;
2458
+ if (typeof navigator > "u")
2459
+ return !1;
2460
+ const n = navigator, e = ((t = n.userAgentData) == null ? void 0 : t.platform) || n.platform || n.userAgent;
2461
+ return /mac|iphone|ipad|ipod/i.test(e);
2462
+ }
2463
+ function Ae(n) {
2464
+ return (n.endsWith("++") ? [...n.slice(0, -2).split("+"), "+"] : n.split("+")).filter(Boolean).map((t) => Vt[t] ?? t);
2465
+ }
2466
+ function qa(n) {
2467
+ return [
2468
+ n.primary ? "Ctrl" : "",
2469
+ n.alt ? "Alt" : "",
2470
+ n.shift ? "Shift" : "",
2471
+ n.key
2472
+ ].filter(Boolean).join("+");
2473
+ }
2474
+ function ft(n, e) {
2475
+ const t = Vt[n] ?? n, a = (e ? Zn[t] : void 0) ?? Jn[t];
2476
+ if (a)
2477
+ return { icon: a[0], spoken: a[1], spokenKey: a[2] };
2478
+ const r = Xn[t];
2479
+ if (r)
2480
+ return { text: r[0], textKey: r[1], spoken: r[0], spokenKey: r[1] };
2481
+ const s = t.length === 1 ? t.toUpperCase() : t;
2482
+ return { text: s, spoken: s };
2483
+ }
2484
+ const ea = { sm: 12, md: 14, lg: 18 }, ta = /* @__PURE__ */ Object.assign(
2485
+ function({
2486
+ keys: e,
2487
+ size: t = "md",
2488
+ platform: a = "auto",
2489
+ className: r,
2490
+ style: s
2491
+ }) {
2492
+ const { t: o } = Z(), i = a === "mac" || a === "auto" && Qn(), c = e.split(" ").filter(Boolean), d = c.map(
2493
+ (u) => Ae(u).map((p) => {
2494
+ const l = ft(p, i);
2495
+ return l.spokenKey ? o(l.spokenKey, l.spoken) : l.spoken;
2496
+ }).join(" + ")
2497
+ ).join(", ");
2498
+ return /* @__PURE__ */ C(
2499
+ "kbd",
2500
+ {
2501
+ className: `nice-keycap nice-keycap--${t}${r ? ` ${r}` : ""}`,
2502
+ style: s,
2503
+ role: "img",
2504
+ "aria-label": d,
2505
+ children: c.map((u, p) => /* @__PURE__ */ C("span", { className: "nice-keycap__chord", "aria-hidden": "true", children: Ae(u).map((l, v) => {
2506
+ const y = ft(l, i);
2507
+ return /* @__PURE__ */ F(Ne.Fragment, { children: [
2508
+ v > 0 && !i && /* @__PURE__ */ C("span", { className: "nice-keycap__plus", children: "+" }),
2509
+ /* @__PURE__ */ C("span", { className: "nice-keycap__key", children: y.icon ? /* @__PURE__ */ C(te, { name: y.icon, size: ea[t] }) : y.textKey ? o(y.textKey, y.text ?? "") : y.text })
2510
+ ] }, v);
2511
+ }) }, p))
2512
+ }
2513
+ );
2514
+ },
2515
+ { displayName: "NiceKeyCap" }
2516
+ ), fe = { sm: 16, md: 20, lg: 28 }, na = {
2517
+ up: "ArrowUp",
2518
+ down: "ArrowDown",
2519
+ left: "ArrowLeft",
2520
+ right: "ArrowRight"
2521
+ }, aa = {
2522
+ up: "dpadUp",
2523
+ down: "dpadDown",
2524
+ left: "dpadLeft",
2525
+ right: "dpadRight"
2526
+ }, ra = /* @__PURE__ */ new Set([
2527
+ "south",
2528
+ "east",
2529
+ "west",
2530
+ "north",
2531
+ "dpadUp",
2532
+ "dpadDown",
2533
+ "dpadLeft",
2534
+ "dpadRight",
2535
+ "leftStick",
2536
+ "rightStick"
2537
+ ]), pt = {
2538
+ activate: ["remote-ok", "OK", "input.remote.ok"],
2539
+ back: ["remote-back", "Back", "input.intent.back"],
2540
+ menu: ["remote-menu", "Menu", "input.intent.menu"]
2541
+ }, Ft = /* @__PURE__ */ Object.assign(
2542
+ function({
2543
+ intent: e,
2544
+ direction: t,
2545
+ button: a,
2546
+ keys: r,
2547
+ label: s,
2548
+ device: o = "auto",
2549
+ family: i,
2550
+ size: c = "md",
2551
+ className: d,
2552
+ style: u
2553
+ }) {
2554
+ const { t: p } = Z(), l = Rt(), v = o !== "auto" ? o : l.method === "gamepad" || l.method === "remote" ? l.method : "keyboard", y = l.preferences.glyphFamily, k = i ?? (y !== "auto" ? y : l.family ?? "xbox"), E = `nice-button-prompt nice-button-prompt--${c}${d ? ` ${d}` : ""}`, H = s !== void 0 && /* @__PURE__ */ C("span", { className: "nice-button-prompt__label", children: s });
2555
+ let x = null;
2556
+ if (v === "remote" && e && pt[e]) {
2557
+ const [M, z, g] = pt[e];
2558
+ x = /* @__PURE__ */ C("span", { className: "nice-button-prompt__glyph", role: "img", "aria-label": p(g, z), children: /* @__PURE__ */ C(te, { name: M, size: fe[c] }) });
2559
+ } else if (v === "gamepad" || v === "remote") {
2560
+ let M = a ? un(a) : null;
2561
+ if (!M && e === "navigate" ? M = t ? aa[t] : null : !M && e && (M = ke(l.preferences, k)[e][0] ?? null), !M && e === "navigate")
2562
+ x = /* @__PURE__ */ C(
2563
+ "span",
2564
+ {
2565
+ className: "nice-button-prompt__glyph",
2566
+ role: "img",
2567
+ "aria-label": p("input.pad.dpad", "D-pad"),
2568
+ children: /* @__PURE__ */ C(te, { name: "pad-dpad", size: fe[c] })
2569
+ }
2570
+ );
2571
+ else if (M) {
2572
+ const { label: z, key: g } = vn(k, M), S = g ? p(g, z) : p("input.prompt.button", "Button {name}").replace("{name}", z);
2573
+ x = ra.has(M) ? /* @__PURE__ */ C(
2574
+ "span",
2575
+ {
2576
+ className: `nice-button-prompt__glyph nice-button-prompt__glyph--${k}-${M}`,
2577
+ role: "img",
2578
+ "aria-label": S,
2579
+ children: /* @__PURE__ */ C(te, { name: mn(k, M), size: fe[c] })
2580
+ }
2581
+ ) : /* @__PURE__ */ C("span", { className: "nice-button-prompt__chip", role: "img", "aria-label": S, children: /* @__PURE__ */ C("span", { "aria-hidden": "true", children: g ? p(g, z) : z }) });
2582
+ }
2583
+ } else {
2584
+ let M = r;
2585
+ !M && e === "navigate" ? M = t ? na[t] : "ArrowUp ArrowDown ArrowLeft ArrowRight" : !M && e && (M = (l.preferences.keyboardBindings[e] ?? Ee[e])[0]), M && (x = /* @__PURE__ */ C(ta, { keys: M, size: c }));
2586
+ }
2587
+ return !x && !H ? null : /* @__PURE__ */ F("span", { className: E, style: u, "data-device": v, children: [
2588
+ x,
2589
+ H
2590
+ ] });
2591
+ },
2592
+ { displayName: "NiceButtonPrompt" }
2593
+ ), Se = [
2594
+ '[role="tab"]',
2595
+ '[role="option"]',
2596
+ '[role="menuitem"]',
2597
+ '[role="menuitemcheckbox"]',
2598
+ '[role="menuitemradio"]',
2599
+ '[role="radio"]',
2600
+ '[role="treeitem"]',
2601
+ "[data-nice-roving-item]"
2602
+ ].join(","), sa = '[aria-selected="true"],[aria-checked="true"],[aria-pressed="true"],[aria-current]:not([aria-current="false"])', oa = 500;
2603
+ function ia(n, e = {}) {
2604
+ const {
2605
+ orientation: t = "horizontal",
2606
+ itemSelector: a = Se,
2607
+ wrap: r = !1,
2608
+ homeEnd: s = !0,
2609
+ pageSize: o = 0,
2610
+ typeahead: i = !1,
2611
+ skipDisabled: c = !0,
2612
+ enabled: d = !0
2613
+ } = e, u = R(e.onMove);
2614
+ u.current = e.onMove;
2615
+ const p = R(e.activateOnMove);
2616
+ p.current = e.activateOnMove;
2617
+ const l = B(), v = O(() => {
2618
+ const E = n.current;
2619
+ return E ? [...E.querySelectorAll(a)].filter(
2620
+ (H) => H.closest("[data-nice-roving]") === E && !(c && (H.getAttribute("aria-disabled") === "true" || H.disabled))
2621
+ ) : [];
2622
+ }, [n, a, c]), y = O(() => {
2623
+ const E = v();
2624
+ if (E.length === 0)
2625
+ return;
2626
+ const H = E[0].ownerDocument, M = E.find((z) => z === H.activeElement || z.contains(H.activeElement)) ?? E.find((z) => z.matches(sa)) ?? E.find((z) => z.getAttribute("tabindex") === "0") ?? E[0];
2627
+ for (const z of E) {
2628
+ const g = z === M ? "0" : "-1";
2629
+ z.getAttribute("tabindex") !== g && z.setAttribute("tabindex", g);
2630
+ }
2631
+ }, [v]), k = O(
2632
+ (E) => {
2633
+ var M;
2634
+ const H = v(), x = H[E];
2635
+ if (x) {
2636
+ for (const z of H)
2637
+ z.setAttribute("tabindex", z === x ? "0" : "-1");
2638
+ l ? l.focusElement(x) : x.focus(), p.current && ((x.matches('button, a[href], [role="button"]') ? x : x.querySelector("button, a[href]")) ?? x).click(), (M = u.current) == null || M.call(u, x, E);
2639
+ }
2640
+ },
2641
+ [v, l]
2642
+ );
2643
+ return _(
2644
+ n,
2645
+ (E) => {
2646
+ if (!d)
2647
+ return;
2648
+ E.setAttribute("data-nice-roving", t), y();
2649
+ let H = "", x;
2650
+ const M = (S) => {
2651
+ var D;
2652
+ if (S.defaultPrevented || S.altKey || S.ctrlKey || S.metaKey)
2653
+ return;
2654
+ const N = v(), w = E.ownerDocument, b = N.findIndex(
2655
+ (L) => L === w.activeElement || L.contains(w.activeElement)
2656
+ );
2657
+ if (b < 0)
2658
+ return;
2659
+ const T = ((D = w.defaultView) == null ? void 0 : D.getComputedStyle(E).direction) === "rtl";
2660
+ let f = -1;
2661
+ const h = (L) => {
2662
+ const P = b + L;
2663
+ return P >= 0 && P < N.length ? P : r ? (P + N.length) % N.length : -1;
2664
+ }, m = {
2665
+ ArrowUp: "up",
2666
+ ArrowDown: "down",
2667
+ ArrowLeft: "left",
2668
+ ArrowRight: "right"
2669
+ }[S.key];
2670
+ if (m) {
2671
+ const L = m === "left" || m === "right";
2672
+ if (t === "grid") {
2673
+ const P = Dt(
2674
+ J(N[b]),
2675
+ N.filter((I, $) => $ !== b),
2676
+ J,
2677
+ m
2678
+ );
2679
+ f = P ? N.indexOf(P) : -1;
2680
+ } else if (t === "both" || t === "horizontal" && L || t === "vertical" && !L) {
2681
+ let P = m === "down" || m === "right";
2682
+ L && T && (P = !P), f = h(P ? 1 : -1);
2683
+ } else
2684
+ return;
2685
+ if (f < 0)
2686
+ return;
2687
+ } else if (s && (S.key === "Home" || S.key === "End"))
2688
+ f = S.key === "Home" ? 0 : N.length - 1;
2689
+ else if (o > 0 && (S.key === "PageUp" || S.key === "PageDown")) {
2690
+ const L = S.key === "PageUp" ? -o : o;
2691
+ f = Math.max(0, Math.min(N.length - 1, b + L));
2692
+ } else if (i && S.key.length === 1 && S.key !== " ") {
2693
+ clearTimeout(x), H += S.key.toLowerCase(), x = setTimeout(() => {
2694
+ H = "";
2695
+ }, oa);
2696
+ for (let L = 1; L <= N.length; L++) {
2697
+ const P = (b + L) % N.length;
2698
+ if ((N[P].getAttribute("aria-label") ?? N[P].textContent ?? "").trim().toLowerCase().startsWith(H)) {
2699
+ f = P;
2700
+ break;
2701
+ }
2702
+ }
2703
+ if (f < 0)
2704
+ return;
2705
+ } else
2706
+ return;
2707
+ S.preventDefault(), f !== b && k(f);
2708
+ }, z = () => y();
2709
+ E.addEventListener("keydown", M), E.addEventListener("focusin", z);
2710
+ const g = typeof MutationObserver > "u" ? null : new MutationObserver(() => y());
2711
+ return g == null || g.observe(E, {
2712
+ childList: !0,
2713
+ subtree: !0,
2714
+ attributes: !0,
2715
+ attributeFilter: [
2716
+ "aria-selected",
2717
+ "aria-checked",
2718
+ "aria-current",
2719
+ "aria-disabled",
2720
+ "disabled"
2721
+ ]
2722
+ }), () => {
2723
+ clearTimeout(x), E.removeEventListener("keydown", M), E.removeEventListener("focusin", z), g == null || g.disconnect(), E.removeAttribute("data-nice-roving");
2724
+ };
2725
+ },
2726
+ [d, t, r, s, o, i, v, y, k]
2727
+ ), { items: v, focusItem: k, refresh: y };
2728
+ }
2729
+ function ca(n, e, t = {}) {
2730
+ const { ref: a, enabled: r = !0 } = t, s = R(e);
2731
+ s.current = e;
2732
+ const o = typeof n == "string" ? n : n.join(",");
2733
+ B();
2734
+ const i = (c) => {
2735
+ const d = new Set(o.split(",")), u = (p) => {
2736
+ const l = p;
2737
+ l.defaultPrevented || !d.has(l.detail.intent) || s.current(l.detail, l) !== !1 && l.preventDefault();
2738
+ };
2739
+ return c.addEventListener(ze, u), () => c.removeEventListener(ze, u);
2740
+ };
2741
+ _(a, (c) => r ? i(c) : void 0, [o, r]), V(() => {
2742
+ if (!(a || !r))
2743
+ return i(document);
2744
+ }, [a, o, r]);
2745
+ }
2746
+ function la(n, e = {}) {
2747
+ const { nav: t, wrap: a, trap: r, enter: s, arrows: o, region: i } = e;
2748
+ B(), _(n, (c) => xn(c, { nav: t, wrap: a, trap: r, enter: s, arrows: o, region: i }), [
2749
+ t,
2750
+ a,
2751
+ r,
2752
+ s,
2753
+ o,
2754
+ i
2755
+ ]);
2756
+ }
2757
+ function $a(n, e = {}) {
2758
+ const { kind: t = "value", disabled: a = !1, restoreOnCancel: r = !1 } = e, [s, o] = K(!1), i = R(e);
2759
+ return i.current = e, B(), _(
2760
+ n,
2761
+ (c) => {
2762
+ const d = c.getAttribute("data-nice-engage");
2763
+ c.setAttribute("data-nice-engage", a ? "none" : t), c.toggleAttribute(ge, r);
2764
+ const u = (p) => {
2765
+ var v, y, k, E;
2766
+ if (p.target !== c)
2767
+ return;
2768
+ const l = p.detail;
2769
+ o(l.engaged), l.engaged ? (y = (v = i.current).onEngage) == null || y.call(v) : (E = (k = i.current).onRelease) == null || E.call(k, l.cancelled);
2770
+ };
2771
+ return c.addEventListener(ae, u), () => {
2772
+ c.removeEventListener(ae, u), c.removeAttribute(ge), d === null ? c.removeAttribute("data-nice-engage") : c.setAttribute("data-nice-engage", d);
2773
+ };
2774
+ },
2775
+ [t, a, r]
2776
+ ), { engaged: s };
2777
+ }
2778
+ function Ya(n, e, t) {
2779
+ const {
2780
+ open: a,
2781
+ orientation: r = "vertical",
2782
+ itemSelector: s = Se,
2783
+ typeahead: o = !0,
2784
+ closeOnFocusOut: i = !0,
2785
+ closeOnOutsidePress: c = !0
2786
+ } = t, d = R(t);
2787
+ d.current = t;
2788
+ const u = R("first");
2789
+ ia(e, { orientation: r, wrap: !0, typeahead: o, itemSelector: s }), Wn(e, {
2790
+ open: a,
2791
+ modal: !1,
2792
+ onClose: () => d.current.onOpenChange(!1)
2793
+ }), _(
2794
+ n,
2795
+ (p) => {
2796
+ const l = (v) => {
2797
+ var E, H;
2798
+ const y = v.niceSource;
2799
+ if (v.defaultPrevented || y === "gamepad" || y === "remote" || v.key !== "ArrowDown" && v.key !== "ArrowUp")
2800
+ return;
2801
+ if (v.preventDefault(), u.current = v.key === "ArrowUp" ? "last" : "first", !d.current.open) {
2802
+ d.current.onOpenChange(!0);
2803
+ return;
2804
+ }
2805
+ const k = [
2806
+ ...((E = e.current) == null ? void 0 : E.querySelectorAll(
2807
+ d.current.itemSelector ?? Se
2808
+ )) ?? []
2809
+ ];
2810
+ (H = u.current === "last" ? k[k.length - 1] : k[0]) == null || H.focus();
2811
+ };
2812
+ return p.addEventListener("keydown", l), () => p.removeEventListener("keydown", l);
2813
+ },
2814
+ []
2815
+ ), _(
2816
+ e,
2817
+ (p) => {
2818
+ var H;
2819
+ if (!a)
2820
+ return;
2821
+ if (u.current === "last") {
2822
+ const x = p.querySelectorAll(s);
2823
+ (H = x[x.length - 1]) == null || H.focus();
2824
+ }
2825
+ u.current = "first";
2826
+ const l = (x) => {
2827
+ const M = x.target;
2828
+ x.defaultPrevented || x.key !== "Enter" && x.key !== " " || !M.matches(s) || M.matches("button, a[href], input, select, textarea") || (x.preventDefault(), M.click());
2829
+ }, v = (x) => {
2830
+ var M;
2831
+ return !!x && !p.contains(x) && !((M = n.current) != null && M.contains(x));
2832
+ }, y = (x) => {
2833
+ v(x.relatedTarget) && d.current.onOpenChange(!1);
2834
+ }, k = (x) => {
2835
+ v(x.target) && d.current.onOpenChange(!1);
2836
+ }, E = p.ownerDocument;
2837
+ return p.addEventListener("keydown", l), i && p.addEventListener("focusout", y), c && (E.addEventListener("mousedown", k), E.addEventListener("touchstart", k)), () => {
2838
+ p.removeEventListener("keydown", l), p.removeEventListener("focusout", y), E.removeEventListener("mousedown", k), E.removeEventListener("touchstart", k);
2839
+ };
2840
+ },
2841
+ [a, s, i, c]
2842
+ );
2843
+ }
2844
+ const ua = 500;
2845
+ function Wa(n, e) {
2846
+ const {
2847
+ itemSelector: t = '[role="treeitem"]',
2848
+ rowSelector: a,
2849
+ typeahead: r = !0,
2850
+ enabled: s = !0
2851
+ } = e, o = R(e);
2852
+ o.current = e;
2853
+ const i = B();
2854
+ _(
2855
+ n,
2856
+ (c) => {
2857
+ if (!s)
2858
+ return;
2859
+ const d = c.ownerDocument, u = (f) => f instanceof HTMLElement && f.matches(t) && c.contains(f), p = () => [...c.querySelectorAll(t)], l = (f) => Number(f.getAttribute("aria-level")) || 0, v = (f) => {
2860
+ var D;
2861
+ const h = ((D = f.parentElement) == null ? void 0 : D.closest(t)) ?? null;
2862
+ if (h && c.contains(h))
2863
+ return h;
2864
+ const A = l(f);
2865
+ if (A < 2)
2866
+ return null;
2867
+ const m = p();
2868
+ for (let L = m.indexOf(f) - 1; L >= 0; L--) {
2869
+ const P = l(m[L]);
2870
+ if (P === A - 1)
2871
+ return m[L];
2872
+ if (P < A - 1)
2873
+ return null;
2874
+ }
2875
+ return null;
2876
+ }, y = (f) => {
2877
+ if (f.closest("[hidden],[inert]"))
2878
+ return !1;
2879
+ for (let h = v(f); h; h = v(h))
2880
+ if (h.getAttribute("aria-expanded") === "false")
2881
+ return !1;
2882
+ return !0;
2883
+ }, k = () => p().filter(y), E = (f) => a ? [...f.querySelectorAll(a)].find(
2884
+ (h) => h.closest(t) === f
2885
+ ) ?? null : null, H = (f) => {
2886
+ const h = f.getAttribute("aria-label");
2887
+ if (h)
2888
+ return h;
2889
+ const A = E(f);
2890
+ return A ? A.textContent ?? "" : [...f.childNodes].filter((m) => !(m instanceof Element && m.matches('[role="group"]'))).map((m) => m.textContent ?? "").join("");
2891
+ }, x = () => {
2892
+ const f = k();
2893
+ if (f.length === 0)
2894
+ return;
2895
+ const h = d.activeElement, A = f.find((m) => m === h) ?? f.find((m) => m.getAttribute("aria-selected") === "true") ?? f.find((m) => m.getAttribute("tabindex") === "0") ?? f[0];
2896
+ for (const m of p()) {
2897
+ const D = m === A ? "0" : "-1";
2898
+ m.getAttribute("tabindex") !== D && m.setAttribute("tabindex", D);
2899
+ }
2900
+ }, M = (f) => {
2901
+ for (const h of p())
2902
+ h.setAttribute("tabindex", h === f ? "0" : "-1");
2903
+ i ? i.focusElement(f) : f.focus();
2904
+ };
2905
+ let z = "", g;
2906
+ const S = (f) => {
2907
+ var $;
2908
+ if (f.defaultPrevented || f.altKey || f.ctrlKey || f.metaKey || !u(f.target))
2909
+ return;
2910
+ const h = f.target, A = k(), m = A.indexOf(h);
2911
+ if (m < 0)
2912
+ return;
2913
+ const D = (($ = d.defaultView) == null ? void 0 : $.getComputedStyle(c).direction) === "rtl", L = D && f.key === "ArrowLeft" ? "ArrowRight" : D && f.key === "ArrowRight" ? "ArrowLeft" : f.key, P = h.getAttribute("aria-expanded");
2914
+ let I;
2915
+ if (L === "ArrowDown")
2916
+ I = A[m + 1];
2917
+ else if (L === "ArrowUp")
2918
+ I = A[m - 1];
2919
+ else if (L === "Home")
2920
+ I = A[0];
2921
+ else if (L === "End")
2922
+ I = A[A.length - 1];
2923
+ else if (L === "ArrowRight") {
2924
+ if (P === "false") {
2925
+ f.preventDefault(), o.current.onToggle(h, !0);
2926
+ return;
2927
+ }
2928
+ const j = A[m + 1];
2929
+ I = P === "true" && j && v(j) === h ? j : void 0;
2930
+ } else if (L === "ArrowLeft") {
2931
+ if (P === "true") {
2932
+ f.preventDefault(), o.current.onToggle(h, !1);
2933
+ return;
2934
+ }
2935
+ I = v(h);
2936
+ } else if (L === "*") {
2937
+ f.preventDefault();
2938
+ const j = v(h);
2939
+ for (const Y of A)
2940
+ v(Y) === j && Y.getAttribute("aria-expanded") === "false" && o.current.onToggle(Y, !0);
2941
+ return;
2942
+ } else if (L === "Enter" || L === " ") {
2943
+ f.preventDefault(), h.click();
2944
+ return;
2945
+ } else if (r && L.length === 1) {
2946
+ clearTimeout(g), z += L.toLowerCase(), g = setTimeout(() => {
2947
+ z = "";
2948
+ }, ua);
2949
+ for (let j = 1; j <= A.length; j++) {
2950
+ const Y = A[(m + j) % A.length];
2951
+ if (H(Y).trim().toLowerCase().startsWith(z)) {
2952
+ I = Y;
2953
+ break;
2954
+ }
2955
+ }
2956
+ }
2957
+ I && I !== h && (f.preventDefault(), M(I));
2958
+ }, N = (f) => {
2959
+ const h = u(f.target) ? E(f.target) : null;
2960
+ h && h.click();
2961
+ }, w = (f) => {
2962
+ const h = u(f.target) ? E(f.target) : null;
2963
+ if (!h)
2964
+ return;
2965
+ const A = h.getBoundingClientRect(), m = new MouseEvent("contextmenu", {
2966
+ bubbles: !0,
2967
+ cancelable: !0,
2968
+ clientX: f.clientX || A.left + A.width / 2,
2969
+ clientY: f.clientY || A.top + A.height / 2
2970
+ });
2971
+ f.stopPropagation(), h.dispatchEvent(m) || f.preventDefault();
2972
+ }, b = () => x();
2973
+ x(), c.addEventListener("keydown", S), c.addEventListener("click", N), c.addEventListener("contextmenu", w), c.addEventListener("focusin", b);
2974
+ const T = typeof MutationObserver > "u" ? null : new MutationObserver(() => x());
2975
+ return T == null || T.observe(c, {
2976
+ childList: !0,
2977
+ subtree: !0,
2978
+ attributes: !0,
2979
+ attributeFilter: ["aria-expanded", "aria-selected", "hidden"]
2980
+ }), () => {
2981
+ clearTimeout(g), c.removeEventListener("keydown", S), c.removeEventListener("click", N), c.removeEventListener("contextmenu", w), c.removeEventListener("focusin", b), T == null || T.disconnect();
2982
+ };
2983
+ },
2984
+ [s, t, a, r, i]
2985
+ );
2986
+ }
2987
+ const da = '[role="row"],tr', ha = '[role="gridcell"],[role="columnheader"],[role="rowheader"],td,th', fa = 'button:not([disabled]),a[href],input:not([disabled]):not([type="hidden"]),select:not([disabled]),textarea:not([disabled])', pa = 'textarea,select,input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="reset"])';
2988
+ function Xa(n, e = {}) {
2989
+ const { rowSelector: t = da, cellSelector: a = ha, pageSize: r = 10, enabled: s = !0 } = e, o = R(e);
2990
+ o.current = e;
2991
+ const i = B();
2992
+ _(
2993
+ n,
2994
+ (c) => {
2995
+ if (!s)
2996
+ return;
2997
+ const d = c.ownerDocument, u = (g) => {
2998
+ var S;
2999
+ return !!g && g.matches(t) && ((S = g.parentElement) == null ? void 0 : S.closest('[role="grid"],[role="treegrid"]')) === c;
3000
+ }, p = () => [...c.querySelectorAll(t)].filter(u), l = (g) => [...g.children].filter((S) => S.matches(a)), v = (g) => {
3001
+ const S = g.querySelectorAll(fa);
3002
+ return S.length === 1 ? S[0] : g;
3003
+ }, y = () => p().flatMap((g) => l(g).map(v)), k = (g) => {
3004
+ const S = (g == null ? void 0 : g.closest(a)) ?? null;
3005
+ return S && u(S.parentElement) ? S : null;
3006
+ }, E = () => {
3007
+ const g = y();
3008
+ if (g.length === 0)
3009
+ return;
3010
+ const S = d.activeElement, N = g.find((w) => w === S || w.contains(S)) ?? g.find((w) => w.getAttribute("tabindex") === "0") ?? g[0];
3011
+ for (const w of g) {
3012
+ const b = w === N ? "0" : "-1";
3013
+ w.getAttribute("tabindex") !== b && w.setAttribute("tabindex", b);
3014
+ }
3015
+ }, H = (g, S, N) => {
3016
+ var b, T;
3017
+ const w = v(g);
3018
+ for (const f of y())
3019
+ f.setAttribute("tabindex", f === w ? "0" : "-1");
3020
+ i ? i.focusElement(w) : w.focus(), (T = (b = o.current).onMove) == null || T.call(b, g, S, N);
3021
+ }, x = (g) => {
3022
+ var D;
3023
+ if (g.defaultPrevented || g.altKey || g.metaKey)
3024
+ return;
3025
+ const S = g.target, N = k(S);
3026
+ if (!N || v(N) !== S || S !== N && S.matches(pa))
3027
+ return;
3028
+ const w = p(), b = w.indexOf(N.parentElement), T = l(w[b]).indexOf(N), f = (L, P) => {
3029
+ const I = w[L] ? l(w[L]) : [];
3030
+ if (I.length === 0)
3031
+ return null;
3032
+ const $ = Math.min(P, I.length - 1);
3033
+ return [I[$], L, $];
3034
+ };
3035
+ let h = null;
3036
+ const A = ((D = d.defaultView) == null ? void 0 : D.getComputedStyle(c).direction) === "rtl", m = A && g.key === "ArrowLeft" ? "ArrowRight" : A && g.key === "ArrowRight" ? "ArrowLeft" : g.key;
3037
+ if (g.ctrlKey && (m === "Home" || m === "End"))
3038
+ h = m === "Home" ? f(0, 0) : f(w.length - 1, Number.MAX_SAFE_INTEGER);
3039
+ else {
3040
+ if (g.ctrlKey)
3041
+ return;
3042
+ if (m === "ArrowRight")
3043
+ h = T + 1 < l(w[b]).length ? f(b, T + 1) : null;
3044
+ else if (m === "ArrowLeft")
3045
+ h = T > 0 ? f(b, T - 1) : null;
3046
+ else if (m === "ArrowDown")
3047
+ h = b + 1 < w.length ? f(b + 1, T) : null;
3048
+ else if (m === "ArrowUp")
3049
+ h = b > 0 ? f(b - 1, T) : null;
3050
+ else if (m === "Home")
3051
+ h = f(b, 0);
3052
+ else if (m === "End")
3053
+ h = f(b, Number.MAX_SAFE_INTEGER);
3054
+ else if (m === "PageDown" || m === "PageUp") {
3055
+ const L = m === "PageDown" ? Math.min(w.length - 1, b + r) : Math.max(0, b - r);
3056
+ h = L !== b ? f(L, T) : null;
3057
+ } else if ((m === "Enter" || m === " ") && S === N && !N.matches("button,a[href]")) {
3058
+ g.preventDefault(), N.click();
3059
+ return;
3060
+ } else
3061
+ return;
3062
+ }
3063
+ h && h[0] !== N && (g.preventDefault(), H(...h));
3064
+ }, M = () => E();
3065
+ E(), c.addEventListener("keydown", x), c.addEventListener("focusin", M);
3066
+ const z = typeof MutationObserver > "u" ? null : new MutationObserver(() => E());
3067
+ return z == null || z.observe(c, {
3068
+ childList: !0,
3069
+ subtree: !0,
3070
+ attributes: !0,
3071
+ attributeFilter: ["disabled"]
3072
+ }), () => {
3073
+ c.removeEventListener("keydown", x), c.removeEventListener("focusin", M), z == null || z.disconnect();
3074
+ };
3075
+ },
3076
+ [s, t, a, r, i]
3077
+ );
3078
+ }
3079
+ const Ja = /* @__PURE__ */ Object.assign(
3080
+ /* @__PURE__ */ Kt(function({ as: e = "div", nav: t, wrap: a, trap: r, enter: s, arrows: o, region: i, children: c, ...d }, u) {
3081
+ const p = R(null);
3082
+ return jt(u, () => p.current), la(p, { nav: t, wrap: a, trap: r, enter: s, arrows: o, region: i }), /* @__PURE__ */ C(e, { ref: p, ...d, children: c });
3083
+ }),
3084
+ { displayName: "NiceFocusScope" }
3085
+ ), X = /* @__PURE__ */ new Map(), Le = /* @__PURE__ */ new Set();
3086
+ let Ce = [];
3087
+ function vt() {
3088
+ Ce = [...X.values()].map((n) => n.current), Le.forEach((n) => n());
3089
+ }
3090
+ const He = (n) => n === void 0 ? [] : typeof n == "string" ? [n] : [...n];
3091
+ function va(n) {
3092
+ return Ae(n).map((e) => e === "Ctrl" ? "Control" : e === "Esc" ? "Escape" : e).join("+");
3093
+ }
3094
+ function ma(n) {
3095
+ if (process.env.NODE_ENV === "production")
3096
+ return;
3097
+ const e = He(n.keyboard);
3098
+ for (const { current: t } of X.values()) {
3099
+ if (t.id === n.id || (t.scope ?? "global") !== (n.scope ?? "global") || n.scope === "local" && t.ref !== n.ref)
3100
+ continue;
3101
+ const a = He(t.keyboard).filter((r) => e.includes(r));
3102
+ (a.length > 0 || n.gamepad && n.gamepad === t.gamepad) && console.warn(
3103
+ `[nice2dev/input] actions "${t.id}" and "${n.id}" share ${a.length > 0 ? a.join(", ") : `the ${n.gamepad} intent`} in the same scope; the inner or later one wins.`
3104
+ );
3105
+ }
3106
+ }
3107
+ function Za(n) {
3108
+ const e = R(n);
3109
+ e.current = n;
3110
+ const { id: t, scope: a = "global", ref: r, gamepad: s, hint: o = !0, shortcutTarget: i } = n, c = He(n.keyboard).join("|");
3111
+ V(() => (ma(e.current), X.set(t, e), vt(), () => {
3112
+ X.get(t) === e && (X.delete(t), vt());
3113
+ }), [t]);
3114
+ const d = (u) => {
3115
+ const p = c.split("|").map(Nt), l = (v) => {
3116
+ const y = v;
3117
+ if (y.defaultPrevented || !p.some((E) => Tt(E, y)))
3118
+ return;
3119
+ const k = e.current;
3120
+ k.when && !k.when() || (y.preventDefault(), k.onTrigger("keyboard"));
3121
+ };
3122
+ return u.addEventListener("keydown", l), () => u.removeEventListener("keydown", l);
3123
+ };
3124
+ _(a === "local" ? r : null, (u) => c ? d(u) : void 0, [
3125
+ c
3126
+ ]), V(() => {
3127
+ if (!(a === "local" || !c))
3128
+ return d(document);
3129
+ }, [c, a]), ca(
3130
+ s ?? "menu",
3131
+ (u) => {
3132
+ const p = e.current;
3133
+ return p.when && !p.when() ? !1 : (p.onTrigger(u.source), !0);
3134
+ },
3135
+ { ref: a === "local" ? r : void 0, enabled: !!s }
3136
+ ), St(
3137
+ a === "local" ? r ?? null : null,
3138
+ s && o ? [{ intent: s, label: n.label, keys: c.split("|")[0] }] : []
3139
+ ), _(
3140
+ i,
3141
+ (u) => {
3142
+ if (!c)
3143
+ return;
3144
+ const p = u.getAttribute("aria-keyshortcuts");
3145
+ return u.setAttribute("aria-keyshortcuts", c.split("|").map(va).join(" ")), () => {
3146
+ p === null ? u.removeAttribute("aria-keyshortcuts") : u.setAttribute("aria-keyshortcuts", p);
3147
+ };
3148
+ },
3149
+ [c]
3150
+ );
3151
+ }
3152
+ function Qa() {
3153
+ return Mt(
3154
+ (n) => (Le.add(n), () => Le.delete(n)),
3155
+ () => Ce,
3156
+ () => Ce
3157
+ );
3158
+ }
3159
+ function er(n, e = "keyboard") {
3160
+ var a;
3161
+ const t = (a = X.get(n)) == null ? void 0 : a.current;
3162
+ return !t || t.when && !t.when() ? !1 : (t.onTrigger(e), !0);
3163
+ }
3164
+ const Ma = [];
3165
+ function ga(n, e, t) {
3166
+ switch (e) {
3167
+ case "popup":
3168
+ return [
3169
+ { intent: "activate", label: t("input.intent.activate", "Select") },
3170
+ { intent: "back", label: t("input.hint.close", "Close") }
3171
+ ];
3172
+ case "text":
3173
+ return [
3174
+ { intent: "menu", label: t("input.hint.confirm", "Confirm") },
3175
+ { intent: "back", label: t("input.hint.done", "Done") }
3176
+ ];
3177
+ case "value":
3178
+ return Yt(n) ? [
3179
+ { intent: "navigate", label: t("input.hint.adjust", "Adjust") },
3180
+ { intent: "activate", label: t("input.hint.done", "Done") },
3181
+ { intent: "back", label: t("input.hint.cancel", "Cancel") }
3182
+ ] : [
3183
+ { intent: "navigate", label: t("input.hint.adjust", "Adjust") },
3184
+ { intent: "back", label: t("input.hint.done", "Done") }
3185
+ ];
3186
+ default:
3187
+ return [{ intent: "back", label: t("input.hint.done", "Done") }];
3188
+ }
3189
+ }
3190
+ const tr = /* @__PURE__ */ Object.assign(
3191
+ function({
3192
+ position: e = "bottom",
3193
+ visibility: t = "auto",
3194
+ automatic: a = !0,
3195
+ hints: r = Ma,
3196
+ max: s = 6,
3197
+ size: o = "sm",
3198
+ className: i,
3199
+ style: c
3200
+ }) {
3201
+ var x;
3202
+ const { t: d } = Z(), u = Rt(), p = B(), l = an(), [, v] = K(0);
3203
+ V(() => {
3204
+ if (!l)
3205
+ return;
3206
+ const M = () => v((g) => g + 1);
3207
+ l.addEventListener(ae, M);
3208
+ const z = typeof MutationObserver > "u" ? null : new MutationObserver(M);
3209
+ return z == null || z.observe(l, { attributes: !0, attributeFilter: ["aria-expanded"] }), () => {
3210
+ l.removeEventListener(ae, M), z == null || z.disconnect();
3211
+ };
3212
+ }, [l]);
3213
+ const y = u.method === "gamepad" || u.method === "remote";
3214
+ if (t === "auto" && !u.hintsVisible || t === "pad" && !(u.hintsVisible && (y || u.preferences.hints === "always")))
3215
+ return null;
3216
+ const k = [...r];
3217
+ if (l && typeof document < "u" && k.push(...nn(l, document)), a && l && l !== document.body) {
3218
+ const M = me(l);
3219
+ M && kt(l, M) ? k.push(...ga(l, M, d)) : (k.push({ intent: "navigate", label: d("input.intent.navigate", "Move") }), M ? k.push({ intent: "activate", label: d("input.hint.edit", "Edit") }) : wt(l) && k.push({ intent: "activate", label: d("input.intent.activate", "Select") }), (x = p == null ? void 0 : p.topOverlay()) != null && x.onClose && k.push({ intent: "back", label: d("input.hint.close", "Close") }));
3220
+ }
3221
+ const E = [], H = /* @__PURE__ */ new Set();
3222
+ for (const M of k) {
3223
+ const z = `${M.intent}:${M.direction ?? ""}`;
3224
+ H.has(z) || (H.add(z), E.push(M));
3225
+ }
3226
+ return E.length === 0 ? null : /* @__PURE__ */ C(
3227
+ "div",
3228
+ {
3229
+ className: `nice-input-hint-bar nice-input-hint-bar--${e}${i ? ` ${i}` : ""}`,
3230
+ style: c,
3231
+ "aria-hidden": "true",
3232
+ children: E.slice(0, s).map((M) => /* @__PURE__ */ C(
3233
+ Ft,
3234
+ {
3235
+ className: "nice-input-hint-bar__item",
3236
+ intent: M.intent,
3237
+ direction: M.direction,
3238
+ button: M.button,
3239
+ keys: M.keys,
3240
+ size: o,
3241
+ label: M.labelKey ? d(M.labelKey, M.label) : M.label
3242
+ },
3243
+ `${M.intent}:${M.direction ?? ""}`
3244
+ ))
3245
+ }
3246
+ );
3247
+ },
3248
+ { displayName: "NiceInputHintBar" }
3249
+ ), nr = /* @__PURE__ */ Object.assign(
3250
+ function({
3251
+ intent: e,
3252
+ direction: t,
3253
+ button: a,
3254
+ keys: r,
3255
+ always: s = !1,
3256
+ size: o = "sm",
3257
+ className: i
3258
+ }) {
3259
+ const c = Gn(), [d] = qn();
3260
+ return !c || !(s || d.hintDensity === "bar-and-controls") ? null : /* @__PURE__ */ C("span", { className: `nice-control-hint${i ? ` ${i}` : ""}`, "aria-hidden": "true", children: /* @__PURE__ */ C(
3261
+ Ft,
3262
+ {
3263
+ intent: e,
3264
+ direction: t,
3265
+ button: a,
3266
+ keys: r,
3267
+ size: o
3268
+ }
3269
+ ) });
3270
+ },
3271
+ { displayName: "NiceControlHint" }
3272
+ ), mt = {
3273
+ en: {
3274
+ code: "en",
3275
+ name: "English",
3276
+ nativeName: "English",
3277
+ rows: [
3278
+ ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"],
3279
+ ["a", "s", "d", "f", "g", "h", "j", "k", "l"],
3280
+ ["z", "x", "c", "v", "b", "n", "m"]
3281
+ ]
3282
+ },
3283
+ pl: {
3284
+ code: "pl",
3285
+ name: "Polish",
3286
+ nativeName: "Polski",
3287
+ rows: [
3288
+ ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"],
3289
+ ["a", "s", "d", "f", "g", "h", "j", "k", "l"],
3290
+ ["z", "x", "c", "v", "b", "n", "m"]
3291
+ ],
3292
+ accents: {
3293
+ a: ["ą"],
3294
+ c: ["ć"],
3295
+ e: ["ę"],
3296
+ l: ["ł"],
3297
+ n: ["ń"],
3298
+ o: ["ó"],
3299
+ s: ["ś"],
3300
+ z: ["ź", "ż"]
3301
+ }
3302
+ },
3303
+ de: {
3304
+ code: "de",
3305
+ name: "German",
3306
+ nativeName: "Deutsch",
3307
+ rows: [
3308
+ ["q", "w", "e", "r", "t", "z", "u", "i", "o", "p", "ü"],
3309
+ ["a", "s", "d", "f", "g", "h", "j", "k", "l", "ö", "ä"],
3310
+ ["y", "x", "c", "v", "b", "n", "m", "ß"]
3311
+ ],
3312
+ accents: { a: ["ä"], o: ["ö"], u: ["ü"], s: ["ß"] }
3313
+ },
3314
+ fr: {
3315
+ code: "fr",
3316
+ name: "French",
3317
+ nativeName: "Français",
3318
+ rows: [
3319
+ ["a", "z", "e", "r", "t", "y", "u", "i", "o", "p"],
3320
+ ["q", "s", "d", "f", "g", "h", "j", "k", "l", "m"],
3321
+ ["w", "x", "c", "v", "b", "n"]
3322
+ ],
3323
+ accents: {
3324
+ a: ["à", "â", "æ"],
3325
+ e: ["é", "è", "ê", "ë"],
3326
+ i: ["î", "ï"],
3327
+ o: ["ô", "œ"],
3328
+ u: ["ù", "û", "ü"],
3329
+ c: ["ç"]
3330
+ }
3331
+ },
3332
+ es: {
3333
+ code: "es",
3334
+ name: "Spanish",
3335
+ nativeName: "Español",
3336
+ rows: [
3337
+ ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"],
3338
+ ["a", "s", "d", "f", "g", "h", "j", "k", "l", "ñ"],
3339
+ ["z", "x", "c", "v", "b", "n", "m"]
3340
+ ],
3341
+ accents: { a: ["á"], e: ["é"], i: ["í"], o: ["ó"], u: ["ú", "ü"], n: ["ñ"] }
3342
+ },
3343
+ it: {
3344
+ code: "it",
3345
+ name: "Italian",
3346
+ nativeName: "Italiano",
3347
+ rows: [
3348
+ ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"],
3349
+ ["a", "s", "d", "f", "g", "h", "j", "k", "l"],
3350
+ ["z", "x", "c", "v", "b", "n", "m"]
3351
+ ],
3352
+ accents: { a: ["à"], e: ["è", "é"], i: ["ì"], o: ["ò"], u: ["ù"] }
3353
+ },
3354
+ pt: {
3355
+ code: "pt",
3356
+ name: "Portuguese",
3357
+ nativeName: "Português",
3358
+ rows: [
3359
+ ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"],
3360
+ ["a", "s", "d", "f", "g", "h", "j", "k", "l", "ç"],
3361
+ ["z", "x", "c", "v", "b", "n", "m"]
3362
+ ],
3363
+ accents: {
3364
+ a: ["á", "ã", "â", "à"],
3365
+ e: ["é", "ê"],
3366
+ i: ["í"],
3367
+ o: ["ó", "õ", "ô"],
3368
+ u: ["ú"],
3369
+ c: ["ç"]
3370
+ }
3371
+ },
3372
+ ru: {
3373
+ code: "ru",
3374
+ name: "Russian",
3375
+ nativeName: "Русский",
3376
+ rows: [
3377
+ ["й", "ц", "у", "к", "е", "н", "г", "ш", "щ", "з", "х", "ъ"],
3378
+ ["ф", "ы", "в", "а", "п", "р", "о", "л", "д", "ж", "э"],
3379
+ ["я", "ч", "с", "м", "и", "т", "ь", "б", "ю"]
3380
+ ]
3381
+ },
3382
+ uk: {
3383
+ code: "uk",
3384
+ name: "Ukrainian",
3385
+ nativeName: "Українська",
3386
+ rows: [
3387
+ ["й", "ц", "у", "к", "е", "н", "г", "ш", "щ", "з", "х", "ї"],
3388
+ ["ф", "і", "в", "а", "п", "р", "о", "л", "д", "ж", "є"],
3389
+ ["я", "ч", "с", "м", "и", "т", "ь", "б", "ю", "ґ"]
3390
+ ]
3391
+ },
3392
+ cs: {
3393
+ code: "cs",
3394
+ name: "Czech",
3395
+ nativeName: "Čeština",
3396
+ rows: [
3397
+ ["q", "w", "e", "r", "t", "z", "u", "i", "o", "p"],
3398
+ ["a", "s", "d", "f", "g", "h", "j", "k", "l"],
3399
+ ["y", "x", "c", "v", "b", "n", "m"]
3400
+ ],
3401
+ accents: {
3402
+ a: ["á"],
3403
+ c: ["č"],
3404
+ d: ["ď"],
3405
+ e: ["é", "ě"],
3406
+ i: ["í"],
3407
+ n: ["ň"],
3408
+ o: ["ó"],
3409
+ r: ["ř"],
3410
+ s: ["š"],
3411
+ t: ["ť"],
3412
+ u: ["ú", "ů"],
3413
+ y: ["ý"],
3414
+ z: ["ž"]
3415
+ }
3416
+ },
3417
+ tr: {
3418
+ code: "tr",
3419
+ name: "Turkish",
3420
+ nativeName: "Türkçe",
3421
+ rows: [
3422
+ ["q", "w", "e", "r", "t", "y", "u", "ı", "o", "p", "ğ", "ü"],
3423
+ ["a", "s", "d", "f", "g", "h", "j", "k", "l", "ş", "i"],
3424
+ ["z", "x", "c", "v", "b", "n", "m", "ö", "ç"]
3425
+ ]
3426
+ },
3427
+ nl: {
3428
+ code: "nl",
3429
+ name: "Dutch",
3430
+ nativeName: "Nederlands",
3431
+ rows: [
3432
+ ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"],
3433
+ ["a", "s", "d", "f", "g", "h", "j", "k", "l"],
3434
+ ["z", "x", "c", "v", "b", "n", "m"]
3435
+ ],
3436
+ accents: { e: ["é", "ë"], i: ["ï"], o: ["ö"], u: ["ü"] }
3437
+ },
3438
+ sv: {
3439
+ code: "sv",
3440
+ name: "Swedish",
3441
+ nativeName: "Svenska",
3442
+ rows: [
3443
+ ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "å"],
3444
+ ["a", "s", "d", "f", "g", "h", "j", "k", "l", "ö", "ä"],
3445
+ ["z", "x", "c", "v", "b", "n", "m"]
3446
+ ]
3447
+ },
3448
+ no: {
3449
+ code: "no",
3450
+ name: "Norwegian",
3451
+ nativeName: "Norsk",
3452
+ rows: [
3453
+ ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "å"],
3454
+ ["a", "s", "d", "f", "g", "h", "j", "k", "l", "ø", "æ"],
3455
+ ["z", "x", "c", "v", "b", "n", "m"]
3456
+ ]
3457
+ },
3458
+ da: {
3459
+ code: "da",
3460
+ name: "Danish",
3461
+ nativeName: "Dansk",
3462
+ rows: [
3463
+ ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "å"],
3464
+ ["a", "s", "d", "f", "g", "h", "j", "k", "l", "æ", "ø"],
3465
+ ["z", "x", "c", "v", "b", "n", "m"]
3466
+ ]
3467
+ },
3468
+ fi: {
3469
+ code: "fi",
3470
+ name: "Finnish",
3471
+ nativeName: "Suomi",
3472
+ rows: [
3473
+ ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "å"],
3474
+ ["a", "s", "d", "f", "g", "h", "j", "k", "l", "ö", "ä"],
3475
+ ["z", "x", "c", "v", "b", "n", "m"]
3476
+ ]
3477
+ },
3478
+ ro: {
3479
+ code: "ro",
3480
+ name: "Romanian",
3481
+ nativeName: "Română",
3482
+ rows: [
3483
+ ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"],
3484
+ ["a", "s", "d", "f", "g", "h", "j", "k", "l"],
3485
+ ["z", "x", "c", "v", "b", "n", "m"]
3486
+ ],
3487
+ accents: { a: ["ă", "â"], i: ["î"], s: ["ș"], t: ["ț"] }
3488
+ },
3489
+ hr: {
3490
+ code: "hr",
3491
+ name: "Croatian",
3492
+ nativeName: "Hrvatski",
3493
+ rows: [
3494
+ ["q", "w", "e", "r", "t", "z", "u", "i", "o", "p", "š", "đ"],
3495
+ ["a", "s", "d", "f", "g", "h", "j", "k", "l", "č", "ć"],
3496
+ ["y", "x", "c", "v", "b", "n", "m", "ž"]
3497
+ ]
3498
+ },
3499
+ el: {
3500
+ code: "el",
3501
+ name: "Greek",
3502
+ nativeName: "Ελληνικά",
3503
+ rows: [
3504
+ ["ς", "ε", "ρ", "τ", "υ", "θ", "ι", "ο", "π"],
3505
+ ["α", "σ", "δ", "φ", "γ", "η", "ξ", "κ", "λ"],
3506
+ ["ζ", "χ", "ψ", "ω", "β", "ν", "μ"]
3507
+ ],
3508
+ accents: { α: ["ά"], ε: ["έ"], η: ["ή"], ι: ["ί", "ϊ"], ο: ["ό"], υ: ["ύ", "ϋ"], ω: ["ώ"] }
3509
+ },
3510
+ hu: {
3511
+ code: "hu",
3512
+ name: "Hungarian",
3513
+ nativeName: "Magyar",
3514
+ rows: [
3515
+ ["q", "w", "e", "r", "t", "z", "u", "i", "o", "p", "ő", "ú"],
3516
+ ["a", "s", "d", "f", "g", "h", "j", "k", "l", "é", "á"],
3517
+ ["y", "x", "c", "v", "b", "n", "m", "ö", "ü", "ó"]
3518
+ ],
3519
+ accents: { a: ["á"], e: ["é"], i: ["í"], o: ["ó", "ö", "ő"], u: ["ú", "ü", "ű"] }
3520
+ },
3521
+ sk: {
3522
+ code: "sk",
3523
+ name: "Slovak",
3524
+ nativeName: "Slovenčina",
3525
+ rows: [
3526
+ ["q", "w", "e", "r", "t", "z", "u", "i", "o", "p"],
3527
+ ["a", "s", "d", "f", "g", "h", "j", "k", "l"],
3528
+ ["y", "x", "c", "v", "b", "n", "m"]
3529
+ ],
3530
+ accents: {
3531
+ a: ["á", "ä"],
3532
+ c: ["č"],
3533
+ d: ["ď"],
3534
+ e: ["é"],
3535
+ i: ["í"],
3536
+ l: ["ĺ", "ľ"],
3537
+ n: ["ň"],
3538
+ o: ["ó", "ô"],
3539
+ r: ["ŕ"],
3540
+ s: ["š"],
3541
+ t: ["ť"],
3542
+ u: ["ú"],
3543
+ y: ["ý"],
3544
+ z: ["ž"]
3545
+ }
3546
+ },
3547
+ bg: {
3548
+ code: "bg",
3549
+ name: "Bulgarian",
3550
+ nativeName: "Български",
3551
+ rows: [
3552
+ ["я", "в", "е", "р", "т", "ъ", "у", "и", "о", "п", "ш", "щ"],
3553
+ ["а", "с", "д", "ф", "г", "х", "й", "к", "л"],
3554
+ ["з", "ь", "ц", "ж", "б", "н", "м", "ч", "ю"]
3555
+ ]
3556
+ },
3557
+ sr: {
3558
+ code: "sr",
3559
+ name: "Serbian",
3560
+ nativeName: "Српски",
3561
+ rows: [
3562
+ ["љ", "њ", "е", "р", "т", "з", "у", "и", "о", "п", "ш", "ђ"],
3563
+ ["а", "с", "д", "ф", "г", "х", "ј", "к", "л", "ч", "ћ"],
3564
+ ["ж", "џ", "ц", "в", "б", "н", "м"]
3565
+ ]
3566
+ },
3567
+ ja: {
3568
+ code: "ja",
3569
+ name: "Japanese (Romaji)",
3570
+ nativeName: "日本語",
3571
+ rows: [
3572
+ ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"],
3573
+ ["a", "s", "d", "f", "g", "h", "j", "k", "l"],
3574
+ ["z", "x", "c", "v", "b", "n", "m"]
3575
+ ]
3576
+ },
3577
+ ko: {
3578
+ code: "ko",
3579
+ name: "Korean (Romaji)",
3580
+ nativeName: "한국어",
3581
+ rows: [
3582
+ ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"],
3583
+ ["a", "s", "d", "f", "g", "h", "j", "k", "l"],
3584
+ ["z", "x", "c", "v", "b", "n", "m"]
3585
+ ]
3586
+ },
3587
+ zh: {
3588
+ code: "zh",
3589
+ name: "Chinese (Pinyin)",
3590
+ nativeName: "中文",
3591
+ rows: [
3592
+ ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"],
3593
+ ["a", "s", "d", "f", "g", "h", "j", "k", "l"],
3594
+ ["z", "x", "c", "v", "b", "n", "m"]
3595
+ ]
3596
+ },
3597
+ ar: {
3598
+ code: "ar",
3599
+ name: "Arabic",
3600
+ nativeName: "العربية",
3601
+ rows: [
3602
+ ["ض", "ص", "ث", "ق", "ف", "غ", "ع", "ه", "خ", "ح", "ج", "د"],
3603
+ ["ش", "س", "ي", "ب", "ل", "ا", "ت", "ن", "م", "ك", "ط"],
3604
+ ["ئ", "ء", "ؤ", "ر", "لا", "ى", "ة", "و", "ز", "ظ"]
3605
+ ]
3606
+ },
3607
+ he: {
3608
+ code: "he",
3609
+ name: "Hebrew",
3610
+ nativeName: "עברית",
3611
+ rows: [
3612
+ ["/", "'", "ק", "ר", "א", "ט", "ו", "ן", "ם", "פ"],
3613
+ ["ש", "ד", "ג", "כ", "ע", "י", "ח", "ל", "ך", "ף"],
3614
+ ["ז", "ס", "ב", "ה", "נ", "מ", "צ", "ת", "ץ"]
3615
+ ]
3616
+ }
3617
+ }, ar = (n) => n === "ar" || n === "he", q = {
3618
+ value: "Backspace",
3619
+ label: "⌫",
3620
+ type: "backspace",
3621
+ width: 1.5
3622
+ }, ba = {
3623
+ value: "Enter",
3624
+ label: "⏎",
3625
+ type: "enter",
3626
+ width: 1.5
3627
+ }, oe = {
3628
+ value: " ",
3629
+ label: "Space",
3630
+ type: "space",
3631
+ width: 5
3632
+ }, ie = {
3633
+ value: "Shift",
3634
+ label: "⇧",
3635
+ type: "shift",
3636
+ width: 1.5
3637
+ }, ya = {
3638
+ value: "CapsLock",
3639
+ label: "⇪",
3640
+ type: "caps",
3641
+ width: 1.75
3642
+ }, wa = { value: "Tab", label: "⇥", type: "tab", width: 1.5 }, pe = [
3643
+ { value: "1" },
3644
+ { value: "2" },
3645
+ { value: "3" },
3646
+ { value: "4" },
3647
+ { value: "5" },
3648
+ { value: "6" },
3649
+ { value: "7" },
3650
+ { value: "8" },
3651
+ { value: "9" },
3652
+ { value: "0" },
3653
+ { value: "-" },
3654
+ { value: "=" }
3655
+ ], Ea = [
3656
+ { value: "!" },
3657
+ { value: "@" },
3658
+ { value: "#" },
3659
+ { value: "$" },
3660
+ { value: "%" },
3661
+ { value: "^" },
3662
+ { value: "&" },
3663
+ { value: "*" },
3664
+ { value: "(" },
3665
+ { value: ")" }
3666
+ ], ka = [
3667
+ { value: "-" },
3668
+ { value: "_" },
3669
+ { value: "=" },
3670
+ { value: "+" },
3671
+ { value: "[" },
3672
+ { value: "]" },
3673
+ { value: "{" },
3674
+ { value: "}" },
3675
+ q
3676
+ ], xa = [
3677
+ { value: "Esc", label: "Esc", type: "fn", width: 1 },
3678
+ { value: "F1", label: "F1", type: "fn" },
3679
+ { value: "F2", label: "F2", type: "fn" },
3680
+ { value: "F3", label: "F3", type: "fn" },
3681
+ { value: "F4", label: "F4", type: "fn" },
3682
+ { value: "F5", label: "F5", type: "fn" },
3683
+ { value: "F6", label: "F6", type: "fn" },
3684
+ { value: "F7", label: "F7", type: "fn" },
3685
+ { value: "F8", label: "F8", type: "fn" },
3686
+ { value: "F9", label: "F9", type: "fn" },
3687
+ { value: "F10", label: "F10", type: "fn" },
3688
+ { value: "F11", label: "F11", type: "fn" },
3689
+ { value: "F12", label: "F12", type: "fn" }
3690
+ ], za = [
3691
+ [{ value: "1" }, { value: "2" }, { value: "3" }],
3692
+ [{ value: "4" }, { value: "5" }, { value: "6" }],
3693
+ [{ value: "7" }, { value: "8" }, { value: "9" }],
3694
+ [{ value: ".", width: 1 }, { value: "0" }, q]
3695
+ ], rr = [
3696
+ [{ value: "7" }, { value: "8" }, { value: "9" }, { value: "/", type: "special" }],
3697
+ [{ value: "4" }, { value: "5" }, { value: "6" }, { value: "*", type: "special" }],
3698
+ [{ value: "1" }, { value: "2" }, { value: "3" }, { value: "-", type: "special" }],
3699
+ [{ value: "0", width: 2 }, { value: "." }, { value: "+", type: "special" }],
3700
+ [
3701
+ { value: "C", label: "C", type: "fn" },
3702
+ q,
3703
+ { value: "=", type: "enter", width: 2 }
3704
+ ]
3705
+ ], sr = [
3706
+ [
3707
+ { value: "1", label: "1" },
3708
+ { value: "2", label: "2 ABC" },
3709
+ { value: "3", label: "3 DEF" }
3710
+ ],
3711
+ [
3712
+ { value: "4", label: "4 GHI" },
3713
+ { value: "5", label: "5 JKL" },
3714
+ { value: "6", label: "6 MNO" }
3715
+ ],
3716
+ [
3717
+ { value: "7", label: "7 PQRS" },
3718
+ { value: "8", label: "8 TUV" },
3719
+ { value: "9", label: "9 WXYZ" }
3720
+ ],
3721
+ [
3722
+ { value: "*", label: "*" },
3723
+ { value: "0", label: "0 +" },
3724
+ { value: "#", label: "#" }
3725
+ ],
3726
+ [{ value: "Call", label: "Call", type: "enter", width: 1.5 }, q]
3727
+ ], or = [
3728
+ [{ value: "1" }, { value: "2" }, { value: "3" }],
3729
+ [{ value: "4" }, { value: "5" }, { value: "6" }],
3730
+ [{ value: "7" }, { value: "8" }, { value: "9" }],
3731
+ [{ value: "Clear", label: "C", type: "fn" }, { value: "0" }, q]
3732
+ ];
3733
+ function ir(n, e, t, a, r) {
3734
+ const s = mt[n] || mt.en, [o, i, c] = s.rows, d = { ...ba, ...r ? { label: r } : {} };
3735
+ if (e === "minimal")
3736
+ return za;
3737
+ if (t) {
3738
+ const l = [pe.slice(0, 10), Ea, ka], v = [{ value: "ABC", label: "ABC", type: "fn", width: 1.5 }];
3739
+ return a && v.push({ value: "Lang", label: "Lang", type: "lang", width: 1 }), v.push({ value: ",", width: 1 }), v.push({ ...oe, width: a ? 3.5 : 4 }), v.push({ value: ".", width: 1 }), v.push(d), l.push(v), l;
3740
+ }
3741
+ if (e === "compact") {
3742
+ const l = [
3743
+ o.map((y) => ({ value: y })),
3744
+ i.map((y) => ({ value: y })),
3745
+ [ie, ...c.map((y) => ({ value: y })), q]
3746
+ ], v = [{ value: "123", label: "123", type: "fn", width: 1.5 }];
3747
+ return a && v.push({ value: "Lang", label: "Lang", type: "lang", width: 1 }), v.push({ value: ",", width: 1 }), v.push({ ...oe, width: a ? 3.5 : 4 }), v.push({ value: ".", width: 1 }), v.push(d), l.push(v), l;
3748
+ }
3749
+ if (e === "standard") {
3750
+ const l = [
3751
+ pe.slice(0, 10),
3752
+ o.map((y) => ({ value: y })),
3753
+ i.map((y) => ({ value: y })),
3754
+ [ie, ...c.map((y) => ({ value: y })), q]
3755
+ ], v = [{ value: "#+=", label: "#+=", type: "fn", width: 1.5 }];
3756
+ return a && v.push({ value: "Lang", label: "Lang", type: "lang", width: 1 }), v.push({ value: ",", width: 1 }), v.push({ ...oe, width: a ? 3 : 4 }), v.push({ value: ".", width: 1 }), v.push(d), l.push(v), l;
3757
+ }
3758
+ const u = [
3759
+ xa,
3760
+ [...pe, q],
3761
+ [wa, ...o.map((l) => ({ value: l }))],
3762
+ [ya, ...i.map((l) => ({ value: l })), { ...d, width: 1.75 }],
3763
+ [
3764
+ { ...ie, width: 2.25 },
3765
+ ...c.map((l) => ({ value: l })),
3766
+ { ...ie, width: 2.25 }
3767
+ ]
3768
+ ], p = [{ value: "#+=", label: "#+=", type: "fn", width: 1.5 }];
3769
+ if (a && p.push({ value: "Lang", label: "Lang", type: "lang", width: 1 }), p.push({ ...oe, width: a ? 6 : 7 }), p.push({ value: ",", width: 1 }), p.push({ value: ".", width: 1 }), u.push(p), s.accents) {
3770
+ const l = [];
3771
+ for (const [, v] of Object.entries(s.accents))
3772
+ for (const y of v)
3773
+ l.find((k) => k.value === y) || l.push({ value: y });
3774
+ l.length > 0 && u.push(l);
3775
+ }
3776
+ return u;
3777
+ }
3778
+ const Fe = (n, e) => Math.max(0, Math.min(n.length, e));
3779
+ function cr(n, e, t) {
3780
+ const a = Fe(n.text, n.caret), r = n.text.slice(0, a) + e + n.text.slice(a);
3781
+ return t !== void 0 && r.length > t ? n : { text: r, caret: a + e.length };
3782
+ }
3783
+ function lr(n) {
3784
+ const e = Fe(n.text, n.caret);
3785
+ if (e === 0)
3786
+ return { text: n.text, caret: e };
3787
+ const t = e >= 2 && /[\uDC00-\uDFFF]/.test(n.text[e - 1]) ? 2 : 1;
3788
+ return { text: n.text.slice(0, e - t) + n.text.slice(e), caret: e - t };
3789
+ }
3790
+ function ur(n, e) {
3791
+ const t = e === "start" ? 0 : e === "end" ? n.text.length : Fe(n.text, n.caret + e);
3792
+ return { text: n.text, caret: t };
3793
+ }
3794
+ const Aa = /* @__PURE__ */ new Set(["Shift", "Control", "Alt", "Meta", "AltGraph"]);
3795
+ function dr() {
3796
+ let n = !1;
3797
+ return (e) => {
3798
+ if (e.key === "Tab") {
3799
+ const t = n;
3800
+ return n = !1, t;
3801
+ }
3802
+ return Aa.has(e.key) || (n = e.key === "Escape"), !1;
3803
+ };
3804
+ }
3805
+ export {
3806
+ U as $,
3807
+ wa as A,
3808
+ Se as B,
3809
+ nr as C,
3810
+ Ja as D,
3811
+ Fn as E,
3812
+ Na as F,
3813
+ Kn as G,
3814
+ tr as H,
3815
+ Ia as I,
3816
+ Ga as J,
3817
+ _a as K,
3818
+ rn as L,
3819
+ Fa as M,
3820
+ te as N,
3821
+ xn as O,
3822
+ ir as P,
3823
+ Tt as Q,
3824
+ Oa as R,
3825
+ qa as S,
3826
+ $t as T,
3827
+ cn as U,
3828
+ dr as V,
3829
+ lr as W,
3830
+ on as X,
3831
+ me as Y,
3832
+ Dn as Z,
3833
+ In as _,
3834
+ Ka as a,
3835
+ vn as a0,
3836
+ mn as a1,
3837
+ kn as a2,
3838
+ nn as a3,
3839
+ cr as a4,
3840
+ bn as a5,
3841
+ wt as a6,
3842
+ kt as a7,
3843
+ ne as a8,
3844
+ Qn as a9,
3845
+ ja as aA,
3846
+ Xa as aB,
3847
+ Ra as aC,
3848
+ Gn as aD,
3849
+ B as aE,
3850
+ St as aF,
3851
+ qn as aG,
3852
+ Rt as aH,
3853
+ Ya as aI,
3854
+ Za as aJ,
3855
+ Qa as aK,
3856
+ Ta as aL,
3857
+ Wa as aM,
3858
+ Lt as aN,
3859
+ sn as aO,
3860
+ ar as aa,
3861
+ bt as ab,
3862
+ ft as ac,
3863
+ ur as ad,
3864
+ Ve as ae,
3865
+ Nt as af,
3866
+ Dt as ag,
3867
+ Pt as ah,
3868
+ J as ai,
3869
+ En as aj,
3870
+ ke as ak,
3871
+ Ye as al,
3872
+ Yt as am,
3873
+ Ha as an,
3874
+ Da as ao,
3875
+ Cn as ap,
3876
+ Ae as aq,
3877
+ va as ar,
3878
+ un as as,
3879
+ er as at,
3880
+ Va as au,
3881
+ Ua as av,
3882
+ Ct as aw,
3883
+ $a as ax,
3884
+ la as ay,
3885
+ an as az,
3886
+ Ft as b,
3887
+ Et as c,
3888
+ ta as d,
3889
+ ia as e,
3890
+ ca as f,
3891
+ jn as g,
3892
+ Pa as h,
3893
+ $e as i,
3894
+ Ee as j,
3895
+ ae as k,
3896
+ he as l,
3897
+ W as m,
3898
+ Ba as n,
3899
+ ze as o,
3900
+ mt as p,
3901
+ za as q,
3902
+ rr as r,
3903
+ sr as s,
3904
+ or as t,
3905
+ Wn as u,
3906
+ q as v,
3907
+ ya as w,
3908
+ ba as x,
3909
+ ie as y,
3910
+ oe as z
3911
+ };