@addsign/moje-agenda-shared-lib 1.0.57 → 1.0.59

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 (39) hide show
  1. package/dist/Dialog-BIo5644U.js +1934 -0
  2. package/dist/Dialog-BIo5644U.js.map +1 -0
  3. package/dist/Dialog-C7qN3E2t.js +1937 -0
  4. package/dist/Dialog-C7qN3E2t.js.map +1 -0
  5. package/dist/assets/tailwind.css +29 -0
  6. package/dist/components/datatable/DataTable.js +2 -1
  7. package/dist/components/datatable/DataTable.js.map +1 -1
  8. package/dist/components/datatable/DataTableServer.js +2 -1
  9. package/dist/components/datatable/DataTableServer.js.map +1 -1
  10. package/dist/components/form/AutocompleteSearchBar.js +2 -1
  11. package/dist/components/form/AutocompleteSearchBar.js.map +1 -1
  12. package/dist/components/form/AutocompleteSearchBarServer.js +2 -1
  13. package/dist/components/form/AutocompleteSearchBarServer.js.map +1 -1
  14. package/dist/components/form/FileInput.js +3 -2
  15. package/dist/components/form/FileInput.js.map +1 -1
  16. package/dist/components/form/FileInputMultiple.js +3 -2
  17. package/dist/components/form/FileInputMultiple.js.map +1 -1
  18. package/dist/components/form/FormField.js +2 -1
  19. package/dist/components/form/FormField.js.map +1 -1
  20. package/dist/components/form/PositionsSelectorSingle.js +2 -1
  21. package/dist/components/form/PositionsSelectorSingle.js.map +1 -1
  22. package/dist/components/form/SelectField.js +2 -1
  23. package/dist/components/form/SelectField.js.map +1 -1
  24. package/dist/components/profiles/ProfileOverview.js +2 -1
  25. package/dist/components/profiles/ProfileOverview.js.map +1 -1
  26. package/dist/components/ui/Dialog.js +1 -1
  27. package/dist/components/ui/ScrollArea.d.ts +5 -0
  28. package/dist/components/ui/ScrollArea.js +798 -0
  29. package/dist/components/ui/ScrollArea.js.map +1 -0
  30. package/dist/index-BC5mPNnY.js +29203 -0
  31. package/dist/index-BC5mPNnY.js.map +1 -0
  32. package/dist/index-DatZqbI8.js +2266 -0
  33. package/dist/index-DatZqbI8.js.map +1 -0
  34. package/dist/index-G6w7G1iI.js +2266 -0
  35. package/dist/index-G6w7G1iI.js.map +1 -0
  36. package/dist/main.d.ts +2 -1
  37. package/dist/main.js +4 -1
  38. package/dist/main.js.map +1 -1
  39. package/package.json +2 -1
@@ -0,0 +1,1934 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { useState, forwardRef, createElement } from "react";
4
+ import { e as useLayoutEffect2, d as useCallbackRef$1, u as useComposedRefs, P as Primitive, b as composeEventHandlers, f as dispatchDiscreteCustomEvent, R as ReactDOM, c as createContextScope, a as Presence, S as Slot, g as createContext2 } from "./index-BC5mPNnY.js";
5
+ import { cn } from "./utils/utils.js";
6
+ var __assign = function() {
7
+ __assign = Object.assign || function __assign2(t) {
8
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
9
+ s = arguments[i];
10
+ for (var p in s)
11
+ if (Object.prototype.hasOwnProperty.call(s, p))
12
+ t[p] = s[p];
13
+ }
14
+ return t;
15
+ };
16
+ return __assign.apply(this, arguments);
17
+ };
18
+ function __rest(s, e) {
19
+ var t = {};
20
+ for (var p in s)
21
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
22
+ t[p] = s[p];
23
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
24
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
25
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
26
+ t[p[i]] = s[p[i]];
27
+ }
28
+ return t;
29
+ }
30
+ function __awaiter(thisArg, _arguments, P, generator) {
31
+ function adopt(value) {
32
+ return value instanceof P ? value : new P(function(resolve) {
33
+ resolve(value);
34
+ });
35
+ }
36
+ return new (P || (P = Promise))(function(resolve, reject) {
37
+ function fulfilled(value) {
38
+ try {
39
+ step(generator.next(value));
40
+ } catch (e) {
41
+ reject(e);
42
+ }
43
+ }
44
+ function rejected(value) {
45
+ try {
46
+ step(generator["throw"](value));
47
+ } catch (e) {
48
+ reject(e);
49
+ }
50
+ }
51
+ function step(result) {
52
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
53
+ }
54
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
55
+ });
56
+ }
57
+ function __generator(thisArg, body) {
58
+ var _ = { label: 0, sent: function() {
59
+ if (t[0] & 1)
60
+ throw t[1];
61
+ return t[1];
62
+ }, trys: [], ops: [] }, f, y, t, g;
63
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
64
+ return this;
65
+ }), g;
66
+ function verb(n) {
67
+ return function(v) {
68
+ return step([n, v]);
69
+ };
70
+ }
71
+ function step(op) {
72
+ if (f)
73
+ throw new TypeError("Generator is already executing.");
74
+ while (g && (g = 0, op[0] && (_ = 0)), _)
75
+ try {
76
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
77
+ return t;
78
+ if (y = 0, t)
79
+ op = [op[0] & 2, t.value];
80
+ switch (op[0]) {
81
+ case 0:
82
+ case 1:
83
+ t = op;
84
+ break;
85
+ case 4:
86
+ _.label++;
87
+ return { value: op[1], done: false };
88
+ case 5:
89
+ _.label++;
90
+ y = op[1];
91
+ op = [0];
92
+ continue;
93
+ case 7:
94
+ op = _.ops.pop();
95
+ _.trys.pop();
96
+ continue;
97
+ default:
98
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
99
+ _ = 0;
100
+ continue;
101
+ }
102
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
103
+ _.label = op[1];
104
+ break;
105
+ }
106
+ if (op[0] === 6 && _.label < t[1]) {
107
+ _.label = t[1];
108
+ t = op;
109
+ break;
110
+ }
111
+ if (t && _.label < t[2]) {
112
+ _.label = t[2];
113
+ _.ops.push(op);
114
+ break;
115
+ }
116
+ if (t[2])
117
+ _.ops.pop();
118
+ _.trys.pop();
119
+ continue;
120
+ }
121
+ op = body.call(thisArg, _);
122
+ } catch (e) {
123
+ op = [6, e];
124
+ y = 0;
125
+ } finally {
126
+ f = t = 0;
127
+ }
128
+ if (op[0] & 5)
129
+ throw op[1];
130
+ return { value: op[0] ? op[1] : void 0, done: true };
131
+ }
132
+ }
133
+ function __read(o, n) {
134
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
135
+ if (!m)
136
+ return o;
137
+ var i = m.call(o), r, ar = [], e;
138
+ try {
139
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
140
+ ar.push(r.value);
141
+ } catch (error) {
142
+ e = { error };
143
+ } finally {
144
+ try {
145
+ if (r && !r.done && (m = i["return"]))
146
+ m.call(i);
147
+ } finally {
148
+ if (e)
149
+ throw e.error;
150
+ }
151
+ }
152
+ return ar;
153
+ }
154
+ function __spreadArray(to, from, pack) {
155
+ if (pack || arguments.length === 2)
156
+ for (var i = 0, l = from.length, ar; i < l; i++) {
157
+ if (ar || !(i in from)) {
158
+ if (!ar)
159
+ ar = Array.prototype.slice.call(from, 0, i);
160
+ ar[i] = from[i];
161
+ }
162
+ }
163
+ return to.concat(ar || Array.prototype.slice.call(from));
164
+ }
165
+ typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
166
+ var e = new Error(message);
167
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
168
+ };
169
+ var useReactId = React["useId".toString()] || (() => void 0);
170
+ var count$1 = 0;
171
+ function useId(deterministicId) {
172
+ const [id, setId] = React.useState(useReactId());
173
+ useLayoutEffect2(() => {
174
+ if (!deterministicId)
175
+ setId((reactId) => reactId ?? String(count$1++));
176
+ }, [deterministicId]);
177
+ return deterministicId || (id ? `radix-${id}` : "");
178
+ }
179
+ function useControllableState({
180
+ prop,
181
+ defaultProp,
182
+ onChange = () => {
183
+ }
184
+ }) {
185
+ const [uncontrolledProp, setUncontrolledProp] = useUncontrolledState({ defaultProp, onChange });
186
+ const isControlled = prop !== void 0;
187
+ const value = isControlled ? prop : uncontrolledProp;
188
+ const handleChange = useCallbackRef$1(onChange);
189
+ const setValue = React.useCallback(
190
+ (nextValue) => {
191
+ if (isControlled) {
192
+ const setter = nextValue;
193
+ const value2 = typeof nextValue === "function" ? setter(prop) : nextValue;
194
+ if (value2 !== prop)
195
+ handleChange(value2);
196
+ } else {
197
+ setUncontrolledProp(nextValue);
198
+ }
199
+ },
200
+ [isControlled, prop, setUncontrolledProp, handleChange]
201
+ );
202
+ return [value, setValue];
203
+ }
204
+ function useUncontrolledState({
205
+ defaultProp,
206
+ onChange
207
+ }) {
208
+ const uncontrolledState = React.useState(defaultProp);
209
+ const [value] = uncontrolledState;
210
+ const prevValueRef = React.useRef(value);
211
+ const handleChange = useCallbackRef$1(onChange);
212
+ React.useEffect(() => {
213
+ if (prevValueRef.current !== value) {
214
+ handleChange(value);
215
+ prevValueRef.current = value;
216
+ }
217
+ }, [value, prevValueRef, handleChange]);
218
+ return uncontrolledState;
219
+ }
220
+ function useEscapeKeydown(onEscapeKeyDownProp, ownerDocument = globalThis == null ? void 0 : globalThis.document) {
221
+ const onEscapeKeyDown = useCallbackRef$1(onEscapeKeyDownProp);
222
+ React.useEffect(() => {
223
+ const handleKeyDown = (event) => {
224
+ if (event.key === "Escape") {
225
+ onEscapeKeyDown(event);
226
+ }
227
+ };
228
+ ownerDocument.addEventListener("keydown", handleKeyDown, { capture: true });
229
+ return () => ownerDocument.removeEventListener("keydown", handleKeyDown, { capture: true });
230
+ }, [onEscapeKeyDown, ownerDocument]);
231
+ }
232
+ var DISMISSABLE_LAYER_NAME = "DismissableLayer";
233
+ var CONTEXT_UPDATE = "dismissableLayer.update";
234
+ var POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside";
235
+ var FOCUS_OUTSIDE = "dismissableLayer.focusOutside";
236
+ var originalBodyPointerEvents;
237
+ var DismissableLayerContext = React.createContext({
238
+ layers: /* @__PURE__ */ new Set(),
239
+ layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
240
+ branches: /* @__PURE__ */ new Set()
241
+ });
242
+ var DismissableLayer = React.forwardRef(
243
+ (props, forwardedRef) => {
244
+ const {
245
+ disableOutsidePointerEvents = false,
246
+ onEscapeKeyDown,
247
+ onPointerDownOutside,
248
+ onFocusOutside,
249
+ onInteractOutside,
250
+ onDismiss,
251
+ ...layerProps
252
+ } = props;
253
+ const context = React.useContext(DismissableLayerContext);
254
+ const [node, setNode] = React.useState(null);
255
+ const ownerDocument = (node == null ? void 0 : node.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document);
256
+ const [, force] = React.useState({});
257
+ const composedRefs = useComposedRefs(forwardedRef, (node2) => setNode(node2));
258
+ const layers = Array.from(context.layers);
259
+ const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1);
260
+ const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);
261
+ const index = node ? layers.indexOf(node) : -1;
262
+ const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
263
+ const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;
264
+ const pointerDownOutside = usePointerDownOutside((event) => {
265
+ const target = event.target;
266
+ const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target));
267
+ if (!isPointerEventsEnabled || isPointerDownOnBranch)
268
+ return;
269
+ onPointerDownOutside == null ? void 0 : onPointerDownOutside(event);
270
+ onInteractOutside == null ? void 0 : onInteractOutside(event);
271
+ if (!event.defaultPrevented)
272
+ onDismiss == null ? void 0 : onDismiss();
273
+ }, ownerDocument);
274
+ const focusOutside = useFocusOutside((event) => {
275
+ const target = event.target;
276
+ const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));
277
+ if (isFocusInBranch)
278
+ return;
279
+ onFocusOutside == null ? void 0 : onFocusOutside(event);
280
+ onInteractOutside == null ? void 0 : onInteractOutside(event);
281
+ if (!event.defaultPrevented)
282
+ onDismiss == null ? void 0 : onDismiss();
283
+ }, ownerDocument);
284
+ useEscapeKeydown((event) => {
285
+ const isHighestLayer = index === context.layers.size - 1;
286
+ if (!isHighestLayer)
287
+ return;
288
+ onEscapeKeyDown == null ? void 0 : onEscapeKeyDown(event);
289
+ if (!event.defaultPrevented && onDismiss) {
290
+ event.preventDefault();
291
+ onDismiss();
292
+ }
293
+ }, ownerDocument);
294
+ React.useEffect(() => {
295
+ if (!node)
296
+ return;
297
+ if (disableOutsidePointerEvents) {
298
+ if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
299
+ originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
300
+ ownerDocument.body.style.pointerEvents = "none";
301
+ }
302
+ context.layersWithOutsidePointerEventsDisabled.add(node);
303
+ }
304
+ context.layers.add(node);
305
+ dispatchUpdate();
306
+ return () => {
307
+ if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) {
308
+ ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;
309
+ }
310
+ };
311
+ }, [node, ownerDocument, disableOutsidePointerEvents, context]);
312
+ React.useEffect(() => {
313
+ return () => {
314
+ if (!node)
315
+ return;
316
+ context.layers.delete(node);
317
+ context.layersWithOutsidePointerEventsDisabled.delete(node);
318
+ dispatchUpdate();
319
+ };
320
+ }, [node, context]);
321
+ React.useEffect(() => {
322
+ const handleUpdate = () => force({});
323
+ document.addEventListener(CONTEXT_UPDATE, handleUpdate);
324
+ return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
325
+ }, []);
326
+ return /* @__PURE__ */ jsx(
327
+ Primitive.div,
328
+ {
329
+ ...layerProps,
330
+ ref: composedRefs,
331
+ style: {
332
+ pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
333
+ ...props.style
334
+ },
335
+ onFocusCapture: composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture),
336
+ onBlurCapture: composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture),
337
+ onPointerDownCapture: composeEventHandlers(
338
+ props.onPointerDownCapture,
339
+ pointerDownOutside.onPointerDownCapture
340
+ )
341
+ }
342
+ );
343
+ }
344
+ );
345
+ DismissableLayer.displayName = DISMISSABLE_LAYER_NAME;
346
+ var BRANCH_NAME = "DismissableLayerBranch";
347
+ var DismissableLayerBranch = React.forwardRef((props, forwardedRef) => {
348
+ const context = React.useContext(DismissableLayerContext);
349
+ const ref = React.useRef(null);
350
+ const composedRefs = useComposedRefs(forwardedRef, ref);
351
+ React.useEffect(() => {
352
+ const node = ref.current;
353
+ if (node) {
354
+ context.branches.add(node);
355
+ return () => {
356
+ context.branches.delete(node);
357
+ };
358
+ }
359
+ }, [context.branches]);
360
+ return /* @__PURE__ */ jsx(Primitive.div, { ...props, ref: composedRefs });
361
+ });
362
+ DismissableLayerBranch.displayName = BRANCH_NAME;
363
+ function usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis == null ? void 0 : globalThis.document) {
364
+ const handlePointerDownOutside = useCallbackRef$1(onPointerDownOutside);
365
+ const isPointerInsideReactTreeRef = React.useRef(false);
366
+ const handleClickRef = React.useRef(() => {
367
+ });
368
+ React.useEffect(() => {
369
+ const handlePointerDown = (event) => {
370
+ if (event.target && !isPointerInsideReactTreeRef.current) {
371
+ let handleAndDispatchPointerDownOutsideEvent2 = function() {
372
+ handleAndDispatchCustomEvent(
373
+ POINTER_DOWN_OUTSIDE,
374
+ handlePointerDownOutside,
375
+ eventDetail,
376
+ { discrete: true }
377
+ );
378
+ };
379
+ const eventDetail = { originalEvent: event };
380
+ if (event.pointerType === "touch") {
381
+ ownerDocument.removeEventListener("click", handleClickRef.current);
382
+ handleClickRef.current = handleAndDispatchPointerDownOutsideEvent2;
383
+ ownerDocument.addEventListener("click", handleClickRef.current, { once: true });
384
+ } else {
385
+ handleAndDispatchPointerDownOutsideEvent2();
386
+ }
387
+ } else {
388
+ ownerDocument.removeEventListener("click", handleClickRef.current);
389
+ }
390
+ isPointerInsideReactTreeRef.current = false;
391
+ };
392
+ const timerId = window.setTimeout(() => {
393
+ ownerDocument.addEventListener("pointerdown", handlePointerDown);
394
+ }, 0);
395
+ return () => {
396
+ window.clearTimeout(timerId);
397
+ ownerDocument.removeEventListener("pointerdown", handlePointerDown);
398
+ ownerDocument.removeEventListener("click", handleClickRef.current);
399
+ };
400
+ }, [ownerDocument, handlePointerDownOutside]);
401
+ return {
402
+ // ensures we check React component tree (not just DOM tree)
403
+ onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true
404
+ };
405
+ }
406
+ function useFocusOutside(onFocusOutside, ownerDocument = globalThis == null ? void 0 : globalThis.document) {
407
+ const handleFocusOutside = useCallbackRef$1(onFocusOutside);
408
+ const isFocusInsideReactTreeRef = React.useRef(false);
409
+ React.useEffect(() => {
410
+ const handleFocus = (event) => {
411
+ if (event.target && !isFocusInsideReactTreeRef.current) {
412
+ const eventDetail = { originalEvent: event };
413
+ handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
414
+ discrete: false
415
+ });
416
+ }
417
+ };
418
+ ownerDocument.addEventListener("focusin", handleFocus);
419
+ return () => ownerDocument.removeEventListener("focusin", handleFocus);
420
+ }, [ownerDocument, handleFocusOutside]);
421
+ return {
422
+ onFocusCapture: () => isFocusInsideReactTreeRef.current = true,
423
+ onBlurCapture: () => isFocusInsideReactTreeRef.current = false
424
+ };
425
+ }
426
+ function dispatchUpdate() {
427
+ const event = new CustomEvent(CONTEXT_UPDATE);
428
+ document.dispatchEvent(event);
429
+ }
430
+ function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
431
+ const target = detail.originalEvent.target;
432
+ const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });
433
+ if (handler)
434
+ target.addEventListener(name, handler, { once: true });
435
+ if (discrete) {
436
+ dispatchDiscreteCustomEvent(target, event);
437
+ } else {
438
+ target.dispatchEvent(event);
439
+ }
440
+ }
441
+ var AUTOFOCUS_ON_MOUNT = "focusScope.autoFocusOnMount";
442
+ var AUTOFOCUS_ON_UNMOUNT = "focusScope.autoFocusOnUnmount";
443
+ var EVENT_OPTIONS = { bubbles: false, cancelable: true };
444
+ var FOCUS_SCOPE_NAME = "FocusScope";
445
+ var FocusScope = React.forwardRef((props, forwardedRef) => {
446
+ const {
447
+ loop = false,
448
+ trapped = false,
449
+ onMountAutoFocus: onMountAutoFocusProp,
450
+ onUnmountAutoFocus: onUnmountAutoFocusProp,
451
+ ...scopeProps
452
+ } = props;
453
+ const [container, setContainer] = React.useState(null);
454
+ const onMountAutoFocus = useCallbackRef$1(onMountAutoFocusProp);
455
+ const onUnmountAutoFocus = useCallbackRef$1(onUnmountAutoFocusProp);
456
+ const lastFocusedElementRef = React.useRef(null);
457
+ const composedRefs = useComposedRefs(forwardedRef, (node) => setContainer(node));
458
+ const focusScope = React.useRef({
459
+ paused: false,
460
+ pause() {
461
+ this.paused = true;
462
+ },
463
+ resume() {
464
+ this.paused = false;
465
+ }
466
+ }).current;
467
+ React.useEffect(() => {
468
+ if (trapped) {
469
+ let handleFocusIn2 = function(event) {
470
+ if (focusScope.paused || !container)
471
+ return;
472
+ const target = event.target;
473
+ if (container.contains(target)) {
474
+ lastFocusedElementRef.current = target;
475
+ } else {
476
+ focus(lastFocusedElementRef.current, { select: true });
477
+ }
478
+ }, handleFocusOut2 = function(event) {
479
+ if (focusScope.paused || !container)
480
+ return;
481
+ const relatedTarget = event.relatedTarget;
482
+ if (relatedTarget === null)
483
+ return;
484
+ if (!container.contains(relatedTarget)) {
485
+ focus(lastFocusedElementRef.current, { select: true });
486
+ }
487
+ }, handleMutations2 = function(mutations) {
488
+ const focusedElement = document.activeElement;
489
+ if (focusedElement !== document.body)
490
+ return;
491
+ for (const mutation of mutations) {
492
+ if (mutation.removedNodes.length > 0)
493
+ focus(container);
494
+ }
495
+ };
496
+ document.addEventListener("focusin", handleFocusIn2);
497
+ document.addEventListener("focusout", handleFocusOut2);
498
+ const mutationObserver = new MutationObserver(handleMutations2);
499
+ if (container)
500
+ mutationObserver.observe(container, { childList: true, subtree: true });
501
+ return () => {
502
+ document.removeEventListener("focusin", handleFocusIn2);
503
+ document.removeEventListener("focusout", handleFocusOut2);
504
+ mutationObserver.disconnect();
505
+ };
506
+ }
507
+ }, [trapped, container, focusScope.paused]);
508
+ React.useEffect(() => {
509
+ if (container) {
510
+ focusScopesStack.add(focusScope);
511
+ const previouslyFocusedElement = document.activeElement;
512
+ const hasFocusedCandidate = container.contains(previouslyFocusedElement);
513
+ if (!hasFocusedCandidate) {
514
+ const mountEvent = new CustomEvent(AUTOFOCUS_ON_MOUNT, EVENT_OPTIONS);
515
+ container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
516
+ container.dispatchEvent(mountEvent);
517
+ if (!mountEvent.defaultPrevented) {
518
+ focusFirst(removeLinks(getTabbableCandidates(container)), { select: true });
519
+ if (document.activeElement === previouslyFocusedElement) {
520
+ focus(container);
521
+ }
522
+ }
523
+ }
524
+ return () => {
525
+ container.removeEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
526
+ setTimeout(() => {
527
+ const unmountEvent = new CustomEvent(AUTOFOCUS_ON_UNMOUNT, EVENT_OPTIONS);
528
+ container.addEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
529
+ container.dispatchEvent(unmountEvent);
530
+ if (!unmountEvent.defaultPrevented) {
531
+ focus(previouslyFocusedElement ?? document.body, { select: true });
532
+ }
533
+ container.removeEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
534
+ focusScopesStack.remove(focusScope);
535
+ }, 0);
536
+ };
537
+ }
538
+ }, [container, onMountAutoFocus, onUnmountAutoFocus, focusScope]);
539
+ const handleKeyDown = React.useCallback(
540
+ (event) => {
541
+ if (!loop && !trapped)
542
+ return;
543
+ if (focusScope.paused)
544
+ return;
545
+ const isTabKey = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey;
546
+ const focusedElement = document.activeElement;
547
+ if (isTabKey && focusedElement) {
548
+ const container2 = event.currentTarget;
549
+ const [first, last] = getTabbableEdges(container2);
550
+ const hasTabbableElementsInside = first && last;
551
+ if (!hasTabbableElementsInside) {
552
+ if (focusedElement === container2)
553
+ event.preventDefault();
554
+ } else {
555
+ if (!event.shiftKey && focusedElement === last) {
556
+ event.preventDefault();
557
+ if (loop)
558
+ focus(first, { select: true });
559
+ } else if (event.shiftKey && focusedElement === first) {
560
+ event.preventDefault();
561
+ if (loop)
562
+ focus(last, { select: true });
563
+ }
564
+ }
565
+ }
566
+ },
567
+ [loop, trapped, focusScope.paused]
568
+ );
569
+ return /* @__PURE__ */ jsx(Primitive.div, { tabIndex: -1, ...scopeProps, ref: composedRefs, onKeyDown: handleKeyDown });
570
+ });
571
+ FocusScope.displayName = FOCUS_SCOPE_NAME;
572
+ function focusFirst(candidates, { select = false } = {}) {
573
+ const previouslyFocusedElement = document.activeElement;
574
+ for (const candidate of candidates) {
575
+ focus(candidate, { select });
576
+ if (document.activeElement !== previouslyFocusedElement)
577
+ return;
578
+ }
579
+ }
580
+ function getTabbableEdges(container) {
581
+ const candidates = getTabbableCandidates(container);
582
+ const first = findVisible(candidates, container);
583
+ const last = findVisible(candidates.reverse(), container);
584
+ return [first, last];
585
+ }
586
+ function getTabbableCandidates(container) {
587
+ const nodes = [];
588
+ const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
589
+ acceptNode: (node) => {
590
+ const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
591
+ if (node.disabled || node.hidden || isHiddenInput)
592
+ return NodeFilter.FILTER_SKIP;
593
+ return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
594
+ }
595
+ });
596
+ while (walker.nextNode())
597
+ nodes.push(walker.currentNode);
598
+ return nodes;
599
+ }
600
+ function findVisible(elements, container) {
601
+ for (const element of elements) {
602
+ if (!isHidden(element, { upTo: container }))
603
+ return element;
604
+ }
605
+ }
606
+ function isHidden(node, { upTo }) {
607
+ if (getComputedStyle(node).visibility === "hidden")
608
+ return true;
609
+ while (node) {
610
+ if (upTo !== void 0 && node === upTo)
611
+ return false;
612
+ if (getComputedStyle(node).display === "none")
613
+ return true;
614
+ node = node.parentElement;
615
+ }
616
+ return false;
617
+ }
618
+ function isSelectableInput(element) {
619
+ return element instanceof HTMLInputElement && "select" in element;
620
+ }
621
+ function focus(element, { select = false } = {}) {
622
+ if (element && element.focus) {
623
+ const previouslyFocusedElement = document.activeElement;
624
+ element.focus({ preventScroll: true });
625
+ if (element !== previouslyFocusedElement && isSelectableInput(element) && select)
626
+ element.select();
627
+ }
628
+ }
629
+ var focusScopesStack = createFocusScopesStack();
630
+ function createFocusScopesStack() {
631
+ let stack = [];
632
+ return {
633
+ add(focusScope) {
634
+ const activeFocusScope = stack[0];
635
+ if (focusScope !== activeFocusScope) {
636
+ activeFocusScope == null ? void 0 : activeFocusScope.pause();
637
+ }
638
+ stack = arrayRemove(stack, focusScope);
639
+ stack.unshift(focusScope);
640
+ },
641
+ remove(focusScope) {
642
+ var _a;
643
+ stack = arrayRemove(stack, focusScope);
644
+ (_a = stack[0]) == null ? void 0 : _a.resume();
645
+ }
646
+ };
647
+ }
648
+ function arrayRemove(array, item) {
649
+ const updatedArray = [...array];
650
+ const index = updatedArray.indexOf(item);
651
+ if (index !== -1) {
652
+ updatedArray.splice(index, 1);
653
+ }
654
+ return updatedArray;
655
+ }
656
+ function removeLinks(items) {
657
+ return items.filter((item) => item.tagName !== "A");
658
+ }
659
+ var PORTAL_NAME$1 = "Portal";
660
+ var Portal$1 = React.forwardRef((props, forwardedRef) => {
661
+ var _a;
662
+ const { container: containerProp, ...portalProps } = props;
663
+ const [mounted, setMounted] = React.useState(false);
664
+ useLayoutEffect2(() => setMounted(true), []);
665
+ const container = containerProp || mounted && ((_a = globalThis == null ? void 0 : globalThis.document) == null ? void 0 : _a.body);
666
+ return container ? ReactDOM.createPortal(/* @__PURE__ */ jsx(Primitive.div, { ...portalProps, ref: forwardedRef }), container) : null;
667
+ });
668
+ Portal$1.displayName = PORTAL_NAME$1;
669
+ var count = 0;
670
+ function useFocusGuards() {
671
+ React.useEffect(() => {
672
+ const edgeGuards = document.querySelectorAll("[data-radix-focus-guard]");
673
+ document.body.insertAdjacentElement("afterbegin", edgeGuards[0] ?? createFocusGuard());
674
+ document.body.insertAdjacentElement("beforeend", edgeGuards[1] ?? createFocusGuard());
675
+ count++;
676
+ return () => {
677
+ if (count === 1) {
678
+ document.querySelectorAll("[data-radix-focus-guard]").forEach((node) => node.remove());
679
+ }
680
+ count--;
681
+ };
682
+ }, []);
683
+ }
684
+ function createFocusGuard() {
685
+ const element = document.createElement("span");
686
+ element.setAttribute("data-radix-focus-guard", "");
687
+ element.tabIndex = 0;
688
+ element.style.outline = "none";
689
+ element.style.opacity = "0";
690
+ element.style.position = "fixed";
691
+ element.style.pointerEvents = "none";
692
+ return element;
693
+ }
694
+ var zeroRightClassName = "right-scroll-bar-position";
695
+ var fullWidthClassName = "width-before-scroll-bar";
696
+ var noScrollbarsClassName = "with-scroll-bars-hidden";
697
+ var removedBarSizeVariable = "--removed-body-scroll-bar-size";
698
+ function assignRef(ref, value) {
699
+ if (typeof ref === "function") {
700
+ ref(value);
701
+ } else if (ref) {
702
+ ref.current = value;
703
+ }
704
+ return ref;
705
+ }
706
+ function useCallbackRef(initialValue, callback) {
707
+ var ref = useState(function() {
708
+ return {
709
+ // value
710
+ value: initialValue,
711
+ // last callback
712
+ callback,
713
+ // "memoized" public interface
714
+ facade: {
715
+ get current() {
716
+ return ref.value;
717
+ },
718
+ set current(value) {
719
+ var last = ref.value;
720
+ if (last !== value) {
721
+ ref.value = value;
722
+ ref.callback(value, last);
723
+ }
724
+ }
725
+ }
726
+ };
727
+ })[0];
728
+ ref.callback = callback;
729
+ return ref.facade;
730
+ }
731
+ var useIsomorphicLayoutEffect = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
732
+ var currentValues = /* @__PURE__ */ new WeakMap();
733
+ function useMergeRefs(refs, defaultValue) {
734
+ var callbackRef = useCallbackRef(null, function(newValue) {
735
+ return refs.forEach(function(ref) {
736
+ return assignRef(ref, newValue);
737
+ });
738
+ });
739
+ useIsomorphicLayoutEffect(function() {
740
+ var oldValue = currentValues.get(callbackRef);
741
+ if (oldValue) {
742
+ var prevRefs_1 = new Set(oldValue);
743
+ var nextRefs_1 = new Set(refs);
744
+ var current_1 = callbackRef.current;
745
+ prevRefs_1.forEach(function(ref) {
746
+ if (!nextRefs_1.has(ref)) {
747
+ assignRef(ref, null);
748
+ }
749
+ });
750
+ nextRefs_1.forEach(function(ref) {
751
+ if (!prevRefs_1.has(ref)) {
752
+ assignRef(ref, current_1);
753
+ }
754
+ });
755
+ }
756
+ currentValues.set(callbackRef, refs);
757
+ }, [refs]);
758
+ return callbackRef;
759
+ }
760
+ function ItoI(a) {
761
+ return a;
762
+ }
763
+ function innerCreateMedium(defaults, middleware) {
764
+ if (middleware === void 0) {
765
+ middleware = ItoI;
766
+ }
767
+ var buffer = [];
768
+ var assigned = false;
769
+ var medium = {
770
+ read: function() {
771
+ if (assigned) {
772
+ throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");
773
+ }
774
+ if (buffer.length) {
775
+ return buffer[buffer.length - 1];
776
+ }
777
+ return defaults;
778
+ },
779
+ useMedium: function(data) {
780
+ var item = middleware(data, assigned);
781
+ buffer.push(item);
782
+ return function() {
783
+ buffer = buffer.filter(function(x) {
784
+ return x !== item;
785
+ });
786
+ };
787
+ },
788
+ assignSyncMedium: function(cb) {
789
+ assigned = true;
790
+ while (buffer.length) {
791
+ var cbs = buffer;
792
+ buffer = [];
793
+ cbs.forEach(cb);
794
+ }
795
+ buffer = {
796
+ push: function(x) {
797
+ return cb(x);
798
+ },
799
+ filter: function() {
800
+ return buffer;
801
+ }
802
+ };
803
+ },
804
+ assignMedium: function(cb) {
805
+ assigned = true;
806
+ var pendingQueue = [];
807
+ if (buffer.length) {
808
+ var cbs = buffer;
809
+ buffer = [];
810
+ cbs.forEach(cb);
811
+ pendingQueue = buffer;
812
+ }
813
+ var executeQueue = function() {
814
+ var cbs2 = pendingQueue;
815
+ pendingQueue = [];
816
+ cbs2.forEach(cb);
817
+ };
818
+ var cycle = function() {
819
+ return Promise.resolve().then(executeQueue);
820
+ };
821
+ cycle();
822
+ buffer = {
823
+ push: function(x) {
824
+ pendingQueue.push(x);
825
+ cycle();
826
+ },
827
+ filter: function(filter) {
828
+ pendingQueue = pendingQueue.filter(filter);
829
+ return buffer;
830
+ }
831
+ };
832
+ }
833
+ };
834
+ return medium;
835
+ }
836
+ function createSidecarMedium(options) {
837
+ if (options === void 0) {
838
+ options = {};
839
+ }
840
+ var medium = innerCreateMedium(null);
841
+ medium.options = __assign({ async: true, ssr: false }, options);
842
+ return medium;
843
+ }
844
+ var SideCar$1 = function(_a) {
845
+ var sideCar = _a.sideCar, rest = __rest(_a, ["sideCar"]);
846
+ if (!sideCar) {
847
+ throw new Error("Sidecar: please provide `sideCar` property to import the right car");
848
+ }
849
+ var Target = sideCar.read();
850
+ if (!Target) {
851
+ throw new Error("Sidecar medium not found");
852
+ }
853
+ return React.createElement(Target, __assign({}, rest));
854
+ };
855
+ SideCar$1.isSideCarExport = true;
856
+ function exportSidecar(medium, exported) {
857
+ medium.useMedium(exported);
858
+ return SideCar$1;
859
+ }
860
+ var effectCar = createSidecarMedium();
861
+ var nothing = function() {
862
+ return;
863
+ };
864
+ var RemoveScroll = React.forwardRef(function(props, parentRef) {
865
+ var ref = React.useRef(null);
866
+ var _a = React.useState({
867
+ onScrollCapture: nothing,
868
+ onWheelCapture: nothing,
869
+ onTouchMoveCapture: nothing
870
+ }), callbacks = _a[0], setCallbacks = _a[1];
871
+ var forwardProps = props.forwardProps, children = props.children, className = props.className, removeScrollBar = props.removeScrollBar, enabled = props.enabled, shards = props.shards, sideCar = props.sideCar, noIsolation = props.noIsolation, inert = props.inert, allowPinchZoom = props.allowPinchZoom, _b = props.as, Container = _b === void 0 ? "div" : _b, gapMode = props.gapMode, rest = __rest(props, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]);
872
+ var SideCar2 = sideCar;
873
+ var containerRef = useMergeRefs([ref, parentRef]);
874
+ var containerProps = __assign(__assign({}, rest), callbacks);
875
+ return React.createElement(
876
+ React.Fragment,
877
+ null,
878
+ enabled && React.createElement(SideCar2, { sideCar: effectCar, removeScrollBar, shards, noIsolation, inert, setCallbacks, allowPinchZoom: !!allowPinchZoom, lockRef: ref, gapMode }),
879
+ forwardProps ? React.cloneElement(React.Children.only(children), __assign(__assign({}, containerProps), { ref: containerRef })) : React.createElement(Container, __assign({}, containerProps, { className, ref: containerRef }), children)
880
+ );
881
+ });
882
+ RemoveScroll.defaultProps = {
883
+ enabled: true,
884
+ removeScrollBar: true,
885
+ inert: false
886
+ };
887
+ RemoveScroll.classNames = {
888
+ fullWidth: fullWidthClassName,
889
+ zeroRight: zeroRightClassName
890
+ };
891
+ var getNonce = function() {
892
+ if (typeof __webpack_nonce__ !== "undefined") {
893
+ return __webpack_nonce__;
894
+ }
895
+ return void 0;
896
+ };
897
+ function makeStyleTag() {
898
+ if (!document)
899
+ return null;
900
+ var tag = document.createElement("style");
901
+ tag.type = "text/css";
902
+ var nonce = getNonce();
903
+ if (nonce) {
904
+ tag.setAttribute("nonce", nonce);
905
+ }
906
+ return tag;
907
+ }
908
+ function injectStyles(tag, css) {
909
+ if (tag.styleSheet) {
910
+ tag.styleSheet.cssText = css;
911
+ } else {
912
+ tag.appendChild(document.createTextNode(css));
913
+ }
914
+ }
915
+ function insertStyleTag(tag) {
916
+ var head = document.head || document.getElementsByTagName("head")[0];
917
+ head.appendChild(tag);
918
+ }
919
+ var stylesheetSingleton = function() {
920
+ var counter = 0;
921
+ var stylesheet = null;
922
+ return {
923
+ add: function(style) {
924
+ if (counter == 0) {
925
+ if (stylesheet = makeStyleTag()) {
926
+ injectStyles(stylesheet, style);
927
+ insertStyleTag(stylesheet);
928
+ }
929
+ }
930
+ counter++;
931
+ },
932
+ remove: function() {
933
+ counter--;
934
+ if (!counter && stylesheet) {
935
+ stylesheet.parentNode && stylesheet.parentNode.removeChild(stylesheet);
936
+ stylesheet = null;
937
+ }
938
+ }
939
+ };
940
+ };
941
+ var styleHookSingleton = function() {
942
+ var sheet = stylesheetSingleton();
943
+ return function(styles, isDynamic) {
944
+ React.useEffect(function() {
945
+ sheet.add(styles);
946
+ return function() {
947
+ sheet.remove();
948
+ };
949
+ }, [styles && isDynamic]);
950
+ };
951
+ };
952
+ var styleSingleton = function() {
953
+ var useStyle = styleHookSingleton();
954
+ var Sheet = function(_a) {
955
+ var styles = _a.styles, dynamic = _a.dynamic;
956
+ useStyle(styles, dynamic);
957
+ return null;
958
+ };
959
+ return Sheet;
960
+ };
961
+ var zeroGap = {
962
+ left: 0,
963
+ top: 0,
964
+ right: 0,
965
+ gap: 0
966
+ };
967
+ var parse = function(x) {
968
+ return parseInt(x || "", 10) || 0;
969
+ };
970
+ var getOffset = function(gapMode) {
971
+ var cs = window.getComputedStyle(document.body);
972
+ var left = cs[gapMode === "padding" ? "paddingLeft" : "marginLeft"];
973
+ var top = cs[gapMode === "padding" ? "paddingTop" : "marginTop"];
974
+ var right = cs[gapMode === "padding" ? "paddingRight" : "marginRight"];
975
+ return [parse(left), parse(top), parse(right)];
976
+ };
977
+ var getGapWidth = function(gapMode) {
978
+ if (gapMode === void 0) {
979
+ gapMode = "margin";
980
+ }
981
+ if (typeof window === "undefined") {
982
+ return zeroGap;
983
+ }
984
+ var offsets = getOffset(gapMode);
985
+ var documentWidth = document.documentElement.clientWidth;
986
+ var windowWidth = window.innerWidth;
987
+ return {
988
+ left: offsets[0],
989
+ top: offsets[1],
990
+ right: offsets[2],
991
+ gap: Math.max(0, windowWidth - documentWidth + offsets[2] - offsets[0])
992
+ };
993
+ };
994
+ var Style = styleSingleton();
995
+ var lockAttribute = "data-scroll-locked";
996
+ var getStyles = function(_a, allowRelative, gapMode, important) {
997
+ var left = _a.left, top = _a.top, right = _a.right, gap = _a.gap;
998
+ if (gapMode === void 0) {
999
+ gapMode = "margin";
1000
+ }
1001
+ return "\n .".concat(noScrollbarsClassName, " {\n overflow: hidden ").concat(important, ";\n padding-right: ").concat(gap, "px ").concat(important, ";\n }\n body[").concat(lockAttribute, "] {\n overflow: hidden ").concat(important, ";\n overscroll-behavior: contain;\n ").concat([
1002
+ allowRelative && "position: relative ".concat(important, ";"),
1003
+ gapMode === "margin" && "\n padding-left: ".concat(left, "px;\n padding-top: ").concat(top, "px;\n padding-right: ").concat(right, "px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(gap, "px ").concat(important, ";\n "),
1004
+ gapMode === "padding" && "padding-right: ".concat(gap, "px ").concat(important, ";")
1005
+ ].filter(Boolean).join(""), "\n }\n \n .").concat(zeroRightClassName, " {\n right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " {\n margin-right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(zeroRightClassName, " .").concat(zeroRightClassName, " {\n right: 0 ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " .").concat(fullWidthClassName, " {\n margin-right: 0 ").concat(important, ";\n }\n \n body[").concat(lockAttribute, "] {\n ").concat(removedBarSizeVariable, ": ").concat(gap, "px;\n }\n");
1006
+ };
1007
+ var getCurrentUseCounter = function() {
1008
+ var counter = parseInt(document.body.getAttribute(lockAttribute) || "0", 10);
1009
+ return isFinite(counter) ? counter : 0;
1010
+ };
1011
+ var useLockAttribute = function() {
1012
+ React.useEffect(function() {
1013
+ document.body.setAttribute(lockAttribute, (getCurrentUseCounter() + 1).toString());
1014
+ return function() {
1015
+ var newCounter = getCurrentUseCounter() - 1;
1016
+ if (newCounter <= 0) {
1017
+ document.body.removeAttribute(lockAttribute);
1018
+ } else {
1019
+ document.body.setAttribute(lockAttribute, newCounter.toString());
1020
+ }
1021
+ };
1022
+ }, []);
1023
+ };
1024
+ var RemoveScrollBar = function(_a) {
1025
+ var noRelative = _a.noRelative, noImportant = _a.noImportant, _b = _a.gapMode, gapMode = _b === void 0 ? "margin" : _b;
1026
+ useLockAttribute();
1027
+ var gap = React.useMemo(function() {
1028
+ return getGapWidth(gapMode);
1029
+ }, [gapMode]);
1030
+ return React.createElement(Style, { styles: getStyles(gap, !noRelative, gapMode, !noImportant ? "!important" : "") });
1031
+ };
1032
+ var passiveSupported = false;
1033
+ if (typeof window !== "undefined") {
1034
+ try {
1035
+ var options = Object.defineProperty({}, "passive", {
1036
+ get: function() {
1037
+ passiveSupported = true;
1038
+ return true;
1039
+ }
1040
+ });
1041
+ window.addEventListener("test", options, options);
1042
+ window.removeEventListener("test", options, options);
1043
+ } catch (err) {
1044
+ passiveSupported = false;
1045
+ }
1046
+ }
1047
+ var nonPassive = passiveSupported ? { passive: false } : false;
1048
+ var alwaysContainsScroll = function(node) {
1049
+ return node.tagName === "TEXTAREA";
1050
+ };
1051
+ var elementCanBeScrolled = function(node, overflow) {
1052
+ if (!(node instanceof Element)) {
1053
+ return false;
1054
+ }
1055
+ var styles = window.getComputedStyle(node);
1056
+ return (
1057
+ // not-not-scrollable
1058
+ styles[overflow] !== "hidden" && // contains scroll inside self
1059
+ !(styles.overflowY === styles.overflowX && !alwaysContainsScroll(node) && styles[overflow] === "visible")
1060
+ );
1061
+ };
1062
+ var elementCouldBeVScrolled = function(node) {
1063
+ return elementCanBeScrolled(node, "overflowY");
1064
+ };
1065
+ var elementCouldBeHScrolled = function(node) {
1066
+ return elementCanBeScrolled(node, "overflowX");
1067
+ };
1068
+ var locationCouldBeScrolled = function(axis, node) {
1069
+ var ownerDocument = node.ownerDocument;
1070
+ var current = node;
1071
+ do {
1072
+ if (typeof ShadowRoot !== "undefined" && current instanceof ShadowRoot) {
1073
+ current = current.host;
1074
+ }
1075
+ var isScrollable = elementCouldBeScrolled(axis, current);
1076
+ if (isScrollable) {
1077
+ var _a = getScrollVariables(axis, current), scrollHeight = _a[1], clientHeight = _a[2];
1078
+ if (scrollHeight > clientHeight) {
1079
+ return true;
1080
+ }
1081
+ }
1082
+ current = current.parentNode;
1083
+ } while (current && current !== ownerDocument.body);
1084
+ return false;
1085
+ };
1086
+ var getVScrollVariables = function(_a) {
1087
+ var scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight;
1088
+ return [
1089
+ scrollTop,
1090
+ scrollHeight,
1091
+ clientHeight
1092
+ ];
1093
+ };
1094
+ var getHScrollVariables = function(_a) {
1095
+ var scrollLeft = _a.scrollLeft, scrollWidth = _a.scrollWidth, clientWidth = _a.clientWidth;
1096
+ return [
1097
+ scrollLeft,
1098
+ scrollWidth,
1099
+ clientWidth
1100
+ ];
1101
+ };
1102
+ var elementCouldBeScrolled = function(axis, node) {
1103
+ return axis === "v" ? elementCouldBeVScrolled(node) : elementCouldBeHScrolled(node);
1104
+ };
1105
+ var getScrollVariables = function(axis, node) {
1106
+ return axis === "v" ? getVScrollVariables(node) : getHScrollVariables(node);
1107
+ };
1108
+ var getDirectionFactor = function(axis, direction) {
1109
+ return axis === "h" && direction === "rtl" ? -1 : 1;
1110
+ };
1111
+ var handleScroll = function(axis, endTarget, event, sourceDelta, noOverscroll) {
1112
+ var directionFactor = getDirectionFactor(axis, window.getComputedStyle(endTarget).direction);
1113
+ var delta = directionFactor * sourceDelta;
1114
+ var target = event.target;
1115
+ var targetInLock = endTarget.contains(target);
1116
+ var shouldCancelScroll = false;
1117
+ var isDeltaPositive = delta > 0;
1118
+ var availableScroll = 0;
1119
+ var availableScrollTop = 0;
1120
+ do {
1121
+ var _a = getScrollVariables(axis, target), position = _a[0], scroll_1 = _a[1], capacity = _a[2];
1122
+ var elementScroll = scroll_1 - capacity - directionFactor * position;
1123
+ if (position || elementScroll) {
1124
+ if (elementCouldBeScrolled(axis, target)) {
1125
+ availableScroll += elementScroll;
1126
+ availableScrollTop += position;
1127
+ }
1128
+ }
1129
+ if (target instanceof ShadowRoot) {
1130
+ target = target.host;
1131
+ } else {
1132
+ target = target.parentNode;
1133
+ }
1134
+ } while (
1135
+ // portaled content
1136
+ !targetInLock && target !== document.body || // self content
1137
+ targetInLock && (endTarget.contains(target) || endTarget === target)
1138
+ );
1139
+ if (isDeltaPositive && (Math.abs(availableScroll) < 1 || !noOverscroll)) {
1140
+ shouldCancelScroll = true;
1141
+ } else if (!isDeltaPositive && (Math.abs(availableScrollTop) < 1 || !noOverscroll)) {
1142
+ shouldCancelScroll = true;
1143
+ }
1144
+ return shouldCancelScroll;
1145
+ };
1146
+ var getTouchXY = function(event) {
1147
+ return "changedTouches" in event ? [event.changedTouches[0].clientX, event.changedTouches[0].clientY] : [0, 0];
1148
+ };
1149
+ var getDeltaXY = function(event) {
1150
+ return [event.deltaX, event.deltaY];
1151
+ };
1152
+ var extractRef = function(ref) {
1153
+ return ref && "current" in ref ? ref.current : ref;
1154
+ };
1155
+ var deltaCompare = function(x, y) {
1156
+ return x[0] === y[0] && x[1] === y[1];
1157
+ };
1158
+ var generateStyle = function(id) {
1159
+ return "\n .block-interactivity-".concat(id, " {pointer-events: none;}\n .allow-interactivity-").concat(id, " {pointer-events: all;}\n");
1160
+ };
1161
+ var idCounter = 0;
1162
+ var lockStack = [];
1163
+ function RemoveScrollSideCar(props) {
1164
+ var shouldPreventQueue = React.useRef([]);
1165
+ var touchStartRef = React.useRef([0, 0]);
1166
+ var activeAxis = React.useRef();
1167
+ var id = React.useState(idCounter++)[0];
1168
+ var Style2 = React.useState(styleSingleton)[0];
1169
+ var lastProps = React.useRef(props);
1170
+ React.useEffect(function() {
1171
+ lastProps.current = props;
1172
+ }, [props]);
1173
+ React.useEffect(function() {
1174
+ if (props.inert) {
1175
+ document.body.classList.add("block-interactivity-".concat(id));
1176
+ var allow_1 = __spreadArray([props.lockRef.current], (props.shards || []).map(extractRef), true).filter(Boolean);
1177
+ allow_1.forEach(function(el) {
1178
+ return el.classList.add("allow-interactivity-".concat(id));
1179
+ });
1180
+ return function() {
1181
+ document.body.classList.remove("block-interactivity-".concat(id));
1182
+ allow_1.forEach(function(el) {
1183
+ return el.classList.remove("allow-interactivity-".concat(id));
1184
+ });
1185
+ };
1186
+ }
1187
+ return;
1188
+ }, [props.inert, props.lockRef.current, props.shards]);
1189
+ var shouldCancelEvent = React.useCallback(function(event, parent) {
1190
+ if ("touches" in event && event.touches.length === 2 || event.type === "wheel" && event.ctrlKey) {
1191
+ return !lastProps.current.allowPinchZoom;
1192
+ }
1193
+ var touch = getTouchXY(event);
1194
+ var touchStart = touchStartRef.current;
1195
+ var deltaX = "deltaX" in event ? event.deltaX : touchStart[0] - touch[0];
1196
+ var deltaY = "deltaY" in event ? event.deltaY : touchStart[1] - touch[1];
1197
+ var currentAxis;
1198
+ var target = event.target;
1199
+ var moveDirection = Math.abs(deltaX) > Math.abs(deltaY) ? "h" : "v";
1200
+ if ("touches" in event && moveDirection === "h" && target.type === "range") {
1201
+ return false;
1202
+ }
1203
+ var canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
1204
+ if (!canBeScrolledInMainDirection) {
1205
+ return true;
1206
+ }
1207
+ if (canBeScrolledInMainDirection) {
1208
+ currentAxis = moveDirection;
1209
+ } else {
1210
+ currentAxis = moveDirection === "v" ? "h" : "v";
1211
+ canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
1212
+ }
1213
+ if (!canBeScrolledInMainDirection) {
1214
+ return false;
1215
+ }
1216
+ if (!activeAxis.current && "changedTouches" in event && (deltaX || deltaY)) {
1217
+ activeAxis.current = currentAxis;
1218
+ }
1219
+ if (!currentAxis) {
1220
+ return true;
1221
+ }
1222
+ var cancelingAxis = activeAxis.current || currentAxis;
1223
+ return handleScroll(cancelingAxis, parent, event, cancelingAxis === "h" ? deltaX : deltaY, true);
1224
+ }, []);
1225
+ var shouldPrevent = React.useCallback(function(_event) {
1226
+ var event = _event;
1227
+ if (!lockStack.length || lockStack[lockStack.length - 1] !== Style2) {
1228
+ return;
1229
+ }
1230
+ var delta = "deltaY" in event ? getDeltaXY(event) : getTouchXY(event);
1231
+ var sourceEvent = shouldPreventQueue.current.filter(function(e) {
1232
+ return e.name === event.type && (e.target === event.target || event.target === e.shadowParent) && deltaCompare(e.delta, delta);
1233
+ })[0];
1234
+ if (sourceEvent && sourceEvent.should) {
1235
+ if (event.cancelable) {
1236
+ event.preventDefault();
1237
+ }
1238
+ return;
1239
+ }
1240
+ if (!sourceEvent) {
1241
+ var shardNodes = (lastProps.current.shards || []).map(extractRef).filter(Boolean).filter(function(node) {
1242
+ return node.contains(event.target);
1243
+ });
1244
+ var shouldStop = shardNodes.length > 0 ? shouldCancelEvent(event, shardNodes[0]) : !lastProps.current.noIsolation;
1245
+ if (shouldStop) {
1246
+ if (event.cancelable) {
1247
+ event.preventDefault();
1248
+ }
1249
+ }
1250
+ }
1251
+ }, []);
1252
+ var shouldCancel = React.useCallback(function(name, delta, target, should) {
1253
+ var event = { name, delta, target, should, shadowParent: getOutermostShadowParent(target) };
1254
+ shouldPreventQueue.current.push(event);
1255
+ setTimeout(function() {
1256
+ shouldPreventQueue.current = shouldPreventQueue.current.filter(function(e) {
1257
+ return e !== event;
1258
+ });
1259
+ }, 1);
1260
+ }, []);
1261
+ var scrollTouchStart = React.useCallback(function(event) {
1262
+ touchStartRef.current = getTouchXY(event);
1263
+ activeAxis.current = void 0;
1264
+ }, []);
1265
+ var scrollWheel = React.useCallback(function(event) {
1266
+ shouldCancel(event.type, getDeltaXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
1267
+ }, []);
1268
+ var scrollTouchMove = React.useCallback(function(event) {
1269
+ shouldCancel(event.type, getTouchXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
1270
+ }, []);
1271
+ React.useEffect(function() {
1272
+ lockStack.push(Style2);
1273
+ props.setCallbacks({
1274
+ onScrollCapture: scrollWheel,
1275
+ onWheelCapture: scrollWheel,
1276
+ onTouchMoveCapture: scrollTouchMove
1277
+ });
1278
+ document.addEventListener("wheel", shouldPrevent, nonPassive);
1279
+ document.addEventListener("touchmove", shouldPrevent, nonPassive);
1280
+ document.addEventListener("touchstart", scrollTouchStart, nonPassive);
1281
+ return function() {
1282
+ lockStack = lockStack.filter(function(inst) {
1283
+ return inst !== Style2;
1284
+ });
1285
+ document.removeEventListener("wheel", shouldPrevent, nonPassive);
1286
+ document.removeEventListener("touchmove", shouldPrevent, nonPassive);
1287
+ document.removeEventListener("touchstart", scrollTouchStart, nonPassive);
1288
+ };
1289
+ }, []);
1290
+ var removeScrollBar = props.removeScrollBar, inert = props.inert;
1291
+ return React.createElement(
1292
+ React.Fragment,
1293
+ null,
1294
+ inert ? React.createElement(Style2, { styles: generateStyle(id) }) : null,
1295
+ removeScrollBar ? React.createElement(RemoveScrollBar, { gapMode: props.gapMode }) : null
1296
+ );
1297
+ }
1298
+ function getOutermostShadowParent(node) {
1299
+ var shadowParent = null;
1300
+ while (node !== null) {
1301
+ if (node instanceof ShadowRoot) {
1302
+ shadowParent = node.host;
1303
+ node = node.host;
1304
+ }
1305
+ node = node.parentNode;
1306
+ }
1307
+ return shadowParent;
1308
+ }
1309
+ const SideCar = exportSidecar(effectCar, RemoveScrollSideCar);
1310
+ var ReactRemoveScroll = React.forwardRef(function(props, ref) {
1311
+ return React.createElement(RemoveScroll, __assign({}, props, { ref, sideCar: SideCar }));
1312
+ });
1313
+ ReactRemoveScroll.classNames = RemoveScroll.classNames;
1314
+ var getDefaultParent = function(originalTarget) {
1315
+ if (typeof document === "undefined") {
1316
+ return null;
1317
+ }
1318
+ var sampleTarget = Array.isArray(originalTarget) ? originalTarget[0] : originalTarget;
1319
+ return sampleTarget.ownerDocument.body;
1320
+ };
1321
+ var counterMap = /* @__PURE__ */ new WeakMap();
1322
+ var uncontrolledNodes = /* @__PURE__ */ new WeakMap();
1323
+ var markerMap = {};
1324
+ var lockCount = 0;
1325
+ var unwrapHost = function(node) {
1326
+ return node && (node.host || unwrapHost(node.parentNode));
1327
+ };
1328
+ var correctTargets = function(parent, targets) {
1329
+ return targets.map(function(target) {
1330
+ if (parent.contains(target)) {
1331
+ return target;
1332
+ }
1333
+ var correctedTarget = unwrapHost(target);
1334
+ if (correctedTarget && parent.contains(correctedTarget)) {
1335
+ return correctedTarget;
1336
+ }
1337
+ console.error("aria-hidden", target, "in not contained inside", parent, ". Doing nothing");
1338
+ return null;
1339
+ }).filter(function(x) {
1340
+ return Boolean(x);
1341
+ });
1342
+ };
1343
+ var applyAttributeToOthers = function(originalTarget, parentNode, markerName, controlAttribute) {
1344
+ var targets = correctTargets(parentNode, Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
1345
+ if (!markerMap[markerName]) {
1346
+ markerMap[markerName] = /* @__PURE__ */ new WeakMap();
1347
+ }
1348
+ var markerCounter = markerMap[markerName];
1349
+ var hiddenNodes = [];
1350
+ var elementsToKeep = /* @__PURE__ */ new Set();
1351
+ var elementsToStop = new Set(targets);
1352
+ var keep = function(el) {
1353
+ if (!el || elementsToKeep.has(el)) {
1354
+ return;
1355
+ }
1356
+ elementsToKeep.add(el);
1357
+ keep(el.parentNode);
1358
+ };
1359
+ targets.forEach(keep);
1360
+ var deep = function(parent) {
1361
+ if (!parent || elementsToStop.has(parent)) {
1362
+ return;
1363
+ }
1364
+ Array.prototype.forEach.call(parent.children, function(node) {
1365
+ if (elementsToKeep.has(node)) {
1366
+ deep(node);
1367
+ } else {
1368
+ try {
1369
+ var attr = node.getAttribute(controlAttribute);
1370
+ var alreadyHidden = attr !== null && attr !== "false";
1371
+ var counterValue = (counterMap.get(node) || 0) + 1;
1372
+ var markerValue = (markerCounter.get(node) || 0) + 1;
1373
+ counterMap.set(node, counterValue);
1374
+ markerCounter.set(node, markerValue);
1375
+ hiddenNodes.push(node);
1376
+ if (counterValue === 1 && alreadyHidden) {
1377
+ uncontrolledNodes.set(node, true);
1378
+ }
1379
+ if (markerValue === 1) {
1380
+ node.setAttribute(markerName, "true");
1381
+ }
1382
+ if (!alreadyHidden) {
1383
+ node.setAttribute(controlAttribute, "true");
1384
+ }
1385
+ } catch (e) {
1386
+ console.error("aria-hidden: cannot operate on ", node, e);
1387
+ }
1388
+ }
1389
+ });
1390
+ };
1391
+ deep(parentNode);
1392
+ elementsToKeep.clear();
1393
+ lockCount++;
1394
+ return function() {
1395
+ hiddenNodes.forEach(function(node) {
1396
+ var counterValue = counterMap.get(node) - 1;
1397
+ var markerValue = markerCounter.get(node) - 1;
1398
+ counterMap.set(node, counterValue);
1399
+ markerCounter.set(node, markerValue);
1400
+ if (!counterValue) {
1401
+ if (!uncontrolledNodes.has(node)) {
1402
+ node.removeAttribute(controlAttribute);
1403
+ }
1404
+ uncontrolledNodes.delete(node);
1405
+ }
1406
+ if (!markerValue) {
1407
+ node.removeAttribute(markerName);
1408
+ }
1409
+ });
1410
+ lockCount--;
1411
+ if (!lockCount) {
1412
+ counterMap = /* @__PURE__ */ new WeakMap();
1413
+ counterMap = /* @__PURE__ */ new WeakMap();
1414
+ uncontrolledNodes = /* @__PURE__ */ new WeakMap();
1415
+ markerMap = {};
1416
+ }
1417
+ };
1418
+ };
1419
+ var hideOthers = function(originalTarget, parentNode, markerName) {
1420
+ if (markerName === void 0) {
1421
+ markerName = "data-aria-hidden";
1422
+ }
1423
+ var targets = Array.from(Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
1424
+ var activeParentNode = getDefaultParent(originalTarget);
1425
+ if (!activeParentNode) {
1426
+ return function() {
1427
+ return null;
1428
+ };
1429
+ }
1430
+ targets.push.apply(targets, Array.from(activeParentNode.querySelectorAll("[aria-live]")));
1431
+ return applyAttributeToOthers(targets, activeParentNode, markerName, "aria-hidden");
1432
+ };
1433
+ var DIALOG_NAME = "Dialog";
1434
+ var [createDialogContext, createDialogScope] = createContextScope(DIALOG_NAME);
1435
+ var [DialogProvider, useDialogContext] = createDialogContext(DIALOG_NAME);
1436
+ var Dialog$1 = (props) => {
1437
+ const {
1438
+ __scopeDialog,
1439
+ children,
1440
+ open: openProp,
1441
+ defaultOpen,
1442
+ onOpenChange,
1443
+ modal = true
1444
+ } = props;
1445
+ const triggerRef = React.useRef(null);
1446
+ const contentRef = React.useRef(null);
1447
+ const [open = false, setOpen] = useControllableState({
1448
+ prop: openProp,
1449
+ defaultProp: defaultOpen,
1450
+ onChange: onOpenChange
1451
+ });
1452
+ return /* @__PURE__ */ jsx(
1453
+ DialogProvider,
1454
+ {
1455
+ scope: __scopeDialog,
1456
+ triggerRef,
1457
+ contentRef,
1458
+ contentId: useId(),
1459
+ titleId: useId(),
1460
+ descriptionId: useId(),
1461
+ open,
1462
+ onOpenChange: setOpen,
1463
+ onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
1464
+ modal,
1465
+ children
1466
+ }
1467
+ );
1468
+ };
1469
+ Dialog$1.displayName = DIALOG_NAME;
1470
+ var TRIGGER_NAME = "DialogTrigger";
1471
+ var DialogTrigger$1 = React.forwardRef(
1472
+ (props, forwardedRef) => {
1473
+ const { __scopeDialog, ...triggerProps } = props;
1474
+ const context = useDialogContext(TRIGGER_NAME, __scopeDialog);
1475
+ const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);
1476
+ return /* @__PURE__ */ jsx(
1477
+ Primitive.button,
1478
+ {
1479
+ type: "button",
1480
+ "aria-haspopup": "dialog",
1481
+ "aria-expanded": context.open,
1482
+ "aria-controls": context.contentId,
1483
+ "data-state": getState(context.open),
1484
+ ...triggerProps,
1485
+ ref: composedTriggerRef,
1486
+ onClick: composeEventHandlers(props.onClick, context.onOpenToggle)
1487
+ }
1488
+ );
1489
+ }
1490
+ );
1491
+ DialogTrigger$1.displayName = TRIGGER_NAME;
1492
+ var PORTAL_NAME = "DialogPortal";
1493
+ var [PortalProvider, usePortalContext] = createDialogContext(PORTAL_NAME, {
1494
+ forceMount: void 0
1495
+ });
1496
+ var DialogPortal$1 = (props) => {
1497
+ const { __scopeDialog, forceMount, children, container } = props;
1498
+ const context = useDialogContext(PORTAL_NAME, __scopeDialog);
1499
+ return /* @__PURE__ */ jsx(PortalProvider, { scope: __scopeDialog, forceMount, children: React.Children.map(children, (child) => /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(Portal$1, { asChild: true, container, children: child }) })) });
1500
+ };
1501
+ DialogPortal$1.displayName = PORTAL_NAME;
1502
+ var OVERLAY_NAME = "DialogOverlay";
1503
+ var DialogOverlay$1 = React.forwardRef(
1504
+ (props, forwardedRef) => {
1505
+ const portalContext = usePortalContext(OVERLAY_NAME, props.__scopeDialog);
1506
+ const { forceMount = portalContext.forceMount, ...overlayProps } = props;
1507
+ const context = useDialogContext(OVERLAY_NAME, props.__scopeDialog);
1508
+ return context.modal ? /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(DialogOverlayImpl, { ...overlayProps, ref: forwardedRef }) }) : null;
1509
+ }
1510
+ );
1511
+ DialogOverlay$1.displayName = OVERLAY_NAME;
1512
+ var DialogOverlayImpl = React.forwardRef(
1513
+ (props, forwardedRef) => {
1514
+ const { __scopeDialog, ...overlayProps } = props;
1515
+ const context = useDialogContext(OVERLAY_NAME, __scopeDialog);
1516
+ return (
1517
+ // Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
1518
+ // ie. when `Overlay` and `Content` are siblings
1519
+ /* @__PURE__ */ jsx(ReactRemoveScroll, { as: Slot, allowPinchZoom: true, shards: [context.contentRef], children: /* @__PURE__ */ jsx(
1520
+ Primitive.div,
1521
+ {
1522
+ "data-state": getState(context.open),
1523
+ ...overlayProps,
1524
+ ref: forwardedRef,
1525
+ style: { pointerEvents: "auto", ...overlayProps.style }
1526
+ }
1527
+ ) })
1528
+ );
1529
+ }
1530
+ );
1531
+ var CONTENT_NAME = "DialogContent";
1532
+ var DialogContent$1 = React.forwardRef(
1533
+ (props, forwardedRef) => {
1534
+ const portalContext = usePortalContext(CONTENT_NAME, props.__scopeDialog);
1535
+ const { forceMount = portalContext.forceMount, ...contentProps } = props;
1536
+ const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
1537
+ return /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: context.modal ? /* @__PURE__ */ jsx(DialogContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsx(DialogContentNonModal, { ...contentProps, ref: forwardedRef }) });
1538
+ }
1539
+ );
1540
+ DialogContent$1.displayName = CONTENT_NAME;
1541
+ var DialogContentModal = React.forwardRef(
1542
+ (props, forwardedRef) => {
1543
+ const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
1544
+ const contentRef = React.useRef(null);
1545
+ const composedRefs = useComposedRefs(forwardedRef, context.contentRef, contentRef);
1546
+ React.useEffect(() => {
1547
+ const content = contentRef.current;
1548
+ if (content)
1549
+ return hideOthers(content);
1550
+ }, []);
1551
+ return /* @__PURE__ */ jsx(
1552
+ DialogContentImpl,
1553
+ {
1554
+ ...props,
1555
+ ref: composedRefs,
1556
+ trapFocus: context.open,
1557
+ disableOutsidePointerEvents: true,
1558
+ onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
1559
+ var _a;
1560
+ event.preventDefault();
1561
+ (_a = context.triggerRef.current) == null ? void 0 : _a.focus();
1562
+ }),
1563
+ onPointerDownOutside: composeEventHandlers(props.onPointerDownOutside, (event) => {
1564
+ const originalEvent = event.detail.originalEvent;
1565
+ const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
1566
+ const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
1567
+ if (isRightClick)
1568
+ event.preventDefault();
1569
+ }),
1570
+ onFocusOutside: composeEventHandlers(
1571
+ props.onFocusOutside,
1572
+ (event) => event.preventDefault()
1573
+ )
1574
+ }
1575
+ );
1576
+ }
1577
+ );
1578
+ var DialogContentNonModal = React.forwardRef(
1579
+ (props, forwardedRef) => {
1580
+ const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
1581
+ const hasInteractedOutsideRef = React.useRef(false);
1582
+ const hasPointerDownOutsideRef = React.useRef(false);
1583
+ return /* @__PURE__ */ jsx(
1584
+ DialogContentImpl,
1585
+ {
1586
+ ...props,
1587
+ ref: forwardedRef,
1588
+ trapFocus: false,
1589
+ disableOutsidePointerEvents: false,
1590
+ onCloseAutoFocus: (event) => {
1591
+ var _a, _b;
1592
+ (_a = props.onCloseAutoFocus) == null ? void 0 : _a.call(props, event);
1593
+ if (!event.defaultPrevented) {
1594
+ if (!hasInteractedOutsideRef.current)
1595
+ (_b = context.triggerRef.current) == null ? void 0 : _b.focus();
1596
+ event.preventDefault();
1597
+ }
1598
+ hasInteractedOutsideRef.current = false;
1599
+ hasPointerDownOutsideRef.current = false;
1600
+ },
1601
+ onInteractOutside: (event) => {
1602
+ var _a, _b;
1603
+ (_a = props.onInteractOutside) == null ? void 0 : _a.call(props, event);
1604
+ if (!event.defaultPrevented) {
1605
+ hasInteractedOutsideRef.current = true;
1606
+ if (event.detail.originalEvent.type === "pointerdown") {
1607
+ hasPointerDownOutsideRef.current = true;
1608
+ }
1609
+ }
1610
+ const target = event.target;
1611
+ const targetIsTrigger = (_b = context.triggerRef.current) == null ? void 0 : _b.contains(target);
1612
+ if (targetIsTrigger)
1613
+ event.preventDefault();
1614
+ if (event.detail.originalEvent.type === "focusin" && hasPointerDownOutsideRef.current) {
1615
+ event.preventDefault();
1616
+ }
1617
+ }
1618
+ }
1619
+ );
1620
+ }
1621
+ );
1622
+ var DialogContentImpl = React.forwardRef(
1623
+ (props, forwardedRef) => {
1624
+ const { __scopeDialog, trapFocus, onOpenAutoFocus, onCloseAutoFocus, ...contentProps } = props;
1625
+ const context = useDialogContext(CONTENT_NAME, __scopeDialog);
1626
+ const contentRef = React.useRef(null);
1627
+ const composedRefs = useComposedRefs(forwardedRef, contentRef);
1628
+ useFocusGuards();
1629
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1630
+ /* @__PURE__ */ jsx(
1631
+ FocusScope,
1632
+ {
1633
+ asChild: true,
1634
+ loop: true,
1635
+ trapped: trapFocus,
1636
+ onMountAutoFocus: onOpenAutoFocus,
1637
+ onUnmountAutoFocus: onCloseAutoFocus,
1638
+ children: /* @__PURE__ */ jsx(
1639
+ DismissableLayer,
1640
+ {
1641
+ role: "dialog",
1642
+ id: context.contentId,
1643
+ "aria-describedby": context.descriptionId,
1644
+ "aria-labelledby": context.titleId,
1645
+ "data-state": getState(context.open),
1646
+ ...contentProps,
1647
+ ref: composedRefs,
1648
+ onDismiss: () => context.onOpenChange(false)
1649
+ }
1650
+ )
1651
+ }
1652
+ ),
1653
+ /* @__PURE__ */ jsxs(Fragment, { children: [
1654
+ /* @__PURE__ */ jsx(TitleWarning, { titleId: context.titleId }),
1655
+ /* @__PURE__ */ jsx(DescriptionWarning, { contentRef, descriptionId: context.descriptionId })
1656
+ ] })
1657
+ ] });
1658
+ }
1659
+ );
1660
+ var TITLE_NAME = "DialogTitle";
1661
+ var DialogTitle$1 = React.forwardRef(
1662
+ (props, forwardedRef) => {
1663
+ const { __scopeDialog, ...titleProps } = props;
1664
+ const context = useDialogContext(TITLE_NAME, __scopeDialog);
1665
+ return /* @__PURE__ */ jsx(Primitive.h2, { id: context.titleId, ...titleProps, ref: forwardedRef });
1666
+ }
1667
+ );
1668
+ DialogTitle$1.displayName = TITLE_NAME;
1669
+ var DESCRIPTION_NAME = "DialogDescription";
1670
+ var DialogDescription$1 = React.forwardRef(
1671
+ (props, forwardedRef) => {
1672
+ const { __scopeDialog, ...descriptionProps } = props;
1673
+ const context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);
1674
+ return /* @__PURE__ */ jsx(Primitive.p, { id: context.descriptionId, ...descriptionProps, ref: forwardedRef });
1675
+ }
1676
+ );
1677
+ DialogDescription$1.displayName = DESCRIPTION_NAME;
1678
+ var CLOSE_NAME = "DialogClose";
1679
+ var DialogClose$1 = React.forwardRef(
1680
+ (props, forwardedRef) => {
1681
+ const { __scopeDialog, ...closeProps } = props;
1682
+ const context = useDialogContext(CLOSE_NAME, __scopeDialog);
1683
+ return /* @__PURE__ */ jsx(
1684
+ Primitive.button,
1685
+ {
1686
+ type: "button",
1687
+ ...closeProps,
1688
+ ref: forwardedRef,
1689
+ onClick: composeEventHandlers(props.onClick, () => context.onOpenChange(false))
1690
+ }
1691
+ );
1692
+ }
1693
+ );
1694
+ DialogClose$1.displayName = CLOSE_NAME;
1695
+ function getState(open) {
1696
+ return open ? "open" : "closed";
1697
+ }
1698
+ var TITLE_WARNING_NAME = "DialogTitleWarning";
1699
+ var [WarningProvider, useWarningContext] = createContext2(TITLE_WARNING_NAME, {
1700
+ contentName: CONTENT_NAME,
1701
+ titleName: TITLE_NAME,
1702
+ docsSlug: "dialog"
1703
+ });
1704
+ var TitleWarning = ({ titleId }) => {
1705
+ const titleWarningContext = useWarningContext(TITLE_WARNING_NAME);
1706
+ const MESSAGE = `\`${titleWarningContext.contentName}\` requires a \`${titleWarningContext.titleName}\` for the component to be accessible for screen reader users.
1707
+
1708
+ If you want to hide the \`${titleWarningContext.titleName}\`, you can wrap it with our VisuallyHidden component.
1709
+
1710
+ For more information, see https://radix-ui.com/primitives/docs/components/${titleWarningContext.docsSlug}`;
1711
+ React.useEffect(() => {
1712
+ if (titleId) {
1713
+ const hasTitle = document.getElementById(titleId);
1714
+ if (!hasTitle)
1715
+ console.error(MESSAGE);
1716
+ }
1717
+ }, [MESSAGE, titleId]);
1718
+ return null;
1719
+ };
1720
+ var DESCRIPTION_WARNING_NAME = "DialogDescriptionWarning";
1721
+ var DescriptionWarning = ({ contentRef, descriptionId }) => {
1722
+ const descriptionWarningContext = useWarningContext(DESCRIPTION_WARNING_NAME);
1723
+ const MESSAGE = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${descriptionWarningContext.contentName}}.`;
1724
+ React.useEffect(() => {
1725
+ var _a;
1726
+ const describedById = (_a = contentRef.current) == null ? void 0 : _a.getAttribute("aria-describedby");
1727
+ if (descriptionId && describedById) {
1728
+ const hasDescription = document.getElementById(descriptionId);
1729
+ if (!hasDescription)
1730
+ console.warn(MESSAGE);
1731
+ }
1732
+ }, [MESSAGE, contentRef, descriptionId]);
1733
+ return null;
1734
+ };
1735
+ var Root = Dialog$1;
1736
+ var Trigger = DialogTrigger$1;
1737
+ var Portal = DialogPortal$1;
1738
+ var Overlay = DialogOverlay$1;
1739
+ var Content = DialogContent$1;
1740
+ var Title = DialogTitle$1;
1741
+ var Description = DialogDescription$1;
1742
+ var Close = DialogClose$1;
1743
+ /**
1744
+ * @license lucide-react v0.456.0 - ISC
1745
+ *
1746
+ * This source code is licensed under the ISC license.
1747
+ * See the LICENSE file in the root directory of this source tree.
1748
+ */
1749
+ const toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
1750
+ const mergeClasses = (...classes) => classes.filter((className, index, array) => {
1751
+ return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
1752
+ }).join(" ").trim();
1753
+ /**
1754
+ * @license lucide-react v0.456.0 - ISC
1755
+ *
1756
+ * This source code is licensed under the ISC license.
1757
+ * See the LICENSE file in the root directory of this source tree.
1758
+ */
1759
+ var defaultAttributes = {
1760
+ xmlns: "http://www.w3.org/2000/svg",
1761
+ width: 24,
1762
+ height: 24,
1763
+ viewBox: "0 0 24 24",
1764
+ fill: "none",
1765
+ stroke: "currentColor",
1766
+ strokeWidth: 2,
1767
+ strokeLinecap: "round",
1768
+ strokeLinejoin: "round"
1769
+ };
1770
+ /**
1771
+ * @license lucide-react v0.456.0 - ISC
1772
+ *
1773
+ * This source code is licensed under the ISC license.
1774
+ * See the LICENSE file in the root directory of this source tree.
1775
+ */
1776
+ const Icon = forwardRef(
1777
+ ({
1778
+ color = "currentColor",
1779
+ size = 24,
1780
+ strokeWidth = 2,
1781
+ absoluteStrokeWidth,
1782
+ className = "",
1783
+ children,
1784
+ iconNode,
1785
+ ...rest
1786
+ }, ref) => {
1787
+ return createElement(
1788
+ "svg",
1789
+ {
1790
+ ref,
1791
+ ...defaultAttributes,
1792
+ width: size,
1793
+ height: size,
1794
+ stroke: color,
1795
+ strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
1796
+ className: mergeClasses("lucide", className),
1797
+ ...rest
1798
+ },
1799
+ [
1800
+ ...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),
1801
+ ...Array.isArray(children) ? children : [children]
1802
+ ]
1803
+ );
1804
+ }
1805
+ );
1806
+ /**
1807
+ * @license lucide-react v0.456.0 - ISC
1808
+ *
1809
+ * This source code is licensed under the ISC license.
1810
+ * See the LICENSE file in the root directory of this source tree.
1811
+ */
1812
+ const createLucideIcon = (iconName, iconNode) => {
1813
+ const Component = forwardRef(
1814
+ ({ className, ...props }, ref) => createElement(Icon, {
1815
+ ref,
1816
+ iconNode,
1817
+ className: mergeClasses(`lucide-${toKebabCase(iconName)}`, className),
1818
+ ...props
1819
+ })
1820
+ );
1821
+ Component.displayName = `${iconName}`;
1822
+ return Component;
1823
+ };
1824
+ /**
1825
+ * @license lucide-react v0.456.0 - ISC
1826
+ *
1827
+ * This source code is licensed under the ISC license.
1828
+ * See the LICENSE file in the root directory of this source tree.
1829
+ */
1830
+ const X = createLucideIcon("X", [
1831
+ ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
1832
+ ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
1833
+ ]);
1834
+ const Dialog = Root;
1835
+ const DialogTrigger = Trigger;
1836
+ const DialogPortal = Portal;
1837
+ const DialogClose = Close;
1838
+ const DialogOverlay = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1839
+ Overlay,
1840
+ {
1841
+ ref,
1842
+ className: cn(
1843
+ "fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
1844
+ className
1845
+ ),
1846
+ ...props
1847
+ }
1848
+ ));
1849
+ DialogOverlay.displayName = Overlay.displayName;
1850
+ const DialogContent = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(DialogPortal, { children: [
1851
+ /* @__PURE__ */ jsx(DialogOverlay, {}),
1852
+ /* @__PURE__ */ jsxs(
1853
+ Content,
1854
+ {
1855
+ ref,
1856
+ className: cn(
1857
+ "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-white p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
1858
+ className
1859
+ ),
1860
+ ...props,
1861
+ children: [
1862
+ children,
1863
+ /* @__PURE__ */ jsxs(Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground", children: [
1864
+ /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }),
1865
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
1866
+ ] })
1867
+ ]
1868
+ }
1869
+ )
1870
+ ] }));
1871
+ DialogContent.displayName = Content.displayName;
1872
+ const DialogHeader = ({
1873
+ className,
1874
+ ...props
1875
+ }) => /* @__PURE__ */ jsx(
1876
+ "div",
1877
+ {
1878
+ className: cn("flex flex-col space-y-1.5 sm:text-left", className),
1879
+ ...props
1880
+ }
1881
+ );
1882
+ DialogHeader.displayName = "DialogHeader";
1883
+ const DialogFooter = ({
1884
+ className,
1885
+ ...props
1886
+ }) => /* @__PURE__ */ jsx(
1887
+ "div",
1888
+ {
1889
+ className: cn(
1890
+ "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
1891
+ className
1892
+ ),
1893
+ ...props
1894
+ }
1895
+ );
1896
+ DialogFooter.displayName = "DialogFooter";
1897
+ const DialogTitle = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1898
+ Title,
1899
+ {
1900
+ ref,
1901
+ className: cn(
1902
+ "text-lg font-semibold leading-none tracking-tight",
1903
+ className
1904
+ ),
1905
+ ...props
1906
+ }
1907
+ ));
1908
+ DialogTitle.displayName = Title.displayName;
1909
+ const DialogDescription = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1910
+ Description,
1911
+ {
1912
+ ref,
1913
+ className: cn("text-sm text-muted-foreground", className),
1914
+ ...props
1915
+ }
1916
+ ));
1917
+ DialogDescription.displayName = Description.displayName;
1918
+ export {
1919
+ Dialog as D,
1920
+ __awaiter as _,
1921
+ DialogPortal as a,
1922
+ DialogOverlay as b,
1923
+ DialogClose as c,
1924
+ DialogTrigger as d,
1925
+ DialogContent as e,
1926
+ DialogHeader as f,
1927
+ DialogFooter as g,
1928
+ DialogTitle as h,
1929
+ DialogDescription as i,
1930
+ __generator as j,
1931
+ __spreadArray as k,
1932
+ __read as l
1933
+ };
1934
+ //# sourceMappingURL=Dialog-BIo5644U.js.map