astro-md-editor 0.0.1

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 (87) hide show
  1. package/.output/nitro.json +17 -0
  2. package/.output/public/assets/index-Cc7yKB0o.js +19 -0
  3. package/.output/public/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
  4. package/.output/public/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
  5. package/.output/public/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
  6. package/.output/public/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
  7. package/.output/public/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
  8. package/.output/public/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  9. package/.output/public/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
  10. package/.output/public/assets/main-DDBjVFnt.js +17 -0
  11. package/.output/public/assets/styles-ggfdUHMo.css +1 -0
  12. package/.output/public/favicon.ico +0 -0
  13. package/.output/public/logo192.png +0 -0
  14. package/.output/public/logo512.png +0 -0
  15. package/.output/public/manifest.json +25 -0
  16. package/.output/public/robots.txt +3 -0
  17. package/.output/server/__root-C09LBXMv.mjs +40 -0
  18. package/.output/server/_chunks/ssr-renderer.mjs +21 -0
  19. package/.output/server/_libs/ajv-formats.mjs +330 -0
  20. package/.output/server/_libs/ajv.mjs +5484 -0
  21. package/.output/server/_libs/base-ui__react.mjs +8712 -0
  22. package/.output/server/_libs/base-ui__utils.mjs +980 -0
  23. package/.output/server/_libs/class-variance-authority.mjs +44 -0
  24. package/.output/server/_libs/clsx.mjs +16 -0
  25. package/.output/server/_libs/cookie-es.mjs +58 -0
  26. package/.output/server/_libs/croner.mjs +1 -0
  27. package/.output/server/_libs/crossws.mjs +1 -0
  28. package/.output/server/_libs/date-fns.mjs +1716 -0
  29. package/.output/server/_libs/date-fns__tz.mjs +217 -0
  30. package/.output/server/_libs/extend-shallow.mjs +35 -0
  31. package/.output/server/_libs/fast-deep-equal.mjs +38 -0
  32. package/.output/server/_libs/fast-uri.mjs +725 -0
  33. package/.output/server/_libs/floating-ui__core.mjs +663 -0
  34. package/.output/server/_libs/floating-ui__dom.mjs +624 -0
  35. package/.output/server/_libs/floating-ui__react-dom.mjs +279 -0
  36. package/.output/server/_libs/floating-ui__utils.mjs +322 -0
  37. package/.output/server/_libs/gray-matter.mjs +393 -0
  38. package/.output/server/_libs/h3-v2.mjs +276 -0
  39. package/.output/server/_libs/h3.mjs +400 -0
  40. package/.output/server/_libs/hookable.mjs +1 -0
  41. package/.output/server/_libs/is-extendable.mjs +13 -0
  42. package/.output/server/_libs/isbot.mjs +20 -0
  43. package/.output/server/_libs/js-yaml.mjs +2822 -0
  44. package/.output/server/_libs/json-schema-traverse.mjs +91 -0
  45. package/.output/server/_libs/kind-of.mjs +125 -0
  46. package/.output/server/_libs/lucide-react.mjs +177 -0
  47. package/.output/server/_libs/ohash.mjs +1 -0
  48. package/.output/server/_libs/react-day-picker.mjs +2216 -0
  49. package/.output/server/_libs/react-dom.mjs +10779 -0
  50. package/.output/server/_libs/react-resizable-panels.mjs +2024 -0
  51. package/.output/server/_libs/react.mjs +513 -0
  52. package/.output/server/_libs/reselect.mjs +326 -0
  53. package/.output/server/_libs/rou3.mjs +8 -0
  54. package/.output/server/_libs/section-matter.mjs +112 -0
  55. package/.output/server/_libs/seroval-plugins.mjs +58 -0
  56. package/.output/server/_libs/seroval.mjs +1765 -0
  57. package/.output/server/_libs/srvx.mjs +736 -0
  58. package/.output/server/_libs/strip-bom-string.mjs +16 -0
  59. package/.output/server/_libs/tabbable.mjs +342 -0
  60. package/.output/server/_libs/tailwind-merge.mjs +3175 -0
  61. package/.output/server/_libs/tanstack__history.mjs +217 -0
  62. package/.output/server/_libs/tanstack__react-router.mjs +1464 -0
  63. package/.output/server/_libs/tanstack__react-store.mjs +1 -0
  64. package/.output/server/_libs/tanstack__router-core.mjs +4912 -0
  65. package/.output/server/_libs/tanstack__store.mjs +1 -0
  66. package/.output/server/_libs/tiny-invariant.mjs +12 -0
  67. package/.output/server/_libs/tiny-warning.mjs +5 -0
  68. package/.output/server/_libs/ufo.mjs +54 -0
  69. package/.output/server/_libs/unctx.mjs +1 -0
  70. package/.output/server/_libs/unstorage.mjs +1 -0
  71. package/.output/server/_libs/use-sync-external-store.mjs +139 -0
  72. package/.output/server/_libs/zod.mjs +3634 -0
  73. package/.output/server/_libs/zustand.mjs +43 -0
  74. package/.output/server/_ssr/RightSidebar-RSY9M7XF.mjs +218 -0
  75. package/.output/server/_ssr/collections.server-D6U2tEsT.mjs +120 -0
  76. package/.output/server/_ssr/createServerRpc-29xaFZcb.mjs +12 -0
  77. package/.output/server/_ssr/index-BaqV4cZC.mjs +2083 -0
  78. package/.output/server/_ssr/index-sQBM6rwN.mjs +115 -0
  79. package/.output/server/_ssr/index.mjs +1448 -0
  80. package/.output/server/_ssr/router-D4G1DGr3.mjs +155 -0
  81. package/.output/server/_ssr/start-HYkvq4Ni.mjs +4 -0
  82. package/.output/server/_tanstack-start-manifest_v-CYEHh_qB.mjs +4 -0
  83. package/.output/server/index.mjs +451 -0
  84. package/README.md +118 -0
  85. package/index.mjs +21 -0
  86. package/package.json +86 -0
  87. package/scripts/bootstrap-collections.mjs +1201 -0
@@ -0,0 +1,980 @@
1
+ import { r as reactExports, R as React } from "./react.mjs";
2
+ import { c as createSelectorCreator, l as lruMemoize } from "./reselect.mjs";
3
+ import { w as withSelectorExports, s as shimExports } from "./use-sync-external-store.mjs";
4
+ import { g as getWindow, i as isOverflowElement } from "./floating-ui__utils.mjs";
5
+ const UNINITIALIZED = {};
6
+ function useRefWithInit(init, initArg) {
7
+ const ref = reactExports.useRef(UNINITIALIZED);
8
+ if (ref.current === UNINITIALIZED) {
9
+ ref.current = init(initArg);
10
+ }
11
+ return ref;
12
+ }
13
+ function useOnFirstRender(fn) {
14
+ const ref = reactExports.useRef(true);
15
+ if (ref.current) {
16
+ ref.current = false;
17
+ fn();
18
+ }
19
+ }
20
+ const noop = () => {
21
+ };
22
+ const useIsoLayoutEffect = typeof document !== "undefined" ? reactExports.useLayoutEffect : noop;
23
+ function formatErrorMessage(code, ...args) {
24
+ const url = new URL("https://base-ui.com/production-error");
25
+ url.searchParams.set("code", code.toString());
26
+ args.forEach((arg) => url.searchParams.append("args[]", arg));
27
+ return `Base UI error #${code}; visit ${url} for the full message.`;
28
+ }
29
+ const EMPTY$2 = [];
30
+ function useOnMount(fn) {
31
+ reactExports.useEffect(fn, EMPTY$2);
32
+ }
33
+ const EMPTY$1 = 0;
34
+ class Timeout {
35
+ static create() {
36
+ return new Timeout();
37
+ }
38
+ currentId = EMPTY$1;
39
+ /**
40
+ * Executes `fn` after `delay`, clearing any previously scheduled call.
41
+ */
42
+ start(delay, fn) {
43
+ this.clear();
44
+ this.currentId = setTimeout(() => {
45
+ this.currentId = EMPTY$1;
46
+ fn();
47
+ }, delay);
48
+ }
49
+ isStarted() {
50
+ return this.currentId !== EMPTY$1;
51
+ }
52
+ clear = () => {
53
+ if (this.currentId !== EMPTY$1) {
54
+ clearTimeout(this.currentId);
55
+ this.currentId = EMPTY$1;
56
+ }
57
+ };
58
+ disposeEffect = () => {
59
+ return this.clear;
60
+ };
61
+ }
62
+ function useTimeout() {
63
+ const timeout = useRefWithInit(Timeout.create).current;
64
+ useOnMount(timeout.disposeEffect);
65
+ return timeout;
66
+ }
67
+ function useValueAsRef(value) {
68
+ const latest = useRefWithInit(createLatestRef, value).current;
69
+ latest.next = value;
70
+ useIsoLayoutEffect(latest.effect);
71
+ return latest;
72
+ }
73
+ function createLatestRef(value) {
74
+ const latest = {
75
+ current: value,
76
+ next: value,
77
+ effect: () => {
78
+ latest.current = latest.next;
79
+ }
80
+ };
81
+ return latest;
82
+ }
83
+ const useInsertionEffect = React[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0, -3)];
84
+ const useSafeInsertionEffect = (
85
+ // React 17 doesn't have useInsertionEffect.
86
+ useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
87
+ useInsertionEffect !== reactExports.useLayoutEffect ? useInsertionEffect : (fn) => fn()
88
+ );
89
+ function useStableCallback(callback) {
90
+ const stable = useRefWithInit(createStableCallback).current;
91
+ stable.next = callback;
92
+ useSafeInsertionEffect(stable.effect);
93
+ return stable.trampoline;
94
+ }
95
+ function createStableCallback() {
96
+ const stable = {
97
+ next: void 0,
98
+ callback: assertNotCalled,
99
+ trampoline: (...args) => stable.callback?.(...args),
100
+ effect: () => {
101
+ stable.callback = stable.next;
102
+ }
103
+ };
104
+ return stable;
105
+ }
106
+ function assertNotCalled() {
107
+ }
108
+ function ownerDocument(node) {
109
+ return node?.ownerDocument || document;
110
+ }
111
+ const hasNavigator = typeof navigator !== "undefined";
112
+ const nav = getNavigatorData();
113
+ const platform = getPlatform();
114
+ const userAgent = getUserAgent();
115
+ const isWebKit = typeof CSS === "undefined" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter:none");
116
+ const isIOS = (
117
+ // iPads can claim to be MacIntel
118
+ nav.platform === "MacIntel" && nav.maxTouchPoints > 1 ? true : /iP(hone|ad|od)|iOS/.test(nav.platform)
119
+ );
120
+ const isSafari = hasNavigator && /apple/i.test(navigator.vendor);
121
+ const isAndroid = hasNavigator && /android/i.test(platform) || /android/i.test(userAgent);
122
+ hasNavigator && platform.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
123
+ const isJSDOM = userAgent.includes("jsdom/");
124
+ function getNavigatorData() {
125
+ if (!hasNavigator) {
126
+ return {
127
+ platform: "",
128
+ maxTouchPoints: -1
129
+ };
130
+ }
131
+ const uaData = navigator.userAgentData;
132
+ if (uaData?.platform) {
133
+ return {
134
+ platform: uaData.platform,
135
+ maxTouchPoints: navigator.maxTouchPoints
136
+ };
137
+ }
138
+ return {
139
+ platform: navigator.platform ?? "",
140
+ maxTouchPoints: navigator.maxTouchPoints ?? -1
141
+ };
142
+ }
143
+ function getUserAgent() {
144
+ if (!hasNavigator) {
145
+ return "";
146
+ }
147
+ const uaData = navigator.userAgentData;
148
+ if (uaData && Array.isArray(uaData.brands)) {
149
+ return uaData.brands.map(({
150
+ brand,
151
+ version
152
+ }) => `${brand}/${version}`).join(" ");
153
+ }
154
+ return navigator.userAgent;
155
+ }
156
+ function getPlatform() {
157
+ if (!hasNavigator) {
158
+ return "";
159
+ }
160
+ const uaData = navigator.userAgentData;
161
+ if (uaData?.platform) {
162
+ return uaData.platform;
163
+ }
164
+ return navigator.platform ?? "";
165
+ }
166
+ const SafeReact = {
167
+ ...React
168
+ };
169
+ let globalId = 0;
170
+ function useGlobalId(idOverride, prefix = "mui") {
171
+ const [defaultId, setDefaultId] = reactExports.useState(idOverride);
172
+ const id = idOverride || defaultId;
173
+ reactExports.useEffect(() => {
174
+ if (defaultId == null) {
175
+ globalId += 1;
176
+ setDefaultId(`${prefix}-${globalId}`);
177
+ }
178
+ }, [defaultId, prefix]);
179
+ return id;
180
+ }
181
+ const maybeReactUseId = SafeReact.useId;
182
+ function useId(idOverride, prefix) {
183
+ if (maybeReactUseId !== void 0) {
184
+ const reactId = maybeReactUseId();
185
+ return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
186
+ }
187
+ return useGlobalId(idOverride, prefix);
188
+ }
189
+ function NOOP() {
190
+ }
191
+ const EMPTY_ARRAY = Object.freeze([]);
192
+ const EMPTY_OBJECT = Object.freeze({});
193
+ function useMergedRefs(a, b, c, d) {
194
+ const forkRef = useRefWithInit(createForkRef).current;
195
+ if (didChange(forkRef, a, b, c, d)) {
196
+ update(forkRef, [a, b, c, d]);
197
+ }
198
+ return forkRef.callback;
199
+ }
200
+ function useMergedRefsN(refs) {
201
+ const forkRef = useRefWithInit(createForkRef).current;
202
+ if (didChangeN(forkRef, refs)) {
203
+ update(forkRef, refs);
204
+ }
205
+ return forkRef.callback;
206
+ }
207
+ function createForkRef() {
208
+ return {
209
+ callback: null,
210
+ cleanup: null,
211
+ refs: []
212
+ };
213
+ }
214
+ function didChange(forkRef, a, b, c, d) {
215
+ return forkRef.refs[0] !== a || forkRef.refs[1] !== b || forkRef.refs[2] !== c || forkRef.refs[3] !== d;
216
+ }
217
+ function didChangeN(forkRef, newRefs) {
218
+ return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index) => ref !== newRefs[index]);
219
+ }
220
+ function update(forkRef, refs) {
221
+ forkRef.refs = refs;
222
+ if (refs.every((ref) => ref == null)) {
223
+ forkRef.callback = null;
224
+ return;
225
+ }
226
+ forkRef.callback = (instance) => {
227
+ if (forkRef.cleanup) {
228
+ forkRef.cleanup();
229
+ forkRef.cleanup = null;
230
+ }
231
+ if (instance != null) {
232
+ const cleanupCallbacks = Array(refs.length).fill(null);
233
+ for (let i = 0; i < refs.length; i += 1) {
234
+ const ref = refs[i];
235
+ if (ref == null) {
236
+ continue;
237
+ }
238
+ switch (typeof ref) {
239
+ case "function": {
240
+ const refCleanup = ref(instance);
241
+ if (typeof refCleanup === "function") {
242
+ cleanupCallbacks[i] = refCleanup;
243
+ }
244
+ break;
245
+ }
246
+ case "object": {
247
+ ref.current = instance;
248
+ break;
249
+ }
250
+ }
251
+ }
252
+ forkRef.cleanup = () => {
253
+ for (let i = 0; i < refs.length; i += 1) {
254
+ const ref = refs[i];
255
+ if (ref == null) {
256
+ continue;
257
+ }
258
+ switch (typeof ref) {
259
+ case "function": {
260
+ const cleanupCallback = cleanupCallbacks[i];
261
+ if (typeof cleanupCallback === "function") {
262
+ cleanupCallback();
263
+ } else {
264
+ ref(null);
265
+ }
266
+ break;
267
+ }
268
+ case "object": {
269
+ ref.current = null;
270
+ break;
271
+ }
272
+ }
273
+ }
274
+ };
275
+ }
276
+ };
277
+ }
278
+ const visuallyHiddenBase = {
279
+ clipPath: "inset(50%)",
280
+ overflow: "hidden",
281
+ whiteSpace: "nowrap",
282
+ border: 0,
283
+ padding: 0,
284
+ width: 1,
285
+ height: 1,
286
+ margin: -1
287
+ };
288
+ const visuallyHidden = {
289
+ ...visuallyHiddenBase,
290
+ position: "fixed",
291
+ top: 0,
292
+ left: 0
293
+ };
294
+ const visuallyHiddenInput = {
295
+ ...visuallyHiddenBase,
296
+ position: "absolute"
297
+ };
298
+ const EMPTY = null;
299
+ class Scheduler {
300
+ /* This implementation uses an array as a backing data-structure for frame callbacks.
301
+ * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
302
+ * never calls the native `cancelAnimationFrame` if there are no frames left. This can
303
+ * be much more efficient if there is a call pattern that alterns as
304
+ * "request-cancel-request-cancel-…".
305
+ * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
306
+ * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
307
+ callbacks = [];
308
+ callbacksCount = 0;
309
+ nextId = 1;
310
+ startId = 1;
311
+ isScheduled = false;
312
+ tick = (timestamp) => {
313
+ this.isScheduled = false;
314
+ const currentCallbacks = this.callbacks;
315
+ const currentCallbacksCount = this.callbacksCount;
316
+ this.callbacks = [];
317
+ this.callbacksCount = 0;
318
+ this.startId = this.nextId;
319
+ if (currentCallbacksCount > 0) {
320
+ for (let i = 0; i < currentCallbacks.length; i += 1) {
321
+ currentCallbacks[i]?.(timestamp);
322
+ }
323
+ }
324
+ };
325
+ request(fn) {
326
+ const id = this.nextId;
327
+ this.nextId += 1;
328
+ this.callbacks.push(fn);
329
+ this.callbacksCount += 1;
330
+ const didRAFChange = false;
331
+ if (!this.isScheduled || didRAFChange) {
332
+ requestAnimationFrame(this.tick);
333
+ this.isScheduled = true;
334
+ }
335
+ return id;
336
+ }
337
+ cancel(id) {
338
+ const index = id - this.startId;
339
+ if (index < 0 || index >= this.callbacks.length) {
340
+ return;
341
+ }
342
+ this.callbacks[index] = null;
343
+ this.callbacksCount -= 1;
344
+ }
345
+ }
346
+ const scheduler = new Scheduler();
347
+ class AnimationFrame {
348
+ static create() {
349
+ return new AnimationFrame();
350
+ }
351
+ static request(fn) {
352
+ return scheduler.request(fn);
353
+ }
354
+ static cancel(id) {
355
+ return scheduler.cancel(id);
356
+ }
357
+ currentId = EMPTY;
358
+ /**
359
+ * Executes `fn` after `delay`, clearing any previously scheduled call.
360
+ */
361
+ request(fn) {
362
+ this.cancel();
363
+ this.currentId = scheduler.request(() => {
364
+ this.currentId = EMPTY;
365
+ fn();
366
+ });
367
+ }
368
+ cancel = () => {
369
+ if (this.currentId !== EMPTY) {
370
+ scheduler.cancel(this.currentId);
371
+ this.currentId = EMPTY;
372
+ }
373
+ };
374
+ disposeEffect = () => {
375
+ return this.cancel;
376
+ };
377
+ }
378
+ function useAnimationFrame() {
379
+ const timeout = useRefWithInit(AnimationFrame.create).current;
380
+ useOnMount(timeout.disposeEffect);
381
+ return timeout;
382
+ }
383
+ const majorVersion = parseInt(reactExports.version, 10);
384
+ function isReactVersionAtLeast(reactVersionToCheck) {
385
+ return majorVersion >= reactVersionToCheck;
386
+ }
387
+ function getReactElementRef(element) {
388
+ if (!/* @__PURE__ */ reactExports.isValidElement(element)) {
389
+ return null;
390
+ }
391
+ const reactElement = element;
392
+ const propsWithRef = reactElement.props;
393
+ return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
394
+ }
395
+ function mergeObjects(a, b) {
396
+ if (a && !b) {
397
+ return a;
398
+ }
399
+ if (!a && b) {
400
+ return b;
401
+ }
402
+ if (a || b) {
403
+ return {
404
+ ...a,
405
+ ...b
406
+ };
407
+ }
408
+ return void 0;
409
+ }
410
+ createSelectorCreator({
411
+ memoize: lruMemoize,
412
+ memoizeOptions: {
413
+ maxSize: 1,
414
+ equalityCheck: Object.is
415
+ }
416
+ });
417
+ const createSelector = (a, b, c, d, e, f, ...other) => {
418
+ if (other.length > 0) {
419
+ throw new Error(formatErrorMessage(1));
420
+ }
421
+ let selector;
422
+ if (a) {
423
+ selector = a;
424
+ } else {
425
+ throw (
426
+ /* minify-error-disabled */
427
+ new Error("Missing arguments")
428
+ );
429
+ }
430
+ return selector;
431
+ };
432
+ const canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
433
+ const useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
434
+ function useStore(store, selector, a1, a2, a3) {
435
+ return useStoreImplementation(store, selector, a1, a2, a3);
436
+ }
437
+ function useStoreR19(store, selector, a1, a2, a3) {
438
+ const getSelection = reactExports.useCallback(() => selector(store.getSnapshot(), a1, a2, a3), [store, selector, a1, a2, a3]);
439
+ return shimExports.useSyncExternalStore(store.subscribe, getSelection, getSelection);
440
+ }
441
+ function useStoreFast(store, selector, a1, a2, a3) {
442
+ {
443
+ return useStoreR19(store, selector, a1, a2, a3);
444
+ }
445
+ }
446
+ function useStoreLegacy(store, selector, a1, a2, a3) {
447
+ return withSelectorExports.useSyncExternalStoreWithSelector(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector(state, a1, a2, a3));
448
+ }
449
+ class Store {
450
+ /**
451
+ * The current state of the store.
452
+ * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
453
+ * To subscribe to state changes, use the {@link useState} method. The value returned by {@link useState} is updated after the component renders (similarly to React's useState).
454
+ * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
455
+ *
456
+ * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
457
+ */
458
+ // Internal state to handle recursive `setState()` calls
459
+ constructor(state) {
460
+ this.state = state;
461
+ this.listeners = /* @__PURE__ */ new Set();
462
+ this.updateTick = 0;
463
+ }
464
+ /**
465
+ * Registers a listener that will be called whenever the store's state changes.
466
+ *
467
+ * @param fn The listener function to be called on state changes.
468
+ * @returns A function to unsubscribe the listener.
469
+ */
470
+ subscribe = (fn) => {
471
+ this.listeners.add(fn);
472
+ return () => {
473
+ this.listeners.delete(fn);
474
+ };
475
+ };
476
+ /**
477
+ * Returns the current state of the store.
478
+ */
479
+ getSnapshot = () => {
480
+ return this.state;
481
+ };
482
+ /**
483
+ * Updates the entire store's state and notifies all registered listeners.
484
+ *
485
+ * @param newState The new state to set for the store.
486
+ */
487
+ setState(newState) {
488
+ if (this.state === newState) {
489
+ return;
490
+ }
491
+ this.state = newState;
492
+ this.updateTick += 1;
493
+ const currentTick = this.updateTick;
494
+ for (const listener of this.listeners) {
495
+ if (currentTick !== this.updateTick) {
496
+ return;
497
+ }
498
+ listener(newState);
499
+ }
500
+ }
501
+ /**
502
+ * Merges the provided changes into the current state and notifies listeners if there are changes.
503
+ *
504
+ * @param changes An object containing the changes to apply to the current state.
505
+ */
506
+ update(changes) {
507
+ for (const key in changes) {
508
+ if (!Object.is(this.state[key], changes[key])) {
509
+ this.setState({
510
+ ...this.state,
511
+ ...changes
512
+ });
513
+ return;
514
+ }
515
+ }
516
+ }
517
+ /**
518
+ * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
519
+ *
520
+ * @param key The key in the store's state to update.
521
+ * @param value The new value to set for the specified key.
522
+ */
523
+ set(key, value) {
524
+ if (!Object.is(this.state[key], value)) {
525
+ this.setState({
526
+ ...this.state,
527
+ [key]: value
528
+ });
529
+ }
530
+ }
531
+ /**
532
+ * Gives the state a new reference and updates all registered listeners.
533
+ */
534
+ notifyAll() {
535
+ const newState = {
536
+ ...this.state
537
+ };
538
+ this.setState(newState);
539
+ }
540
+ use(selector, a1, a2, a3) {
541
+ return useStore(this, selector, a1, a2, a3);
542
+ }
543
+ }
544
+ class ReactStore extends Store {
545
+ /**
546
+ * Creates a new ReactStore instance.
547
+ *
548
+ * @param state Initial state of the store.
549
+ * @param context Non-reactive context values.
550
+ * @param selectors Optional selectors for use with `useState`.
551
+ */
552
+ constructor(state, context = {}, selectors) {
553
+ super(state);
554
+ this.context = context;
555
+ this.selectors = selectors;
556
+ }
557
+ /**
558
+ * Non-reactive values such as refs, callbacks, etc.
559
+ */
560
+ /**
561
+ * Synchronizes a single external value into the store.
562
+ *
563
+ * Note that the while the value in `state` is updated immediately, the value returned
564
+ * by `useState` is updated before the next render (similarly to React's `useState`).
565
+ */
566
+ useSyncedValue(key, value) {
567
+ reactExports.useDebugValue(key);
568
+ useIsoLayoutEffect(() => {
569
+ if (this.state[key] !== value) {
570
+ this.set(key, value);
571
+ }
572
+ }, [key, value]);
573
+ }
574
+ /**
575
+ * Synchronizes a single external value into the store and
576
+ * cleans it up (sets to `undefined`) on unmount.
577
+ *
578
+ * Note that the while the value in `state` is updated immediately, the value returned
579
+ * by `useState` is updated before the next render (similarly to React's `useState`).
580
+ */
581
+ useSyncedValueWithCleanup(key, value) {
582
+ const store = this;
583
+ useIsoLayoutEffect(() => {
584
+ if (store.state[key] !== value) {
585
+ store.set(key, value);
586
+ }
587
+ return () => {
588
+ store.set(key, void 0);
589
+ };
590
+ }, [store, key, value]);
591
+ }
592
+ /**
593
+ * Synchronizes multiple external values into the store.
594
+ *
595
+ * Note that the while the values in `state` are updated immediately, the values returned
596
+ * by `useState` are updated before the next render (similarly to React's `useState`).
597
+ */
598
+ useSyncedValues(statePart) {
599
+ const store = this;
600
+ const dependencies = Object.values(statePart);
601
+ useIsoLayoutEffect(() => {
602
+ store.update(statePart);
603
+ }, [store, ...dependencies]);
604
+ }
605
+ /**
606
+ * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
607
+ * is non-undefined, the store's state at `key` is updated to match `controlled`.
608
+ */
609
+ useControlledProp(key, controlled) {
610
+ reactExports.useDebugValue(key);
611
+ const isControlled = controlled !== void 0;
612
+ useIsoLayoutEffect(() => {
613
+ if (isControlled && !Object.is(this.state[key], controlled)) {
614
+ super.setState({
615
+ ...this.state,
616
+ [key]: controlled
617
+ });
618
+ }
619
+ }, [key, controlled, isControlled]);
620
+ }
621
+ /** Gets the current value from the store using a selector with the provided key.
622
+ *
623
+ * @param key Key of the selector to use.
624
+ */
625
+ select(key, a1, a2, a3) {
626
+ const selector = this.selectors[key];
627
+ return selector(this.state, a1, a2, a3);
628
+ }
629
+ /**
630
+ * Returns a value from the store's state using a selector function.
631
+ * Used to subscribe to specific parts of the state.
632
+ * This methods causes a rerender whenever the selected state changes.
633
+ *
634
+ * @param key Key of the selector to use.
635
+ */
636
+ useState(key, a1, a2, a3) {
637
+ reactExports.useDebugValue(key);
638
+ return useStore(this, this.selectors[key], a1, a2, a3);
639
+ }
640
+ /**
641
+ * Wraps a function with `useStableCallback` to ensure it has a stable reference
642
+ * and assigns it to the context.
643
+ *
644
+ * @param key Key of the event callback. Must be a function in the context.
645
+ * @param fn Function to assign.
646
+ */
647
+ useContextCallback(key, fn) {
648
+ reactExports.useDebugValue(key);
649
+ const stableFunction = useStableCallback(fn ?? NOOP);
650
+ this.context[key] = stableFunction;
651
+ }
652
+ /**
653
+ * Returns a stable setter function for a specific key in the store's state.
654
+ * It's commonly used to pass as a ref callback to React elements.
655
+ *
656
+ * @param key Key of the state to set.
657
+ */
658
+ useStateSetter(key) {
659
+ const ref = reactExports.useRef(void 0);
660
+ if (ref.current === void 0) {
661
+ ref.current = (value) => {
662
+ this.set(key, value);
663
+ };
664
+ }
665
+ return ref.current;
666
+ }
667
+ /**
668
+ * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
669
+ *
670
+ * @param key Key of the selector to observe.
671
+ * @param listener Listener function called when the selector result changes.
672
+ */
673
+ observe(selector, listener) {
674
+ let selectFn;
675
+ if (typeof selector === "function") {
676
+ selectFn = selector;
677
+ } else {
678
+ selectFn = this.selectors[selector];
679
+ }
680
+ let prevValue = selectFn(this.state);
681
+ listener(prevValue, prevValue, this);
682
+ return this.subscribe((nextState) => {
683
+ const nextValue = selectFn(nextState);
684
+ if (!Object.is(prevValue, nextValue)) {
685
+ const oldValue = prevValue;
686
+ prevValue = nextValue;
687
+ listener(nextValue, oldValue, this);
688
+ }
689
+ });
690
+ }
691
+ }
692
+ function inertValue(value) {
693
+ if (isReactVersionAtLeast(19)) {
694
+ return value;
695
+ }
696
+ return value ? "true" : void 0;
697
+ }
698
+ function useControlled({
699
+ controlled,
700
+ default: defaultProp,
701
+ name,
702
+ state = "value"
703
+ }) {
704
+ const {
705
+ current: isControlled
706
+ } = reactExports.useRef(controlled !== void 0);
707
+ const [valueState, setValue] = reactExports.useState(defaultProp);
708
+ const value = isControlled ? controlled : valueState;
709
+ const setValueIfUncontrolled = reactExports.useCallback((newValue) => {
710
+ if (!isControlled) {
711
+ setValue(newValue);
712
+ }
713
+ }, []);
714
+ return [value, setValueIfUncontrolled];
715
+ }
716
+ function useEnhancedClickHandler(handler) {
717
+ const lastClickInteractionTypeRef = reactExports.useRef("");
718
+ const handlePointerDown = reactExports.useCallback((event) => {
719
+ if (event.defaultPrevented) {
720
+ return;
721
+ }
722
+ lastClickInteractionTypeRef.current = event.pointerType;
723
+ handler(event, event.pointerType);
724
+ }, [handler]);
725
+ const handleClick = reactExports.useCallback((event) => {
726
+ if (event.detail === 0) {
727
+ handler(event, "keyboard");
728
+ return;
729
+ }
730
+ if ("pointerType" in event) {
731
+ handler(event, event.pointerType);
732
+ } else {
733
+ handler(event, lastClickInteractionTypeRef.current);
734
+ }
735
+ lastClickInteractionTypeRef.current = "";
736
+ }, [handler]);
737
+ return {
738
+ onClick: handleClick,
739
+ onPointerDown: handlePointerDown
740
+ };
741
+ }
742
+ let originalHtmlStyles = {};
743
+ let originalBodyStyles = {};
744
+ let originalHtmlScrollBehavior = "";
745
+ function hasInsetScrollbars(referenceElement) {
746
+ if (typeof document === "undefined") {
747
+ return false;
748
+ }
749
+ const doc = ownerDocument(referenceElement);
750
+ const win = getWindow(doc);
751
+ return win.innerWidth - doc.documentElement.clientWidth > 0;
752
+ }
753
+ function supportsStableScrollbarGutter(referenceElement) {
754
+ const supported = typeof CSS !== "undefined" && CSS.supports && CSS.supports("scrollbar-gutter", "stable");
755
+ if (!supported || typeof document === "undefined") {
756
+ return false;
757
+ }
758
+ const doc = ownerDocument(referenceElement);
759
+ const html = doc.documentElement;
760
+ const body = doc.body;
761
+ const scrollContainer = isOverflowElement(html) ? html : body;
762
+ const originalScrollContainerOverflowY = scrollContainer.style.overflowY;
763
+ const originalHtmlStyleGutter = html.style.scrollbarGutter;
764
+ html.style.scrollbarGutter = "stable";
765
+ scrollContainer.style.overflowY = "scroll";
766
+ const before = scrollContainer.offsetWidth;
767
+ scrollContainer.style.overflowY = "hidden";
768
+ const after = scrollContainer.offsetWidth;
769
+ scrollContainer.style.overflowY = originalScrollContainerOverflowY;
770
+ html.style.scrollbarGutter = originalHtmlStyleGutter;
771
+ return before === after;
772
+ }
773
+ function preventScrollOverlayScrollbars(referenceElement) {
774
+ const doc = ownerDocument(referenceElement);
775
+ const html = doc.documentElement;
776
+ const body = doc.body;
777
+ const elementToLock = isOverflowElement(html) ? html : body;
778
+ const originalElementToLockStyles = {
779
+ overflowY: elementToLock.style.overflowY,
780
+ overflowX: elementToLock.style.overflowX
781
+ };
782
+ Object.assign(elementToLock.style, {
783
+ overflowY: "hidden",
784
+ overflowX: "hidden"
785
+ });
786
+ return () => {
787
+ Object.assign(elementToLock.style, originalElementToLockStyles);
788
+ };
789
+ }
790
+ function preventScrollInsetScrollbars(referenceElement) {
791
+ const doc = ownerDocument(referenceElement);
792
+ const html = doc.documentElement;
793
+ const body = doc.body;
794
+ const win = getWindow(html);
795
+ let scrollTop = 0;
796
+ let scrollLeft = 0;
797
+ let updateGutterOnly = false;
798
+ const resizeFrame = AnimationFrame.create();
799
+ if (isWebKit && (win.visualViewport?.scale ?? 1) !== 1) {
800
+ return () => {
801
+ };
802
+ }
803
+ function lockScroll() {
804
+ const htmlStyles = win.getComputedStyle(html);
805
+ const bodyStyles = win.getComputedStyle(body);
806
+ const htmlScrollbarGutterValue = htmlStyles.scrollbarGutter || "";
807
+ const hasBothEdges = htmlScrollbarGutterValue.includes("both-edges");
808
+ const scrollbarGutterValue = hasBothEdges ? "stable both-edges" : "stable";
809
+ scrollTop = html.scrollTop;
810
+ scrollLeft = html.scrollLeft;
811
+ originalHtmlStyles = {
812
+ scrollbarGutter: html.style.scrollbarGutter,
813
+ overflowY: html.style.overflowY,
814
+ overflowX: html.style.overflowX
815
+ };
816
+ originalHtmlScrollBehavior = html.style.scrollBehavior;
817
+ originalBodyStyles = {
818
+ position: body.style.position,
819
+ height: body.style.height,
820
+ width: body.style.width,
821
+ boxSizing: body.style.boxSizing,
822
+ overflowY: body.style.overflowY,
823
+ overflowX: body.style.overflowX,
824
+ scrollBehavior: body.style.scrollBehavior
825
+ };
826
+ const isScrollableY = html.scrollHeight > html.clientHeight;
827
+ const isScrollableX = html.scrollWidth > html.clientWidth;
828
+ const hasConstantOverflowY = htmlStyles.overflowY === "scroll" || bodyStyles.overflowY === "scroll";
829
+ const hasConstantOverflowX = htmlStyles.overflowX === "scroll" || bodyStyles.overflowX === "scroll";
830
+ const scrollbarWidth = Math.max(0, win.innerWidth - body.clientWidth);
831
+ const scrollbarHeight = Math.max(0, win.innerHeight - body.clientHeight);
832
+ const marginY = parseFloat(bodyStyles.marginTop) + parseFloat(bodyStyles.marginBottom);
833
+ const marginX = parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight);
834
+ const elementToLock = isOverflowElement(html) ? html : body;
835
+ updateGutterOnly = supportsStableScrollbarGutter(referenceElement);
836
+ if (updateGutterOnly) {
837
+ html.style.scrollbarGutter = scrollbarGutterValue;
838
+ elementToLock.style.overflowY = "hidden";
839
+ elementToLock.style.overflowX = "hidden";
840
+ return;
841
+ }
842
+ Object.assign(html.style, {
843
+ scrollbarGutter: scrollbarGutterValue,
844
+ overflowY: "hidden",
845
+ overflowX: "hidden"
846
+ });
847
+ if (isScrollableY || hasConstantOverflowY) {
848
+ html.style.overflowY = "scroll";
849
+ }
850
+ if (isScrollableX || hasConstantOverflowX) {
851
+ html.style.overflowX = "scroll";
852
+ }
853
+ Object.assign(body.style, {
854
+ position: "relative",
855
+ height: marginY || scrollbarHeight ? `calc(100dvh - ${marginY + scrollbarHeight}px)` : "100dvh",
856
+ width: marginX || scrollbarWidth ? `calc(100vw - ${marginX + scrollbarWidth}px)` : "100vw",
857
+ boxSizing: "border-box",
858
+ overflow: "hidden",
859
+ scrollBehavior: "unset"
860
+ });
861
+ body.scrollTop = scrollTop;
862
+ body.scrollLeft = scrollLeft;
863
+ html.setAttribute("data-base-ui-scroll-locked", "");
864
+ html.style.scrollBehavior = "unset";
865
+ }
866
+ function cleanup() {
867
+ Object.assign(html.style, originalHtmlStyles);
868
+ Object.assign(body.style, originalBodyStyles);
869
+ if (!updateGutterOnly) {
870
+ html.scrollTop = scrollTop;
871
+ html.scrollLeft = scrollLeft;
872
+ html.removeAttribute("data-base-ui-scroll-locked");
873
+ html.style.scrollBehavior = originalHtmlScrollBehavior;
874
+ }
875
+ }
876
+ function handleResize() {
877
+ cleanup();
878
+ resizeFrame.request(lockScroll);
879
+ }
880
+ lockScroll();
881
+ win.addEventListener("resize", handleResize);
882
+ return () => {
883
+ resizeFrame.cancel();
884
+ cleanup();
885
+ if (typeof win.removeEventListener === "function") {
886
+ win.removeEventListener("resize", handleResize);
887
+ }
888
+ };
889
+ }
890
+ class ScrollLocker {
891
+ lockCount = 0;
892
+ restore = null;
893
+ timeoutLock = Timeout.create();
894
+ timeoutUnlock = Timeout.create();
895
+ acquire(referenceElement) {
896
+ this.lockCount += 1;
897
+ if (this.lockCount === 1 && this.restore === null) {
898
+ this.timeoutLock.start(0, () => this.lock(referenceElement));
899
+ }
900
+ return this.release;
901
+ }
902
+ release = () => {
903
+ this.lockCount -= 1;
904
+ if (this.lockCount === 0 && this.restore) {
905
+ this.timeoutUnlock.start(0, this.unlock);
906
+ }
907
+ };
908
+ unlock = () => {
909
+ if (this.lockCount === 0 && this.restore) {
910
+ this.restore?.();
911
+ this.restore = null;
912
+ }
913
+ };
914
+ lock(referenceElement) {
915
+ if (this.lockCount === 0 || this.restore !== null) {
916
+ return;
917
+ }
918
+ const doc = ownerDocument(referenceElement);
919
+ const html = doc.documentElement;
920
+ const htmlOverflowY = getWindow(html).getComputedStyle(html).overflowY;
921
+ if (htmlOverflowY === "hidden" || htmlOverflowY === "clip") {
922
+ this.restore = NOOP;
923
+ return;
924
+ }
925
+ const hasOverlayScrollbars = isIOS || !hasInsetScrollbars(referenceElement);
926
+ this.restore = hasOverlayScrollbars ? preventScrollOverlayScrollbars(referenceElement) : preventScrollInsetScrollbars(referenceElement);
927
+ }
928
+ }
929
+ const SCROLL_LOCKER = new ScrollLocker();
930
+ function useScrollLock(enabled = true, referenceElement = null) {
931
+ useIsoLayoutEffect(() => {
932
+ if (!enabled) {
933
+ return void 0;
934
+ }
935
+ return SCROLL_LOCKER.acquire(referenceElement);
936
+ }, [enabled, referenceElement]);
937
+ }
938
+ function isMouseWithinBounds(event) {
939
+ const targetRect = event.currentTarget.getBoundingClientRect();
940
+ const isWithinBounds = targetRect.top + 1 <= event.clientY && event.clientY <= targetRect.bottom - 1 && targetRect.left + 1 <= event.clientX && event.clientX <= targetRect.right - 1;
941
+ return isWithinBounds;
942
+ }
943
+ export {
944
+ AnimationFrame as A,
945
+ EMPTY_ARRAY as B,
946
+ useScrollLock as C,
947
+ inertValue as D,
948
+ EMPTY_OBJECT as E,
949
+ isMouseWithinBounds as F,
950
+ NOOP as N,
951
+ ReactStore as R,
952
+ Store as S,
953
+ Timeout as T,
954
+ isJSDOM as a,
955
+ useId as b,
956
+ useIsoLayoutEffect as c,
957
+ useTimeout as d,
958
+ isSafari as e,
959
+ useMergedRefs as f,
960
+ useMergedRefsN as g,
961
+ getReactElementRef as h,
962
+ isAndroid as i,
963
+ formatErrorMessage as j,
964
+ useStableCallback as k,
965
+ useValueAsRef as l,
966
+ mergeObjects as m,
967
+ useAnimationFrame as n,
968
+ ownerDocument as o,
969
+ isWebKit as p,
970
+ createSelector as q,
971
+ useOnMount as r,
972
+ useEnhancedClickHandler as s,
973
+ isIOS as t,
974
+ useRefWithInit as u,
975
+ visuallyHidden as v,
976
+ useControlled as w,
977
+ useStore as x,
978
+ useOnFirstRender as y,
979
+ visuallyHiddenInput as z
980
+ };