@almadar/shell-web 0.0.0-stage → 0.1.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 (274) hide show
  1. package/bundling.d.mts +18 -0
  2. package/bundling.mjs +28 -0
  3. package/dist/ArbitraryClassCompiler-Mzabq-UB.d.ts +100 -0
  4. package/dist/AvlGlyph-JKJOAH23.js +6 -0
  5. package/dist/AvlStateMachine-PI4YGREK.js +8 -0
  6. package/dist/AvlTransitionDetail-ZH7V24UG.js +12 -0
  7. package/dist/AvlTransitionExplainer-ZSRT7L6Y.js +13 -0
  8. package/dist/BehaviorValueFrame-6RUJXT4A.js +29 -0
  9. package/dist/BehaviorValueFrame-SSEMEBTG.css +1756 -0
  10. package/dist/BehaviorView-RFEE5J6E.js +10 -0
  11. package/dist/Canvas3DHost-_Y-5uLM_.d.ts +552 -0
  12. package/dist/EventBusProvider-CVwjkV_2.d.ts +284 -0
  13. package/dist/FileTree-BCFnBEuQ.d.ts +254 -0
  14. package/dist/FlowCanvas-3JRMNJLV.css +1756 -0
  15. package/dist/FlowCanvas-STDC4OWK.js +27 -0
  16. package/dist/GameAudioProvider-Cm9BnvmP.d.ts +93 -0
  17. package/dist/KaTeX_AMS-Regular-CYEKBG2K.woff +0 -0
  18. package/dist/KaTeX_AMS-Regular-JKX5W2C4.ttf +0 -0
  19. package/dist/KaTeX_AMS-Regular-U6PRYMIZ.woff2 +0 -0
  20. package/dist/KaTeX_Caligraphic-Bold-5QL5CMTE.woff2 +0 -0
  21. package/dist/KaTeX_Caligraphic-Bold-WZ3QSGD3.woff +0 -0
  22. package/dist/KaTeX_Caligraphic-Bold-ZTS3R3HK.ttf +0 -0
  23. package/dist/KaTeX_Caligraphic-Regular-3LKEU76G.woff +0 -0
  24. package/dist/KaTeX_Caligraphic-Regular-A7XRTZ5Q.ttf +0 -0
  25. package/dist/KaTeX_Caligraphic-Regular-KX5MEWCF.woff2 +0 -0
  26. package/dist/KaTeX_Fraktur-Bold-2QVFK6NQ.woff2 +0 -0
  27. package/dist/KaTeX_Fraktur-Bold-T4SWXBMT.woff +0 -0
  28. package/dist/KaTeX_Fraktur-Bold-WGHVTYOR.ttf +0 -0
  29. package/dist/KaTeX_Fraktur-Regular-2PEIFJSJ.woff2 +0 -0
  30. package/dist/KaTeX_Fraktur-Regular-5U4OPH2X.ttf +0 -0
  31. package/dist/KaTeX_Fraktur-Regular-PQMHCIK6.woff +0 -0
  32. package/dist/KaTeX_Main-Bold-2GA4IZIN.woff +0 -0
  33. package/dist/KaTeX_Main-Bold-W5FBVCZM.ttf +0 -0
  34. package/dist/KaTeX_Main-Bold-YP5VVQRP.woff2 +0 -0
  35. package/dist/KaTeX_Main-BoldItalic-4P4C7HJH.woff +0 -0
  36. package/dist/KaTeX_Main-BoldItalic-N4V3DX7S.woff2 +0 -0
  37. package/dist/KaTeX_Main-BoldItalic-ODMLBJJQ.ttf +0 -0
  38. package/dist/KaTeX_Main-Italic-I43T2HSR.ttf +0 -0
  39. package/dist/KaTeX_Main-Italic-RELBIK7M.woff2 +0 -0
  40. package/dist/KaTeX_Main-Italic-SASNQFN2.woff +0 -0
  41. package/dist/KaTeX_Main-Regular-ARRPAO67.woff2 +0 -0
  42. package/dist/KaTeX_Main-Regular-P5I74A2A.woff +0 -0
  43. package/dist/KaTeX_Main-Regular-W74P5G27.ttf +0 -0
  44. package/dist/KaTeX_Math-BoldItalic-6EBV3DK5.woff +0 -0
  45. package/dist/KaTeX_Math-BoldItalic-K4WTGH3J.woff2 +0 -0
  46. package/dist/KaTeX_Math-BoldItalic-VB447A4D.ttf +0 -0
  47. package/dist/KaTeX_Math-Italic-6KGCHLFN.woff2 +0 -0
  48. package/dist/KaTeX_Math-Italic-KKK3USB2.woff +0 -0
  49. package/dist/KaTeX_Math-Italic-SON4MRCA.ttf +0 -0
  50. package/dist/KaTeX_SansSerif-Bold-RRNVJFFW.woff2 +0 -0
  51. package/dist/KaTeX_SansSerif-Bold-STQ6RXC7.ttf +0 -0
  52. package/dist/KaTeX_SansSerif-Bold-X5M5EMOD.woff +0 -0
  53. package/dist/KaTeX_SansSerif-Italic-HMPFTM52.woff2 +0 -0
  54. package/dist/KaTeX_SansSerif-Italic-PSN4QKYX.woff +0 -0
  55. package/dist/KaTeX_SansSerif-Italic-WTBAZBGY.ttf +0 -0
  56. package/dist/KaTeX_SansSerif-Regular-2TL3USAE.ttf +0 -0
  57. package/dist/KaTeX_SansSerif-Regular-OQCII6EP.woff +0 -0
  58. package/dist/KaTeX_SansSerif-Regular-XIQ62X4E.woff2 +0 -0
  59. package/dist/KaTeX_Script-Regular-72OLXYNA.ttf +0 -0
  60. package/dist/KaTeX_Script-Regular-A5IFOEBS.woff +0 -0
  61. package/dist/KaTeX_Script-Regular-APUWIHLP.woff2 +0 -0
  62. package/dist/KaTeX_Size1-Regular-4HRHTS65.woff +0 -0
  63. package/dist/KaTeX_Size1-Regular-5LRUTBFT.woff2 +0 -0
  64. package/dist/KaTeX_Size1-Regular-7K6AASVL.ttf +0 -0
  65. package/dist/KaTeX_Size2-Regular-222HN3GT.ttf +0 -0
  66. package/dist/KaTeX_Size2-Regular-K5ZHAIS6.woff +0 -0
  67. package/dist/KaTeX_Size2-Regular-LELKET5D.woff2 +0 -0
  68. package/dist/KaTeX_Size3-Regular-TLFPAHDE.woff +0 -0
  69. package/dist/KaTeX_Size3-Regular-UFCO6WCA.ttf +0 -0
  70. package/dist/KaTeX_Size3-Regular-WQRQ47UD.woff2 +0 -0
  71. package/dist/KaTeX_Size4-Regular-7PGNVPQK.ttf +0 -0
  72. package/dist/KaTeX_Size4-Regular-CDMV7U5C.woff2 +0 -0
  73. package/dist/KaTeX_Size4-Regular-PKMWZHNC.woff +0 -0
  74. package/dist/KaTeX_Typewriter-Regular-3F5K6SQ6.ttf +0 -0
  75. package/dist/KaTeX_Typewriter-Regular-MJMFSK64.woff +0 -0
  76. package/dist/KaTeX_Typewriter-Regular-VBYJ4NRC.woff2 +0 -0
  77. package/dist/KernelEngineContext-BOCQoFwk.d.ts +43 -0
  78. package/dist/LayersPanel-BBQ54IVG.js +7 -0
  79. package/dist/ModuleCard-3TT2X7IW.js +7 -0
  80. package/dist/OrbInspector-K6T6O7GI.js +27 -0
  81. package/dist/OrbInspector-MHLJ6OEE.css +1756 -0
  82. package/dist/Select-mDZIwNqN.d.ts +199 -0
  83. package/dist/ServerBridge-Cm1On51b.d.ts +233 -0
  84. package/dist/ThemeContext-DJmO59xd.d.ts +147 -0
  85. package/dist/TraitValueFrame-2PJGLLVI.js +28 -0
  86. package/dist/TraitValueFrame-4G3KOUBR.css +1756 -0
  87. package/dist/UISlotContext-Dl_ewwCI.d.ts +79 -0
  88. package/dist/UISlotRenderer-JKFSX24W.js +27 -0
  89. package/dist/UISlotRenderer-KVFO6J7R.css +1756 -0
  90. package/dist/UserContext-DqWeZkUZ.d.ts +100 -0
  91. package/dist/auth/browser/index.d.ts +2 -0
  92. package/dist/auth/browser/index.js +1 -0
  93. package/dist/auth/react/index.d.ts +49 -0
  94. package/dist/auth/react/index.js +119 -0
  95. package/dist/avl/index.css +1756 -0
  96. package/dist/avl/index.d.ts +2238 -0
  97. package/dist/avl/index.js +2693 -0
  98. package/dist/avl-3d-context-BIRKWpaL.d.ts +204 -0
  99. package/dist/avl-schema-parser-CtJxJ9KU.d.ts +132 -0
  100. package/dist/avl-zoom-state-CKMVuBFg.d.ts +17 -0
  101. package/dist/chunk-2PY54Z44.js +227 -0
  102. package/dist/chunk-2QOH2HWM.js +95 -0
  103. package/dist/chunk-3BBUBJFF.js +339 -0
  104. package/dist/chunk-42FY4RYA.js +191 -0
  105. package/dist/chunk-5QTYQTPS.js +15 -0
  106. package/dist/chunk-6P3MWXYE.js +440 -0
  107. package/dist/chunk-73SRAB4P.js +1053 -0
  108. package/dist/chunk-A2LR6VQQ.js +349 -0
  109. package/dist/chunk-AILY3XPS.js +562 -0
  110. package/dist/chunk-B4BU77LT.js +432 -0
  111. package/dist/chunk-DFNZUYX4.js +378 -0
  112. package/dist/chunk-DJ433ET5.js +1327 -0
  113. package/dist/chunk-DLZF4PVE.js +24 -0
  114. package/dist/chunk-DYEKAA4L.js +787 -0
  115. package/dist/chunk-DZ42OJQC.js +176 -0
  116. package/dist/chunk-EOWMARUB.js +16 -0
  117. package/dist/chunk-EQAMU2ZC.js +14 -0
  118. package/dist/chunk-FAJDTHWC.js +98 -0
  119. package/dist/chunk-FIW6WN23.js +508 -0
  120. package/dist/chunk-FP3WIKTC.js +303 -0
  121. package/dist/chunk-G7DCAZ22.js +19 -0
  122. package/dist/chunk-GAR5TQ5B.js +199 -0
  123. package/dist/chunk-GKIFONTE.js +131 -0
  124. package/dist/chunk-GYTPOFVC.js +47155 -0
  125. package/dist/chunk-KVQS4GXU.js +328 -0
  126. package/dist/chunk-L2DEKY4J.js +97 -0
  127. package/dist/chunk-L677XGY3.js +701 -0
  128. package/dist/chunk-MBQAMMSE.js +11877 -0
  129. package/dist/chunk-P4LNHAFI.js +1051 -0
  130. package/dist/chunk-P4ZFUQFF.js +93 -0
  131. package/dist/chunk-PC7K4SK7.js +1384 -0
  132. package/dist/chunk-R5O5AUPI.js +573 -0
  133. package/dist/chunk-SGM3FASH.js +672 -0
  134. package/dist/chunk-SJGJJKBY.js +502 -0
  135. package/dist/chunk-TESBIVUA.js +11 -0
  136. package/dist/chunk-TZZBINQY.js +82 -0
  137. package/dist/chunk-U6QRZASX.js +280 -0
  138. package/dist/chunk-VFF5OO47.js +319 -0
  139. package/dist/chunk-YDNJLLG6.js +516 -0
  140. package/dist/chunk-YHMRX6YA.js +455 -0
  141. package/dist/chunk-ZO6MXAS3.js +69 -0
  142. package/dist/components/index.css +1756 -0
  143. package/dist/components/index.d.ts +11093 -0
  144. package/dist/components/index.js +1110 -0
  145. package/dist/context/index.d.ts +9 -0
  146. package/dist/context/index.js +7 -0
  147. package/dist/core.d.ts +2523 -0
  148. package/dist/core.js +2 -0
  149. package/dist/design-classes/index.cjs +429 -0
  150. package/dist/design-classes/index.d.cts +165 -0
  151. package/dist/design-classes/index.d.ts +165 -0
  152. package/dist/design-classes/index.js +397 -0
  153. package/dist/emojiItems-QGSNAABW.js +20 -0
  154. package/dist/fx-CmQjnHmT.d.ts +371 -0
  155. package/dist/hooks/index.d.ts +936 -0
  156. package/dist/hooks/index.js +7 -0
  157. package/dist/index.d.ts +486 -0
  158. package/dist/index.js +38 -0
  159. package/dist/katexPlugin-FA7NX4PE.css +1161 -0
  160. package/dist/katexPlugin-NCDKOOQY.js +2 -0
  161. package/dist/kernel-client-ZH4PSMCN.js +367 -0
  162. package/dist/kernel-wire-B4S8pnP3.d.ts +65 -0
  163. package/dist/lib/index.d.ts +602 -0
  164. package/dist/lib/index.js +1288 -0
  165. package/dist/paintDispatch-ChW5mVuK.d.ts +698 -0
  166. package/dist/parseLessonSegments-GpCeMrb2.d.ts +334 -0
  167. package/dist/perf-CKiBKbkw.d.ts +22 -0
  168. package/dist/perf-Dr28-AgT.d.ts +57 -0
  169. package/dist/prism-AIWGN2X5.js +134 -0
  170. package/dist/providers/index.css +1756 -0
  171. package/dist/providers/index.d.ts +340 -0
  172. package/dist/providers/index.js +30 -0
  173. package/dist/renderer/index.d.ts +467 -0
  174. package/dist/renderer/index.js +3 -0
  175. package/dist/runtime/index.css +1756 -0
  176. package/dist/runtime/index.d.ts +440 -0
  177. package/dist/runtime/index.js +31 -0
  178. package/dist/slot-host-CPzrxLo9.d.ts +48 -0
  179. package/dist/ssr/index.cjs +7631 -0
  180. package/dist/ssr/index.d.cts +487 -0
  181. package/dist/ssr/index.d.ts +487 -0
  182. package/dist/ssr/index.js +7599 -0
  183. package/dist/storage/browser/index.d.ts +1 -0
  184. package/dist/storage/browser/index.js +1 -0
  185. package/dist/test-support.d.ts +35 -0
  186. package/dist/test-support.js +114 -0
  187. package/dist/themeTokens-CRd8AEDF.d.ts +125 -0
  188. package/dist/three/index.css +503 -0
  189. package/dist/three/index.d.ts +1185 -0
  190. package/dist/three/index.js +3896 -0
  191. package/dist/useKeyboardRouter-Dsq553Ur.d.ts +42 -0
  192. package/dist/useUISlots-CiobNFGb.d.ts +211 -0
  193. package/dist/verification-C5pTeMJv.d.ts +66 -0
  194. package/dist/verificationRegistry-CabxhfTv.d.ts +122 -0
  195. package/dist/wrapCallbackForEvent-B9QLbhxX.d.ts +19 -0
  196. package/index.css +199 -0
  197. package/package.json +269 -3
  198. package/src/core/locales/ar.json +1263 -0
  199. package/src/core/locales/en.json +1263 -0
  200. package/src/core/locales/index.ts +54 -0
  201. package/src/core/locales/sl.json +1263 -0
  202. package/src/core/tokens/native-tokens.json +369 -0
  203. package/tailwind-compile.cjs +29 -0
  204. package/tailwind-preset.cjs +991 -0
  205. package/themes/_base.css +451 -0
  206. package/themes/_contract.md +307 -0
  207. package/themes/_fonts-kenney.css +11 -0
  208. package/themes/_fonts.css +12 -0
  209. package/themes/_foundation.css +105 -0
  210. package/themes/_head.css +22 -0
  211. package/themes/_presets.css +67 -0
  212. package/themes/almadar-heritage.css +455 -0
  213. package/themes/almadar-website.css +269 -0
  214. package/themes/almadar.css +269 -0
  215. package/themes/aqua.css +455 -0
  216. package/themes/arabesque.css +459 -0
  217. package/themes/art-deco.css +457 -0
  218. package/themes/art-nouveau.css +459 -0
  219. package/themes/atelier.css +463 -0
  220. package/themes/bauhaus.css +461 -0
  221. package/themes/bloomberg-dense.css +463 -0
  222. package/themes/blueprint.css +457 -0
  223. package/themes/clay.css +449 -0
  224. package/themes/comic.css +453 -0
  225. package/themes/constructivist.css +457 -0
  226. package/themes/corporate.css +449 -0
  227. package/themes/cyberpunk.css +453 -0
  228. package/themes/frutiger-aero.css +458 -0
  229. package/themes/game-adventure.css +201 -0
  230. package/themes/game-rpg.css +203 -0
  231. package/themes/game-sci-fi.css +201 -0
  232. package/themes/game-ui-pack.css +200 -0
  233. package/themes/gazette.css +449 -0
  234. package/themes/glass.css +457 -0
  235. package/themes/gothic.css +453 -0
  236. package/themes/index.css +21 -0
  237. package/themes/ink-wash.css +459 -0
  238. package/themes/kawaii.css +459 -0
  239. package/themes/kflow.css +310 -0
  240. package/themes/kiosk.css +449 -0
  241. package/themes/linear-clean.css +463 -0
  242. package/themes/luxury.css +451 -0
  243. package/themes/mac-classic.css +455 -0
  244. package/themes/material.css +463 -0
  245. package/themes/memphis.css +453 -0
  246. package/themes/mid-century.css +455 -0
  247. package/themes/minimalist.css +449 -0
  248. package/themes/mudcloth.css +459 -0
  249. package/themes/nata.css +310 -0
  250. package/themes/neon.css +453 -0
  251. package/themes/neumorphic.css +451 -0
  252. package/themes/newsprint.css +455 -0
  253. package/themes/notion-editorial.css +463 -0
  254. package/themes/orb.css +465 -0
  255. package/themes/pixel.css +449 -0
  256. package/themes/prism.css +309 -0
  257. package/themes/rawi.css +310 -0
  258. package/themes/retro.css +452 -0
  259. package/themes/risograph.css +463 -0
  260. package/themes/scandi.css +469 -0
  261. package/themes/sketch.css +455 -0
  262. package/themes/solarpunk.css +469 -0
  263. package/themes/steampunk.css +451 -0
  264. package/themes/swiss.css +455 -0
  265. package/themes/terminal.css +466 -0
  266. package/themes/trait-wars.css +487 -0
  267. package/themes/ukiyo-e.css +459 -0
  268. package/themes/vaporwave.css +455 -0
  269. package/themes/victorian.css +453 -0
  270. package/themes/wabi-sabi.css +459 -0
  271. package/themes/win95.css +455 -0
  272. package/themes/wireframe.css +439 -0
  273. package/themes/zine.css +455 -0
  274. package/README.md +0 -3
@@ -0,0 +1,573 @@
1
+ import { useEventBus, useTranslate } from './chunk-MBQAMMSE.js';
2
+ import { useRef, useEffect, useCallback, useState, useMemo } from 'react';
3
+ import { resolvePageMeta } from '@almadar/core';
4
+
5
+ function mergeCaptureTables(tables) {
6
+ const merged = {};
7
+ for (const table of tables) {
8
+ for (const [target, entry] of Object.entries(table)) {
9
+ const current = merged[target];
10
+ if (!current) {
11
+ merged[target] = { mode: entry.mode, keys: new Set(entry.keys) };
12
+ continue;
13
+ }
14
+ for (const key of entry.keys) current.keys.add(key);
15
+ if (current.mode === "any" || entry.mode === "any") current.mode = "any";
16
+ else if (current.mode !== entry.mode) {
17
+ current.mode = Array.from(/* @__PURE__ */ new Set([...current.mode.split("|"), entry.mode])).sort().join("|");
18
+ }
19
+ }
20
+ }
21
+ return merged;
22
+ }
23
+ function keyChord(event) {
24
+ const parts = [];
25
+ if (event.ctrlKey) parts.push("Control");
26
+ if (event.altKey) parts.push("Alt");
27
+ if (event.shiftKey) parts.push("Shift");
28
+ if (event.metaKey) parts.push("Meta");
29
+ parts.push(event.key);
30
+ return parts.join("+");
31
+ }
32
+ function useKeyboardRouter(options) {
33
+ const {
34
+ captureTable,
35
+ editorFocusEvent = "EDITOR_FOCUS",
36
+ editorBlurEvent = "EDITOR_BLUR",
37
+ keyEvent = "KEY",
38
+ enabled = true
39
+ } = options;
40
+ const eventBus = useEventBus();
41
+ const captureTableRef = useRef(captureTable);
42
+ captureTableRef.current = captureTable;
43
+ const focusedEditorIdRef = useRef(null);
44
+ useEffect(() => {
45
+ const unsubFocus = eventBus.on(`UI:${editorFocusEvent}`, (event) => {
46
+ const editorId = event.payload?.editorId;
47
+ if (typeof editorId === "string") {
48
+ focusedEditorIdRef.current = editorId;
49
+ }
50
+ });
51
+ const unsubBlur = eventBus.on(`UI:${editorBlurEvent}`, (event) => {
52
+ const editorId = event.payload?.editorId;
53
+ if (typeof editorId === "string" && focusedEditorIdRef.current === editorId) {
54
+ focusedEditorIdRef.current = null;
55
+ }
56
+ });
57
+ return () => {
58
+ unsubFocus();
59
+ unsubBlur();
60
+ };
61
+ }, [eventBus, editorFocusEvent, editorBlurEvent]);
62
+ useEffect(() => {
63
+ if (!enabled) return;
64
+ const handleKeyDown = (event) => {
65
+ if (event.isComposing) return;
66
+ const target = focusedEditorIdRef.current ?? "shell";
67
+ const entry = captureTableRef.current[target];
68
+ const captured = entry !== void 0 && (entry.keys.has(event.key) || entry.keys.has(keyChord(event)));
69
+ if (captured) {
70
+ event.preventDefault();
71
+ }
72
+ eventBus.emit(`UI:${keyEvent}`, {
73
+ editorId: target,
74
+ key: event.key,
75
+ code: event.code,
76
+ ctrl: event.ctrlKey,
77
+ alt: event.altKey,
78
+ shift: event.shiftKey,
79
+ meta: event.metaKey,
80
+ repeat: event.repeat
81
+ });
82
+ };
83
+ window.addEventListener("keydown", handleKeyDown, { capture: true });
84
+ return () => {
85
+ window.removeEventListener("keydown", handleKeyDown, { capture: true });
86
+ };
87
+ }, [eventBus, enabled, keyEvent]);
88
+ }
89
+ function useSwipeGesture(callbacks, options = {}) {
90
+ const { threshold = 50, velocityThreshold = 0.3, preventDefault = false } = options;
91
+ const startX = useRef(0);
92
+ const startY = useRef(0);
93
+ const startTime = useRef(0);
94
+ const currentX = useRef(0);
95
+ const tracking = useRef(false);
96
+ const offsetXRef = useRef(0);
97
+ const isSwipingRef = useRef(false);
98
+ const onPointerDown = useCallback((e) => {
99
+ startX.current = e.clientX;
100
+ startY.current = e.clientY;
101
+ currentX.current = e.clientX;
102
+ startTime.current = Date.now();
103
+ tracking.current = true;
104
+ isSwipingRef.current = false;
105
+ offsetXRef.current = 0;
106
+ e.target.setPointerCapture?.(e.pointerId);
107
+ }, []);
108
+ const onPointerMove = useCallback((e) => {
109
+ if (!tracking.current) return;
110
+ if (preventDefault) e.preventDefault();
111
+ currentX.current = e.clientX;
112
+ const dx = e.clientX - startX.current;
113
+ const dy = e.clientY - startY.current;
114
+ if (Math.abs(dx) > 10 && Math.abs(dx) > Math.abs(dy)) {
115
+ isSwipingRef.current = true;
116
+ offsetXRef.current = dx;
117
+ }
118
+ }, [preventDefault]);
119
+ const onPointerUp = useCallback((e) => {
120
+ if (!tracking.current) return;
121
+ tracking.current = false;
122
+ const dx = e.clientX - startX.current;
123
+ const dy = e.clientY - startY.current;
124
+ const elapsed = Date.now() - startTime.current;
125
+ const velocity = Math.abs(dx) / Math.max(elapsed, 1);
126
+ offsetXRef.current = 0;
127
+ isSwipingRef.current = false;
128
+ if (Math.abs(dx) < threshold && velocity < velocityThreshold) return;
129
+ if (Math.abs(dx) > Math.abs(dy)) {
130
+ if (dx < -threshold) callbacks.onSwipeLeft?.();
131
+ else if (dx > threshold) callbacks.onSwipeRight?.();
132
+ } else {
133
+ if (dy < -threshold) callbacks.onSwipeUp?.();
134
+ else if (dy > threshold) callbacks.onSwipeDown?.();
135
+ }
136
+ }, [threshold, velocityThreshold, callbacks]);
137
+ const onPointerCancel = useCallback(() => {
138
+ tracking.current = false;
139
+ offsetXRef.current = 0;
140
+ isSwipingRef.current = false;
141
+ }, []);
142
+ return {
143
+ onPointerDown,
144
+ onPointerMove,
145
+ onPointerUp,
146
+ onPointerCancel,
147
+ offsetX: offsetXRef.current,
148
+ isSwiping: isSwipingRef.current
149
+ };
150
+ }
151
+ function localPoint(canvas, clientX, clientY) {
152
+ if (!canvas) return { x: clientX, y: clientY };
153
+ const rect = canvas.getBoundingClientRect();
154
+ return { x: clientX - rect.left, y: clientY - rect.top };
155
+ }
156
+ function useCanvasGestures(options) {
157
+ const {
158
+ canvasRef,
159
+ enabled = true,
160
+ wheelStep = 1.1,
161
+ onPointerDown,
162
+ onPointerMove,
163
+ onPointerUp,
164
+ onZoom,
165
+ onPanDelta,
166
+ onMultiTouchStart
167
+ } = options;
168
+ const pointers = useRef(/* @__PURE__ */ new Map());
169
+ const pinch = useRef(null);
170
+ const computePinch = useCallback(() => {
171
+ const pts = [...pointers.current.values()];
172
+ const dx = pts[1].x - pts[0].x;
173
+ const dy = pts[1].y - pts[0].y;
174
+ return {
175
+ distance: Math.hypot(dx, dy) || 1,
176
+ centroid: { x: (pts[0].x + pts[1].x) / 2, y: (pts[0].y + pts[1].y) / 2 }
177
+ };
178
+ }, []);
179
+ const handlePointerDown = useCallback(
180
+ (e) => {
181
+ if (!enabled) return;
182
+ e.currentTarget.setPointerCapture(e.pointerId);
183
+ pointers.current.set(e.pointerId, localPoint(canvasRef.current, e.clientX, e.clientY));
184
+ if (pointers.current.size === 2) {
185
+ onMultiTouchStart?.();
186
+ pinch.current = computePinch();
187
+ } else if (pointers.current.size === 1) {
188
+ onPointerDown?.(e);
189
+ }
190
+ },
191
+ [enabled, canvasRef, onMultiTouchStart, computePinch, onPointerDown]
192
+ );
193
+ const handlePointerMove = useCallback(
194
+ (e) => {
195
+ if (!enabled) return;
196
+ if (pointers.current.has(e.pointerId)) {
197
+ pointers.current.set(e.pointerId, localPoint(canvasRef.current, e.clientX, e.clientY));
198
+ }
199
+ if (pointers.current.size >= 2 && pinch.current) {
200
+ const next = computePinch();
201
+ const prev = pinch.current;
202
+ if (next.distance !== prev.distance) {
203
+ onZoom?.(next.distance / prev.distance, next.centroid.x, next.centroid.y);
204
+ }
205
+ onPanDelta?.(next.centroid.x - prev.centroid.x, next.centroid.y - prev.centroid.y);
206
+ pinch.current = next;
207
+ return;
208
+ }
209
+ onPointerMove?.(e);
210
+ },
211
+ [enabled, canvasRef, computePinch, onZoom, onPanDelta, onPointerMove]
212
+ );
213
+ const endPointer = useCallback(
214
+ (e, fireUp) => {
215
+ const wasMulti = pointers.current.size >= 2;
216
+ pointers.current.delete(e.pointerId);
217
+ if (pointers.current.size < 2) pinch.current = null;
218
+ if (wasMulti && pointers.current.size === 1) return;
219
+ if (pointers.current.size === 0 && fireUp) onPointerUp?.(e);
220
+ },
221
+ [onPointerUp]
222
+ );
223
+ const handlePointerUp = useCallback(
224
+ (e) => {
225
+ if (!enabled) return;
226
+ endPointer(e, true);
227
+ },
228
+ [enabled, endPointer]
229
+ );
230
+ const handlePointerCancel = useCallback(
231
+ (e) => {
232
+ if (!enabled) return;
233
+ endPointer(e, false);
234
+ },
235
+ [enabled, endPointer]
236
+ );
237
+ const handleWheel = useCallback(
238
+ (e) => {
239
+ if (!enabled) return;
240
+ e.preventDefault();
241
+ const { x, y } = localPoint(canvasRef.current, e.clientX, e.clientY);
242
+ onZoom?.(e.deltaY < 0 ? wheelStep : 1 / wheelStep, x, y);
243
+ },
244
+ [enabled, canvasRef, wheelStep, onZoom]
245
+ );
246
+ return {
247
+ onPointerDown: handlePointerDown,
248
+ onPointerMove: handlePointerMove,
249
+ onPointerUp: handlePointerUp,
250
+ onPointerCancel: handlePointerCancel,
251
+ onWheel: handleWheel
252
+ };
253
+ }
254
+ function useLongPress(onLongPress, options = {}) {
255
+ const { duration = 500, moveThreshold = 10 } = options;
256
+ const timerRef = useRef(null);
257
+ const startPos = useRef({ x: 0, y: 0 });
258
+ const isPressedRef = useRef(false);
259
+ const firedRef = useRef(false);
260
+ const cancel = useCallback(() => {
261
+ if (timerRef.current) {
262
+ clearTimeout(timerRef.current);
263
+ timerRef.current = null;
264
+ }
265
+ isPressedRef.current = false;
266
+ }, []);
267
+ const onPointerDown = useCallback((e) => {
268
+ firedRef.current = false;
269
+ startPos.current = { x: e.clientX, y: e.clientY };
270
+ isPressedRef.current = true;
271
+ timerRef.current = setTimeout(() => {
272
+ firedRef.current = true;
273
+ isPressedRef.current = false;
274
+ onLongPress();
275
+ }, duration);
276
+ }, [duration, onLongPress]);
277
+ const onPointerMove = useCallback((e) => {
278
+ if (!isPressedRef.current) return;
279
+ const dx = e.clientX - startPos.current.x;
280
+ const dy = e.clientY - startPos.current.y;
281
+ if (Math.sqrt(dx * dx + dy * dy) > moveThreshold) {
282
+ cancel();
283
+ }
284
+ }, [moveThreshold, cancel]);
285
+ const onPointerUp = useCallback(() => {
286
+ cancel();
287
+ }, [cancel]);
288
+ const onPointerCancel = useCallback(() => {
289
+ cancel();
290
+ }, [cancel]);
291
+ return {
292
+ onPointerDown,
293
+ onPointerMove,
294
+ onPointerUp,
295
+ onPointerCancel,
296
+ isPressed: isPressedRef.current
297
+ };
298
+ }
299
+
300
+ // src/hooks/useAuthContext.ts
301
+ function useAuthContext() {
302
+ return {
303
+ user: null,
304
+ loading: false,
305
+ signIn: void 0,
306
+ signOut: void 0
307
+ };
308
+ }
309
+ var queryStores = /* @__PURE__ */ new Map();
310
+ function getOrCreateStore(query) {
311
+ if (!queryStores.has(query)) {
312
+ queryStores.set(query, {
313
+ search: "",
314
+ filters: {},
315
+ sortField: void 0,
316
+ sortDirection: void 0,
317
+ listeners: /* @__PURE__ */ new Set()
318
+ });
319
+ }
320
+ return queryStores.get(query);
321
+ }
322
+ function useQuerySingleton(query) {
323
+ const [, forceUpdate] = useState({});
324
+ if (!query) {
325
+ return null;
326
+ }
327
+ const store = useMemo(() => getOrCreateStore(query), [query]);
328
+ useMemo(() => {
329
+ const listener = () => forceUpdate({});
330
+ store.listeners.add(listener);
331
+ return () => {
332
+ store.listeners.delete(listener);
333
+ };
334
+ }, [store]);
335
+ const notifyListeners = useCallback(() => {
336
+ store.listeners.forEach((listener) => listener());
337
+ }, [store]);
338
+ const setSearch = useCallback((value) => {
339
+ store.search = value;
340
+ notifyListeners();
341
+ }, [store, notifyListeners]);
342
+ const setFilter = useCallback((key, value) => {
343
+ store.filters = { ...store.filters, [key]: value };
344
+ notifyListeners();
345
+ }, [store, notifyListeners]);
346
+ const clearFilters = useCallback(() => {
347
+ store.filters = {};
348
+ store.search = "";
349
+ notifyListeners();
350
+ }, [store, notifyListeners]);
351
+ const setSort = useCallback((field, direction) => {
352
+ store.sortField = field;
353
+ store.sortDirection = direction;
354
+ notifyListeners();
355
+ }, [store, notifyListeners]);
356
+ return {
357
+ search: store.search,
358
+ setSearch,
359
+ filters: store.filters,
360
+ setFilter,
361
+ clearFilters,
362
+ sortField: store.sortField,
363
+ sortDirection: store.sortDirection,
364
+ setSort
365
+ };
366
+ }
367
+ function parseQueryBinding(binding) {
368
+ const cleaned = binding.startsWith("@") ? binding.slice(1) : binding;
369
+ const parts = cleaned.split(".");
370
+ return {
371
+ query: parts[0],
372
+ field: parts.length > 1 ? parts.slice(1).join(".") : void 0
373
+ };
374
+ }
375
+ function usePullToRefresh(onRefresh, options = {}) {
376
+ const { threshold = 60, maxPull = 120 } = options;
377
+ const [pullDistance, setPullDistance] = useState(0);
378
+ const [isPulling, setIsPulling] = useState(false);
379
+ const [isRefreshing, setIsRefreshing] = useState(false);
380
+ const startY = useRef(0);
381
+ const scrollTopRef = useRef(0);
382
+ const onTouchStart = useCallback((e) => {
383
+ const container = e.currentTarget;
384
+ scrollTopRef.current = container.scrollTop;
385
+ if (scrollTopRef.current <= 0) {
386
+ startY.current = e.touches[0].clientY;
387
+ setIsPulling(true);
388
+ }
389
+ }, []);
390
+ const onTouchMove = useCallback((e) => {
391
+ if (!isPulling || isRefreshing) return;
392
+ const container = e.currentTarget;
393
+ if (container.scrollTop > 0) {
394
+ setPullDistance(0);
395
+ return;
396
+ }
397
+ const dy = e.touches[0].clientY - startY.current;
398
+ if (dy > 0) {
399
+ const distance = Math.min(dy * 0.5, maxPull);
400
+ setPullDistance(distance);
401
+ }
402
+ }, [isPulling, isRefreshing, maxPull]);
403
+ const onTouchEnd = useCallback(() => {
404
+ if (!isPulling) return;
405
+ setIsPulling(false);
406
+ if (pullDistance >= threshold && !isRefreshing) {
407
+ setIsRefreshing(true);
408
+ setPullDistance(threshold);
409
+ onRefresh();
410
+ } else {
411
+ setPullDistance(0);
412
+ }
413
+ }, [isPulling, pullDistance, threshold, isRefreshing, onRefresh]);
414
+ const endRefresh = useCallback(() => {
415
+ setIsRefreshing(false);
416
+ setPullDistance(0);
417
+ }, []);
418
+ const containerProps = {
419
+ onTouchStart,
420
+ onTouchMove,
421
+ onTouchEnd,
422
+ style: {
423
+ transform: pullDistance > 0 ? `translateY(${pullDistance}px)` : void 0,
424
+ transition: isPulling ? "none" : "transform 300ms ease-out"
425
+ }
426
+ };
427
+ return {
428
+ pullDistance,
429
+ isPulling,
430
+ isRefreshing,
431
+ containerProps,
432
+ endRefresh
433
+ };
434
+ }
435
+
436
+ // src/lib/bus-claim.ts
437
+ var claims = /* @__PURE__ */ new WeakMap();
438
+ function claimDelivery(source, trait, event) {
439
+ if (source === void 0) return true;
440
+ const key = `${trait}\0${event}`;
441
+ const seen = claims.get(source);
442
+ if (seen === void 0) {
443
+ claims.set(source, /* @__PURE__ */ new Set([key]));
444
+ return true;
445
+ }
446
+ if (seen.has(key)) return false;
447
+ seen.add(key);
448
+ return true;
449
+ }
450
+ var OWNED = "data-orb-head";
451
+ var shellTitle;
452
+ function ownedTag(tag, attrs) {
453
+ const el = document.createElement(tag);
454
+ for (const [k, v] of Object.entries(attrs)) el.setAttribute(k, v);
455
+ el.setAttribute(OWNED, "");
456
+ return el;
457
+ }
458
+ function usePageHead(input) {
459
+ const { messages, locale } = useTranslate();
460
+ const title = input ? resolvePageMeta(input.title, (k) => messages?.[k]) : void 0;
461
+ const description = input ? resolvePageMeta(input.description, (k) => messages?.[k]) : void 0;
462
+ const isPublic = input?.access !== "authenticated" && input?.indexing !== "noindex";
463
+ const canonical = input?.origin !== void 0 ? `${input.origin.replace(/\/+$/, "")}${input.path}` : void 0;
464
+ const siteName = input?.siteName;
465
+ const active = input !== null;
466
+ const originBase = input?.origin?.replace(/\/+$/, "");
467
+ const hreflang = [];
468
+ if (originBase !== void 0) {
469
+ for (const alt of input?.alternates ?? []) hreflang.push([alt.locale, `${originBase}${alt.path}`]);
470
+ const fallback = input?.alternates?.find((alt) => alt.locale === input.defaultLocale);
471
+ if (fallback !== void 0) hreflang.push(["x-default", `${originBase}${fallback.path}`]);
472
+ }
473
+ const hreflangKey = hreflang.map(([lang, href]) => `${lang} ${href}`).join("\n");
474
+ useEffect(() => {
475
+ if (!active || typeof document === "undefined") return void 0;
476
+ shellTitle ??= document.title;
477
+ document.title = title ?? siteName ?? shellTitle;
478
+ const tags = [];
479
+ if (!isPublic) tags.push(ownedTag("meta", { name: "robots", content: "noindex" }));
480
+ if (isPublic && description !== void 0) {
481
+ tags.push(ownedTag("meta", { name: "description", content: description }));
482
+ tags.push(ownedTag("meta", { property: "og:description", content: description }));
483
+ }
484
+ if (isPublic && title !== void 0) tags.push(ownedTag("meta", { property: "og:title", content: title }));
485
+ if (isPublic && canonical !== void 0) {
486
+ tags.push(ownedTag("link", { rel: "canonical", href: canonical }));
487
+ tags.push(ownedTag("meta", { property: "og:url", content: canonical }));
488
+ }
489
+ if (isPublic && siteName !== void 0) tags.push(ownedTag("meta", { property: "og:site_name", content: siteName }));
490
+ if (isPublic) tags.push(ownedTag("meta", { property: "og:locale", content: locale }));
491
+ if (isPublic && hreflangKey !== "") {
492
+ for (const line of hreflangKey.split("\n")) {
493
+ const space = line.indexOf(" ");
494
+ tags.push(ownedTag("link", { rel: "alternate", hreflang: line.slice(0, space), href: line.slice(space + 1) }));
495
+ }
496
+ }
497
+ for (const stale of Array.from(document.head.querySelectorAll(`[${OWNED}]`))) stale.remove();
498
+ for (const tag of tags) document.head.appendChild(tag);
499
+ return () => {
500
+ for (const tag of tags) tag.remove();
501
+ };
502
+ }, [active, title, description, isPublic, canonical, siteName, locale, hreflangKey]);
503
+ }
504
+ function useDragReorder(initialItems, onReorder) {
505
+ const [items, setItems] = useState(initialItems);
506
+ const [dragIndex, setDragIndex] = useState(-1);
507
+ const [dragOverIndex, setDragOverIndex] = useState(-1);
508
+ const itemsRef = useRef(initialItems);
509
+ if (initialItems !== itemsRef.current) {
510
+ itemsRef.current = initialItems;
511
+ setItems(initialItems);
512
+ }
513
+ const isDragging = dragIndex >= 0;
514
+ const handleDragStart = useCallback((index) => (e) => {
515
+ e.preventDefault();
516
+ setDragIndex(index);
517
+ setDragOverIndex(index);
518
+ e.target.setPointerCapture?.(e.pointerId);
519
+ }, []);
520
+ const handleDragMove = useCallback((index) => (e) => {
521
+ if (dragIndex < 0) return;
522
+ const target = document.elementFromPoint(e.clientX, e.clientY);
523
+ if (!target) return;
524
+ let el = target;
525
+ while (el && !el.dataset.dragIndex) {
526
+ el = el.parentElement;
527
+ }
528
+ if (el?.dataset.dragIndex) {
529
+ const overIndex = parseInt(el.dataset.dragIndex, 10);
530
+ if (!isNaN(overIndex) && overIndex !== dragOverIndex) {
531
+ setDragOverIndex(overIndex);
532
+ }
533
+ }
534
+ }, [dragIndex, dragOverIndex]);
535
+ const handleDragEnd = useCallback(() => {
536
+ if (dragIndex >= 0 && dragOverIndex >= 0 && dragIndex !== dragOverIndex) {
537
+ const newItems = [...items];
538
+ const [movedItem] = newItems.splice(dragIndex, 1);
539
+ newItems.splice(dragOverIndex, 0, movedItem);
540
+ setItems(newItems);
541
+ onReorder(dragIndex, dragOverIndex, items[dragIndex]);
542
+ }
543
+ setDragIndex(-1);
544
+ setDragOverIndex(-1);
545
+ }, [dragIndex, dragOverIndex, items, onReorder]);
546
+ const getDragHandleProps = useCallback((index) => ({
547
+ onPointerDown: handleDragStart(index),
548
+ style: { cursor: "grab", touchAction: "none" },
549
+ "aria-grabbed": dragIndex === index,
550
+ role: "button"
551
+ }), [handleDragStart, dragIndex]);
552
+ const getItemProps = useCallback((index) => ({
553
+ onPointerMove: handleDragMove(index),
554
+ onPointerUp: handleDragEnd,
555
+ "aria-dropeffect": "move",
556
+ "data-drag-index": String(index),
557
+ style: {
558
+ opacity: dragIndex === index ? 0.5 : 1,
559
+ transition: isDragging ? "transform 150ms ease" : void 0,
560
+ transform: isDragging && dragOverIndex >= 0 ? index === dragIndex ? "scale(1.02)" : index > dragIndex && index <= dragOverIndex ? "translateY(-100%)" : index < dragIndex && index >= dragOverIndex ? "translateY(100%)" : void 0 : void 0
561
+ }
562
+ }), [handleDragMove, handleDragEnd, dragIndex, dragOverIndex, isDragging]);
563
+ return {
564
+ items,
565
+ dragIndex,
566
+ dragOverIndex,
567
+ isDragging,
568
+ getDragHandleProps,
569
+ getItemProps
570
+ };
571
+ }
572
+
573
+ export { claimDelivery, keyChord, mergeCaptureTables, parseQueryBinding, useAuthContext, useCanvasGestures, useDragReorder, useKeyboardRouter, useLongPress, usePageHead, usePullToRefresh, useQuerySingleton, useSwipeGesture };