PluginProbe
Gutenberg / 23.3.1
Gutenberg v23.3.1
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / build / widgets / activity / render.js

render.js in Gutenberg 23.3.1, at build/widgets/activity/render.js

26,694 lines 918.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var __create = Object.create;
2 var __defProp = Object.defineProperty;
3 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4 var __getOwnPropNames = Object.getOwnPropertyNames;
5 var __getProtoOf = Object.getPrototypeOf;
6 var __hasOwnProp = Object.prototype.hasOwnProperty;
7 var __commonJS = (cb, mod) => function __require() {
8 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9 };
10 var __export = (target, all) => {
11 for (var name in all)
12 __defProp(target, name, { get: all[name], enumerable: true });
13 };
14 var __copyProps = (to, from, except, desc) => {
15 if (from && typeof from === "object" || typeof from === "function") {
16 for (let key of __getOwnPropNames(from))
17 if (!__hasOwnProp.call(to, key) && key !== except)
18 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19 }
20 return to;
21 };
22 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23 // If the importer is in node compatibility mode or this is not an ESM
24 // file that has been converted to a CommonJS file using a Babel-
25 // compatible transform (i.e. "__esModule" has not been set), then set
26 // "default" to the CommonJS "module.exports" for node compatibility.
27 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28 mod
29 ));
30
31 // package-external:@wordpress/element
32 var require_element = __commonJS({
33 "package-external:@wordpress/element"(exports, module) {
34 module.exports = window.wp.element;
35 }
36 });
37
38 // package-external:@wordpress/data
39 var require_data = __commonJS({
40 "package-external:@wordpress/data"(exports, module) {
41 module.exports = window.wp.data;
42 }
43 });
44
45 // package-external:@wordpress/core-data
46 var require_core_data = __commonJS({
47 "package-external:@wordpress/core-data"(exports, module) {
48 module.exports = window.wp.coreData;
49 }
50 });
51
52 // package-external:@wordpress/i18n
53 var require_i18n = __commonJS({
54 "package-external:@wordpress/i18n"(exports, module) {
55 module.exports = window.wp.i18n;
56 }
57 });
58
59 // package-external:@wordpress/date
60 var require_date = __commonJS({
61 "package-external:@wordpress/date"(exports, module) {
62 module.exports = window.wp.date;
63 }
64 });
65
66 // package-external:@wordpress/html-entities
67 var require_html_entities = __commonJS({
68 "package-external:@wordpress/html-entities"(exports, module) {
69 module.exports = window.wp.htmlEntities;
70 }
71 });
72
73 // package-external:@wordpress/components
74 var require_components = __commonJS({
75 "package-external:@wordpress/components"(exports, module) {
76 module.exports = window.wp.components;
77 }
78 });
79
80 // package-external:@wordpress/primitives
81 var require_primitives = __commonJS({
82 "package-external:@wordpress/primitives"(exports, module) {
83 module.exports = window.wp.primitives;
84 }
85 });
86
87 // vendor-external:react/jsx-runtime
88 var require_jsx_runtime = __commonJS({
89 "vendor-external:react/jsx-runtime"(exports, module) {
90 module.exports = window.ReactJSXRuntime;
91 }
92 });
93
94 // package-external:@wordpress/compose
95 var require_compose = __commonJS({
96 "package-external:@wordpress/compose"(exports, module) {
97 module.exports = window.wp.compose;
98 }
99 });
100
101 // vendor-external:react
102 var require_react = __commonJS({
103 "vendor-external:react"(exports, module) {
104 module.exports = window.React;
105 }
106 });
107
108 // vendor-external:react-dom
109 var require_react_dom = __commonJS({
110 "vendor-external:react-dom"(exports, module) {
111 module.exports = window.ReactDOM;
112 }
113 });
114
115 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
116 var require_use_sync_external_store_shim_development = __commonJS({
117 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
118 "use strict";
119 (function() {
120 function is(x2, y2) {
121 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
122 }
123 function useSyncExternalStore$2(subscribe2, getSnapshot) {
124 didWarnOld18Alpha || void 0 === React51.startTransition || (didWarnOld18Alpha = true, console.error(
125 "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
126 ));
127 var value = getSnapshot();
128 if (!didWarnUncachedGetSnapshot) {
129 var cachedValue = getSnapshot();
130 objectIs(value, cachedValue) || (console.error(
131 "The result of getSnapshot should be cached to avoid an infinite loop"
132 ), didWarnUncachedGetSnapshot = true);
133 }
134 cachedValue = useState36({
135 inst: { value, getSnapshot }
136 });
137 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
138 useLayoutEffect6(
139 function() {
140 inst.value = value;
141 inst.getSnapshot = getSnapshot;
142 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
143 },
144 [subscribe2, value, getSnapshot]
145 );
146 useEffect31(
147 function() {
148 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
149 return subscribe2(function() {
150 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
151 });
152 },
153 [subscribe2]
154 );
155 useDebugValue2(value);
156 return value;
157 }
158 function checkIfSnapshotChanged(inst) {
159 var latestGetSnapshot = inst.getSnapshot;
160 inst = inst.value;
161 try {
162 var nextValue = latestGetSnapshot();
163 return !objectIs(inst, nextValue);
164 } catch (error) {
165 return true;
166 }
167 }
168 function useSyncExternalStore$1(subscribe2, getSnapshot) {
169 return getSnapshot();
170 }
171 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
172 var React51 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState36 = React51.useState, useEffect31 = React51.useEffect, useLayoutEffect6 = React51.useLayoutEffect, useDebugValue2 = React51.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
173 exports.useSyncExternalStore = void 0 !== React51.useSyncExternalStore ? React51.useSyncExternalStore : shim;
174 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
175 })();
176 }
177 });
178
179 // node_modules/use-sync-external-store/shim/index.js
180 var require_shim = __commonJS({
181 "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
182 "use strict";
183 if (false) {
184 module.exports = null;
185 } else {
186 module.exports = require_use_sync_external_store_shim_development();
187 }
188 }
189 });
190
191 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
192 var require_with_selector_development = __commonJS({
193 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) {
194 "use strict";
195 (function() {
196 function is(x2, y2) {
197 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
198 }
199 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
200 var React51 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore3 = shim.useSyncExternalStore, useRef44 = React51.useRef, useEffect31 = React51.useEffect, useMemo40 = React51.useMemo, useDebugValue2 = React51.useDebugValue;
201 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector2, isEqual) {
202 var instRef = useRef44(null);
203 if (null === instRef.current) {
204 var inst = { hasValue: false, value: null };
205 instRef.current = inst;
206 } else inst = instRef.current;
207 instRef = useMemo40(
208 function() {
209 function memoizedSelector(nextSnapshot) {
210 if (!hasMemo) {
211 hasMemo = true;
212 memoizedSnapshot = nextSnapshot;
213 nextSnapshot = selector2(nextSnapshot);
214 if (void 0 !== isEqual && inst.hasValue) {
215 var currentSelection = inst.value;
216 if (isEqual(currentSelection, nextSnapshot))
217 return memoizedSelection = currentSelection;
218 }
219 return memoizedSelection = nextSnapshot;
220 }
221 currentSelection = memoizedSelection;
222 if (objectIs(memoizedSnapshot, nextSnapshot))
223 return currentSelection;
224 var nextSelection = selector2(nextSnapshot);
225 if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
226 return memoizedSnapshot = nextSnapshot, currentSelection;
227 memoizedSnapshot = nextSnapshot;
228 return memoizedSelection = nextSelection;
229 }
230 var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
231 return [
232 function() {
233 return memoizedSelector(getSnapshot());
234 },
235 null === maybeGetServerSnapshot ? void 0 : function() {
236 return memoizedSelector(maybeGetServerSnapshot());
237 }
238 ];
239 },
240 [getSnapshot, getServerSnapshot, selector2, isEqual]
241 );
242 var value = useSyncExternalStore3(subscribe2, instRef[0], instRef[1]);
243 useEffect31(
244 function() {
245 inst.hasValue = true;
246 inst.value = value;
247 },
248 [value]
249 );
250 useDebugValue2(value);
251 return value;
252 };
253 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
254 })();
255 }
256 });
257
258 // node_modules/use-sync-external-store/shim/with-selector.js
259 var require_with_selector = __commonJS({
260 "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) {
261 "use strict";
262 if (false) {
263 module.exports = null;
264 } else {
265 module.exports = require_with_selector_development();
266 }
267 }
268 });
269
270 // package-external:@wordpress/theme
271 var require_theme = __commonJS({
272 "package-external:@wordpress/theme"(exports, module) {
273 module.exports = window.wp.theme;
274 }
275 });
276
277 // package-external:@wordpress/private-apis
278 var require_private_apis = __commonJS({
279 "package-external:@wordpress/private-apis"(exports, module) {
280 module.exports = window.wp.privateApis;
281 }
282 });
283
284 // package-external:@wordpress/keycodes
285 var require_keycodes = __commonJS({
286 "package-external:@wordpress/keycodes"(exports, module) {
287 module.exports = window.wp.keycodes;
288 }
289 });
290
291 // node_modules/remove-accents/index.js
292 var require_remove_accents = __commonJS({
293 "node_modules/remove-accents/index.js"(exports, module) {
294 var characterMap = {
295 "\xC0": "A",
296 "\xC1": "A",
297 "\xC2": "A",
298 "\xC3": "A",
299 "\xC4": "A",
300 "\xC5": "A",
301 "\u1EA4": "A",
302 "\u1EAE": "A",
303 "\u1EB2": "A",
304 "\u1EB4": "A",
305 "\u1EB6": "A",
306 "\xC6": "AE",
307 "\u1EA6": "A",
308 "\u1EB0": "A",
309 "\u0202": "A",
310 "\u1EA2": "A",
311 "\u1EA0": "A",
312 "\u1EA8": "A",
313 "\u1EAA": "A",
314 "\u1EAC": "A",
315 "\xC7": "C",
316 "\u1E08": "C",
317 "\xC8": "E",
318 "\xC9": "E",
319 "\xCA": "E",
320 "\xCB": "E",
321 "\u1EBE": "E",
322 "\u1E16": "E",
323 "\u1EC0": "E",
324 "\u1E14": "E",
325 "\u1E1C": "E",
326 "\u0206": "E",
327 "\u1EBA": "E",
328 "\u1EBC": "E",
329 "\u1EB8": "E",
330 "\u1EC2": "E",
331 "\u1EC4": "E",
332 "\u1EC6": "E",
333 "\xCC": "I",
334 "\xCD": "I",
335 "\xCE": "I",
336 "\xCF": "I",
337 "\u1E2E": "I",
338 "\u020A": "I",
339 "\u1EC8": "I",
340 "\u1ECA": "I",
341 "\xD0": "D",
342 "\xD1": "N",
343 "\xD2": "O",
344 "\xD3": "O",
345 "\xD4": "O",
346 "\xD5": "O",
347 "\xD6": "O",
348 "\xD8": "O",
349 "\u1ED0": "O",
350 "\u1E4C": "O",
351 "\u1E52": "O",
352 "\u020E": "O",
353 "\u1ECE": "O",
354 "\u1ECC": "O",
355 "\u1ED4": "O",
356 "\u1ED6": "O",
357 "\u1ED8": "O",
358 "\u1EDC": "O",
359 "\u1EDE": "O",
360 "\u1EE0": "O",
361 "\u1EDA": "O",
362 "\u1EE2": "O",
363 "\xD9": "U",
364 "\xDA": "U",
365 "\xDB": "U",
366 "\xDC": "U",
367 "\u1EE6": "U",
368 "\u1EE4": "U",
369 "\u1EEC": "U",
370 "\u1EEE": "U",
371 "\u1EF0": "U",
372 "\xDD": "Y",
373 "\xE0": "a",
374 "\xE1": "a",
375 "\xE2": "a",
376 "\xE3": "a",
377 "\xE4": "a",
378 "\xE5": "a",
379 "\u1EA5": "a",
380 "\u1EAF": "a",
381 "\u1EB3": "a",
382 "\u1EB5": "a",
383 "\u1EB7": "a",
384 "\xE6": "ae",
385 "\u1EA7": "a",
386 "\u1EB1": "a",
387 "\u0203": "a",
388 "\u1EA3": "a",
389 "\u1EA1": "a",
390 "\u1EA9": "a",
391 "\u1EAB": "a",
392 "\u1EAD": "a",
393 "\xE7": "c",
394 "\u1E09": "c",
395 "\xE8": "e",
396 "\xE9": "e",
397 "\xEA": "e",
398 "\xEB": "e",
399 "\u1EBF": "e",
400 "\u1E17": "e",
401 "\u1EC1": "e",
402 "\u1E15": "e",
403 "\u1E1D": "e",
404 "\u0207": "e",
405 "\u1EBB": "e",
406 "\u1EBD": "e",
407 "\u1EB9": "e",
408 "\u1EC3": "e",
409 "\u1EC5": "e",
410 "\u1EC7": "e",
411 "\xEC": "i",
412 "\xED": "i",
413 "\xEE": "i",
414 "\xEF": "i",
415 "\u1E2F": "i",
416 "\u020B": "i",
417 "\u1EC9": "i",
418 "\u1ECB": "i",
419 "\xF0": "d",
420 "\xF1": "n",
421 "\xF2": "o",
422 "\xF3": "o",
423 "\xF4": "o",
424 "\xF5": "o",
425 "\xF6": "o",
426 "\xF8": "o",
427 "\u1ED1": "o",
428 "\u1E4D": "o",
429 "\u1E53": "o",
430 "\u020F": "o",
431 "\u1ECF": "o",
432 "\u1ECD": "o",
433 "\u1ED5": "o",
434 "\u1ED7": "o",
435 "\u1ED9": "o",
436 "\u1EDD": "o",
437 "\u1EDF": "o",
438 "\u1EE1": "o",
439 "\u1EDB": "o",
440 "\u1EE3": "o",
441 "\xF9": "u",
442 "\xFA": "u",
443 "\xFB": "u",
444 "\xFC": "u",
445 "\u1EE7": "u",
446 "\u1EE5": "u",
447 "\u1EED": "u",
448 "\u1EEF": "u",
449 "\u1EF1": "u",
450 "\xFD": "y",
451 "\xFF": "y",
452 "\u0100": "A",
453 "\u0101": "a",
454 "\u0102": "A",
455 "\u0103": "a",
456 "\u0104": "A",
457 "\u0105": "a",
458 "\u0106": "C",
459 "\u0107": "c",
460 "\u0108": "C",
461 "\u0109": "c",
462 "\u010A": "C",
463 "\u010B": "c",
464 "\u010C": "C",
465 "\u010D": "c",
466 "C\u0306": "C",
467 "c\u0306": "c",
468 "\u010E": "D",
469 "\u010F": "d",
470 "\u0110": "D",
471 "\u0111": "d",
472 "\u0112": "E",
473 "\u0113": "e",
474 "\u0114": "E",
475 "\u0115": "e",
476 "\u0116": "E",
477 "\u0117": "e",
478 "\u0118": "E",
479 "\u0119": "e",
480 "\u011A": "E",
481 "\u011B": "e",
482 "\u011C": "G",
483 "\u01F4": "G",
484 "\u011D": "g",
485 "\u01F5": "g",
486 "\u011E": "G",
487 "\u011F": "g",
488 "\u0120": "G",
489 "\u0121": "g",
490 "\u0122": "G",
491 "\u0123": "g",
492 "\u0124": "H",
493 "\u0125": "h",
494 "\u0126": "H",
495 "\u0127": "h",
496 "\u1E2A": "H",
497 "\u1E2B": "h",
498 "\u0128": "I",
499 "\u0129": "i",
500 "\u012A": "I",
501 "\u012B": "i",
502 "\u012C": "I",
503 "\u012D": "i",
504 "\u012E": "I",
505 "\u012F": "i",
506 "\u0130": "I",
507 "\u0131": "i",
508 "\u0132": "IJ",
509 "\u0133": "ij",
510 "\u0134": "J",
511 "\u0135": "j",
512 "\u0136": "K",
513 "\u0137": "k",
514 "\u1E30": "K",
515 "\u1E31": "k",
516 "K\u0306": "K",
517 "k\u0306": "k",
518 "\u0139": "L",
519 "\u013A": "l",
520 "\u013B": "L",
521 "\u013C": "l",
522 "\u013D": "L",
523 "\u013E": "l",
524 "\u013F": "L",
525 "\u0140": "l",
526 "\u0141": "l",
527 "\u0142": "l",
528 "\u1E3E": "M",
529 "\u1E3F": "m",
530 "M\u0306": "M",
531 "m\u0306": "m",
532 "\u0143": "N",
533 "\u0144": "n",
534 "\u0145": "N",
535 "\u0146": "n",
536 "\u0147": "N",
537 "\u0148": "n",
538 "\u0149": "n",
539 "N\u0306": "N",
540 "n\u0306": "n",
541 "\u014C": "O",
542 "\u014D": "o",
543 "\u014E": "O",
544 "\u014F": "o",
545 "\u0150": "O",
546 "\u0151": "o",
547 "\u0152": "OE",
548 "\u0153": "oe",
549 "P\u0306": "P",
550 "p\u0306": "p",
551 "\u0154": "R",
552 "\u0155": "r",
553 "\u0156": "R",
554 "\u0157": "r",
555 "\u0158": "R",
556 "\u0159": "r",
557 "R\u0306": "R",
558 "r\u0306": "r",
559 "\u0212": "R",
560 "\u0213": "r",
561 "\u015A": "S",
562 "\u015B": "s",
563 "\u015C": "S",
564 "\u015D": "s",
565 "\u015E": "S",
566 "\u0218": "S",
567 "\u0219": "s",
568 "\u015F": "s",
569 "\u0160": "S",
570 "\u0161": "s",
571 "\u0162": "T",
572 "\u0163": "t",
573 "\u021B": "t",
574 "\u021A": "T",
575 "\u0164": "T",
576 "\u0165": "t",
577 "\u0166": "T",
578 "\u0167": "t",
579 "T\u0306": "T",
580 "t\u0306": "t",
581 "\u0168": "U",
582 "\u0169": "u",
583 "\u016A": "U",
584 "\u016B": "u",
585 "\u016C": "U",
586 "\u016D": "u",
587 "\u016E": "U",
588 "\u016F": "u",
589 "\u0170": "U",
590 "\u0171": "u",
591 "\u0172": "U",
592 "\u0173": "u",
593 "\u0216": "U",
594 "\u0217": "u",
595 "V\u0306": "V",
596 "v\u0306": "v",
597 "\u0174": "W",
598 "\u0175": "w",
599 "\u1E82": "W",
600 "\u1E83": "w",
601 "X\u0306": "X",
602 "x\u0306": "x",
603 "\u0176": "Y",
604 "\u0177": "y",
605 "\u0178": "Y",
606 "Y\u0306": "Y",
607 "y\u0306": "y",
608 "\u0179": "Z",
609 "\u017A": "z",
610 "\u017B": "Z",
611 "\u017C": "z",
612 "\u017D": "Z",
613 "\u017E": "z",
614 "\u017F": "s",
615 "\u0192": "f",
616 "\u01A0": "O",
617 "\u01A1": "o",
618 "\u01AF": "U",
619 "\u01B0": "u",
620 "\u01CD": "A",
621 "\u01CE": "a",
622 "\u01CF": "I",
623 "\u01D0": "i",
624 "\u01D1": "O",
625 "\u01D2": "o",
626 "\u01D3": "U",
627 "\u01D4": "u",
628 "\u01D5": "U",
629 "\u01D6": "u",
630 "\u01D7": "U",
631 "\u01D8": "u",
632 "\u01D9": "U",
633 "\u01DA": "u",
634 "\u01DB": "U",
635 "\u01DC": "u",
636 "\u1EE8": "U",
637 "\u1EE9": "u",
638 "\u1E78": "U",
639 "\u1E79": "u",
640 "\u01FA": "A",
641 "\u01FB": "a",
642 "\u01FC": "AE",
643 "\u01FD": "ae",
644 "\u01FE": "O",
645 "\u01FF": "o",
646 "\xDE": "TH",
647 "\xFE": "th",
648 "\u1E54": "P",
649 "\u1E55": "p",
650 "\u1E64": "S",
651 "\u1E65": "s",
652 "X\u0301": "X",
653 "x\u0301": "x",
654 "\u0403": "\u0413",
655 "\u0453": "\u0433",
656 "\u040C": "\u041A",
657 "\u045C": "\u043A",
658 "A\u030B": "A",
659 "a\u030B": "a",
660 "E\u030B": "E",
661 "e\u030B": "e",
662 "I\u030B": "I",
663 "i\u030B": "i",
664 "\u01F8": "N",
665 "\u01F9": "n",
666 "\u1ED2": "O",
667 "\u1ED3": "o",
668 "\u1E50": "O",
669 "\u1E51": "o",
670 "\u1EEA": "U",
671 "\u1EEB": "u",
672 "\u1E80": "W",
673 "\u1E81": "w",
674 "\u1EF2": "Y",
675 "\u1EF3": "y",
676 "\u0200": "A",
677 "\u0201": "a",
678 "\u0204": "E",
679 "\u0205": "e",
680 "\u0208": "I",
681 "\u0209": "i",
682 "\u020C": "O",
683 "\u020D": "o",
684 "\u0210": "R",
685 "\u0211": "r",
686 "\u0214": "U",
687 "\u0215": "u",
688 "B\u030C": "B",
689 "b\u030C": "b",
690 "\u010C\u0323": "C",
691 "\u010D\u0323": "c",
692 "\xCA\u030C": "E",
693 "\xEA\u030C": "e",
694 "F\u030C": "F",
695 "f\u030C": "f",
696 "\u01E6": "G",
697 "\u01E7": "g",
698 "\u021E": "H",
699 "\u021F": "h",
700 "J\u030C": "J",
701 "\u01F0": "j",
702 "\u01E8": "K",
703 "\u01E9": "k",
704 "M\u030C": "M",
705 "m\u030C": "m",
706 "P\u030C": "P",
707 "p\u030C": "p",
708 "Q\u030C": "Q",
709 "q\u030C": "q",
710 "\u0158\u0329": "R",
711 "\u0159\u0329": "r",
712 "\u1E66": "S",
713 "\u1E67": "s",
714 "V\u030C": "V",
715 "v\u030C": "v",
716 "W\u030C": "W",
717 "w\u030C": "w",
718 "X\u030C": "X",
719 "x\u030C": "x",
720 "Y\u030C": "Y",
721 "y\u030C": "y",
722 "A\u0327": "A",
723 "a\u0327": "a",
724 "B\u0327": "B",
725 "b\u0327": "b",
726 "\u1E10": "D",
727 "\u1E11": "d",
728 "\u0228": "E",
729 "\u0229": "e",
730 "\u0190\u0327": "E",
731 "\u025B\u0327": "e",
732 "\u1E28": "H",
733 "\u1E29": "h",
734 "I\u0327": "I",
735 "i\u0327": "i",
736 "\u0197\u0327": "I",
737 "\u0268\u0327": "i",
738 "M\u0327": "M",
739 "m\u0327": "m",
740 "O\u0327": "O",
741 "o\u0327": "o",
742 "Q\u0327": "Q",
743 "q\u0327": "q",
744 "U\u0327": "U",
745 "u\u0327": "u",
746 "X\u0327": "X",
747 "x\u0327": "x",
748 "Z\u0327": "Z",
749 "z\u0327": "z",
750 "\u0439": "\u0438",
751 "\u0419": "\u0418",
752 "\u0451": "\u0435",
753 "\u0401": "\u0415"
754 };
755 var chars = Object.keys(characterMap).join("|");
756 var allAccents = new RegExp(chars, "g");
757 var firstAccent = new RegExp(chars, "");
758 function matcher(match2) {
759 return characterMap[match2];
760 }
761 var removeAccents3 = function(string) {
762 return string.replace(allAccents, matcher);
763 };
764 var hasAccents = function(string) {
765 return !!string.match(firstAccent);
766 };
767 module.exports = removeAccents3;
768 module.exports.has = hasAccents;
769 module.exports.remove = removeAccents3;
770 }
771 });
772
773 // node_modules/fast-deep-equal/es6/index.js
774 var require_es6 = __commonJS({
775 "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
776 "use strict";
777 module.exports = function equal(a2, b2) {
778 if (a2 === b2) return true;
779 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
780 if (a2.constructor !== b2.constructor) return false;
781 var length, i2, keys;
782 if (Array.isArray(a2)) {
783 length = a2.length;
784 if (length != b2.length) return false;
785 for (i2 = length; i2-- !== 0; )
786 if (!equal(a2[i2], b2[i2])) return false;
787 return true;
788 }
789 if (a2 instanceof Map && b2 instanceof Map) {
790 if (a2.size !== b2.size) return false;
791 for (i2 of a2.entries())
792 if (!b2.has(i2[0])) return false;
793 for (i2 of a2.entries())
794 if (!equal(i2[1], b2.get(i2[0]))) return false;
795 return true;
796 }
797 if (a2 instanceof Set && b2 instanceof Set) {
798 if (a2.size !== b2.size) return false;
799 for (i2 of a2.entries())
800 if (!b2.has(i2[0])) return false;
801 return true;
802 }
803 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
804 length = a2.length;
805 if (length != b2.length) return false;
806 for (i2 = length; i2-- !== 0; )
807 if (a2[i2] !== b2[i2]) return false;
808 return true;
809 }
810 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
811 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
812 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
813 keys = Object.keys(a2);
814 length = keys.length;
815 if (length !== Object.keys(b2).length) return false;
816 for (i2 = length; i2-- !== 0; )
817 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
818 for (i2 = length; i2-- !== 0; ) {
819 var key = keys[i2];
820 if (!equal(a2[key], b2[key])) return false;
821 }
822 return true;
823 }
824 return a2 !== a2 && b2 !== b2;
825 };
826 }
827 });
828
829 // package-external:@wordpress/warning
830 var require_warning = __commonJS({
831 "package-external:@wordpress/warning"(exports, module) {
832 module.exports = window.wp.warning;
833 }
834 });
835
836 // package-external:@wordpress/deprecated
837 var require_deprecated = __commonJS({
838 "package-external:@wordpress/deprecated"(exports, module) {
839 module.exports = window.wp.deprecated;
840 }
841 });
842
843 // widgets/activity/render.tsx
844 var import_element81 = __toESM(require_element());
845 var import_data6 = __toESM(require_data());
846 var import_core_data = __toESM(require_core_data());
847 var import_i18n44 = __toESM(require_i18n());
848 var import_date10 = __toESM(require_date());
849 var import_html_entities = __toESM(require_html_entities());
850 var import_components45 = __toESM(require_components());
851
852 // packages/icons/build-module/icon/index.mjs
853 var import_element = __toESM(require_element(), 1);
854 var icon_default = (0, import_element.forwardRef)(
855 ({ icon, size: size4 = 24, ...props }, ref) => {
856 return (0, import_element.cloneElement)(
857 icon,
858 {
859 width: size4,
860 height: size4,
861 ...props,
862 ref
863 }
864 );
865 }
866 );
867
868 // packages/icons/build-module/library/arrow-down.mjs
869 var import_primitives = __toESM(require_primitives(), 1);
870 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
871 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.Path, { d: "m16.5 13.5-3.7 3.7V4h-1.5v13.2l-3.8-3.7-1 1 5.5 5.6 5.5-5.6z" }) });
872
873 // packages/icons/build-module/library/arrow-left.mjs
874 var import_primitives2 = __toESM(require_primitives(), 1);
875 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
876 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.Path, { d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" }) });
877
878 // packages/icons/build-module/library/arrow-right.mjs
879 var import_primitives3 = __toESM(require_primitives(), 1);
880 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
881 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.Path, { d: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) });
882
883 // packages/icons/build-module/library/arrow-up.mjs
884 var import_primitives4 = __toESM(require_primitives(), 1);
885 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
886 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) });
887
888 // packages/icons/build-module/library/block-table.mjs
889 var import_primitives5 = __toESM(require_primitives(), 1);
890 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
891 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.Path, { d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5 4.5h14c.3 0 .5.2.5.5v3.5h-15V5c0-.3.2-.5.5-.5zm8 5.5h6.5v3.5H13V10zm-1.5 3.5h-7V10h7v3.5zm-7 5.5v-4h7v4.5H5c-.3 0-.5-.2-.5-.5zm14.5.5h-6V15h6.5v4c0 .3-.2.5-.5.5z" }) });
892
893 // packages/icons/build-module/library/category.mjs
894 var import_primitives6 = __toESM(require_primitives(), 1);
895 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
896 var category_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M6 5.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM4 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2V6zm11-.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5h-3a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM13 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2h-3a2 2 0 01-2-2V6zm5 8.5h-3a.5.5 0 00-.5.5v3a.5.5 0 00.5.5h3a.5.5 0 00.5-.5v-3a.5.5 0 00-.5-.5zM15 13a2 2 0 00-2 2v3a2 2 0 002 2h3a2 2 0 002-2v-3a2 2 0 00-2-2h-3zm-9 1.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5v-3a.5.5 0 01.5-.5zM4 15a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2v-3z" }) });
897
898 // packages/icons/build-module/library/check.mjs
899 var import_primitives7 = __toESM(require_primitives(), 1);
900 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
901 var check_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });
902
903 // packages/icons/build-module/library/close-small.mjs
904 var import_primitives8 = __toESM(require_primitives(), 1);
905 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
906 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.Path, { d: "M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z" }) });
907
908 // packages/icons/build-module/library/cog.mjs
909 var import_primitives9 = __toESM(require_primitives(), 1);
910 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
911 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M10.289 4.836A1 1 0 0111.275 4h1.306a1 1 0 01.987.836l.244 1.466c.787.26 1.503.679 2.108 1.218l1.393-.522a1 1 0 011.216.437l.653 1.13a1 1 0 01-.23 1.273l-1.148.944a6.025 6.025 0 010 2.435l1.149.946a1 1 0 01.23 1.272l-.653 1.13a1 1 0 01-1.216.437l-1.394-.522c-.605.54-1.32.958-2.108 1.218l-.244 1.466a1 1 0 01-.987.836h-1.306a1 1 0 01-.986-.836l-.244-1.466a5.995 5.995 0 01-2.108-1.218l-1.394.522a1 1 0 01-1.217-.436l-.653-1.131a1 1 0 01.23-1.272l1.149-.946a6.026 6.026 0 010-2.435l-1.148-.944a1 1 0 01-.23-1.272l.653-1.131a1 1 0 011.217-.437l1.393.522a5.994 5.994 0 012.108-1.218l.244-1.466zM14.929 12a3 3 0 11-6 0 3 3 0 016 0z" }) });
912
913 // packages/icons/build-module/library/comment.mjs
914 var import_primitives10 = __toESM(require_primitives(), 1);
915 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
916 var comment_default = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.Path, { d: "M18 4H6c-1.1 0-2 .9-2 2v12.9c0 .6.5 1.1 1.1 1.1.3 0 .5-.1.8-.3L8.5 17H18c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 11c0 .3-.2.5-.5.5H7.9l-2.4 2.4V6c0-.3.2-.5.5-.5h12c.3 0 .5.2.5.5v9z" }) });
917
918 // packages/icons/build-module/library/envelope.mjs
919 var import_primitives11 = __toESM(require_primitives(), 1);
920 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
921 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M3 7c0-1.1.9-2 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Zm2-.5h14c.3 0 .5.2.5.5v1L12 13.5 4.5 7.9V7c0-.3.2-.5.5-.5Zm-.5 3.3V17c0 .3.2.5.5.5h14c.3 0 .5-.2.5-.5V9.8L12 15.4 4.5 9.8Z" }) });
922
923 // packages/icons/build-module/library/error.mjs
924 var import_primitives12 = __toESM(require_primitives(), 1);
925 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
926 var error_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12.218 5.377a.25.25 0 0 0-.436 0l-7.29 12.96a.25.25 0 0 0 .218.373h14.58a.25.25 0 0 0 .218-.372l-7.29-12.96Zm-1.743-.735c.669-1.19 2.381-1.19 3.05 0l7.29 12.96a1.75 1.75 0 0 1-1.525 2.608H4.71a1.75 1.75 0 0 1-1.525-2.608l7.29-12.96ZM12.75 17.46h-1.5v-1.5h1.5v1.5Zm-1.5-3h1.5v-5h-1.5v5Z" }) });
927
928 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
929 var import_primitives13 = __toESM(require_primitives(), 1);
930 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
931 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.Path, { d: "M4 8.8h8.9V7.2H4v1.6zm0 7h8.9v-1.5H4v1.5zM18 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2z" }) });
932
933 // packages/icons/build-module/library/format-list-bullets.mjs
934 var import_primitives14 = __toESM(require_primitives(), 1);
935 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
936 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives14.Path, { d: "M11.1 15.8H20v-1.5h-8.9v1.5zm0-8.6v1.5H20V7.2h-8.9zM6 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-7c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" }) });
937
938 // packages/icons/build-module/library/funnel.mjs
939 var import_primitives15 = __toESM(require_primitives(), 1);
940 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
941 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives15.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) });
942
943 // packages/icons/build-module/library/link.mjs
944 var import_primitives16 = __toESM(require_primitives(), 1);
945 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
946 var link_default = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives16.Path, { d: "M10 17.389H8.444A5.194 5.194 0 1 1 8.444 7H10v1.5H8.444a3.694 3.694 0 0 0 0 7.389H10v1.5ZM14 7h1.556a5.194 5.194 0 0 1 0 10.39H14v-1.5h1.556a3.694 3.694 0 0 0 0-7.39H14V7Zm-4.5 6h5v-1.5h-5V13Z" }) });
947
948 // packages/icons/build-module/library/mobile.mjs
949 var import_primitives17 = __toESM(require_primitives(), 1);
950 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
951 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives17.Path, { d: "M15 4H9c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h6c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H9c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h6c.3 0 .5.2.5.5v12zm-4.5-.5h2V16h-2v1.5z" }) });
952
953 // packages/icons/build-module/library/more-vertical.mjs
954 var import_primitives18 = __toESM(require_primitives(), 1);
955 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
956 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
957
958 // packages/icons/build-module/library/next.mjs
959 var import_primitives19 = __toESM(require_primitives(), 1);
960 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
961 var next_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives19.Path, { d: "M6.6 6L5.4 7l4.5 5-4.5 5 1.1 1 5.5-6-5.4-6zm6 0l-1.1 1 4.5 5-4.5 5 1.1 1 5.5-6-5.5-6z" }) });
962
963 // packages/icons/build-module/library/post-list.mjs
964 var import_primitives20 = __toESM(require_primitives(), 1);
965 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
966 var post_list_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives20.Path, { d: "M18 5.5H6a.5.5 0 0 0-.5.5v12a.5.5 0 0 0 .5.5h12a.5.5 0 0 0 .5-.5V6a.5.5 0 0 0-.5-.5ZM6 4h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2Zm1 5h1.5v1.5H7V9Zm1.5 4.5H7V15h1.5v-1.5ZM10 9h7v1.5h-7V9Zm7 4.5h-7V15h7v-1.5Z" }) });
967
968 // packages/icons/build-module/library/previous.mjs
969 var import_primitives21 = __toESM(require_primitives(), 1);
970 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
971 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives21.Path, { d: "M11.6 7l-1.1-1L5 12l5.5 6 1.1-1L7 12l4.6-5zm6 0l-1.1-1-5.5 6 5.5 6 1.1-1-4.6-5 4.6-5z" }) });
972
973 // packages/icons/build-module/library/scheduled.mjs
974 var import_primitives22 = __toESM(require_primitives(), 1);
975 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
976 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives22.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm9 1V8h-1.5v3.5h-2V13H13Z" }) });
977
978 // packages/icons/build-module/library/search.mjs
979 var import_primitives23 = __toESM(require_primitives(), 1);
980 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
981 var search_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives23.Path, { d: "M13 5c-3.3 0-6 2.7-6 6 0 1.4.5 2.7 1.3 3.7l-3.8 3.8 1.1 1.1 3.8-3.8c1 .8 2.3 1.3 3.7 1.3 3.3 0 6-2.7 6-6S16.3 5 13 5zm0 10.5c-2.5 0-4.5-2-4.5-4.5s2-4.5 4.5-4.5 4.5 2 4.5 4.5-2 4.5-4.5 4.5z" }) });
982
983 // packages/icons/build-module/library/seen.mjs
984 var import_primitives24 = __toESM(require_primitives(), 1);
985 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
986 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives24.Path, { d: "M3.99961 13C4.67043 13.3354 4.6703 13.3357 4.67017 13.3359L4.67298 13.3305C4.67621 13.3242 4.68184 13.3135 4.68988 13.2985C4.70595 13.2686 4.7316 13.2218 4.76695 13.1608C4.8377 13.0385 4.94692 12.8592 5.09541 12.6419C5.39312 12.2062 5.84436 11.624 6.45435 11.0431C7.67308 9.88241 9.49719 8.75 11.9996 8.75C14.502 8.75 16.3261 9.88241 17.5449 11.0431C18.1549 11.624 18.6061 12.2062 18.9038 12.6419C19.0523 12.8592 19.1615 13.0385 19.2323 13.1608C19.2676 13.2218 19.2933 13.2686 19.3093 13.2985C19.3174 13.3135 19.323 13.3242 19.3262 13.3305L19.3291 13.3359C19.3289 13.3357 19.3288 13.3354 19.9996 13C20.6704 12.6646 20.6703 12.6643 20.6701 12.664L20.6697 12.6632L20.6688 12.6614L20.6662 12.6563L20.6583 12.6408C20.6517 12.6282 20.6427 12.6108 20.631 12.5892C20.6078 12.5459 20.5744 12.4852 20.5306 12.4096C20.4432 12.2584 20.3141 12.0471 20.1423 11.7956C19.7994 11.2938 19.2819 10.626 18.5794 9.9569C17.1731 8.61759 14.9972 7.25 11.9996 7.25C9.00203 7.25 6.82614 8.61759 5.41987 9.9569C4.71736 10.626 4.19984 11.2938 3.85694 11.7956C3.68511 12.0471 3.55605 12.2584 3.4686 12.4096C3.42484 12.4852 3.39142 12.5459 3.36818 12.5892C3.35656 12.6108 3.34748 12.6282 3.34092 12.6408L3.33297 12.6563L3.33041 12.6614L3.32948 12.6632L3.32911 12.664C3.32894 12.6643 3.32879 12.6646 3.99961 13ZM11.9996 16C13.9326 16 15.4996 14.433 15.4996 12.5C15.4996 10.567 13.9326 9 11.9996 9C10.0666 9 8.49961 10.567 8.49961 12.5C8.49961 14.433 10.0666 16 11.9996 16Z" }) });
987
988 // packages/icons/build-module/library/unseen.mjs
989 var import_primitives25 = __toESM(require_primitives(), 1);
990 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
991 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives25.Path, { d: "M20.7 12.7s0-.1-.1-.2c0-.2-.2-.4-.4-.6-.3-.5-.9-1.2-1.6-1.8-.7-.6-1.5-1.3-2.6-1.8l-.6 1.4c.9.4 1.6 1 2.1 1.5.6.6 1.1 1.2 1.4 1.6.1.2.3.4.3.5v.1l.7-.3.7-.3Zm-5.2-9.3-1.8 4c-.5-.1-1.1-.2-1.7-.2-3 0-5.2 1.4-6.6 2.7-.7.7-1.2 1.3-1.6 1.8-.2.3-.3.5-.4.6 0 0 0 .1-.1.2s0 0 .7.3l.7.3V13c0-.1.2-.3.3-.5.3-.4.7-1 1.4-1.6 1.2-1.2 3-2.3 5.5-2.3H13v.3c-.4 0-.8-.1-1.1-.1-1.9 0-3.5 1.6-3.5 3.5s.6 2.3 1.6 2.9l-2 4.4.9.4 7.6-16.2-.9-.4Zm-3 12.6c1.7-.2 3-1.7 3-3.5s-.2-1.4-.6-1.9L12.4 16Z" }) });
992
993 // node_modules/clsx/dist/clsx.mjs
994 function r(e2) {
995 var t2, f2, n2 = "";
996 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
997 else if ("object" == typeof e2) if (Array.isArray(e2)) {
998 var o2 = e2.length;
999 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
1000 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
1001 return n2;
1002 }
1003 function clsx() {
1004 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
1005 return n2;
1006 }
1007 var clsx_default = clsx;
1008
1009 // packages/dataviews/build-module/dataviews/index.mjs
1010 var import_element80 = __toESM(require_element(), 1);
1011 var import_compose12 = __toESM(require_compose(), 1);
1012
1013 // node_modules/@base-ui/utils/esm/useStableCallback.js
1014 var React2 = __toESM(require_react(), 1);
1015
1016 // node_modules/@base-ui/utils/esm/useRefWithInit.js
1017 var React = __toESM(require_react(), 1);
1018 var UNINITIALIZED = {};
1019 function useRefWithInit(init2, initArg) {
1020 const ref = React.useRef(UNINITIALIZED);
1021 if (ref.current === UNINITIALIZED) {
1022 ref.current = init2(initArg);
1023 }
1024 return ref;
1025 }
1026
1027 // node_modules/@base-ui/utils/esm/useStableCallback.js
1028 var useInsertionEffect = React2[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0, -3)];
1029 var useSafeInsertionEffect = (
1030 // React 17 doesn't have useInsertionEffect.
1031 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
1032 useInsertionEffect !== React2.useLayoutEffect ? useInsertionEffect : (fn) => fn()
1033 );
1034 function useStableCallback(callback) {
1035 const stable = useRefWithInit(createStableCallback).current;
1036 stable.next = callback;
1037 useSafeInsertionEffect(stable.effect);
1038 return stable.trampoline;
1039 }
1040 function createStableCallback() {
1041 const stable = {
1042 next: void 0,
1043 callback: assertNotCalled,
1044 trampoline: (...args) => stable.callback?.(...args),
1045 effect: () => {
1046 stable.callback = stable.next;
1047 }
1048 };
1049 return stable;
1050 }
1051 function assertNotCalled() {
1052 if (true) {
1053 throw (
1054 /* minify-error-disabled */
1055 new Error("Base UI: Cannot call an event handler while rendering.")
1056 );
1057 }
1058 }
1059
1060 // node_modules/@base-ui/utils/esm/useIsoLayoutEffect.js
1061 var React3 = __toESM(require_react(), 1);
1062 var noop = () => {
1063 };
1064 var useIsoLayoutEffect = typeof document !== "undefined" ? React3.useLayoutEffect : noop;
1065
1066 // node_modules/@base-ui/utils/esm/warn.js
1067 var set;
1068 if (true) {
1069 set = /* @__PURE__ */ new Set();
1070 }
1071 function warn(...messages) {
1072 if (true) {
1073 const messageKey = messages.join(" ");
1074 if (!set.has(messageKey)) {
1075 set.add(messageKey);
1076 console.warn(`Base UI: ${messageKey}`);
1077 }
1078 }
1079 }
1080
1081 // node_modules/@base-ui/react/esm/internals/direction-context/DirectionContext.js
1082 var React4 = __toESM(require_react(), 1);
1083 var DirectionContext = /* @__PURE__ */ React4.createContext(void 0);
1084 if (true) DirectionContext.displayName = "DirectionContext";
1085 function useDirection() {
1086 const context = React4.useContext(DirectionContext);
1087 return context?.direction ?? "ltr";
1088 }
1089
1090 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1091 var React7 = __toESM(require_react(), 1);
1092
1093 // node_modules/@base-ui/utils/esm/useMergedRefs.js
1094 function useMergedRefs(a2, b2, c2, d2) {
1095 const forkRef = useRefWithInit(createForkRef).current;
1096 if (didChange(forkRef, a2, b2, c2, d2)) {
1097 update(forkRef, [a2, b2, c2, d2]);
1098 }
1099 return forkRef.callback;
1100 }
1101 function useMergedRefsN(refs) {
1102 const forkRef = useRefWithInit(createForkRef).current;
1103 if (didChangeN(forkRef, refs)) {
1104 update(forkRef, refs);
1105 }
1106 return forkRef.callback;
1107 }
1108 function createForkRef() {
1109 return {
1110 callback: null,
1111 cleanup: null,
1112 refs: []
1113 };
1114 }
1115 function didChange(forkRef, a2, b2, c2, d2) {
1116 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
1117 }
1118 function didChangeN(forkRef, newRefs) {
1119 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
1120 }
1121 function update(forkRef, refs) {
1122 forkRef.refs = refs;
1123 if (refs.every((ref) => ref == null)) {
1124 forkRef.callback = null;
1125 return;
1126 }
1127 forkRef.callback = (instance) => {
1128 if (forkRef.cleanup) {
1129 forkRef.cleanup();
1130 forkRef.cleanup = null;
1131 }
1132 if (instance != null) {
1133 const cleanupCallbacks = Array(refs.length).fill(null);
1134 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1135 const ref = refs[i2];
1136 if (ref == null) {
1137 continue;
1138 }
1139 switch (typeof ref) {
1140 case "function": {
1141 const refCleanup = ref(instance);
1142 if (typeof refCleanup === "function") {
1143 cleanupCallbacks[i2] = refCleanup;
1144 }
1145 break;
1146 }
1147 case "object": {
1148 ref.current = instance;
1149 break;
1150 }
1151 default:
1152 }
1153 }
1154 forkRef.cleanup = () => {
1155 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1156 const ref = refs[i2];
1157 if (ref == null) {
1158 continue;
1159 }
1160 switch (typeof ref) {
1161 case "function": {
1162 const cleanupCallback = cleanupCallbacks[i2];
1163 if (typeof cleanupCallback === "function") {
1164 cleanupCallback();
1165 } else {
1166 ref(null);
1167 }
1168 break;
1169 }
1170 case "object": {
1171 ref.current = null;
1172 break;
1173 }
1174 default:
1175 }
1176 }
1177 };
1178 }
1179 };
1180 }
1181
1182 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1183 var React6 = __toESM(require_react(), 1);
1184
1185 // node_modules/@base-ui/utils/esm/reactVersion.js
1186 var React5 = __toESM(require_react(), 1);
1187 var majorVersion = parseInt(React5.version, 10);
1188 function isReactVersionAtLeast(reactVersionToCheck) {
1189 return majorVersion >= reactVersionToCheck;
1190 }
1191
1192 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1193 function getReactElementRef(element) {
1194 if (!/* @__PURE__ */ React6.isValidElement(element)) {
1195 return null;
1196 }
1197 const reactElement = element;
1198 const propsWithRef = reactElement.props;
1199 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1200 }
1201
1202 // node_modules/@base-ui/utils/esm/mergeObjects.js
1203 function mergeObjects(a2, b2) {
1204 if (a2 && !b2) {
1205 return a2;
1206 }
1207 if (!a2 && b2) {
1208 return b2;
1209 }
1210 if (a2 || b2) {
1211 return {
1212 ...a2,
1213 ...b2
1214 };
1215 }
1216 return void 0;
1217 }
1218
1219 // node_modules/@base-ui/utils/esm/empty.js
1220 function NOOP() {
1221 }
1222 var EMPTY_ARRAY = Object.freeze([]);
1223 var EMPTY_OBJECT = Object.freeze({});
1224
1225 // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js
1226 function getStateAttributesProps(state, customMapping) {
1227 const props = {};
1228 for (const key in state) {
1229 const value = state[key];
1230 if (customMapping?.hasOwnProperty(key)) {
1231 const customProps = customMapping[key](value);
1232 if (customProps != null) {
1233 Object.assign(props, customProps);
1234 }
1235 continue;
1236 }
1237 if (value === true) {
1238 props[`data-${key.toLowerCase()}`] = "";
1239 } else if (value) {
1240 props[`data-${key.toLowerCase()}`] = value.toString();
1241 }
1242 }
1243 return props;
1244 }
1245
1246 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
1247 function resolveClassName(className, state) {
1248 return typeof className === "function" ? className(state) : className;
1249 }
1250
1251 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
1252 function resolveStyle(style, state) {
1253 return typeof style === "function" ? style(state) : style;
1254 }
1255
1256 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
1257 var EMPTY_PROPS = {};
1258 function mergeProps(a2, b2, c2, d2, e2) {
1259 if (!c2 && !d2 && !e2 && !a2) {
1260 return createInitialMergedProps(b2);
1261 }
1262 let merged = createInitialMergedProps(a2);
1263 if (b2) {
1264 merged = mergeInto(merged, b2);
1265 }
1266 if (c2) {
1267 merged = mergeInto(merged, c2);
1268 }
1269 if (d2) {
1270 merged = mergeInto(merged, d2);
1271 }
1272 if (e2) {
1273 merged = mergeInto(merged, e2);
1274 }
1275 return merged;
1276 }
1277 function mergePropsN(props) {
1278 if (props.length === 0) {
1279 return EMPTY_PROPS;
1280 }
1281 if (props.length === 1) {
1282 return createInitialMergedProps(props[0]);
1283 }
1284 let merged = createInitialMergedProps(props[0]);
1285 for (let i2 = 1; i2 < props.length; i2 += 1) {
1286 merged = mergeInto(merged, props[i2]);
1287 }
1288 return merged;
1289 }
1290 function createInitialMergedProps(inputProps) {
1291 if (isPropsGetter(inputProps)) {
1292 return {
1293 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1294 };
1295 }
1296 return copyInitialProps(inputProps);
1297 }
1298 function mergeInto(merged, inputProps) {
1299 if (isPropsGetter(inputProps)) {
1300 return resolvePropsGetter(inputProps, merged);
1301 }
1302 return mutablyMergeInto(merged, inputProps);
1303 }
1304 function copyInitialProps(inputProps) {
1305 const copiedProps = {
1306 ...inputProps
1307 };
1308 for (const propName in copiedProps) {
1309 const propValue = copiedProps[propName];
1310 if (isEventHandler(propName, propValue)) {
1311 copiedProps[propName] = wrapEventHandler(propValue);
1312 }
1313 }
1314 return copiedProps;
1315 }
1316 function mutablyMergeInto(mergedProps, externalProps) {
1317 if (!externalProps) {
1318 return mergedProps;
1319 }
1320 for (const propName in externalProps) {
1321 const externalPropValue = externalProps[propName];
1322 switch (propName) {
1323 case "style": {
1324 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1325 break;
1326 }
1327 case "className": {
1328 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1329 break;
1330 }
1331 default: {
1332 if (isEventHandler(propName, externalPropValue)) {
1333 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1334 } else {
1335 mergedProps[propName] = externalPropValue;
1336 }
1337 }
1338 }
1339 }
1340 return mergedProps;
1341 }
1342 function isEventHandler(key, value) {
1343 const code0 = key.charCodeAt(0);
1344 const code1 = key.charCodeAt(1);
1345 const code2 = key.charCodeAt(2);
1346 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1347 }
1348 function isPropsGetter(inputProps) {
1349 return typeof inputProps === "function";
1350 }
1351 function resolvePropsGetter(inputProps, previousProps) {
1352 if (isPropsGetter(inputProps)) {
1353 return inputProps(previousProps);
1354 }
1355 return inputProps ?? EMPTY_PROPS;
1356 }
1357 function mergeEventHandlers(ourHandler, theirHandler) {
1358 if (!theirHandler) {
1359 return ourHandler;
1360 }
1361 if (!ourHandler) {
1362 return wrapEventHandler(theirHandler);
1363 }
1364 return (...args) => {
1365 const event = args[0];
1366 if (isSyntheticEvent(event)) {
1367 const baseUIEvent = event;
1368 makeEventPreventable(baseUIEvent);
1369 const result2 = theirHandler(...args);
1370 if (!baseUIEvent.baseUIHandlerPrevented) {
1371 ourHandler?.(...args);
1372 }
1373 return result2;
1374 }
1375 const result = theirHandler(...args);
1376 ourHandler?.(...args);
1377 return result;
1378 };
1379 }
1380 function wrapEventHandler(handler) {
1381 if (!handler) {
1382 return handler;
1383 }
1384 return (...args) => {
1385 const event = args[0];
1386 if (isSyntheticEvent(event)) {
1387 makeEventPreventable(event);
1388 }
1389 return handler(...args);
1390 };
1391 }
1392 function makeEventPreventable(event) {
1393 event.preventBaseUIHandler = () => {
1394 event.baseUIHandlerPrevented = true;
1395 };
1396 return event;
1397 }
1398 function mergeClassNames(ourClassName, theirClassName) {
1399 if (theirClassName) {
1400 if (ourClassName) {
1401 return theirClassName + " " + ourClassName;
1402 }
1403 return theirClassName;
1404 }
1405 return ourClassName;
1406 }
1407 function isSyntheticEvent(event) {
1408 return event != null && typeof event === "object" && "nativeEvent" in event;
1409 }
1410
1411 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1412 var import_react = __toESM(require_react(), 1);
1413 function useRenderElement(element, componentProps, params = {}) {
1414 const renderProp = componentProps.render;
1415 const outProps = useRenderElementProps(componentProps, params);
1416 if (params.enabled === false) {
1417 return null;
1418 }
1419 const state = params.state ?? EMPTY_OBJECT;
1420 return evaluateRenderProp(element, renderProp, outProps, state);
1421 }
1422 function useRenderElementProps(componentProps, params = {}) {
1423 const {
1424 className: classNameProp,
1425 style: styleProp,
1426 render: renderProp
1427 } = componentProps;
1428 const {
1429 state = EMPTY_OBJECT,
1430 ref,
1431 props,
1432 stateAttributesMapping: stateAttributesMapping3,
1433 enabled = true
1434 } = params;
1435 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1436 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1437 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping3) : EMPTY_OBJECT;
1438 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1439 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1440 if (typeof document !== "undefined") {
1441 if (!enabled) {
1442 useMergedRefs(null, null);
1443 } else if (Array.isArray(ref)) {
1444 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1445 } else {
1446 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1447 }
1448 }
1449 if (!enabled) {
1450 return EMPTY_OBJECT;
1451 }
1452 if (className !== void 0) {
1453 outProps.className = mergeClassNames(outProps.className, className);
1454 }
1455 if (style !== void 0) {
1456 outProps.style = mergeObjects(outProps.style, style);
1457 }
1458 return outProps;
1459 }
1460 function resolveRenderFunctionProps(props) {
1461 if (Array.isArray(props)) {
1462 return mergePropsN(props);
1463 }
1464 return mergeProps(void 0, props);
1465 }
1466 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1467 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1468 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1469 function evaluateRenderProp(element, render4, props, state) {
1470 if (render4) {
1471 if (typeof render4 === "function") {
1472 if (true) {
1473 warnIfRenderPropLooksLikeComponent(render4);
1474 }
1475 return render4(props, state);
1476 }
1477 const mergedProps = mergeProps(props, render4.props);
1478 mergedProps.ref = props.ref;
1479 let newElement = render4;
1480 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1481 const children = React7.Children.toArray(render4);
1482 newElement = children[0];
1483 }
1484 if (true) {
1485 if (!/* @__PURE__ */ React7.isValidElement(newElement)) {
1486 throw new Error(["Base UI: The `render` prop was provided an invalid React element as `React.isValidElement(render)` is `false`.", "A valid React element must be provided to the `render` prop because it is cloned with props to replace the default element.", "https://base-ui.com/r/invalid-render-prop"].join("\n"));
1487 }
1488 }
1489 return /* @__PURE__ */ React7.cloneElement(newElement, mergedProps);
1490 }
1491 if (element) {
1492 if (typeof element === "string") {
1493 return renderTag(element, props);
1494 }
1495 }
1496 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1497 }
1498 function warnIfRenderPropLooksLikeComponent(renderFn) {
1499 const functionName = renderFn.name;
1500 if (functionName.length === 0) {
1501 return;
1502 }
1503 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1504 return;
1505 }
1506 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1507 return;
1508 }
1509 warn(`The \`render\` prop received a function named \`${functionName}\` that starts with an uppercase letter.`, "This usually means a React component was passed directly as `render={Component}`.", "Base UI calls `render` as a plain function, which can break the Rules of Hooks during reconciliation.", "If this is an intentional render callback, rename it to start with a lowercase letter.", "Use `render={<Component />}` or `render={(props) => <Component {...props} />}` instead.", "https://base-ui.com/r/invalid-render-prop");
1510 }
1511 function renderTag(Tag, props) {
1512 if (Tag === "button") {
1513 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1514 type: "button",
1515 ...props,
1516 key: props.key
1517 });
1518 }
1519 if (Tag === "img") {
1520 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1521 alt: "",
1522 ...props,
1523 key: props.key
1524 });
1525 }
1526 return /* @__PURE__ */ React7.createElement(Tag, props);
1527 }
1528
1529 // node_modules/@base-ui/react/esm/internals/reason-parts.js
1530 var reason_parts_exports = {};
1531 __export(reason_parts_exports, {
1532 cancelOpen: () => cancelOpen,
1533 chipRemovePress: () => chipRemovePress,
1534 clearPress: () => clearPress,
1535 closePress: () => closePress,
1536 closeWatcher: () => closeWatcher,
1537 decrementPress: () => decrementPress,
1538 disabled: () => disabled,
1539 drag: () => drag,
1540 escapeKey: () => escapeKey,
1541 focusOut: () => focusOut,
1542 imperativeAction: () => imperativeAction,
1543 incrementPress: () => incrementPress,
1544 inputBlur: () => inputBlur,
1545 inputChange: () => inputChange,
1546 inputClear: () => inputClear,
1547 inputPaste: () => inputPaste,
1548 inputPress: () => inputPress,
1549 itemPress: () => itemPress,
1550 keyboard: () => keyboard,
1551 linkPress: () => linkPress,
1552 listNavigation: () => listNavigation,
1553 none: () => none,
1554 outsidePress: () => outsidePress,
1555 pointer: () => pointer,
1556 scrub: () => scrub,
1557 siblingOpen: () => siblingOpen,
1558 swipe: () => swipe,
1559 trackPress: () => trackPress,
1560 triggerFocus: () => triggerFocus,
1561 triggerHover: () => triggerHover,
1562 triggerPress: () => triggerPress,
1563 wheel: () => wheel,
1564 windowResize: () => windowResize
1565 });
1566 var none = "none";
1567 var triggerPress = "trigger-press";
1568 var triggerHover = "trigger-hover";
1569 var triggerFocus = "trigger-focus";
1570 var outsidePress = "outside-press";
1571 var itemPress = "item-press";
1572 var closePress = "close-press";
1573 var linkPress = "link-press";
1574 var clearPress = "clear-press";
1575 var chipRemovePress = "chip-remove-press";
1576 var trackPress = "track-press";
1577 var incrementPress = "increment-press";
1578 var decrementPress = "decrement-press";
1579 var inputChange = "input-change";
1580 var inputClear = "input-clear";
1581 var inputBlur = "input-blur";
1582 var inputPaste = "input-paste";
1583 var inputPress = "input-press";
1584 var focusOut = "focus-out";
1585 var escapeKey = "escape-key";
1586 var closeWatcher = "close-watcher";
1587 var listNavigation = "list-navigation";
1588 var keyboard = "keyboard";
1589 var pointer = "pointer";
1590 var drag = "drag";
1591 var wheel = "wheel";
1592 var scrub = "scrub";
1593 var cancelOpen = "cancel-open";
1594 var siblingOpen = "sibling-open";
1595 var disabled = "disabled";
1596 var imperativeAction = "imperative-action";
1597 var swipe = "swipe";
1598 var windowResize = "window-resize";
1599
1600 // node_modules/@base-ui/react/esm/internals/createBaseUIEventDetails.js
1601 function createChangeEventDetails(reason, event, trigger, customProperties) {
1602 let canceled = false;
1603 let allowPropagation = false;
1604 const custom = customProperties ?? EMPTY_OBJECT;
1605 const details = {
1606 reason,
1607 event: event ?? new Event("base-ui"),
1608 cancel() {
1609 canceled = true;
1610 },
1611 allowPropagation() {
1612 allowPropagation = true;
1613 },
1614 get isCanceled() {
1615 return canceled;
1616 },
1617 get isPropagationAllowed() {
1618 return allowPropagation;
1619 },
1620 trigger,
1621 ...custom
1622 };
1623 return details;
1624 }
1625
1626 // node_modules/@base-ui/utils/esm/useId.js
1627 var React9 = __toESM(require_react(), 1);
1628
1629 // node_modules/@base-ui/utils/esm/safeReact.js
1630 var React8 = __toESM(require_react(), 1);
1631 var SafeReact = {
1632 ...React8
1633 };
1634
1635 // node_modules/@base-ui/utils/esm/useId.js
1636 var globalId = 0;
1637 function useGlobalId(idOverride, prefix = "mui") {
1638 const [defaultId, setDefaultId] = React9.useState(idOverride);
1639 const id = idOverride || defaultId;
1640 React9.useEffect(() => {
1641 if (defaultId == null) {
1642 globalId += 1;
1643 setDefaultId(`${prefix}-${globalId}`);
1644 }
1645 }, [defaultId, prefix]);
1646 return id;
1647 }
1648 var maybeReactUseId = SafeReact.useId;
1649 function useId(idOverride, prefix) {
1650 if (maybeReactUseId !== void 0) {
1651 const reactId = maybeReactUseId();
1652 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
1653 }
1654 return useGlobalId(idOverride, prefix);
1655 }
1656
1657 // node_modules/@base-ui/react/esm/internals/useBaseUiId.js
1658 function useBaseUiId(idOverride) {
1659 return useId(idOverride, "base-ui");
1660 }
1661
1662 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
1663 var ReactDOM = __toESM(require_react_dom(), 1);
1664
1665 // node_modules/@base-ui/utils/esm/useOnMount.js
1666 var React10 = __toESM(require_react(), 1);
1667 var EMPTY = [];
1668 function useOnMount(fn) {
1669 React10.useEffect(fn, EMPTY);
1670 }
1671
1672 // node_modules/@base-ui/utils/esm/useAnimationFrame.js
1673 var EMPTY2 = null;
1674 var LAST_RAF = globalThis.requestAnimationFrame;
1675 var Scheduler = class {
1676 /* This implementation uses an array as a backing data-structure for frame callbacks.
1677 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
1678 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
1679 * be much more efficient if there is a call pattern that alterns as
1680 * "request-cancel-request-cancel-…".
1681 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
1682 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
1683 callbacks = [];
1684 callbacksCount = 0;
1685 nextId = 1;
1686 startId = 1;
1687 isScheduled = false;
1688 tick = (timestamp) => {
1689 this.isScheduled = false;
1690 const currentCallbacks = this.callbacks;
1691 const currentCallbacksCount = this.callbacksCount;
1692 this.callbacks = [];
1693 this.callbacksCount = 0;
1694 this.startId = this.nextId;
1695 if (currentCallbacksCount > 0) {
1696 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
1697 currentCallbacks[i2]?.(timestamp);
1698 }
1699 }
1700 };
1701 request(fn) {
1702 const id = this.nextId;
1703 this.nextId += 1;
1704 this.callbacks.push(fn);
1705 this.callbacksCount += 1;
1706 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
1707 if (!this.isScheduled || didRAFChange) {
1708 requestAnimationFrame(this.tick);
1709 this.isScheduled = true;
1710 }
1711 return id;
1712 }
1713 cancel(id) {
1714 const index2 = id - this.startId;
1715 if (index2 < 0 || index2 >= this.callbacks.length) {
1716 return;
1717 }
1718 this.callbacks[index2] = null;
1719 this.callbacksCount -= 1;
1720 }
1721 };
1722 var scheduler = new Scheduler();
1723 var AnimationFrame = class _AnimationFrame {
1724 static create() {
1725 return new _AnimationFrame();
1726 }
1727 static request(fn) {
1728 return scheduler.request(fn);
1729 }
1730 static cancel(id) {
1731 return scheduler.cancel(id);
1732 }
1733 currentId = EMPTY2;
1734 /**
1735 * Executes `fn` after `delay`, clearing any previously scheduled call.
1736 */
1737 request(fn) {
1738 this.cancel();
1739 this.currentId = scheduler.request(() => {
1740 this.currentId = EMPTY2;
1741 fn();
1742 });
1743 }
1744 cancel = () => {
1745 if (this.currentId !== EMPTY2) {
1746 scheduler.cancel(this.currentId);
1747 this.currentId = EMPTY2;
1748 }
1749 };
1750 disposeEffect = () => {
1751 return this.cancel;
1752 };
1753 };
1754 function useAnimationFrame() {
1755 const timeout = useRefWithInit(AnimationFrame.create).current;
1756 useOnMount(timeout.disposeEffect);
1757 return timeout;
1758 }
1759
1760 // node_modules/@base-ui/react/esm/utils/resolveRef.js
1761 function resolveRef(maybeRef) {
1762 if (maybeRef == null) {
1763 return maybeRef;
1764 }
1765 return "current" in maybeRef ? maybeRef.current : maybeRef;
1766 }
1767
1768 // node_modules/@base-ui/react/esm/internals/stateAttributesMapping.js
1769 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
1770 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
1771 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
1772 return TransitionStatusDataAttributes2;
1773 })({});
1774 var STARTING_HOOK = {
1775 [TransitionStatusDataAttributes.startingStyle]: ""
1776 };
1777 var ENDING_HOOK = {
1778 [TransitionStatusDataAttributes.endingStyle]: ""
1779 };
1780 var transitionStatusMapping = {
1781 transitionStatus(value) {
1782 if (value === "starting") {
1783 return STARTING_HOOK;
1784 }
1785 if (value === "ending") {
1786 return ENDING_HOOK;
1787 }
1788 return null;
1789 }
1790 };
1791
1792 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
1793 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
1794 const frame = useAnimationFrame();
1795 return useStableCallback((fnToExecute, signal = null) => {
1796 frame.cancel();
1797 const element = resolveRef(elementOrRef);
1798 if (element == null) {
1799 return;
1800 }
1801 const resolvedElement = element;
1802 const done = () => {
1803 ReactDOM.flushSync(fnToExecute);
1804 };
1805 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
1806 fnToExecute();
1807 return;
1808 }
1809 function exec() {
1810 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
1811 if (!signal?.aborted) {
1812 done();
1813 }
1814 }).catch(() => {
1815 if (treatAbortedAsFinished) {
1816 if (!signal?.aborted) {
1817 done();
1818 }
1819 return;
1820 }
1821 const currentAnimations = resolvedElement.getAnimations();
1822 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
1823 exec();
1824 }
1825 });
1826 }
1827 if (waitForStartingStyleRemoved) {
1828 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
1829 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
1830 frame.request(exec);
1831 return;
1832 }
1833 const attributeObserver = new MutationObserver(() => {
1834 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
1835 attributeObserver.disconnect();
1836 exec();
1837 }
1838 });
1839 attributeObserver.observe(resolvedElement, {
1840 attributes: true,
1841 attributeFilter: [startingStyleAttribute]
1842 });
1843 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
1844 once: true
1845 });
1846 return;
1847 }
1848 frame.request(exec);
1849 });
1850 }
1851
1852 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1853 var React11 = __toESM(require_react(), 1);
1854 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
1855 const [transitionStatus, setTransitionStatus] = React11.useState(open && enableIdleState ? "idle" : void 0);
1856 const [mounted, setMounted] = React11.useState(open);
1857 if (open && !mounted) {
1858 setMounted(true);
1859 setTransitionStatus("starting");
1860 }
1861 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
1862 setTransitionStatus("ending");
1863 }
1864 if (!open && !mounted && transitionStatus === "ending") {
1865 setTransitionStatus(void 0);
1866 }
1867 useIsoLayoutEffect(() => {
1868 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
1869 const frame = AnimationFrame.request(() => {
1870 setTransitionStatus("ending");
1871 });
1872 return () => {
1873 AnimationFrame.cancel(frame);
1874 };
1875 }
1876 return void 0;
1877 }, [open, mounted, transitionStatus, deferEndingState]);
1878 useIsoLayoutEffect(() => {
1879 if (!open || enableIdleState) {
1880 return void 0;
1881 }
1882 const frame = AnimationFrame.request(() => {
1883 setTransitionStatus(void 0);
1884 });
1885 return () => {
1886 AnimationFrame.cancel(frame);
1887 };
1888 }, [enableIdleState, open]);
1889 useIsoLayoutEffect(() => {
1890 if (!open || !enableIdleState) {
1891 return void 0;
1892 }
1893 if (open && mounted && transitionStatus !== "idle") {
1894 setTransitionStatus("starting");
1895 }
1896 const frame = AnimationFrame.request(() => {
1897 setTransitionStatus("idle");
1898 });
1899 return () => {
1900 AnimationFrame.cancel(frame);
1901 };
1902 }, [enableIdleState, open, mounted, transitionStatus]);
1903 return {
1904 mounted,
1905 setMounted,
1906 transitionStatus
1907 };
1908 }
1909
1910 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
1911 function hasWindow() {
1912 return typeof window !== "undefined";
1913 }
1914 function getNodeName(node) {
1915 if (isNode(node)) {
1916 return (node.nodeName || "").toLowerCase();
1917 }
1918 return "#document";
1919 }
1920 function getWindow(node) {
1921 var _node$ownerDocument;
1922 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1923 }
1924 function getDocumentElement(node) {
1925 var _ref;
1926 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1927 }
1928 function isNode(value) {
1929 if (!hasWindow()) {
1930 return false;
1931 }
1932 return value instanceof Node || value instanceof getWindow(value).Node;
1933 }
1934 function isElement(value) {
1935 if (!hasWindow()) {
1936 return false;
1937 }
1938 return value instanceof Element || value instanceof getWindow(value).Element;
1939 }
1940 function isHTMLElement(value) {
1941 if (!hasWindow()) {
1942 return false;
1943 }
1944 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1945 }
1946 function isShadowRoot(value) {
1947 if (!hasWindow() || typeof ShadowRoot === "undefined") {
1948 return false;
1949 }
1950 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1951 }
1952 function isOverflowElement(element) {
1953 const {
1954 overflow,
1955 overflowX,
1956 overflowY,
1957 display
1958 } = getComputedStyle2(element);
1959 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
1960 }
1961 function isTableElement(element) {
1962 return /^(table|td|th)$/.test(getNodeName(element));
1963 }
1964 function isTopLayer(element) {
1965 try {
1966 if (element.matches(":popover-open")) {
1967 return true;
1968 }
1969 } catch (_e) {
1970 }
1971 try {
1972 return element.matches(":modal");
1973 } catch (_e) {
1974 return false;
1975 }
1976 }
1977 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
1978 var containRe = /paint|layout|strict|content/;
1979 var isNotNone = (value) => !!value && value !== "none";
1980 var isWebKitValue;
1981 function isContainingBlock(elementOrCss) {
1982 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
1983 return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || "") || containRe.test(css.contain || "");
1984 }
1985 function getContainingBlock(element) {
1986 let currentNode = getParentNode(element);
1987 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1988 if (isContainingBlock(currentNode)) {
1989 return currentNode;
1990 } else if (isTopLayer(currentNode)) {
1991 return null;
1992 }
1993 currentNode = getParentNode(currentNode);
1994 }
1995 return null;
1996 }
1997 function isWebKit() {
1998 if (isWebKitValue == null) {
1999 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
2000 }
2001 return isWebKitValue;
2002 }
2003 function isLastTraversableNode(node) {
2004 return /^(html|body|#document)$/.test(getNodeName(node));
2005 }
2006 function getComputedStyle2(element) {
2007 return getWindow(element).getComputedStyle(element);
2008 }
2009 function getNodeScroll(element) {
2010 if (isElement(element)) {
2011 return {
2012 scrollLeft: element.scrollLeft,
2013 scrollTop: element.scrollTop
2014 };
2015 }
2016 return {
2017 scrollLeft: element.scrollX,
2018 scrollTop: element.scrollY
2019 };
2020 }
2021 function getParentNode(node) {
2022 if (getNodeName(node) === "html") {
2023 return node;
2024 }
2025 const result = (
2026 // Step into the shadow DOM of the parent of a slotted node.
2027 node.assignedSlot || // DOM Element detected.
2028 node.parentNode || // ShadowRoot detected.
2029 isShadowRoot(node) && node.host || // Fallback.
2030 getDocumentElement(node)
2031 );
2032 return isShadowRoot(result) ? result.host : result;
2033 }
2034 function getNearestOverflowAncestor(node) {
2035 const parentNode = getParentNode(node);
2036 if (isLastTraversableNode(parentNode)) {
2037 return node.ownerDocument ? node.ownerDocument.body : node.body;
2038 }
2039 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
2040 return parentNode;
2041 }
2042 return getNearestOverflowAncestor(parentNode);
2043 }
2044 function getOverflowAncestors(node, list, traverseIframes) {
2045 var _node$ownerDocument2;
2046 if (list === void 0) {
2047 list = [];
2048 }
2049 if (traverseIframes === void 0) {
2050 traverseIframes = true;
2051 }
2052 const scrollableAncestor = getNearestOverflowAncestor(node);
2053 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
2054 const win = getWindow(scrollableAncestor);
2055 if (isBody) {
2056 const frameElement = getFrameElement(win);
2057 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
2058 } else {
2059 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
2060 }
2061 }
2062 function getFrameElement(win) {
2063 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
2064 }
2065
2066 // node_modules/@base-ui/utils/esm/detectBrowser.js
2067 var hasNavigator = typeof navigator !== "undefined";
2068 var nav = getNavigatorData();
2069 var platform = getPlatform();
2070 var userAgent = getUserAgent();
2071 var isWebKit2 = typeof CSS === "undefined" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter:none");
2072 var isIOS = (
2073 // iPads can claim to be MacIntel
2074 nav.platform === "MacIntel" && nav.maxTouchPoints > 1 ? true : /iP(hone|ad|od)|iOS/.test(nav.platform)
2075 );
2076 var isFirefox = hasNavigator && /firefox/i.test(userAgent);
2077 var isSafari = hasNavigator && /apple/i.test(navigator.vendor);
2078 var isEdge = hasNavigator && /Edg/i.test(userAgent);
2079 var isAndroid = hasNavigator && /android/i.test(platform) || /android/i.test(userAgent);
2080 var isMac = hasNavigator && platform.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
2081 var isJSDOM = userAgent.includes("jsdom/");
2082 function getNavigatorData() {
2083 if (!hasNavigator) {
2084 return {
2085 platform: "",
2086 maxTouchPoints: -1
2087 };
2088 }
2089 const uaData = navigator.userAgentData;
2090 if (uaData?.platform) {
2091 return {
2092 platform: uaData.platform,
2093 maxTouchPoints: navigator.maxTouchPoints
2094 };
2095 }
2096 return {
2097 platform: navigator.platform ?? "",
2098 maxTouchPoints: navigator.maxTouchPoints ?? -1
2099 };
2100 }
2101 function getUserAgent() {
2102 if (!hasNavigator) {
2103 return "";
2104 }
2105 const uaData = navigator.userAgentData;
2106 if (uaData && Array.isArray(uaData.brands)) {
2107 return uaData.brands.map(({
2108 brand,
2109 version: version2
2110 }) => `${brand}/${version2}`).join(" ");
2111 }
2112 return navigator.userAgent;
2113 }
2114 function getPlatform() {
2115 if (!hasNavigator) {
2116 return "";
2117 }
2118 const uaData = navigator.userAgentData;
2119 if (uaData?.platform) {
2120 return uaData.platform;
2121 }
2122 return navigator.platform ?? "";
2123 }
2124
2125 // node_modules/@base-ui/react/esm/floating-ui-react/utils/constants.js
2126 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
2127 var ACTIVE_KEY = "active";
2128 var SELECTED_KEY = "selected";
2129 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
2130
2131 // node_modules/@base-ui/react/esm/internals/shadowDom.js
2132 function activeElement(doc) {
2133 let element = doc.activeElement;
2134 while (element?.shadowRoot?.activeElement != null) {
2135 element = element.shadowRoot.activeElement;
2136 }
2137 return element;
2138 }
2139 function contains(parent, child) {
2140 if (!parent || !child) {
2141 return false;
2142 }
2143 const rootNode = child.getRootNode?.();
2144 if (parent.contains(child)) {
2145 return true;
2146 }
2147 if (rootNode && isShadowRoot(rootNode)) {
2148 let next = child;
2149 while (next) {
2150 if (parent === next) {
2151 return true;
2152 }
2153 next = next.parentNode || next.host;
2154 }
2155 }
2156 return false;
2157 }
2158 function getTarget(event) {
2159 if ("composedPath" in event) {
2160 return event.composedPath()[0];
2161 }
2162 return event.target;
2163 }
2164
2165 // node_modules/@base-ui/react/esm/floating-ui-react/utils/element.js
2166 function isTargetInsideEnabledTrigger(target, triggerElements) {
2167 if (!isElement(target)) {
2168 return false;
2169 }
2170 const targetElement = target;
2171 if (triggerElements.hasElement(targetElement)) {
2172 return !targetElement.hasAttribute("data-trigger-disabled");
2173 }
2174 for (const [, trigger] of triggerElements.entries()) {
2175 if (contains(trigger, targetElement)) {
2176 return !trigger.hasAttribute("data-trigger-disabled");
2177 }
2178 }
2179 return false;
2180 }
2181 function isEventTargetWithin(event, node) {
2182 if (node == null) {
2183 return false;
2184 }
2185 if ("composedPath" in event) {
2186 return event.composedPath().includes(node);
2187 }
2188 const eventAgain = event;
2189 return eventAgain.target != null && node.contains(eventAgain.target);
2190 }
2191 function isRootElement(element) {
2192 return element.matches("html,body");
2193 }
2194 function isTypeableElement(element) {
2195 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
2196 }
2197 function isInteractiveElement(element) {
2198 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
2199 }
2200 function matchesFocusVisible(element) {
2201 if (!element || isJSDOM) {
2202 return true;
2203 }
2204 try {
2205 return element.matches(":focus-visible");
2206 } catch (_e) {
2207 return true;
2208 }
2209 }
2210
2211 // node_modules/@base-ui/react/esm/floating-ui-react/utils/nodes.js
2212 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
2213 const directChildren = nodes.filter((node) => node.parentId === id);
2214 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
2215 }
2216
2217 // node_modules/@base-ui/react/esm/floating-ui-react/utils/event.js
2218 function isReactEvent(event) {
2219 return "nativeEvent" in event;
2220 }
2221 function isMouseLikePointerType(pointerType, strict) {
2222 const values = ["mouse", "pen"];
2223 if (!strict) {
2224 values.push("", void 0);
2225 }
2226 return values.includes(pointerType);
2227 }
2228 function isClickLikeEvent(event) {
2229 const type = event.type;
2230 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
2231 }
2232
2233 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
2234 var sides = ["top", "right", "bottom", "left"];
2235 var min = Math.min;
2236 var max = Math.max;
2237 var round = Math.round;
2238 var floor = Math.floor;
2239 var createCoords = (v2) => ({
2240 x: v2,
2241 y: v2
2242 });
2243 var oppositeSideMap = {
2244 left: "right",
2245 right: "left",
2246 bottom: "top",
2247 top: "bottom"
2248 };
2249 function clamp(start, value, end) {
2250 return max(start, min(value, end));
2251 }
2252 function evaluate(value, param) {
2253 return typeof value === "function" ? value(param) : value;
2254 }
2255 function getSide(placement) {
2256 return placement.split("-")[0];
2257 }
2258 function getAlignment(placement) {
2259 return placement.split("-")[1];
2260 }
2261 function getOppositeAxis(axis) {
2262 return axis === "x" ? "y" : "x";
2263 }
2264 function getAxisLength(axis) {
2265 return axis === "y" ? "height" : "width";
2266 }
2267 function getSideAxis(placement) {
2268 const firstChar = placement[0];
2269 return firstChar === "t" || firstChar === "b" ? "y" : "x";
2270 }
2271 function getAlignmentAxis(placement) {
2272 return getOppositeAxis(getSideAxis(placement));
2273 }
2274 function getAlignmentSides(placement, rects, rtl) {
2275 if (rtl === void 0) {
2276 rtl = false;
2277 }
2278 const alignment = getAlignment(placement);
2279 const alignmentAxis = getAlignmentAxis(placement);
2280 const length = getAxisLength(alignmentAxis);
2281 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
2282 if (rects.reference[length] > rects.floating[length]) {
2283 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
2284 }
2285 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
2286 }
2287 function getExpandedPlacements(placement) {
2288 const oppositePlacement = getOppositePlacement(placement);
2289 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
2290 }
2291 function getOppositeAlignmentPlacement(placement) {
2292 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
2293 }
2294 var lrPlacement = ["left", "right"];
2295 var rlPlacement = ["right", "left"];
2296 var tbPlacement = ["top", "bottom"];
2297 var btPlacement = ["bottom", "top"];
2298 function getSideList(side, isStart, rtl) {
2299 switch (side) {
2300 case "top":
2301 case "bottom":
2302 if (rtl) return isStart ? rlPlacement : lrPlacement;
2303 return isStart ? lrPlacement : rlPlacement;
2304 case "left":
2305 case "right":
2306 return isStart ? tbPlacement : btPlacement;
2307 default:
2308 return [];
2309 }
2310 }
2311 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
2312 const alignment = getAlignment(placement);
2313 let list = getSideList(getSide(placement), direction === "start", rtl);
2314 if (alignment) {
2315 list = list.map((side) => side + "-" + alignment);
2316 if (flipAlignment) {
2317 list = list.concat(list.map(getOppositeAlignmentPlacement));
2318 }
2319 }
2320 return list;
2321 }
2322 function getOppositePlacement(placement) {
2323 const side = getSide(placement);
2324 return oppositeSideMap[side] + placement.slice(side.length);
2325 }
2326 function expandPaddingObject(padding) {
2327 return {
2328 top: 0,
2329 right: 0,
2330 bottom: 0,
2331 left: 0,
2332 ...padding
2333 };
2334 }
2335 function getPaddingObject(padding) {
2336 return typeof padding !== "number" ? expandPaddingObject(padding) : {
2337 top: padding,
2338 right: padding,
2339 bottom: padding,
2340 left: padding
2341 };
2342 }
2343 function rectToClientRect(rect) {
2344 const {
2345 x: x2,
2346 y: y2,
2347 width,
2348 height
2349 } = rect;
2350 return {
2351 width,
2352 height,
2353 top: y2,
2354 left: x2,
2355 right: x2 + width,
2356 bottom: y2 + height,
2357 x: x2,
2358 y: y2
2359 };
2360 }
2361
2362 // node_modules/@base-ui/react/esm/floating-ui-react/utils/composite.js
2363 function isHiddenByStyles(styles) {
2364 return styles.visibility === "hidden" || styles.visibility === "collapse";
2365 }
2366 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
2367 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
2368 return false;
2369 }
2370 if (typeof element.checkVisibility === "function") {
2371 return element.checkVisibility();
2372 }
2373 return styles.display !== "none" && styles.display !== "contents";
2374 }
2375
2376 // node_modules/@base-ui/utils/esm/owner.js
2377 function ownerDocument(node) {
2378 return node?.ownerDocument || document;
2379 }
2380
2381 // node_modules/@base-ui/react/esm/floating-ui-react/utils/tabbable.js
2382 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
2383 function getParentElement(element) {
2384 const assignedSlot = element.assignedSlot;
2385 if (assignedSlot) {
2386 return assignedSlot;
2387 }
2388 if (element.parentElement) {
2389 return element.parentElement;
2390 }
2391 const rootNode = element.getRootNode();
2392 return isShadowRoot(rootNode) ? rootNode.host : null;
2393 }
2394 function getDetailsSummary(details) {
2395 for (const child of Array.from(details.children)) {
2396 if (getNodeName(child) === "summary") {
2397 return child;
2398 }
2399 }
2400 return null;
2401 }
2402 function isWithinOpenDetailsSummary(element, details) {
2403 const summary = getDetailsSummary(details);
2404 return !!summary && (element === summary || contains(summary, element));
2405 }
2406 function isFocusableCandidate(element) {
2407 const nodeName = element ? getNodeName(element) : "";
2408 return element != null && element.matches(CANDIDATE_SELECTOR) && (nodeName !== "summary" || element.parentElement != null && getNodeName(element.parentElement) === "details" && getDetailsSummary(element.parentElement) === element) && (nodeName !== "details" || getDetailsSummary(element) == null) && (nodeName !== "input" || element.type !== "hidden");
2409 }
2410 function isFocusableElement(element) {
2411 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
2412 return false;
2413 }
2414 for (let current = element; current; current = getParentElement(current)) {
2415 const isAncestor = current !== element;
2416 const isSlot = getNodeName(current) === "slot";
2417 if (current.hasAttribute("inert")) {
2418 return false;
2419 }
2420 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
2421 return false;
2422 }
2423 }
2424 return true;
2425 }
2426 function isVisibleInTabbableTree(element, isAncestor) {
2427 const styles = getComputedStyle2(element);
2428 if (!isAncestor) {
2429 return isElementVisible(element, styles);
2430 }
2431 return styles.display !== "none";
2432 }
2433 function getTabIndex(element) {
2434 const tabIndex = element.tabIndex;
2435 if (tabIndex < 0) {
2436 const nodeName = getNodeName(element);
2437 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
2438 return 0;
2439 }
2440 }
2441 return tabIndex;
2442 }
2443 function getNamedRadioInput(element) {
2444 if (getNodeName(element) !== "input") {
2445 return null;
2446 }
2447 const input = element;
2448 return input.type === "radio" && input.name !== "" ? input : null;
2449 }
2450 function isTabbableRadio(element, candidates) {
2451 const input = getNamedRadioInput(element);
2452 if (!input) {
2453 return true;
2454 }
2455 const checkedRadio = candidates.find((candidate) => {
2456 const radio = getNamedRadioInput(candidate);
2457 return radio?.name === input.name && radio.form === input.form && radio.checked;
2458 });
2459 if (checkedRadio) {
2460 return checkedRadio === input;
2461 }
2462 return candidates.find((candidate) => {
2463 const radio = getNamedRadioInput(candidate);
2464 return radio?.name === input.name && radio.form === input.form;
2465 }) === input;
2466 }
2467 function getComposedChildren(container) {
2468 if (isHTMLElement(container) && getNodeName(container) === "slot") {
2469 const assignedElements = container.assignedElements({
2470 flatten: true
2471 });
2472 if (assignedElements.length > 0) {
2473 return assignedElements;
2474 }
2475 }
2476 if (isHTMLElement(container) && container.shadowRoot) {
2477 return Array.from(container.shadowRoot.children);
2478 }
2479 return Array.from(container.children);
2480 }
2481 function appendCandidates(container, list) {
2482 getComposedChildren(container).forEach((child) => {
2483 if (isFocusableCandidate(child)) {
2484 list.push(child);
2485 }
2486 appendCandidates(child, list);
2487 });
2488 }
2489 function appendMatchingElements(container, selector2, list) {
2490 getComposedChildren(container).forEach((child) => {
2491 if (isHTMLElement(child) && child.matches(selector2)) {
2492 list.push(child);
2493 }
2494 appendMatchingElements(child, selector2, list);
2495 });
2496 }
2497 function focusable(container) {
2498 const candidates = [];
2499 appendCandidates(container, candidates);
2500 return candidates.filter(isFocusableElement);
2501 }
2502 function tabbable(container) {
2503 const candidates = focusable(container);
2504 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
2505 }
2506 function getTabbableIn(container, dir) {
2507 const list = tabbable(container);
2508 const len = list.length;
2509 if (len === 0) {
2510 return void 0;
2511 }
2512 const active = activeElement(ownerDocument(container));
2513 const index2 = list.indexOf(active);
2514 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
2515 return list[nextIndex];
2516 }
2517 function getNextTabbable(referenceElement) {
2518 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
2519 }
2520 function getPreviousTabbable(referenceElement) {
2521 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
2522 }
2523 function isOutsideEvent(event, container) {
2524 const containerElement = container || event.currentTarget;
2525 const relatedTarget = event.relatedTarget;
2526 return !relatedTarget || !contains(containerElement, relatedTarget);
2527 }
2528 function disableFocusInside(container) {
2529 const tabbableElements = tabbable(container);
2530 tabbableElements.forEach((element) => {
2531 element.dataset.tabindex = element.getAttribute("tabindex") || "";
2532 element.setAttribute("tabindex", "-1");
2533 });
2534 }
2535 function enableFocusInside(container) {
2536 const elements = [];
2537 appendMatchingElements(container, "[data-tabindex]", elements);
2538 elements.forEach((element) => {
2539 const tabindex = element.dataset.tabindex;
2540 delete element.dataset.tabindex;
2541 if (tabindex) {
2542 element.setAttribute("tabindex", tabindex);
2543 } else {
2544 element.removeAttribute("tabindex");
2545 }
2546 });
2547 }
2548
2549 // node_modules/@base-ui/utils/esm/addEventListener.js
2550 function addEventListener(target, type, listener, options) {
2551 target.addEventListener(type, listener, options);
2552 return () => {
2553 target.removeEventListener(type, listener, options);
2554 };
2555 }
2556
2557 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
2558 var React12 = __toESM(require_react(), 1);
2559 function useOpenChangeComplete(parameters) {
2560 const {
2561 enabled = true,
2562 open,
2563 ref,
2564 onComplete: onCompleteParam
2565 } = parameters;
2566 const onComplete = useStableCallback(onCompleteParam);
2567 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
2568 React12.useEffect(() => {
2569 if (!enabled) {
2570 return void 0;
2571 }
2572 const abortController = new AbortController();
2573 runOnceAnimationsFinish(onComplete, abortController.signal);
2574 return () => {
2575 abortController.abort();
2576 };
2577 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
2578 }
2579
2580 // node_modules/@base-ui/utils/esm/useOnFirstRender.js
2581 var React13 = __toESM(require_react(), 1);
2582 function useOnFirstRender(fn) {
2583 const ref = React13.useRef(true);
2584 if (ref.current) {
2585 ref.current = false;
2586 fn();
2587 }
2588 }
2589
2590 // node_modules/@base-ui/utils/esm/useTimeout.js
2591 var EMPTY3 = 0;
2592 var Timeout = class _Timeout {
2593 static create() {
2594 return new _Timeout();
2595 }
2596 currentId = EMPTY3;
2597 /**
2598 * Executes `fn` after `delay`, clearing any previously scheduled call.
2599 */
2600 start(delay, fn) {
2601 this.clear();
2602 this.currentId = setTimeout(() => {
2603 this.currentId = EMPTY3;
2604 fn();
2605 }, delay);
2606 }
2607 isStarted() {
2608 return this.currentId !== EMPTY3;
2609 }
2610 clear = () => {
2611 if (this.currentId !== EMPTY3) {
2612 clearTimeout(this.currentId);
2613 this.currentId = EMPTY3;
2614 }
2615 };
2616 disposeEffect = () => {
2617 return this.clear;
2618 };
2619 };
2620 function useTimeout() {
2621 const timeout = useRefWithInit(Timeout.create).current;
2622 useOnMount(timeout.disposeEffect);
2623 return timeout;
2624 }
2625
2626 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2627 var React14 = __toESM(require_react(), 1);
2628
2629 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverShared.js
2630 function resolveValue(value, pointerType) {
2631 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
2632 return 0;
2633 }
2634 if (typeof value === "function") {
2635 return value();
2636 }
2637 return value;
2638 }
2639 function getDelay(value, prop, pointerType) {
2640 const result = resolveValue(value, pointerType);
2641 if (typeof result === "number") {
2642 return result;
2643 }
2644 return result?.[prop];
2645 }
2646 function getRestMs(value) {
2647 if (typeof value === "function") {
2648 return value();
2649 }
2650 return value;
2651 }
2652 function isClickLikeOpenEvent(openEventType, interactedInside) {
2653 return interactedInside || openEventType === "click" || openEventType === "mousedown";
2654 }
2655
2656 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2657 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
2658 var FloatingDelayGroupContext = /* @__PURE__ */ React14.createContext({
2659 hasProvider: false,
2660 timeoutMs: 0,
2661 delayRef: {
2662 current: 0
2663 },
2664 initialDelayRef: {
2665 current: 0
2666 },
2667 timeout: new Timeout(),
2668 currentIdRef: {
2669 current: null
2670 },
2671 currentContextRef: {
2672 current: null
2673 }
2674 });
2675 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
2676 function FloatingDelayGroup(props) {
2677 const {
2678 children,
2679 delay,
2680 timeoutMs = 0
2681 } = props;
2682 const delayRef = React14.useRef(delay);
2683 const initialDelayRef = React14.useRef(delay);
2684 const currentIdRef = React14.useRef(null);
2685 const currentContextRef = React14.useRef(null);
2686 const timeout = useTimeout();
2687 return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(FloatingDelayGroupContext.Provider, {
2688 value: React14.useMemo(() => ({
2689 hasProvider: true,
2690 delayRef,
2691 initialDelayRef,
2692 currentIdRef,
2693 timeoutMs,
2694 currentContextRef,
2695 timeout
2696 }), [timeoutMs, timeout]),
2697 children
2698 });
2699 }
2700 function useDelayGroup(context, options = {
2701 open: false
2702 }) {
2703 const store = "rootStore" in context ? context.rootStore : context;
2704 const floatingId = store.useState("floatingId");
2705 const {
2706 open
2707 } = options;
2708 const groupContext = React14.useContext(FloatingDelayGroupContext);
2709 const {
2710 currentIdRef,
2711 delayRef,
2712 timeoutMs,
2713 initialDelayRef,
2714 currentContextRef,
2715 hasProvider,
2716 timeout
2717 } = groupContext;
2718 const [isInstantPhase, setIsInstantPhase] = React14.useState(false);
2719 useIsoLayoutEffect(() => {
2720 function unset() {
2721 setIsInstantPhase(false);
2722 currentContextRef.current?.setIsInstantPhase(false);
2723 currentIdRef.current = null;
2724 currentContextRef.current = null;
2725 delayRef.current = initialDelayRef.current;
2726 }
2727 if (!currentIdRef.current) {
2728 return void 0;
2729 }
2730 if (!open && currentIdRef.current === floatingId) {
2731 setIsInstantPhase(false);
2732 if (timeoutMs) {
2733 const closingId = floatingId;
2734 timeout.start(timeoutMs, () => {
2735 if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
2736 return;
2737 }
2738 unset();
2739 });
2740 return () => {
2741 timeout.clear();
2742 };
2743 }
2744 unset();
2745 }
2746 return void 0;
2747 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]);
2748 useIsoLayoutEffect(() => {
2749 if (!open) {
2750 return;
2751 }
2752 const prevContext = currentContextRef.current;
2753 const prevId = currentIdRef.current;
2754 timeout.clear();
2755 currentContextRef.current = {
2756 onOpenChange: store.setOpen,
2757 setIsInstantPhase
2758 };
2759 currentIdRef.current = floatingId;
2760 delayRef.current = {
2761 open: 0,
2762 close: getDelay(initialDelayRef.current, "close")
2763 };
2764 if (prevId !== null && prevId !== floatingId) {
2765 setIsInstantPhase(true);
2766 prevContext?.setIsInstantPhase(true);
2767 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
2768 } else {
2769 setIsInstantPhase(false);
2770 prevContext?.setIsInstantPhase(false);
2771 }
2772 }, [open, floatingId, store, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout]);
2773 useIsoLayoutEffect(() => {
2774 return () => {
2775 currentContextRef.current = null;
2776 };
2777 }, [currentContextRef]);
2778 return React14.useMemo(() => ({
2779 hasProvider,
2780 delayRef,
2781 isInstantPhase
2782 }), [hasProvider, delayRef, isInstantPhase]);
2783 }
2784
2785 // node_modules/@base-ui/utils/esm/mergeCleanups.js
2786 function mergeCleanups(...cleanups) {
2787 return () => {
2788 for (let i2 = 0; i2 < cleanups.length; i2 += 1) {
2789 const cleanup = cleanups[i2];
2790 if (cleanup) {
2791 cleanup();
2792 }
2793 }
2794 };
2795 }
2796
2797 // node_modules/@base-ui/utils/esm/useValueAsRef.js
2798 function useValueAsRef(value) {
2799 const latest = useRefWithInit(createLatestRef, value).current;
2800 latest.next = value;
2801 useIsoLayoutEffect(latest.effect);
2802 return latest;
2803 }
2804 function createLatestRef(value) {
2805 const latest = {
2806 current: value,
2807 next: value,
2808 effect: () => {
2809 latest.current = latest.next;
2810 }
2811 };
2812 return latest;
2813 }
2814
2815 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
2816 var React15 = __toESM(require_react(), 1);
2817
2818 // node_modules/@base-ui/utils/esm/visuallyHidden.js
2819 var visuallyHiddenBase = {
2820 clipPath: "inset(50%)",
2821 overflow: "hidden",
2822 whiteSpace: "nowrap",
2823 border: 0,
2824 padding: 0,
2825 width: 1,
2826 height: 1,
2827 margin: -1
2828 };
2829 var visuallyHidden = {
2830 ...visuallyHiddenBase,
2831 position: "fixed",
2832 top: 0,
2833 left: 0
2834 };
2835 var visuallyHiddenInput = {
2836 ...visuallyHiddenBase,
2837 position: "absolute"
2838 };
2839
2840 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
2841 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
2842 var FocusGuard = /* @__PURE__ */ React15.forwardRef(function FocusGuard2(props, ref) {
2843 const [role, setRole] = React15.useState();
2844 useIsoLayoutEffect(() => {
2845 if (isSafari) {
2846 setRole("button");
2847 }
2848 }, []);
2849 const restProps = {
2850 tabIndex: 0,
2851 // Role is only for VoiceOver
2852 role
2853 };
2854 return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", {
2855 ...props,
2856 ref,
2857 style: visuallyHidden,
2858 "aria-hidden": role ? void 0 : true,
2859 ...restProps,
2860 "data-base-ui-focus-guard": ""
2861 });
2862 });
2863 if (true) FocusGuard.displayName = "FocusGuard";
2864
2865 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createAttribute.js
2866 function createAttribute(name) {
2867 return `data-base-ui-${name}`;
2868 }
2869
2870 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
2871 var React16 = __toESM(require_react(), 1);
2872 var ReactDOM2 = __toESM(require_react_dom(), 1);
2873
2874 // node_modules/@base-ui/react/esm/internals/constants.js
2875 var DISABLED_TRANSITIONS_STYLE = {
2876 style: {
2877 transition: "none"
2878 }
2879 };
2880 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
2881 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
2882 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
2883 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
2884 var POPUP_COLLISION_AVOIDANCE = {
2885 fallbackAxisSide: "end"
2886 };
2887 var ownerVisuallyHidden = {
2888 clipPath: "inset(50%)",
2889 position: "fixed",
2890 top: 0,
2891 left: 0
2892 };
2893
2894 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
2895 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
2896 var PortalContext = /* @__PURE__ */ React16.createContext(null);
2897 if (true) PortalContext.displayName = "PortalContext";
2898 var usePortalContext = () => React16.useContext(PortalContext);
2899 var attr = createAttribute("portal");
2900 function useFloatingPortalNode(props = {}) {
2901 const {
2902 ref,
2903 container: containerProp,
2904 componentProps = EMPTY_OBJECT,
2905 elementProps
2906 } = props;
2907 const uniqueId = useId();
2908 const portalContext = usePortalContext();
2909 const parentPortalNode = portalContext?.portalNode;
2910 const [containerElement, setContainerElement] = React16.useState(null);
2911 const [portalNode, setPortalNode] = React16.useState(null);
2912 const setPortalNodeRef = useStableCallback((node) => {
2913 if (node !== null) {
2914 setPortalNode(node);
2915 }
2916 });
2917 const containerRef = React16.useRef(null);
2918 useIsoLayoutEffect(() => {
2919 if (containerProp === null) {
2920 if (containerRef.current) {
2921 containerRef.current = null;
2922 setPortalNode(null);
2923 setContainerElement(null);
2924 }
2925 return;
2926 }
2927 if (uniqueId == null) {
2928 return;
2929 }
2930 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
2931 if (resolvedContainer == null) {
2932 if (containerRef.current) {
2933 containerRef.current = null;
2934 setPortalNode(null);
2935 setContainerElement(null);
2936 }
2937 return;
2938 }
2939 if (containerRef.current !== resolvedContainer) {
2940 containerRef.current = resolvedContainer;
2941 setPortalNode(null);
2942 setContainerElement(resolvedContainer);
2943 }
2944 }, [containerProp, parentPortalNode, uniqueId]);
2945 const portalElement = useRenderElement("div", componentProps, {
2946 ref: [ref, setPortalNodeRef],
2947 props: [{
2948 id: uniqueId,
2949 [attr]: ""
2950 }, elementProps]
2951 });
2952 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
2953 return {
2954 portalNode,
2955 portalSubtree
2956 };
2957 }
2958 var FloatingPortal = /* @__PURE__ */ React16.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
2959 const {
2960 children,
2961 container,
2962 className,
2963 render: render4,
2964 renderGuards,
2965 style,
2966 ...elementProps
2967 } = componentProps;
2968 const {
2969 portalNode,
2970 portalSubtree
2971 } = useFloatingPortalNode({
2972 container,
2973 ref: forwardedRef,
2974 componentProps,
2975 elementProps
2976 });
2977 const beforeOutsideRef = React16.useRef(null);
2978 const afterOutsideRef = React16.useRef(null);
2979 const beforeInsideRef = React16.useRef(null);
2980 const afterInsideRef = React16.useRef(null);
2981 const [focusManagerState, setFocusManagerState] = React16.useState(null);
2982 const focusInsideDisabledRef = React16.useRef(false);
2983 const modal = focusManagerState?.modal;
2984 const open = focusManagerState?.open;
2985 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
2986 React16.useEffect(() => {
2987 if (!portalNode || modal) {
2988 return void 0;
2989 }
2990 function onFocus(event) {
2991 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
2992 if (event.type === "focusin") {
2993 if (focusInsideDisabledRef.current) {
2994 enableFocusInside(portalNode);
2995 focusInsideDisabledRef.current = false;
2996 }
2997 } else {
2998 disableFocusInside(portalNode);
2999 focusInsideDisabledRef.current = true;
3000 }
3001 }
3002 }
3003 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
3004 }, [portalNode, modal]);
3005 React16.useEffect(() => {
3006 if (!portalNode || open !== false) {
3007 return;
3008 }
3009 enableFocusInside(portalNode);
3010 focusInsideDisabledRef.current = false;
3011 }, [open, portalNode]);
3012 const portalContextValue = React16.useMemo(() => ({
3013 beforeOutsideRef,
3014 afterOutsideRef,
3015 beforeInsideRef,
3016 afterInsideRef,
3017 portalNode,
3018 setFocusManagerState
3019 }), [portalNode]);
3020 return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(React16.Fragment, {
3021 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(PortalContext.Provider, {
3022 value: portalContextValue,
3023 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(FocusGuard, {
3024 "data-type": "outside",
3025 ref: beforeOutsideRef,
3026 onFocus: (event) => {
3027 if (isOutsideEvent(event, portalNode)) {
3028 beforeInsideRef.current?.focus();
3029 } else {
3030 const domReference = focusManagerState ? focusManagerState.domReference : null;
3031 const prevTabbable = getPreviousTabbable(domReference);
3032 prevTabbable?.focus();
3033 }
3034 }
3035 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", {
3036 "aria-owns": portalNode.id,
3037 style: ownerVisuallyHidden
3038 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(FocusGuard, {
3039 "data-type": "outside",
3040 ref: afterOutsideRef,
3041 onFocus: (event) => {
3042 if (isOutsideEvent(event, portalNode)) {
3043 afterInsideRef.current?.focus();
3044 } else {
3045 const domReference = focusManagerState ? focusManagerState.domReference : null;
3046 const nextTabbable = getNextTabbable(domReference);
3047 nextTabbable?.focus();
3048 if (focusManagerState?.closeOnFocusOut) {
3049 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
3050 }
3051 }
3052 }
3053 })]
3054 })]
3055 });
3056 });
3057 if (true) FloatingPortal.displayName = "FloatingPortal";
3058
3059 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
3060 var React17 = __toESM(require_react(), 1);
3061
3062 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createEventEmitter.js
3063 function createEventEmitter() {
3064 const map = /* @__PURE__ */ new Map();
3065 return {
3066 emit(event, data) {
3067 map.get(event)?.forEach((listener) => listener(data));
3068 },
3069 on(event, listener) {
3070 if (!map.has(event)) {
3071 map.set(event, /* @__PURE__ */ new Set());
3072 }
3073 map.get(event).add(listener);
3074 },
3075 off(event, listener) {
3076 map.get(event)?.delete(listener);
3077 }
3078 };
3079 }
3080
3081 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
3082 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
3083 var FloatingNodeContext = /* @__PURE__ */ React17.createContext(null);
3084 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
3085 var FloatingTreeContext = /* @__PURE__ */ React17.createContext(null);
3086 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
3087 var useFloatingParentNodeId = () => React17.useContext(FloatingNodeContext)?.id || null;
3088 var useFloatingTree = (externalTree) => {
3089 const contextTree = React17.useContext(FloatingTreeContext);
3090 return externalTree ?? contextTree;
3091 };
3092
3093 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useClientPoint.js
3094 var React18 = __toESM(require_react(), 1);
3095 function createVirtualElement(domElement, data) {
3096 let offsetX = null;
3097 let offsetY = null;
3098 let isAutoUpdateEvent = false;
3099 return {
3100 contextElement: domElement || void 0,
3101 getBoundingClientRect() {
3102 const domRect = domElement?.getBoundingClientRect() || {
3103 width: 0,
3104 height: 0,
3105 x: 0,
3106 y: 0
3107 };
3108 const isXAxis = data.axis === "x" || data.axis === "both";
3109 const isYAxis = data.axis === "y" || data.axis === "both";
3110 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
3111 let width = domRect.width;
3112 let height = domRect.height;
3113 let x2 = domRect.x;
3114 let y2 = domRect.y;
3115 if (offsetX == null && data.x && isXAxis) {
3116 offsetX = domRect.x - data.x;
3117 }
3118 if (offsetY == null && data.y && isYAxis) {
3119 offsetY = domRect.y - data.y;
3120 }
3121 x2 -= offsetX || 0;
3122 y2 -= offsetY || 0;
3123 width = 0;
3124 height = 0;
3125 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
3126 width = data.axis === "y" ? domRect.width : 0;
3127 height = data.axis === "x" ? domRect.height : 0;
3128 x2 = isXAxis && data.x != null ? data.x : x2;
3129 y2 = isYAxis && data.y != null ? data.y : y2;
3130 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
3131 height = data.axis === "x" ? domRect.height : height;
3132 width = data.axis === "y" ? domRect.width : width;
3133 }
3134 isAutoUpdateEvent = true;
3135 return {
3136 width,
3137 height,
3138 x: x2,
3139 y: y2,
3140 top: y2,
3141 right: x2 + width,
3142 bottom: y2 + height,
3143 left: x2
3144 };
3145 }
3146 };
3147 }
3148 function isMouseBasedEvent(event) {
3149 return event != null && event.clientX != null;
3150 }
3151 function useClientPoint(context, props = {}) {
3152 const store = "rootStore" in context ? context.rootStore : context;
3153 const open = store.useState("open");
3154 const floating = store.useState("floatingElement");
3155 const domReference = store.useState("domReferenceElement");
3156 const dataRef = store.context.dataRef;
3157 const {
3158 enabled = true,
3159 axis = "both"
3160 } = props;
3161 const initialRef = React18.useRef(false);
3162 const cleanupListenerRef = React18.useRef(null);
3163 const [pointerType, setPointerType] = React18.useState();
3164 const [reactive, setReactive] = React18.useState([]);
3165 const setReference = useStableCallback((newX, newY, referenceElement) => {
3166 if (initialRef.current) {
3167 return;
3168 }
3169 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
3170 return;
3171 }
3172 store.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
3173 x: newX,
3174 y: newY,
3175 axis,
3176 dataRef,
3177 pointerType
3178 }));
3179 });
3180 const handleReferenceEnterOrMove = useStableCallback((event) => {
3181 if (!open) {
3182 setReference(event.clientX, event.clientY, event.currentTarget);
3183 } else if (!cleanupListenerRef.current) {
3184 setReactive([]);
3185 }
3186 });
3187 const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
3188 const addListener = React18.useCallback(() => {
3189 if (!openCheck || !enabled) {
3190 return void 0;
3191 }
3192 const win = getWindow(floating);
3193 function handleMouseMove(event) {
3194 const target = getTarget(event);
3195 if (!contains(floating, target)) {
3196 setReference(event.clientX, event.clientY);
3197 } else {
3198 cleanupListenerRef.current?.();
3199 cleanupListenerRef.current = null;
3200 }
3201 }
3202 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
3203 const cleanup = () => {
3204 cleanupListenerRef.current?.();
3205 cleanupListenerRef.current = null;
3206 };
3207 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
3208 return cleanup;
3209 }
3210 store.set("positionReference", domReference);
3211 return void 0;
3212 }, [openCheck, enabled, floating, dataRef, domReference, store, setReference]);
3213 React18.useEffect(() => {
3214 return addListener();
3215 }, [addListener, reactive]);
3216 React18.useEffect(() => {
3217 if (enabled && !floating) {
3218 initialRef.current = false;
3219 }
3220 }, [enabled, floating]);
3221 React18.useEffect(() => {
3222 if (!enabled && open) {
3223 initialRef.current = true;
3224 }
3225 }, [enabled, open]);
3226 const reference = React18.useMemo(() => {
3227 function setPointerTypeRef(event) {
3228 setPointerType(event.pointerType);
3229 }
3230 return {
3231 onPointerDown: setPointerTypeRef,
3232 onPointerEnter: setPointerTypeRef,
3233 onMouseMove: handleReferenceEnterOrMove,
3234 onMouseEnter: handleReferenceEnterOrMove
3235 };
3236 }, [handleReferenceEnterOrMove]);
3237 return React18.useMemo(() => enabled ? {
3238 reference,
3239 trigger: reference
3240 } : {}, [enabled, reference]);
3241 }
3242
3243 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useDismiss.js
3244 var React19 = __toESM(require_react(), 1);
3245 var bubbleHandlerKeys = {
3246 intentional: "onClick",
3247 sloppy: "onPointerDown"
3248 };
3249 function alwaysFalse() {
3250 return false;
3251 }
3252 function normalizeProp(normalizable) {
3253 return {
3254 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
3255 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
3256 };
3257 }
3258 function useDismiss(context, props = {}) {
3259 const store = "rootStore" in context ? context.rootStore : context;
3260 const open = store.useState("open");
3261 const floatingElement = store.useState("floatingElement");
3262 const {
3263 dataRef
3264 } = store.context;
3265 const {
3266 enabled = true,
3267 escapeKey: escapeKey2 = true,
3268 outsidePress: outsidePressProp = true,
3269 outsidePressEvent = "sloppy",
3270 referencePress = alwaysFalse,
3271 referencePressEvent = "sloppy",
3272 bubbles,
3273 externalTree
3274 } = props;
3275 const tree = useFloatingTree(externalTree);
3276 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
3277 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
3278 const outsidePressEnabled = outsidePress2 !== false;
3279 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
3280 const pressStartedInsideRef = React19.useRef(false);
3281 const pressStartPreventedRef = React19.useRef(false);
3282 const suppressNextOutsideClickRef = React19.useRef(false);
3283 const {
3284 escapeKey: escapeKeyBubbles,
3285 outsidePress: outsidePressBubbles
3286 } = normalizeProp(bubbles);
3287 const touchStateRef = React19.useRef(null);
3288 const cancelDismissOnEndTimeout = useTimeout();
3289 const clearInsideReactTreeTimeout = useTimeout();
3290 const clearInsideReactTree = useStableCallback(() => {
3291 clearInsideReactTreeTimeout.clear();
3292 dataRef.current.insideReactTree = false;
3293 });
3294 const isComposingRef = React19.useRef(false);
3295 const currentPointerTypeRef = React19.useRef("");
3296 const isReferencePressEnabled = useStableCallback(referencePress);
3297 const closeOnEscapeKeyDown = useStableCallback((event) => {
3298 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
3299 return;
3300 }
3301 if (isComposingRef.current) {
3302 return;
3303 }
3304 const nodeId = dataRef.current.floatingContext?.nodeId;
3305 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
3306 if (!escapeKeyBubbles) {
3307 if (children.length > 0) {
3308 let shouldDismiss = true;
3309 children.forEach((child) => {
3310 if (child.context?.open && !child.context.dataRef.current.__escapeKeyBubbles) {
3311 shouldDismiss = false;
3312 }
3313 });
3314 if (!shouldDismiss) {
3315 return;
3316 }
3317 }
3318 }
3319 const native = isReactEvent(event) ? event.nativeEvent : event;
3320 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
3321 store.setOpen(false, eventDetails);
3322 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
3323 event.stopPropagation();
3324 }
3325 });
3326 const markInsideReactTree = useStableCallback(() => {
3327 dataRef.current.insideReactTree = true;
3328 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
3329 });
3330 React19.useEffect(() => {
3331 if (!open || !enabled) {
3332 return void 0;
3333 }
3334 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
3335 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
3336 const compositionTimeout = new Timeout();
3337 const preventedPressSuppressionTimeout = new Timeout();
3338 function handleCompositionStart() {
3339 compositionTimeout.clear();
3340 isComposingRef.current = true;
3341 }
3342 function handleCompositionEnd() {
3343 compositionTimeout.start(
3344 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
3345 // Only apply to WebKit for the test to remain 0ms.
3346 isWebKit() ? 5 : 0,
3347 () => {
3348 isComposingRef.current = false;
3349 }
3350 );
3351 }
3352 function suppressImmediateOutsideClickAfterPreventedStart() {
3353 suppressNextOutsideClickRef.current = true;
3354 preventedPressSuppressionTimeout.start(0, () => {
3355 suppressNextOutsideClickRef.current = false;
3356 });
3357 }
3358 function resetPressStartState() {
3359 pressStartedInsideRef.current = false;
3360 pressStartPreventedRef.current = false;
3361 }
3362 function getOutsidePressEvent() {
3363 const type = currentPointerTypeRef.current;
3364 const computedType = type === "pen" || !type ? "mouse" : type;
3365 const outsidePressEventValue = getOutsidePressEventProp();
3366 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
3367 if (typeof resolved === "string") {
3368 return resolved;
3369 }
3370 return resolved[computedType];
3371 }
3372 function shouldIgnoreEvent(event) {
3373 const computedOutsidePressEvent = getOutsidePressEvent();
3374 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
3375 }
3376 function isEventWithinFloatingTree(event) {
3377 const nodeId = dataRef.current.floatingContext?.nodeId;
3378 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
3379 return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement")) || targetIsInsideChildren;
3380 }
3381 function closeOnPressOutside(event) {
3382 if (shouldIgnoreEvent(event)) {
3383 clearInsideReactTree();
3384 return;
3385 }
3386 if (dataRef.current.insideReactTree) {
3387 clearInsideReactTree();
3388 return;
3389 }
3390 const target = getTarget(event);
3391 const inertSelector = `[${createAttribute("inert")}]`;
3392 const targetRoot = isElement(target) ? target.getRootNode() : null;
3393 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
3394 const triggers = store.context.triggerElements;
3395 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
3396 return;
3397 }
3398 let targetRootAncestor = isElement(target) ? target : null;
3399 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
3400 const nextParent = getParentNode(targetRootAncestor);
3401 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
3402 break;
3403 }
3404 targetRootAncestor = nextParent;
3405 }
3406 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
3407 !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
3408 // element was injected after the floating element rendered.
3409 markers.every((marker) => !contains(targetRootAncestor, marker))) {
3410 return;
3411 }
3412 if (isHTMLElement(target) && !("touches" in event)) {
3413 const lastTraversableNode = isLastTraversableNode(target);
3414 const style = getComputedStyle2(target);
3415 const scrollRe = /auto|scroll/;
3416 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
3417 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
3418 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
3419 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
3420 const isRTL7 = style.direction === "rtl";
3421 const pressedVerticalScrollbar = canScrollY && (isRTL7 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
3422 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
3423 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
3424 return;
3425 }
3426 }
3427 if (isEventWithinFloatingTree(event)) {
3428 return;
3429 }
3430 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
3431 preventedPressSuppressionTimeout.clear();
3432 suppressNextOutsideClickRef.current = false;
3433 return;
3434 }
3435 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3436 return;
3437 }
3438 const nodeId = dataRef.current.floatingContext?.nodeId;
3439 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
3440 if (children.length > 0) {
3441 let shouldDismiss = true;
3442 children.forEach((child) => {
3443 if (child.context?.open && !child.context.dataRef.current.__outsidePressBubbles) {
3444 shouldDismiss = false;
3445 }
3446 });
3447 if (!shouldDismiss) {
3448 return;
3449 }
3450 }
3451 store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
3452 clearInsideReactTree();
3453 }
3454 function handlePointerDown(event) {
3455 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
3456 return;
3457 }
3458 closeOnPressOutside(event);
3459 }
3460 function handleTouchStart(event) {
3461 if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
3462 return;
3463 }
3464 const touch = event.touches[0];
3465 if (touch) {
3466 touchStateRef.current = {
3467 startTime: Date.now(),
3468 startX: touch.clientX,
3469 startY: touch.clientY,
3470 dismissOnTouchEnd: false,
3471 dismissOnMouseDown: true
3472 };
3473 cancelDismissOnEndTimeout.start(1e3, () => {
3474 if (touchStateRef.current) {
3475 touchStateRef.current.dismissOnTouchEnd = false;
3476 touchStateRef.current.dismissOnMouseDown = false;
3477 }
3478 });
3479 }
3480 }
3481 function addTargetEventListenerOnce(event, listener) {
3482 const target = getTarget(event);
3483 if (!target) {
3484 return;
3485 }
3486 const unsubscribe2 = addEventListener(target, event.type, () => {
3487 listener(event);
3488 unsubscribe2();
3489 });
3490 }
3491 function handleTouchStartCapture(event) {
3492 currentPointerTypeRef.current = "touch";
3493 addTargetEventListenerOnce(event, handleTouchStart);
3494 }
3495 function closeOnPressOutsideCapture(event) {
3496 cancelDismissOnEndTimeout.clear();
3497 if (event.type === "pointerdown") {
3498 currentPointerTypeRef.current = event.pointerType;
3499 }
3500 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
3501 return;
3502 }
3503 addTargetEventListenerOnce(event, (targetEvent) => {
3504 if (targetEvent.type === "pointerdown") {
3505 handlePointerDown(targetEvent);
3506 } else {
3507 closeOnPressOutside(targetEvent);
3508 }
3509 });
3510 }
3511 function handlePressEndCapture(event) {
3512 if (!pressStartedInsideRef.current) {
3513 return;
3514 }
3515 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
3516 resetPressStartState();
3517 if (getOutsidePressEvent() !== "intentional") {
3518 return;
3519 }
3520 if (event.type === "pointercancel") {
3521 if (pressStartedInsideDefaultPrevented) {
3522 suppressImmediateOutsideClickAfterPreventedStart();
3523 }
3524 return;
3525 }
3526 if (isEventWithinFloatingTree(event)) {
3527 return;
3528 }
3529 if (pressStartedInsideDefaultPrevented) {
3530 suppressImmediateOutsideClickAfterPreventedStart();
3531 return;
3532 }
3533 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3534 return;
3535 }
3536 preventedPressSuppressionTimeout.clear();
3537 suppressNextOutsideClickRef.current = true;
3538 clearInsideReactTree();
3539 }
3540 function handleTouchMove(event) {
3541 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
3542 return;
3543 }
3544 const touch = event.touches[0];
3545 if (!touch) {
3546 return;
3547 }
3548 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
3549 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
3550 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
3551 if (distance > 5) {
3552 touchStateRef.current.dismissOnTouchEnd = true;
3553 }
3554 if (distance > 10) {
3555 closeOnPressOutside(event);
3556 cancelDismissOnEndTimeout.clear();
3557 touchStateRef.current = null;
3558 }
3559 }
3560 function handleTouchMoveCapture(event) {
3561 addTargetEventListenerOnce(event, handleTouchMove);
3562 }
3563 function handleTouchEnd(event) {
3564 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
3565 return;
3566 }
3567 if (touchStateRef.current.dismissOnTouchEnd) {
3568 closeOnPressOutside(event);
3569 }
3570 cancelDismissOnEndTimeout.clear();
3571 touchStateRef.current = null;
3572 }
3573 function handleTouchEndCapture(event) {
3574 addTargetEventListenerOnce(event, handleTouchEnd);
3575 }
3576 const doc = ownerDocument(floatingElement);
3577 const unsubscribe = mergeCleanups(escapeKey2 && mergeCleanups(addEventListener(doc, "keydown", closeOnEscapeKeyDown), addEventListener(doc, "compositionstart", handleCompositionStart), addEventListener(doc, "compositionend", handleCompositionEnd)), outsidePressEnabled && mergeCleanups(addEventListener(doc, "click", closeOnPressOutsideCapture, true), addEventListener(doc, "pointerdown", closeOnPressOutsideCapture, true), addEventListener(doc, "pointerup", handlePressEndCapture, true), addEventListener(doc, "pointercancel", handlePressEndCapture, true), addEventListener(doc, "mousedown", closeOnPressOutsideCapture, true), addEventListener(doc, "mouseup", handlePressEndCapture, true), addEventListener(doc, "touchstart", handleTouchStartCapture, true), addEventListener(doc, "touchmove", handleTouchMoveCapture, true), addEventListener(doc, "touchend", handleTouchEndCapture, true)));
3578 return () => {
3579 unsubscribe();
3580 compositionTimeout.clear();
3581 preventedPressSuppressionTimeout.clear();
3582 resetPressStartState();
3583 suppressNextOutsideClickRef.current = false;
3584 };
3585 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, tree, store, cancelDismissOnEndTimeout]);
3586 React19.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
3587 const reference = React19.useMemo(() => ({
3588 onKeyDown: closeOnEscapeKeyDown,
3589 [bubbleHandlerKeys[referencePressEvent]]: (event) => {
3590 if (!isReferencePressEnabled()) {
3591 return;
3592 }
3593 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
3594 },
3595 ...referencePressEvent !== "intentional" && {
3596 onClick(event) {
3597 if (!isReferencePressEnabled()) {
3598 return;
3599 }
3600 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
3601 }
3602 }
3603 }), [closeOnEscapeKeyDown, store, referencePressEvent, isReferencePressEnabled]);
3604 const markPressStartedInsideReactTree = useStableCallback((event) => {
3605 if (!open || !enabled || event.button !== 0) {
3606 return;
3607 }
3608 const target = getTarget(event.nativeEvent);
3609 if (!contains(store.select("floatingElement"), target)) {
3610 return;
3611 }
3612 if (!pressStartedInsideRef.current) {
3613 pressStartedInsideRef.current = true;
3614 pressStartPreventedRef.current = false;
3615 }
3616 });
3617 const markInsidePressStartPrevented = useStableCallback((event) => {
3618 if (!open || !enabled) {
3619 return;
3620 }
3621 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
3622 return;
3623 }
3624 if (pressStartedInsideRef.current) {
3625 pressStartPreventedRef.current = true;
3626 }
3627 });
3628 const floating = React19.useMemo(() => ({
3629 onKeyDown: closeOnEscapeKeyDown,
3630 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
3631 // `onPointerDown`, such as with <NumberField.ScrubArea>.
3632 // See https://github.com/mui/base-ui/pull/3379
3633 onPointerDown: markInsidePressStartPrevented,
3634 onMouseDown: markInsidePressStartPrevented,
3635 onClickCapture: markInsideReactTree,
3636 onMouseDownCapture(event) {
3637 markInsideReactTree();
3638 markPressStartedInsideReactTree(event);
3639 },
3640 onPointerDownCapture(event) {
3641 markInsideReactTree();
3642 markPressStartedInsideReactTree(event);
3643 },
3644 onMouseUpCapture: markInsideReactTree,
3645 onTouchEndCapture: markInsideReactTree,
3646 onTouchMoveCapture: markInsideReactTree
3647 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
3648 return React19.useMemo(() => enabled ? {
3649 reference,
3650 floating,
3651 trigger: reference
3652 } : {}, [enabled, reference, floating]);
3653 }
3654
3655 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
3656 var React25 = __toESM(require_react(), 1);
3657
3658 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
3659 function computeCoordsFromPlacement(_ref, placement, rtl) {
3660 let {
3661 reference,
3662 floating
3663 } = _ref;
3664 const sideAxis = getSideAxis(placement);
3665 const alignmentAxis = getAlignmentAxis(placement);
3666 const alignLength = getAxisLength(alignmentAxis);
3667 const side = getSide(placement);
3668 const isVertical = sideAxis === "y";
3669 const commonX = reference.x + reference.width / 2 - floating.width / 2;
3670 const commonY = reference.y + reference.height / 2 - floating.height / 2;
3671 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
3672 let coords;
3673 switch (side) {
3674 case "top":
3675 coords = {
3676 x: commonX,
3677 y: reference.y - floating.height
3678 };
3679 break;
3680 case "bottom":
3681 coords = {
3682 x: commonX,
3683 y: reference.y + reference.height
3684 };
3685 break;
3686 case "right":
3687 coords = {
3688 x: reference.x + reference.width,
3689 y: commonY
3690 };
3691 break;
3692 case "left":
3693 coords = {
3694 x: reference.x - floating.width,
3695 y: commonY
3696 };
3697 break;
3698 default:
3699 coords = {
3700 x: reference.x,
3701 y: reference.y
3702 };
3703 }
3704 switch (getAlignment(placement)) {
3705 case "start":
3706 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
3707 break;
3708 case "end":
3709 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
3710 break;
3711 }
3712 return coords;
3713 }
3714 async function detectOverflow(state, options) {
3715 var _await$platform$isEle;
3716 if (options === void 0) {
3717 options = {};
3718 }
3719 const {
3720 x: x2,
3721 y: y2,
3722 platform: platform3,
3723 rects,
3724 elements,
3725 strategy
3726 } = state;
3727 const {
3728 boundary = "clippingAncestors",
3729 rootBoundary = "viewport",
3730 elementContext = "floating",
3731 altBoundary = false,
3732 padding = 0
3733 } = evaluate(options, state);
3734 const paddingObject = getPaddingObject(padding);
3735 const altContext = elementContext === "floating" ? "reference" : "floating";
3736 const element = elements[altBoundary ? altContext : elementContext];
3737 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
3738 element: ((_await$platform$isEle = await (platform3.isElement == null ? void 0 : platform3.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform3.getDocumentElement == null ? void 0 : platform3.getDocumentElement(elements.floating)),
3739 boundary,
3740 rootBoundary,
3741 strategy
3742 }));
3743 const rect = elementContext === "floating" ? {
3744 x: x2,
3745 y: y2,
3746 width: rects.floating.width,
3747 height: rects.floating.height
3748 } : rects.reference;
3749 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
3750 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
3751 x: 1,
3752 y: 1
3753 } : {
3754 x: 1,
3755 y: 1
3756 };
3757 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
3758 elements,
3759 rect,
3760 offsetParent,
3761 strategy
3762 }) : rect);
3763 return {
3764 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
3765 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
3766 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
3767 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
3768 };
3769 }
3770 var MAX_RESET_COUNT = 50;
3771 var computePosition = async (reference, floating, config) => {
3772 const {
3773 placement = "bottom",
3774 strategy = "absolute",
3775 middleware = [],
3776 platform: platform3
3777 } = config;
3778 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
3779 ...platform3,
3780 detectOverflow
3781 };
3782 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
3783 let rects = await platform3.getElementRects({
3784 reference,
3785 floating,
3786 strategy
3787 });
3788 let {
3789 x: x2,
3790 y: y2
3791 } = computeCoordsFromPlacement(rects, placement, rtl);
3792 let statefulPlacement = placement;
3793 let resetCount = 0;
3794 const middlewareData = {};
3795 for (let i2 = 0; i2 < middleware.length; i2++) {
3796 const currentMiddleware = middleware[i2];
3797 if (!currentMiddleware) {
3798 continue;
3799 }
3800 const {
3801 name,
3802 fn
3803 } = currentMiddleware;
3804 const {
3805 x: nextX,
3806 y: nextY,
3807 data,
3808 reset
3809 } = await fn({
3810 x: x2,
3811 y: y2,
3812 initialPlacement: placement,
3813 placement: statefulPlacement,
3814 strategy,
3815 middlewareData,
3816 rects,
3817 platform: platformWithDetectOverflow,
3818 elements: {
3819 reference,
3820 floating
3821 }
3822 });
3823 x2 = nextX != null ? nextX : x2;
3824 y2 = nextY != null ? nextY : y2;
3825 middlewareData[name] = {
3826 ...middlewareData[name],
3827 ...data
3828 };
3829 if (reset && resetCount < MAX_RESET_COUNT) {
3830 resetCount++;
3831 if (typeof reset === "object") {
3832 if (reset.placement) {
3833 statefulPlacement = reset.placement;
3834 }
3835 if (reset.rects) {
3836 rects = reset.rects === true ? await platform3.getElementRects({
3837 reference,
3838 floating,
3839 strategy
3840 }) : reset.rects;
3841 }
3842 ({
3843 x: x2,
3844 y: y2
3845 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
3846 }
3847 i2 = -1;
3848 }
3849 }
3850 return {
3851 x: x2,
3852 y: y2,
3853 placement: statefulPlacement,
3854 strategy,
3855 middlewareData
3856 };
3857 };
3858 var flip = function(options) {
3859 if (options === void 0) {
3860 options = {};
3861 }
3862 return {
3863 name: "flip",
3864 options,
3865 async fn(state) {
3866 var _middlewareData$arrow, _middlewareData$flip;
3867 const {
3868 placement,
3869 middlewareData,
3870 rects,
3871 initialPlacement,
3872 platform: platform3,
3873 elements
3874 } = state;
3875 const {
3876 mainAxis: checkMainAxis = true,
3877 crossAxis: checkCrossAxis = true,
3878 fallbackPlacements: specifiedFallbackPlacements,
3879 fallbackStrategy = "bestFit",
3880 fallbackAxisSideDirection = "none",
3881 flipAlignment = true,
3882 ...detectOverflowOptions
3883 } = evaluate(options, state);
3884 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
3885 return {};
3886 }
3887 const side = getSide(placement);
3888 const initialSideAxis = getSideAxis(initialPlacement);
3889 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
3890 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
3891 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
3892 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
3893 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
3894 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
3895 }
3896 const placements2 = [initialPlacement, ...fallbackPlacements];
3897 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
3898 const overflows = [];
3899 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
3900 if (checkMainAxis) {
3901 overflows.push(overflow[side]);
3902 }
3903 if (checkCrossAxis) {
3904 const sides2 = getAlignmentSides(placement, rects, rtl);
3905 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
3906 }
3907 overflowsData = [...overflowsData, {
3908 placement,
3909 overflows
3910 }];
3911 if (!overflows.every((side2) => side2 <= 0)) {
3912 var _middlewareData$flip2, _overflowsData$filter;
3913 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
3914 const nextPlacement = placements2[nextIndex];
3915 if (nextPlacement) {
3916 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
3917 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
3918 // overflows the main axis.
3919 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) {
3920 return {
3921 data: {
3922 index: nextIndex,
3923 overflows: overflowsData
3924 },
3925 reset: {
3926 placement: nextPlacement
3927 }
3928 };
3929 }
3930 }
3931 let resetPlacement = (_overflowsData$filter = overflowsData.filter((d2) => d2.overflows[0] <= 0).sort((a2, b2) => a2.overflows[1] - b2.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
3932 if (!resetPlacement) {
3933 switch (fallbackStrategy) {
3934 case "bestFit": {
3935 var _overflowsData$filter2;
3936 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
3937 if (hasFallbackAxisSideDirection) {
3938 const currentSideAxis = getSideAxis(d2.placement);
3939 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
3940 // reading directions favoring greater width.
3941 currentSideAxis === "y";
3942 }
3943 return true;
3944 }).map((d2) => [d2.placement, d2.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a2, b2) => a2[1] - b2[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
3945 if (placement2) {
3946 resetPlacement = placement2;
3947 }
3948 break;
3949 }
3950 case "initialPlacement":
3951 resetPlacement = initialPlacement;
3952 break;
3953 }
3954 }
3955 if (placement !== resetPlacement) {
3956 return {
3957 reset: {
3958 placement: resetPlacement
3959 }
3960 };
3961 }
3962 }
3963 return {};
3964 }
3965 };
3966 };
3967 function getSideOffsets(overflow, rect) {
3968 return {
3969 top: overflow.top - rect.height,
3970 right: overflow.right - rect.width,
3971 bottom: overflow.bottom - rect.height,
3972 left: overflow.left - rect.width
3973 };
3974 }
3975 function isAnySideFullyClipped(overflow) {
3976 return sides.some((side) => overflow[side] >= 0);
3977 }
3978 var hide = function(options) {
3979 if (options === void 0) {
3980 options = {};
3981 }
3982 return {
3983 name: "hide",
3984 options,
3985 async fn(state) {
3986 const {
3987 rects,
3988 platform: platform3
3989 } = state;
3990 const {
3991 strategy = "referenceHidden",
3992 ...detectOverflowOptions
3993 } = evaluate(options, state);
3994 switch (strategy) {
3995 case "referenceHidden": {
3996 const overflow = await platform3.detectOverflow(state, {
3997 ...detectOverflowOptions,
3998 elementContext: "reference"
3999 });
4000 const offsets = getSideOffsets(overflow, rects.reference);
4001 return {
4002 data: {
4003 referenceHiddenOffsets: offsets,
4004 referenceHidden: isAnySideFullyClipped(offsets)
4005 }
4006 };
4007 }
4008 case "escaped": {
4009 const overflow = await platform3.detectOverflow(state, {
4010 ...detectOverflowOptions,
4011 altBoundary: true
4012 });
4013 const offsets = getSideOffsets(overflow, rects.floating);
4014 return {
4015 data: {
4016 escapedOffsets: offsets,
4017 escaped: isAnySideFullyClipped(offsets)
4018 }
4019 };
4020 }
4021 default: {
4022 return {};
4023 }
4024 }
4025 }
4026 };
4027 };
4028 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
4029 async function convertValueToCoords(state, options) {
4030 const {
4031 placement,
4032 platform: platform3,
4033 elements
4034 } = state;
4035 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4036 const side = getSide(placement);
4037 const alignment = getAlignment(placement);
4038 const isVertical = getSideAxis(placement) === "y";
4039 const mainAxisMulti = originSides.has(side) ? -1 : 1;
4040 const crossAxisMulti = rtl && isVertical ? -1 : 1;
4041 const rawValue = evaluate(options, state);
4042 let {
4043 mainAxis,
4044 crossAxis,
4045 alignmentAxis
4046 } = typeof rawValue === "number" ? {
4047 mainAxis: rawValue,
4048 crossAxis: 0,
4049 alignmentAxis: null
4050 } : {
4051 mainAxis: rawValue.mainAxis || 0,
4052 crossAxis: rawValue.crossAxis || 0,
4053 alignmentAxis: rawValue.alignmentAxis
4054 };
4055 if (alignment && typeof alignmentAxis === "number") {
4056 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
4057 }
4058 return isVertical ? {
4059 x: crossAxis * crossAxisMulti,
4060 y: mainAxis * mainAxisMulti
4061 } : {
4062 x: mainAxis * mainAxisMulti,
4063 y: crossAxis * crossAxisMulti
4064 };
4065 }
4066 var offset = function(options) {
4067 if (options === void 0) {
4068 options = 0;
4069 }
4070 return {
4071 name: "offset",
4072 options,
4073 async fn(state) {
4074 var _middlewareData$offse, _middlewareData$arrow;
4075 const {
4076 x: x2,
4077 y: y2,
4078 placement,
4079 middlewareData
4080 } = state;
4081 const diffCoords = await convertValueToCoords(state, options);
4082 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4083 return {};
4084 }
4085 return {
4086 x: x2 + diffCoords.x,
4087 y: y2 + diffCoords.y,
4088 data: {
4089 ...diffCoords,
4090 placement
4091 }
4092 };
4093 }
4094 };
4095 };
4096 var shift = function(options) {
4097 if (options === void 0) {
4098 options = {};
4099 }
4100 return {
4101 name: "shift",
4102 options,
4103 async fn(state) {
4104 const {
4105 x: x2,
4106 y: y2,
4107 placement,
4108 platform: platform3
4109 } = state;
4110 const {
4111 mainAxis: checkMainAxis = true,
4112 crossAxis: checkCrossAxis = false,
4113 limiter = {
4114 fn: (_ref) => {
4115 let {
4116 x: x3,
4117 y: y3
4118 } = _ref;
4119 return {
4120 x: x3,
4121 y: y3
4122 };
4123 }
4124 },
4125 ...detectOverflowOptions
4126 } = evaluate(options, state);
4127 const coords = {
4128 x: x2,
4129 y: y2
4130 };
4131 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4132 const crossAxis = getSideAxis(getSide(placement));
4133 const mainAxis = getOppositeAxis(crossAxis);
4134 let mainAxisCoord = coords[mainAxis];
4135 let crossAxisCoord = coords[crossAxis];
4136 if (checkMainAxis) {
4137 const minSide = mainAxis === "y" ? "top" : "left";
4138 const maxSide = mainAxis === "y" ? "bottom" : "right";
4139 const min2 = mainAxisCoord + overflow[minSide];
4140 const max2 = mainAxisCoord - overflow[maxSide];
4141 mainAxisCoord = clamp(min2, mainAxisCoord, max2);
4142 }
4143 if (checkCrossAxis) {
4144 const minSide = crossAxis === "y" ? "top" : "left";
4145 const maxSide = crossAxis === "y" ? "bottom" : "right";
4146 const min2 = crossAxisCoord + overflow[minSide];
4147 const max2 = crossAxisCoord - overflow[maxSide];
4148 crossAxisCoord = clamp(min2, crossAxisCoord, max2);
4149 }
4150 const limitedCoords = limiter.fn({
4151 ...state,
4152 [mainAxis]: mainAxisCoord,
4153 [crossAxis]: crossAxisCoord
4154 });
4155 return {
4156 ...limitedCoords,
4157 data: {
4158 x: limitedCoords.x - x2,
4159 y: limitedCoords.y - y2,
4160 enabled: {
4161 [mainAxis]: checkMainAxis,
4162 [crossAxis]: checkCrossAxis
4163 }
4164 }
4165 };
4166 }
4167 };
4168 };
4169 var limitShift = function(options) {
4170 if (options === void 0) {
4171 options = {};
4172 }
4173 return {
4174 options,
4175 fn(state) {
4176 const {
4177 x: x2,
4178 y: y2,
4179 placement,
4180 rects,
4181 middlewareData
4182 } = state;
4183 const {
4184 offset: offset4 = 0,
4185 mainAxis: checkMainAxis = true,
4186 crossAxis: checkCrossAxis = true
4187 } = evaluate(options, state);
4188 const coords = {
4189 x: x2,
4190 y: y2
4191 };
4192 const crossAxis = getSideAxis(placement);
4193 const mainAxis = getOppositeAxis(crossAxis);
4194 let mainAxisCoord = coords[mainAxis];
4195 let crossAxisCoord = coords[crossAxis];
4196 const rawOffset = evaluate(offset4, state);
4197 const computedOffset = typeof rawOffset === "number" ? {
4198 mainAxis: rawOffset,
4199 crossAxis: 0
4200 } : {
4201 mainAxis: 0,
4202 crossAxis: 0,
4203 ...rawOffset
4204 };
4205 if (checkMainAxis) {
4206 const len = mainAxis === "y" ? "height" : "width";
4207 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
4208 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
4209 if (mainAxisCoord < limitMin) {
4210 mainAxisCoord = limitMin;
4211 } else if (mainAxisCoord > limitMax) {
4212 mainAxisCoord = limitMax;
4213 }
4214 }
4215 if (checkCrossAxis) {
4216 var _middlewareData$offse, _middlewareData$offse2;
4217 const len = mainAxis === "y" ? "width" : "height";
4218 const isOriginSide = originSides.has(getSide(placement));
4219 const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
4220 const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
4221 if (crossAxisCoord < limitMin) {
4222 crossAxisCoord = limitMin;
4223 } else if (crossAxisCoord > limitMax) {
4224 crossAxisCoord = limitMax;
4225 }
4226 }
4227 return {
4228 [mainAxis]: mainAxisCoord,
4229 [crossAxis]: crossAxisCoord
4230 };
4231 }
4232 };
4233 };
4234 var size = function(options) {
4235 if (options === void 0) {
4236 options = {};
4237 }
4238 return {
4239 name: "size",
4240 options,
4241 async fn(state) {
4242 var _state$middlewareData, _state$middlewareData2;
4243 const {
4244 placement,
4245 rects,
4246 platform: platform3,
4247 elements
4248 } = state;
4249 const {
4250 apply = () => {
4251 },
4252 ...detectOverflowOptions
4253 } = evaluate(options, state);
4254 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4255 const side = getSide(placement);
4256 const alignment = getAlignment(placement);
4257 const isYAxis = getSideAxis(placement) === "y";
4258 const {
4259 width,
4260 height
4261 } = rects.floating;
4262 let heightSide;
4263 let widthSide;
4264 if (side === "top" || side === "bottom") {
4265 heightSide = side;
4266 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
4267 } else {
4268 widthSide = side;
4269 heightSide = alignment === "end" ? "top" : "bottom";
4270 }
4271 const maximumClippingHeight = height - overflow.top - overflow.bottom;
4272 const maximumClippingWidth = width - overflow.left - overflow.right;
4273 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
4274 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
4275 const noShift = !state.middlewareData.shift;
4276 let availableHeight = overflowAvailableHeight;
4277 let availableWidth = overflowAvailableWidth;
4278 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
4279 availableWidth = maximumClippingWidth;
4280 }
4281 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
4282 availableHeight = maximumClippingHeight;
4283 }
4284 if (noShift && !alignment) {
4285 const xMin = max(overflow.left, 0);
4286 const xMax = max(overflow.right, 0);
4287 const yMin = max(overflow.top, 0);
4288 const yMax = max(overflow.bottom, 0);
4289 if (isYAxis) {
4290 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
4291 } else {
4292 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
4293 }
4294 }
4295 await apply({
4296 ...state,
4297 availableWidth,
4298 availableHeight
4299 });
4300 const nextDimensions = await platform3.getDimensions(elements.floating);
4301 if (width !== nextDimensions.width || height !== nextDimensions.height) {
4302 return {
4303 reset: {
4304 rects: true
4305 }
4306 };
4307 }
4308 return {};
4309 }
4310 };
4311 };
4312
4313 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
4314 function getCssDimensions(element) {
4315 const css = getComputedStyle2(element);
4316 let width = parseFloat(css.width) || 0;
4317 let height = parseFloat(css.height) || 0;
4318 const hasOffset = isHTMLElement(element);
4319 const offsetWidth = hasOffset ? element.offsetWidth : width;
4320 const offsetHeight = hasOffset ? element.offsetHeight : height;
4321 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
4322 if (shouldFallback) {
4323 width = offsetWidth;
4324 height = offsetHeight;
4325 }
4326 return {
4327 width,
4328 height,
4329 $: shouldFallback
4330 };
4331 }
4332 function unwrapElement(element) {
4333 return !isElement(element) ? element.contextElement : element;
4334 }
4335 function getScale(element) {
4336 const domElement = unwrapElement(element);
4337 if (!isHTMLElement(domElement)) {
4338 return createCoords(1);
4339 }
4340 const rect = domElement.getBoundingClientRect();
4341 const {
4342 width,
4343 height,
4344 $: $2
4345 } = getCssDimensions(domElement);
4346 let x2 = ($2 ? round(rect.width) : rect.width) / width;
4347 let y2 = ($2 ? round(rect.height) : rect.height) / height;
4348 if (!x2 || !Number.isFinite(x2)) {
4349 x2 = 1;
4350 }
4351 if (!y2 || !Number.isFinite(y2)) {
4352 y2 = 1;
4353 }
4354 return {
4355 x: x2,
4356 y: y2
4357 };
4358 }
4359 var noOffsets = /* @__PURE__ */ createCoords(0);
4360 function getVisualOffsets(element) {
4361 const win = getWindow(element);
4362 if (!isWebKit() || !win.visualViewport) {
4363 return noOffsets;
4364 }
4365 return {
4366 x: win.visualViewport.offsetLeft,
4367 y: win.visualViewport.offsetTop
4368 };
4369 }
4370 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
4371 if (isFixed === void 0) {
4372 isFixed = false;
4373 }
4374 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
4375 return false;
4376 }
4377 return isFixed;
4378 }
4379 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
4380 if (includeScale === void 0) {
4381 includeScale = false;
4382 }
4383 if (isFixedStrategy === void 0) {
4384 isFixedStrategy = false;
4385 }
4386 const clientRect = element.getBoundingClientRect();
4387 const domElement = unwrapElement(element);
4388 let scale = createCoords(1);
4389 if (includeScale) {
4390 if (offsetParent) {
4391 if (isElement(offsetParent)) {
4392 scale = getScale(offsetParent);
4393 }
4394 } else {
4395 scale = getScale(element);
4396 }
4397 }
4398 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
4399 let x2 = (clientRect.left + visualOffsets.x) / scale.x;
4400 let y2 = (clientRect.top + visualOffsets.y) / scale.y;
4401 let width = clientRect.width / scale.x;
4402 let height = clientRect.height / scale.y;
4403 if (domElement) {
4404 const win = getWindow(domElement);
4405 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
4406 let currentWin = win;
4407 let currentIFrame = getFrameElement(currentWin);
4408 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
4409 const iframeScale = getScale(currentIFrame);
4410 const iframeRect = currentIFrame.getBoundingClientRect();
4411 const css = getComputedStyle2(currentIFrame);
4412 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
4413 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
4414 x2 *= iframeScale.x;
4415 y2 *= iframeScale.y;
4416 width *= iframeScale.x;
4417 height *= iframeScale.y;
4418 x2 += left;
4419 y2 += top;
4420 currentWin = getWindow(currentIFrame);
4421 currentIFrame = getFrameElement(currentWin);
4422 }
4423 }
4424 return rectToClientRect({
4425 width,
4426 height,
4427 x: x2,
4428 y: y2
4429 });
4430 }
4431 function getWindowScrollBarX(element, rect) {
4432 const leftScroll = getNodeScroll(element).scrollLeft;
4433 if (!rect) {
4434 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
4435 }
4436 return rect.left + leftScroll;
4437 }
4438 function getHTMLOffset(documentElement, scroll) {
4439 const htmlRect = documentElement.getBoundingClientRect();
4440 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
4441 const y2 = htmlRect.top + scroll.scrollTop;
4442 return {
4443 x: x2,
4444 y: y2
4445 };
4446 }
4447 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
4448 let {
4449 elements,
4450 rect,
4451 offsetParent,
4452 strategy
4453 } = _ref;
4454 const isFixed = strategy === "fixed";
4455 const documentElement = getDocumentElement(offsetParent);
4456 const topLayer = elements ? isTopLayer(elements.floating) : false;
4457 if (offsetParent === documentElement || topLayer && isFixed) {
4458 return rect;
4459 }
4460 let scroll = {
4461 scrollLeft: 0,
4462 scrollTop: 0
4463 };
4464 let scale = createCoords(1);
4465 const offsets = createCoords(0);
4466 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4467 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4468 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4469 scroll = getNodeScroll(offsetParent);
4470 }
4471 if (isOffsetParentAnElement) {
4472 const offsetRect = getBoundingClientRect(offsetParent);
4473 scale = getScale(offsetParent);
4474 offsets.x = offsetRect.x + offsetParent.clientLeft;
4475 offsets.y = offsetRect.y + offsetParent.clientTop;
4476 }
4477 }
4478 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4479 return {
4480 width: rect.width * scale.x,
4481 height: rect.height * scale.y,
4482 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
4483 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
4484 };
4485 }
4486 function getClientRects(element) {
4487 return Array.from(element.getClientRects());
4488 }
4489 function getDocumentRect(element) {
4490 const html = getDocumentElement(element);
4491 const scroll = getNodeScroll(element);
4492 const body = element.ownerDocument.body;
4493 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
4494 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
4495 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
4496 const y2 = -scroll.scrollTop;
4497 if (getComputedStyle2(body).direction === "rtl") {
4498 x2 += max(html.clientWidth, body.clientWidth) - width;
4499 }
4500 return {
4501 width,
4502 height,
4503 x: x2,
4504 y: y2
4505 };
4506 }
4507 var SCROLLBAR_MAX = 25;
4508 function getViewportRect(element, strategy) {
4509 const win = getWindow(element);
4510 const html = getDocumentElement(element);
4511 const visualViewport = win.visualViewport;
4512 let width = html.clientWidth;
4513 let height = html.clientHeight;
4514 let x2 = 0;
4515 let y2 = 0;
4516 if (visualViewport) {
4517 width = visualViewport.width;
4518 height = visualViewport.height;
4519 const visualViewportBased = isWebKit();
4520 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
4521 x2 = visualViewport.offsetLeft;
4522 y2 = visualViewport.offsetTop;
4523 }
4524 }
4525 const windowScrollbarX = getWindowScrollBarX(html);
4526 if (windowScrollbarX <= 0) {
4527 const doc = html.ownerDocument;
4528 const body = doc.body;
4529 const bodyStyles = getComputedStyle(body);
4530 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
4531 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
4532 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
4533 width -= clippingStableScrollbarWidth;
4534 }
4535 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
4536 width += windowScrollbarX;
4537 }
4538 return {
4539 width,
4540 height,
4541 x: x2,
4542 y: y2
4543 };
4544 }
4545 function getInnerBoundingClientRect(element, strategy) {
4546 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
4547 const top = clientRect.top + element.clientTop;
4548 const left = clientRect.left + element.clientLeft;
4549 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
4550 const width = element.clientWidth * scale.x;
4551 const height = element.clientHeight * scale.y;
4552 const x2 = left * scale.x;
4553 const y2 = top * scale.y;
4554 return {
4555 width,
4556 height,
4557 x: x2,
4558 y: y2
4559 };
4560 }
4561 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
4562 let rect;
4563 if (clippingAncestor === "viewport") {
4564 rect = getViewportRect(element, strategy);
4565 } else if (clippingAncestor === "document") {
4566 rect = getDocumentRect(getDocumentElement(element));
4567 } else if (isElement(clippingAncestor)) {
4568 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
4569 } else {
4570 const visualOffsets = getVisualOffsets(element);
4571 rect = {
4572 x: clippingAncestor.x - visualOffsets.x,
4573 y: clippingAncestor.y - visualOffsets.y,
4574 width: clippingAncestor.width,
4575 height: clippingAncestor.height
4576 };
4577 }
4578 return rectToClientRect(rect);
4579 }
4580 function hasFixedPositionAncestor(element, stopNode) {
4581 const parentNode = getParentNode(element);
4582 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
4583 return false;
4584 }
4585 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
4586 }
4587 function getClippingElementAncestors(element, cache) {
4588 const cachedResult = cache.get(element);
4589 if (cachedResult) {
4590 return cachedResult;
4591 }
4592 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
4593 let currentContainingBlockComputedStyle = null;
4594 const elementIsFixed = getComputedStyle2(element).position === "fixed";
4595 let currentNode = elementIsFixed ? getParentNode(element) : element;
4596 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
4597 const computedStyle = getComputedStyle2(currentNode);
4598 const currentNodeIsContaining = isContainingBlock(currentNode);
4599 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
4600 currentContainingBlockComputedStyle = null;
4601 }
4602 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
4603 if (shouldDropCurrentNode) {
4604 result = result.filter((ancestor) => ancestor !== currentNode);
4605 } else {
4606 currentContainingBlockComputedStyle = computedStyle;
4607 }
4608 currentNode = getParentNode(currentNode);
4609 }
4610 cache.set(element, result);
4611 return result;
4612 }
4613 function getClippingRect(_ref) {
4614 let {
4615 element,
4616 boundary,
4617 rootBoundary,
4618 strategy
4619 } = _ref;
4620 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
4621 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
4622 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
4623 let top = firstRect.top;
4624 let right = firstRect.right;
4625 let bottom = firstRect.bottom;
4626 let left = firstRect.left;
4627 for (let i2 = 1; i2 < clippingAncestors.length; i2++) {
4628 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy);
4629 top = max(rect.top, top);
4630 right = min(rect.right, right);
4631 bottom = min(rect.bottom, bottom);
4632 left = max(rect.left, left);
4633 }
4634 return {
4635 width: right - left,
4636 height: bottom - top,
4637 x: left,
4638 y: top
4639 };
4640 }
4641 function getDimensions(element) {
4642 const {
4643 width,
4644 height
4645 } = getCssDimensions(element);
4646 return {
4647 width,
4648 height
4649 };
4650 }
4651 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
4652 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4653 const documentElement = getDocumentElement(offsetParent);
4654 const isFixed = strategy === "fixed";
4655 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
4656 let scroll = {
4657 scrollLeft: 0,
4658 scrollTop: 0
4659 };
4660 const offsets = createCoords(0);
4661 function setLeftRTLScrollbarOffset() {
4662 offsets.x = getWindowScrollBarX(documentElement);
4663 }
4664 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4665 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4666 scroll = getNodeScroll(offsetParent);
4667 }
4668 if (isOffsetParentAnElement) {
4669 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
4670 offsets.x = offsetRect.x + offsetParent.clientLeft;
4671 offsets.y = offsetRect.y + offsetParent.clientTop;
4672 } else if (documentElement) {
4673 setLeftRTLScrollbarOffset();
4674 }
4675 }
4676 if (isFixed && !isOffsetParentAnElement && documentElement) {
4677 setLeftRTLScrollbarOffset();
4678 }
4679 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4680 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
4681 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
4682 return {
4683 x: x2,
4684 y: y2,
4685 width: rect.width,
4686 height: rect.height
4687 };
4688 }
4689 function isStaticPositioned(element) {
4690 return getComputedStyle2(element).position === "static";
4691 }
4692 function getTrueOffsetParent(element, polyfill) {
4693 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
4694 return null;
4695 }
4696 if (polyfill) {
4697 return polyfill(element);
4698 }
4699 let rawOffsetParent = element.offsetParent;
4700 if (getDocumentElement(element) === rawOffsetParent) {
4701 rawOffsetParent = rawOffsetParent.ownerDocument.body;
4702 }
4703 return rawOffsetParent;
4704 }
4705 function getOffsetParent(element, polyfill) {
4706 const win = getWindow(element);
4707 if (isTopLayer(element)) {
4708 return win;
4709 }
4710 if (!isHTMLElement(element)) {
4711 let svgOffsetParent = getParentNode(element);
4712 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
4713 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
4714 return svgOffsetParent;
4715 }
4716 svgOffsetParent = getParentNode(svgOffsetParent);
4717 }
4718 return win;
4719 }
4720 let offsetParent = getTrueOffsetParent(element, polyfill);
4721 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
4722 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
4723 }
4724 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
4725 return win;
4726 }
4727 return offsetParent || getContainingBlock(element) || win;
4728 }
4729 var getElementRects = async function(data) {
4730 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
4731 const getDimensionsFn = this.getDimensions;
4732 const floatingDimensions = await getDimensionsFn(data.floating);
4733 return {
4734 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
4735 floating: {
4736 x: 0,
4737 y: 0,
4738 width: floatingDimensions.width,
4739 height: floatingDimensions.height
4740 }
4741 };
4742 };
4743 function isRTL(element) {
4744 return getComputedStyle2(element).direction === "rtl";
4745 }
4746 var platform2 = {
4747 convertOffsetParentRelativeRectToViewportRelativeRect,
4748 getDocumentElement,
4749 getClippingRect,
4750 getOffsetParent,
4751 getElementRects,
4752 getClientRects,
4753 getDimensions,
4754 getScale,
4755 isElement,
4756 isRTL
4757 };
4758 function rectsAreEqual(a2, b2) {
4759 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
4760 }
4761 function observeMove(element, onMove) {
4762 let io = null;
4763 let timeoutId;
4764 const root = getDocumentElement(element);
4765 function cleanup() {
4766 var _io;
4767 clearTimeout(timeoutId);
4768 (_io = io) == null || _io.disconnect();
4769 io = null;
4770 }
4771 function refresh(skip, threshold) {
4772 if (skip === void 0) {
4773 skip = false;
4774 }
4775 if (threshold === void 0) {
4776 threshold = 1;
4777 }
4778 cleanup();
4779 const elementRectForRootMargin = element.getBoundingClientRect();
4780 const {
4781 left,
4782 top,
4783 width,
4784 height
4785 } = elementRectForRootMargin;
4786 if (!skip) {
4787 onMove();
4788 }
4789 if (!width || !height) {
4790 return;
4791 }
4792 const insetTop = floor(top);
4793 const insetRight = floor(root.clientWidth - (left + width));
4794 const insetBottom = floor(root.clientHeight - (top + height));
4795 const insetLeft = floor(left);
4796 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
4797 const options = {
4798 rootMargin,
4799 threshold: max(0, min(1, threshold)) || 1
4800 };
4801 let isFirstUpdate = true;
4802 function handleObserve(entries) {
4803 const ratio = entries[0].intersectionRatio;
4804 if (ratio !== threshold) {
4805 if (!isFirstUpdate) {
4806 return refresh();
4807 }
4808 if (!ratio) {
4809 timeoutId = setTimeout(() => {
4810 refresh(false, 1e-7);
4811 }, 1e3);
4812 } else {
4813 refresh(false, ratio);
4814 }
4815 }
4816 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
4817 refresh();
4818 }
4819 isFirstUpdate = false;
4820 }
4821 try {
4822 io = new IntersectionObserver(handleObserve, {
4823 ...options,
4824 // Handle <iframe>s
4825 root: root.ownerDocument
4826 });
4827 } catch (_e) {
4828 io = new IntersectionObserver(handleObserve, options);
4829 }
4830 io.observe(element);
4831 }
4832 refresh(true);
4833 return cleanup;
4834 }
4835 function autoUpdate(reference, floating, update2, options) {
4836 if (options === void 0) {
4837 options = {};
4838 }
4839 const {
4840 ancestorScroll = true,
4841 ancestorResize = true,
4842 elementResize = typeof ResizeObserver === "function",
4843 layoutShift = typeof IntersectionObserver === "function",
4844 animationFrame = false
4845 } = options;
4846 const referenceEl = unwrapElement(reference);
4847 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
4848 ancestors.forEach((ancestor) => {
4849 ancestorScroll && ancestor.addEventListener("scroll", update2, {
4850 passive: true
4851 });
4852 ancestorResize && ancestor.addEventListener("resize", update2);
4853 });
4854 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
4855 let reobserveFrame = -1;
4856 let resizeObserver = null;
4857 if (elementResize) {
4858 resizeObserver = new ResizeObserver((_ref) => {
4859 let [firstEntry] = _ref;
4860 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
4861 resizeObserver.unobserve(floating);
4862 cancelAnimationFrame(reobserveFrame);
4863 reobserveFrame = requestAnimationFrame(() => {
4864 var _resizeObserver;
4865 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
4866 });
4867 }
4868 update2();
4869 });
4870 if (referenceEl && !animationFrame) {
4871 resizeObserver.observe(referenceEl);
4872 }
4873 if (floating) {
4874 resizeObserver.observe(floating);
4875 }
4876 }
4877 let frameId;
4878 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
4879 if (animationFrame) {
4880 frameLoop();
4881 }
4882 function frameLoop() {
4883 const nextRefRect = getBoundingClientRect(reference);
4884 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
4885 update2();
4886 }
4887 prevRefRect = nextRefRect;
4888 frameId = requestAnimationFrame(frameLoop);
4889 }
4890 update2();
4891 return () => {
4892 var _resizeObserver2;
4893 ancestors.forEach((ancestor) => {
4894 ancestorScroll && ancestor.removeEventListener("scroll", update2);
4895 ancestorResize && ancestor.removeEventListener("resize", update2);
4896 });
4897 cleanupIo == null || cleanupIo();
4898 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
4899 resizeObserver = null;
4900 if (animationFrame) {
4901 cancelAnimationFrame(frameId);
4902 }
4903 };
4904 }
4905 var offset2 = offset;
4906 var shift2 = shift;
4907 var flip2 = flip;
4908 var size2 = size;
4909 var hide2 = hide;
4910 var limitShift2 = limitShift;
4911 var computePosition2 = (reference, floating, options) => {
4912 const cache = /* @__PURE__ */ new Map();
4913 const mergedOptions = {
4914 platform: platform2,
4915 ...options
4916 };
4917 const platformWithCache = {
4918 ...mergedOptions.platform,
4919 _c: cache
4920 };
4921 return computePosition(reference, floating, {
4922 ...mergedOptions,
4923 platform: platformWithCache
4924 });
4925 };
4926
4927 // node_modules/@base-ui/react/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
4928 var React20 = __toESM(require_react(), 1);
4929 var import_react2 = __toESM(require_react(), 1);
4930 var ReactDOM3 = __toESM(require_react_dom(), 1);
4931 var isClient = typeof document !== "undefined";
4932 var noop2 = function noop3() {
4933 };
4934 var index = isClient ? import_react2.useLayoutEffect : noop2;
4935 function deepEqual(a2, b2) {
4936 if (a2 === b2) {
4937 return true;
4938 }
4939 if (typeof a2 !== typeof b2) {
4940 return false;
4941 }
4942 if (typeof a2 === "function" && a2.toString() === b2.toString()) {
4943 return true;
4944 }
4945 let length;
4946 let i2;
4947 let keys;
4948 if (a2 && b2 && typeof a2 === "object") {
4949 if (Array.isArray(a2)) {
4950 length = a2.length;
4951 if (length !== b2.length) return false;
4952 for (i2 = length; i2-- !== 0; ) {
4953 if (!deepEqual(a2[i2], b2[i2])) {
4954 return false;
4955 }
4956 }
4957 return true;
4958 }
4959 keys = Object.keys(a2);
4960 length = keys.length;
4961 if (length !== Object.keys(b2).length) {
4962 return false;
4963 }
4964 for (i2 = length; i2-- !== 0; ) {
4965 if (!{}.hasOwnProperty.call(b2, keys[i2])) {
4966 return false;
4967 }
4968 }
4969 for (i2 = length; i2-- !== 0; ) {
4970 const key = keys[i2];
4971 if (key === "_owner" && a2.$$typeof) {
4972 continue;
4973 }
4974 if (!deepEqual(a2[key], b2[key])) {
4975 return false;
4976 }
4977 }
4978 return true;
4979 }
4980 return a2 !== a2 && b2 !== b2;
4981 }
4982 function getDPR(element) {
4983 if (typeof window === "undefined") {
4984 return 1;
4985 }
4986 const win = element.ownerDocument.defaultView || window;
4987 return win.devicePixelRatio || 1;
4988 }
4989 function roundByDPR(element, value) {
4990 const dpr = getDPR(element);
4991 return Math.round(value * dpr) / dpr;
4992 }
4993 function useLatestRef(value) {
4994 const ref = React20.useRef(value);
4995 index(() => {
4996 ref.current = value;
4997 });
4998 return ref;
4999 }
5000 function useFloating(options) {
5001 if (options === void 0) {
5002 options = {};
5003 }
5004 const {
5005 placement = "bottom",
5006 strategy = "absolute",
5007 middleware = [],
5008 platform: platform3,
5009 elements: {
5010 reference: externalReference,
5011 floating: externalFloating
5012 } = {},
5013 transform = true,
5014 whileElementsMounted,
5015 open
5016 } = options;
5017 const [data, setData] = React20.useState({
5018 x: 0,
5019 y: 0,
5020 strategy,
5021 placement,
5022 middlewareData: {},
5023 isPositioned: false
5024 });
5025 const [latestMiddleware, setLatestMiddleware] = React20.useState(middleware);
5026 if (!deepEqual(latestMiddleware, middleware)) {
5027 setLatestMiddleware(middleware);
5028 }
5029 const [_reference, _setReference] = React20.useState(null);
5030 const [_floating, _setFloating] = React20.useState(null);
5031 const setReference = React20.useCallback((node) => {
5032 if (node !== referenceRef.current) {
5033 referenceRef.current = node;
5034 _setReference(node);
5035 }
5036 }, []);
5037 const setFloating = React20.useCallback((node) => {
5038 if (node !== floatingRef.current) {
5039 floatingRef.current = node;
5040 _setFloating(node);
5041 }
5042 }, []);
5043 const referenceEl = externalReference || _reference;
5044 const floatingEl = externalFloating || _floating;
5045 const referenceRef = React20.useRef(null);
5046 const floatingRef = React20.useRef(null);
5047 const dataRef = React20.useRef(data);
5048 const hasWhileElementsMounted = whileElementsMounted != null;
5049 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
5050 const platformRef = useLatestRef(platform3);
5051 const openRef = useLatestRef(open);
5052 const update2 = React20.useCallback(() => {
5053 if (!referenceRef.current || !floatingRef.current) {
5054 return;
5055 }
5056 const config = {
5057 placement,
5058 strategy,
5059 middleware: latestMiddleware
5060 };
5061 if (platformRef.current) {
5062 config.platform = platformRef.current;
5063 }
5064 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
5065 const fullData = {
5066 ...data2,
5067 // The floating element's position may be recomputed while it's closed
5068 // but still mounted (such as when transitioning out). To ensure
5069 // `isPositioned` will be `false` initially on the next open, avoid
5070 // setting it to `true` when `open === false` (must be specified).
5071 isPositioned: openRef.current !== false
5072 };
5073 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
5074 dataRef.current = fullData;
5075 ReactDOM3.flushSync(() => {
5076 setData(fullData);
5077 });
5078 }
5079 });
5080 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
5081 index(() => {
5082 if (open === false && dataRef.current.isPositioned) {
5083 dataRef.current.isPositioned = false;
5084 setData((data2) => ({
5085 ...data2,
5086 isPositioned: false
5087 }));
5088 }
5089 }, [open]);
5090 const isMountedRef = React20.useRef(false);
5091 index(() => {
5092 isMountedRef.current = true;
5093 return () => {
5094 isMountedRef.current = false;
5095 };
5096 }, []);
5097 index(() => {
5098 if (referenceEl) referenceRef.current = referenceEl;
5099 if (floatingEl) floatingRef.current = floatingEl;
5100 if (referenceEl && floatingEl) {
5101 if (whileElementsMountedRef.current) {
5102 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
5103 }
5104 update2();
5105 }
5106 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
5107 const refs = React20.useMemo(() => ({
5108 reference: referenceRef,
5109 floating: floatingRef,
5110 setReference,
5111 setFloating
5112 }), [setReference, setFloating]);
5113 const elements = React20.useMemo(() => ({
5114 reference: referenceEl,
5115 floating: floatingEl
5116 }), [referenceEl, floatingEl]);
5117 const floatingStyles = React20.useMemo(() => {
5118 const initialStyles = {
5119 position: strategy,
5120 left: 0,
5121 top: 0
5122 };
5123 if (!elements.floating) {
5124 return initialStyles;
5125 }
5126 const x2 = roundByDPR(elements.floating, data.x);
5127 const y2 = roundByDPR(elements.floating, data.y);
5128 if (transform) {
5129 return {
5130 ...initialStyles,
5131 transform: "translate(" + x2 + "px, " + y2 + "px)",
5132 ...getDPR(elements.floating) >= 1.5 && {
5133 willChange: "transform"
5134 }
5135 };
5136 }
5137 return {
5138 position: strategy,
5139 left: x2,
5140 top: y2
5141 };
5142 }, [strategy, transform, elements.floating, data.x, data.y]);
5143 return React20.useMemo(() => ({
5144 ...data,
5145 update: update2,
5146 refs,
5147 elements,
5148 floatingStyles
5149 }), [data, update2, refs, elements, floatingStyles]);
5150 }
5151 var offset3 = (options, deps) => {
5152 const result = offset2(options);
5153 return {
5154 name: result.name,
5155 fn: result.fn,
5156 options: [options, deps]
5157 };
5158 };
5159 var shift3 = (options, deps) => {
5160 const result = shift2(options);
5161 return {
5162 name: result.name,
5163 fn: result.fn,
5164 options: [options, deps]
5165 };
5166 };
5167 var limitShift3 = (options, deps) => {
5168 const result = limitShift2(options);
5169 return {
5170 fn: result.fn,
5171 options: [options, deps]
5172 };
5173 };
5174 var flip3 = (options, deps) => {
5175 const result = flip2(options);
5176 return {
5177 name: result.name,
5178 fn: result.fn,
5179 options: [options, deps]
5180 };
5181 };
5182 var size3 = (options, deps) => {
5183 const result = size2(options);
5184 return {
5185 name: result.name,
5186 fn: result.fn,
5187 options: [options, deps]
5188 };
5189 };
5190 var hide3 = (options, deps) => {
5191 const result = hide2(options);
5192 return {
5193 name: result.name,
5194 fn: result.fn,
5195 options: [options, deps]
5196 };
5197 };
5198
5199 // node_modules/@base-ui/utils/esm/store/createSelector.js
5200 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => {
5201 if (other.length > 0) {
5202 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
5203 }
5204 let selector2;
5205 if (a2 && b2 && c2 && d2 && e2 && f2) {
5206 selector2 = (state, a1, a22, a3) => {
5207 const va = a2(state, a1, a22, a3);
5208 const vb = b2(state, a1, a22, a3);
5209 const vc = c2(state, a1, a22, a3);
5210 const vd = d2(state, a1, a22, a3);
5211 const ve = e2(state, a1, a22, a3);
5212 return f2(va, vb, vc, vd, ve, a1, a22, a3);
5213 };
5214 } else if (a2 && b2 && c2 && d2 && e2) {
5215 selector2 = (state, a1, a22, a3) => {
5216 const va = a2(state, a1, a22, a3);
5217 const vb = b2(state, a1, a22, a3);
5218 const vc = c2(state, a1, a22, a3);
5219 const vd = d2(state, a1, a22, a3);
5220 return e2(va, vb, vc, vd, a1, a22, a3);
5221 };
5222 } else if (a2 && b2 && c2 && d2) {
5223 selector2 = (state, a1, a22, a3) => {
5224 const va = a2(state, a1, a22, a3);
5225 const vb = b2(state, a1, a22, a3);
5226 const vc = c2(state, a1, a22, a3);
5227 return d2(va, vb, vc, a1, a22, a3);
5228 };
5229 } else if (a2 && b2 && c2) {
5230 selector2 = (state, a1, a22, a3) => {
5231 const va = a2(state, a1, a22, a3);
5232 const vb = b2(state, a1, a22, a3);
5233 return c2(va, vb, a1, a22, a3);
5234 };
5235 } else if (a2 && b2) {
5236 selector2 = (state, a1, a22, a3) => {
5237 const va = a2(state, a1, a22, a3);
5238 return b2(va, a1, a22, a3);
5239 };
5240 } else if (a2) {
5241 selector2 = a2;
5242 } else {
5243 throw (
5244 /* minify-error-disabled */
5245 new Error("Missing arguments")
5246 );
5247 }
5248 return selector2;
5249 };
5250
5251 // node_modules/@base-ui/utils/esm/store/useStore.js
5252 var React22 = __toESM(require_react(), 1);
5253 var import_shim = __toESM(require_shim(), 1);
5254 var import_with_selector = __toESM(require_with_selector(), 1);
5255
5256 // node_modules/@base-ui/utils/esm/fastHooks.js
5257 var React21 = __toESM(require_react(), 1);
5258 var hooks = [];
5259 var currentInstance = void 0;
5260 function getInstance() {
5261 return currentInstance;
5262 }
5263 function register(hook) {
5264 hooks.push(hook);
5265 }
5266 function fastComponent(fn) {
5267 const FastComponent = (props, forwardedRef) => {
5268 const instance = useRefWithInit(createInstance).current;
5269 let result;
5270 try {
5271 currentInstance = instance;
5272 for (const hook of hooks) {
5273 hook.before(instance);
5274 }
5275 result = fn(props, forwardedRef);
5276 for (const hook of hooks) {
5277 hook.after(instance);
5278 }
5279 instance.didInitialize = true;
5280 } finally {
5281 currentInstance = void 0;
5282 }
5283 return result;
5284 };
5285 FastComponent.displayName = fn.displayName || fn.name;
5286 return FastComponent;
5287 }
5288 function fastComponentRef(fn) {
5289 return /* @__PURE__ */ React21.forwardRef(fastComponent(fn));
5290 }
5291 function createInstance() {
5292 return {
5293 didInitialize: false
5294 };
5295 }
5296
5297 // node_modules/@base-ui/utils/esm/store/useStore.js
5298 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
5299 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
5300 function useStore(store, selector2, a1, a2, a3) {
5301 return useStoreImplementation(store, selector2, a1, a2, a3);
5302 }
5303 function useStoreR19(store, selector2, a1, a2, a3) {
5304 const getSelection = React22.useCallback(() => selector2(store.getSnapshot(), a1, a2, a3), [store, selector2, a1, a2, a3]);
5305 return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection);
5306 }
5307 register({
5308 before(instance) {
5309 instance.syncIndex = 0;
5310 if (!instance.didInitialize) {
5311 instance.syncTick = 1;
5312 instance.syncHooks = [];
5313 instance.didChangeStore = true;
5314 instance.getSnapshot = () => {
5315 let didChange2 = false;
5316 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) {
5317 const hook = instance.syncHooks[i2];
5318 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
5319 if (hook.didChange || !Object.is(hook.value, value)) {
5320 didChange2 = true;
5321 hook.value = value;
5322 hook.didChange = false;
5323 }
5324 }
5325 if (didChange2) {
5326 instance.syncTick += 1;
5327 }
5328 return instance.syncTick;
5329 };
5330 }
5331 },
5332 after(instance) {
5333 if (instance.syncHooks.length > 0) {
5334 if (instance.didChangeStore) {
5335 instance.didChangeStore = false;
5336 instance.subscribe = (onStoreChange) => {
5337 const stores = /* @__PURE__ */ new Set();
5338 for (const hook of instance.syncHooks) {
5339 stores.add(hook.store);
5340 }
5341 const unsubscribes = [];
5342 for (const store of stores) {
5343 unsubscribes.push(store.subscribe(onStoreChange));
5344 }
5345 return () => {
5346 for (const unsubscribe of unsubscribes) {
5347 unsubscribe();
5348 }
5349 };
5350 };
5351 }
5352 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
5353 }
5354 }
5355 });
5356 function useStoreFast(store, selector2, a1, a2, a3) {
5357 const instance = getInstance();
5358 if (!instance) {
5359 return useStoreR19(store, selector2, a1, a2, a3);
5360 }
5361 const index2 = instance.syncIndex;
5362 instance.syncIndex += 1;
5363 let hook;
5364 if (!instance.didInitialize) {
5365 hook = {
5366 store,
5367 selector: selector2,
5368 a1,
5369 a2,
5370 a3,
5371 value: selector2(store.getSnapshot(), a1, a2, a3),
5372 didChange: false
5373 };
5374 instance.syncHooks.push(hook);
5375 } else {
5376 hook = instance.syncHooks[index2];
5377 if (hook.store !== store || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
5378 if (hook.store !== store) {
5379 instance.didChangeStore = true;
5380 }
5381 hook.store = store;
5382 hook.selector = selector2;
5383 hook.a1 = a1;
5384 hook.a2 = a2;
5385 hook.a3 = a3;
5386 hook.didChange = true;
5387 }
5388 }
5389 return hook.value;
5390 }
5391 function useStoreLegacy(store, selector2, a1, a2, a3) {
5392 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector2(state, a1, a2, a3));
5393 }
5394
5395 // node_modules/@base-ui/utils/esm/store/Store.js
5396 var Store = class {
5397 /**
5398 * The current state of the store.
5399 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
5400 * 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).
5401 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
5402 *
5403 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
5404 */
5405 // Internal state to handle recursive `setState()` calls
5406 constructor(state) {
5407 this.state = state;
5408 this.listeners = /* @__PURE__ */ new Set();
5409 this.updateTick = 0;
5410 }
5411 /**
5412 * Registers a listener that will be called whenever the store's state changes.
5413 *
5414 * @param fn The listener function to be called on state changes.
5415 * @returns A function to unsubscribe the listener.
5416 */
5417 subscribe = (fn) => {
5418 this.listeners.add(fn);
5419 return () => {
5420 this.listeners.delete(fn);
5421 };
5422 };
5423 /**
5424 * Returns the current state of the store.
5425 */
5426 getSnapshot = () => {
5427 return this.state;
5428 };
5429 /**
5430 * Updates the entire store's state and notifies all registered listeners.
5431 *
5432 * @param newState The new state to set for the store.
5433 */
5434 setState(newState) {
5435 if (this.state === newState) {
5436 return;
5437 }
5438 this.state = newState;
5439 this.updateTick += 1;
5440 const currentTick = this.updateTick;
5441 for (const listener of this.listeners) {
5442 if (currentTick !== this.updateTick) {
5443 return;
5444 }
5445 listener(newState);
5446 }
5447 }
5448 /**
5449 * Merges the provided changes into the current state and notifies listeners if there are changes.
5450 *
5451 * @param changes An object containing the changes to apply to the current state.
5452 */
5453 update(changes) {
5454 for (const key in changes) {
5455 if (!Object.is(this.state[key], changes[key])) {
5456 this.setState({
5457 ...this.state,
5458 ...changes
5459 });
5460 return;
5461 }
5462 }
5463 }
5464 /**
5465 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
5466 *
5467 * @param key The key in the store's state to update.
5468 * @param value The new value to set for the specified key.
5469 */
5470 set(key, value) {
5471 if (!Object.is(this.state[key], value)) {
5472 this.setState({
5473 ...this.state,
5474 [key]: value
5475 });
5476 }
5477 }
5478 /**
5479 * Gives the state a new reference and updates all registered listeners.
5480 */
5481 notifyAll() {
5482 const newState = {
5483 ...this.state
5484 };
5485 this.setState(newState);
5486 }
5487 use(selector2, a1, a2, a3) {
5488 return useStore(this, selector2, a1, a2, a3);
5489 }
5490 };
5491
5492 // node_modules/@base-ui/utils/esm/store/ReactStore.js
5493 var React23 = __toESM(require_react(), 1);
5494 var ReactStore = class extends Store {
5495 /**
5496 * Creates a new ReactStore instance.
5497 *
5498 * @param state Initial state of the store.
5499 * @param context Non-reactive context values.
5500 * @param selectors Optional selectors for use with `useState`.
5501 */
5502 constructor(state, context = {}, selectors3) {
5503 super(state);
5504 this.context = context;
5505 this.selectors = selectors3;
5506 }
5507 /**
5508 * Non-reactive values such as refs, callbacks, etc.
5509 */
5510 /**
5511 * Synchronizes a single external value into the store.
5512 *
5513 * Note that the while the value in `state` is updated immediately, the value returned
5514 * by `useState` is updated before the next render (similarly to React's `useState`).
5515 */
5516 useSyncedValue(key, value) {
5517 React23.useDebugValue(key);
5518 useIsoLayoutEffect(() => {
5519 if (this.state[key] !== value) {
5520 this.set(key, value);
5521 }
5522 }, [key, value]);
5523 }
5524 /**
5525 * Synchronizes a single external value into the store and
5526 * cleans it up (sets to `undefined`) on unmount.
5527 *
5528 * Note that the while the value in `state` is updated immediately, the value returned
5529 * by `useState` is updated before the next render (similarly to React's `useState`).
5530 */
5531 useSyncedValueWithCleanup(key, value) {
5532 const store = this;
5533 useIsoLayoutEffect(() => {
5534 if (store.state[key] !== value) {
5535 store.set(key, value);
5536 }
5537 return () => {
5538 store.set(key, void 0);
5539 };
5540 }, [store, key, value]);
5541 }
5542 /**
5543 * Synchronizes multiple external values into the store.
5544 *
5545 * Note that the while the values in `state` are updated immediately, the values returned
5546 * by `useState` are updated before the next render (similarly to React's `useState`).
5547 */
5548 useSyncedValues(statePart) {
5549 const store = this;
5550 if (true) {
5551 React23.useDebugValue(statePart, (p2) => Object.keys(p2));
5552 const keys = React23.useRef(Object.keys(statePart)).current;
5553 const nextKeys = Object.keys(statePart);
5554 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
5555 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
5556 }
5557 }
5558 const dependencies = Object.values(statePart);
5559 useIsoLayoutEffect(() => {
5560 store.update(statePart);
5561 }, [store, ...dependencies]);
5562 }
5563 /**
5564 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
5565 * is non-undefined, the store's state at `key` is updated to match `controlled`.
5566 */
5567 useControlledProp(key, controlled) {
5568 React23.useDebugValue(key);
5569 const isControlled = controlled !== void 0;
5570 useIsoLayoutEffect(() => {
5571 if (isControlled && !Object.is(this.state[key], controlled)) {
5572 super.setState({
5573 ...this.state,
5574 [key]: controlled
5575 });
5576 }
5577 }, [key, controlled, isControlled]);
5578 if (true) {
5579 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
5580 if (!cache.has(key)) {
5581 cache.set(key, isControlled);
5582 }
5583 const previouslyControlled = cache.get(key);
5584 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
5585 console.error(`A component is changing the ${isControlled ? "" : "un"}controlled state of ${key.toString()} to be ${isControlled ? "un" : ""}controlled. Elements should not switch from uncontrolled to controlled (or vice versa).`);
5586 }
5587 }
5588 }
5589 /** Gets the current value from the store using a selector with the provided key.
5590 *
5591 * @param key Key of the selector to use.
5592 */
5593 select(key, a1, a2, a3) {
5594 const selector2 = this.selectors[key];
5595 return selector2(this.state, a1, a2, a3);
5596 }
5597 /**
5598 * Returns a value from the store's state using a selector function.
5599 * Used to subscribe to specific parts of the state.
5600 * This methods causes a rerender whenever the selected state changes.
5601 *
5602 * @param key Key of the selector to use.
5603 */
5604 useState(key, a1, a2, a3) {
5605 React23.useDebugValue(key);
5606 return useStore(this, this.selectors[key], a1, a2, a3);
5607 }
5608 /**
5609 * Wraps a function with `useStableCallback` to ensure it has a stable reference
5610 * and assigns it to the context.
5611 *
5612 * @param key Key of the event callback. Must be a function in the context.
5613 * @param fn Function to assign.
5614 */
5615 useContextCallback(key, fn) {
5616 React23.useDebugValue(key);
5617 const stableFunction = useStableCallback(fn ?? NOOP);
5618 this.context[key] = stableFunction;
5619 }
5620 /**
5621 * Returns a stable setter function for a specific key in the store's state.
5622 * It's commonly used to pass as a ref callback to React elements.
5623 *
5624 * @param key Key of the state to set.
5625 */
5626 useStateSetter(key) {
5627 const ref = React23.useRef(void 0);
5628 if (ref.current === void 0) {
5629 ref.current = (value) => {
5630 this.set(key, value);
5631 };
5632 }
5633 return ref.current;
5634 }
5635 /**
5636 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
5637 *
5638 * @param key Key of the selector to observe.
5639 * @param listener Listener function called when the selector result changes.
5640 */
5641 observe(selector2, listener) {
5642 let selectFn;
5643 if (typeof selector2 === "function") {
5644 selectFn = selector2;
5645 } else {
5646 selectFn = this.selectors[selector2];
5647 }
5648 let prevValue = selectFn(this.state);
5649 listener(prevValue, prevValue, this);
5650 return this.subscribe((nextState) => {
5651 const nextValue = selectFn(nextState);
5652 if (!Object.is(prevValue, nextValue)) {
5653 const oldValue = prevValue;
5654 prevValue = nextValue;
5655 listener(nextValue, oldValue, this);
5656 }
5657 });
5658 }
5659 };
5660
5661 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingRootStore.js
5662 var selectors = {
5663 open: createSelector((state) => state.open),
5664 transitionStatus: createSelector((state) => state.transitionStatus),
5665 domReferenceElement: createSelector((state) => state.domReferenceElement),
5666 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
5667 floatingElement: createSelector((state) => state.floatingElement),
5668 floatingId: createSelector((state) => state.floatingId)
5669 };
5670 var FloatingRootStore = class extends ReactStore {
5671 constructor(options) {
5672 const {
5673 syncOnly,
5674 nested,
5675 onOpenChange,
5676 triggerElements,
5677 ...initialState
5678 } = options;
5679 super({
5680 ...initialState,
5681 positionReference: initialState.referenceElement,
5682 domReferenceElement: initialState.referenceElement
5683 }, {
5684 onOpenChange,
5685 dataRef: {
5686 current: {}
5687 },
5688 events: createEventEmitter(),
5689 nested,
5690 triggerElements
5691 }, selectors);
5692 this.syncOnly = syncOnly;
5693 }
5694 /**
5695 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
5696 */
5697 syncOpenEvent = (newOpen, event) => {
5698 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
5699 // click events to upgrade a hover-open.
5700 event != null && isClickLikeEvent(event)) {
5701 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
5702 }
5703 };
5704 /**
5705 * Runs the root-owned side effects for an open state change.
5706 */
5707 dispatchOpenChange = (newOpen, eventDetails) => {
5708 this.syncOpenEvent(newOpen, eventDetails.event);
5709 const details = {
5710 open: newOpen,
5711 reason: eventDetails.reason,
5712 nativeEvent: eventDetails.event,
5713 nested: this.context.nested,
5714 triggerElement: eventDetails.trigger
5715 };
5716 this.context.events.emit("openchange", details);
5717 };
5718 /**
5719 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
5720 *
5721 * @param newOpen The new open state.
5722 * @param eventDetails Details about the event that triggered the open state change.
5723 */
5724 setOpen = (newOpen, eventDetails) => {
5725 if (this.syncOnly) {
5726 this.context.onOpenChange?.(newOpen, eventDetails);
5727 return;
5728 }
5729 this.dispatchOpenChange(newOpen, eventDetails);
5730 this.context.onOpenChange?.(newOpen, eventDetails);
5731 };
5732 };
5733
5734 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
5735 var React24 = __toESM(require_react(), 1);
5736 function useTriggerRegistration(id, store) {
5737 const registeredElementIdRef = React24.useRef(null);
5738 const registeredElementRef = React24.useRef(null);
5739 return React24.useCallback((element) => {
5740 if (id === void 0) {
5741 return;
5742 }
5743 if (registeredElementIdRef.current !== null) {
5744 const registeredId = registeredElementIdRef.current;
5745 const registeredElement = registeredElementRef.current;
5746 const currentElement = store.context.triggerElements.getById(registeredId);
5747 if (registeredElement && currentElement === registeredElement) {
5748 store.context.triggerElements.delete(registeredId);
5749 }
5750 registeredElementIdRef.current = null;
5751 registeredElementRef.current = null;
5752 }
5753 if (element !== null) {
5754 registeredElementIdRef.current = id;
5755 registeredElementRef.current = element;
5756 store.context.triggerElements.add(id, element);
5757 }
5758 }, [store, id]);
5759 }
5760 function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
5761 const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
5762 const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
5763 const registerTrigger = useStableCallback((element) => {
5764 baseRegisterTrigger(element);
5765 if (!element || !store.select("open")) {
5766 return;
5767 }
5768 const activeTriggerId = store.select("activeTriggerId");
5769 if (activeTriggerId === triggerId) {
5770 store.update({
5771 activeTriggerElement: element,
5772 ...stateUpdates
5773 });
5774 return;
5775 }
5776 if (activeTriggerId == null) {
5777 store.update({
5778 activeTriggerId: triggerId,
5779 activeTriggerElement: element,
5780 ...stateUpdates
5781 });
5782 }
5783 });
5784 useIsoLayoutEffect(() => {
5785 if (isMountedByThisTrigger) {
5786 store.update({
5787 activeTriggerElement: triggerElementRef.current,
5788 ...stateUpdates
5789 });
5790 }
5791 }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]);
5792 return {
5793 registerTrigger,
5794 isMountedByThisTrigger
5795 };
5796 }
5797 function useImplicitActiveTrigger(store) {
5798 const open = store.useState("open");
5799 useIsoLayoutEffect(() => {
5800 if (open && !store.select("activeTriggerId") && store.context.triggerElements.size === 1) {
5801 const iteratorResult = store.context.triggerElements.entries().next();
5802 if (!iteratorResult.done) {
5803 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
5804 store.update({
5805 activeTriggerId: implicitTriggerId,
5806 activeTriggerElement: implicitTriggerElement
5807 });
5808 }
5809 }
5810 }, [open, store]);
5811 }
5812 function useOpenStateTransitions(open, store, onUnmount) {
5813 const {
5814 mounted,
5815 setMounted,
5816 transitionStatus
5817 } = useTransitionStatus(open);
5818 store.useSyncedValues({
5819 mounted,
5820 transitionStatus
5821 });
5822 const forceUnmount = useStableCallback(() => {
5823 setMounted(false);
5824 store.update({
5825 activeTriggerId: null,
5826 activeTriggerElement: null,
5827 mounted: false
5828 });
5829 onUnmount?.();
5830 store.context.onOpenChangeComplete?.(false);
5831 });
5832 const preventUnmountingOnClose = store.useState("preventUnmountingOnClose");
5833 useOpenChangeComplete({
5834 enabled: !preventUnmountingOnClose,
5835 open,
5836 ref: store.context.popupRef,
5837 onComplete() {
5838 if (!open) {
5839 forceUnmount();
5840 }
5841 }
5842 });
5843 return {
5844 forceUnmount,
5845 transitionStatus
5846 };
5847 }
5848
5849 // node_modules/@base-ui/react/esm/utils/popups/popupTriggerMap.js
5850 var PopupTriggerMap = class {
5851 constructor() {
5852 this.elementsSet = /* @__PURE__ */ new Set();
5853 this.idMap = /* @__PURE__ */ new Map();
5854 }
5855 /**
5856 * Adds a trigger element with the given ID.
5857 *
5858 * Note: The provided element is assumed to not be registered under multiple IDs.
5859 */
5860 add(id, element) {
5861 const existingElement = this.idMap.get(id);
5862 if (existingElement === element) {
5863 return;
5864 }
5865 if (existingElement !== void 0) {
5866 this.elementsSet.delete(existingElement);
5867 }
5868 this.elementsSet.add(element);
5869 this.idMap.set(id, element);
5870 if (true) {
5871 if (this.elementsSet.size !== this.idMap.size) {
5872 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
5873 }
5874 }
5875 }
5876 /**
5877 * Removes the trigger element with the given ID.
5878 */
5879 delete(id) {
5880 const element = this.idMap.get(id);
5881 if (element) {
5882 this.elementsSet.delete(element);
5883 this.idMap.delete(id);
5884 }
5885 }
5886 /**
5887 * Whether the given element is registered as a trigger.
5888 */
5889 hasElement(element) {
5890 return this.elementsSet.has(element);
5891 }
5892 /**
5893 * Whether there is a registered trigger element matching the given predicate.
5894 */
5895 hasMatchingElement(predicate) {
5896 for (const element of this.elementsSet) {
5897 if (predicate(element)) {
5898 return true;
5899 }
5900 }
5901 return false;
5902 }
5903 /**
5904 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
5905 */
5906 getById(id) {
5907 return this.idMap.get(id);
5908 }
5909 /**
5910 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
5911 */
5912 entries() {
5913 return this.idMap.entries();
5914 }
5915 /**
5916 * Returns an iterable of all registered trigger elements.
5917 */
5918 elements() {
5919 return this.elementsSet.values();
5920 }
5921 /**
5922 * Returns the number of registered trigger elements.
5923 */
5924 get size() {
5925 return this.idMap.size;
5926 }
5927 };
5928
5929 // node_modules/@base-ui/react/esm/floating-ui-react/utils/getEmptyRootContext.js
5930 function getEmptyRootContext() {
5931 return new FloatingRootStore({
5932 open: false,
5933 transitionStatus: void 0,
5934 floatingElement: null,
5935 referenceElement: null,
5936 triggerElements: new PopupTriggerMap(),
5937 floatingId: "",
5938 syncOnly: false,
5939 nested: false,
5940 onOpenChange: void 0
5941 });
5942 }
5943
5944 // node_modules/@base-ui/react/esm/utils/popups/store.js
5945 function createInitialPopupStoreState() {
5946 return {
5947 open: false,
5948 openProp: void 0,
5949 mounted: false,
5950 transitionStatus: void 0,
5951 floatingRootContext: getEmptyRootContext(),
5952 preventUnmountingOnClose: false,
5953 payload: void 0,
5954 activeTriggerId: null,
5955 activeTriggerElement: null,
5956 triggerIdProp: void 0,
5957 popupElement: null,
5958 positionerElement: null,
5959 activeTriggerProps: EMPTY_OBJECT,
5960 inactiveTriggerProps: EMPTY_OBJECT,
5961 popupProps: EMPTY_OBJECT
5962 };
5963 }
5964 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
5965 var popupStoreSelectors = {
5966 open: createSelector((state) => state.openProp ?? state.open),
5967 mounted: createSelector((state) => state.mounted),
5968 transitionStatus: createSelector((state) => state.transitionStatus),
5969 floatingRootContext: createSelector((state) => state.floatingRootContext),
5970 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
5971 payload: createSelector((state) => state.payload),
5972 activeTriggerId: activeTriggerIdSelector,
5973 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
5974 /**
5975 * Whether the trigger with the given ID was used to open the popup.
5976 */
5977 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
5978 /**
5979 * Whether the popup is open and was activated by a trigger with the given ID.
5980 */
5981 isOpenedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.open),
5982 /**
5983 * Whether the popup is mounted and was activated by a trigger with the given ID.
5984 */
5985 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
5986 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
5987 popupProps: createSelector((state) => state.popupProps),
5988 popupElement: createSelector((state) => state.popupElement),
5989 positionerElement: createSelector((state) => state.positionerElement)
5990 };
5991
5992 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloatingRootContext.js
5993 function useFloatingRootContext(options) {
5994 const {
5995 open = false,
5996 onOpenChange,
5997 elements = {}
5998 } = options;
5999 const floatingId = useId();
6000 const nested = useFloatingParentNodeId() != null;
6001 if (true) {
6002 const optionDomReference = elements.reference;
6003 if (optionDomReference && !isElement(optionDomReference)) {
6004 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
6005 }
6006 }
6007 const store = useRefWithInit(() => new FloatingRootStore({
6008 open,
6009 transitionStatus: void 0,
6010 onOpenChange,
6011 referenceElement: elements.reference ?? null,
6012 floatingElement: elements.floating ?? null,
6013 triggerElements: new PopupTriggerMap(),
6014 floatingId,
6015 syncOnly: false,
6016 nested
6017 })).current;
6018 useIsoLayoutEffect(() => {
6019 const valuesToSync = {
6020 open,
6021 floatingId
6022 };
6023 if (elements.reference !== void 0) {
6024 valuesToSync.referenceElement = elements.reference;
6025 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
6026 }
6027 if (elements.floating !== void 0) {
6028 valuesToSync.floatingElement = elements.floating;
6029 }
6030 store.update(valuesToSync);
6031 }, [open, floatingId, elements.reference, elements.floating, store]);
6032 store.context.onOpenChange = onOpenChange;
6033 store.context.nested = nested;
6034 return store;
6035 }
6036
6037 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
6038 function useFloating2(options = {}) {
6039 const {
6040 nodeId,
6041 externalTree
6042 } = options;
6043 const internalRootStore = useFloatingRootContext(options);
6044 const rootContext = options.rootContext || internalRootStore;
6045 const rootContextElements = {
6046 reference: rootContext.useState("referenceElement"),
6047 floating: rootContext.useState("floatingElement"),
6048 domReference: rootContext.useState("domReferenceElement")
6049 };
6050 const [positionReference, setPositionReferenceRaw] = React25.useState(null);
6051 const domReferenceRef = React25.useRef(null);
6052 const tree = useFloatingTree(externalTree);
6053 useIsoLayoutEffect(() => {
6054 if (rootContextElements.domReference) {
6055 domReferenceRef.current = rootContextElements.domReference;
6056 }
6057 }, [rootContextElements.domReference]);
6058 const position = useFloating({
6059 ...options,
6060 elements: {
6061 ...rootContextElements,
6062 ...positionReference && {
6063 reference: positionReference
6064 }
6065 }
6066 });
6067 const setPositionReference = React25.useCallback((node) => {
6068 const computedPositionReference = isElement(node) ? {
6069 getBoundingClientRect: () => node.getBoundingClientRect(),
6070 getClientRects: () => node.getClientRects(),
6071 contextElement: node
6072 } : node;
6073 setPositionReferenceRaw(computedPositionReference);
6074 position.refs.setReference(computedPositionReference);
6075 }, [position.refs]);
6076 const [localDomReference, setLocalDomReference] = React25.useState(void 0);
6077 const [localFloatingElement, setLocalFloatingElement] = React25.useState(null);
6078 rootContext.useSyncedValue("referenceElement", localDomReference ?? null);
6079 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
6080 rootContext.useSyncedValue("domReferenceElement", localDomReference === void 0 ? rootContextElements.domReference : localDomReferenceElement);
6081 rootContext.useSyncedValue("floatingElement", localFloatingElement);
6082 const setReference = React25.useCallback((node) => {
6083 if (isElement(node) || node === null) {
6084 domReferenceRef.current = node;
6085 setLocalDomReference(node);
6086 }
6087 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
6088 // `null` to support `positionReference` + an unstable `reference`
6089 // callback ref.
6090 node !== null && !isElement(node)) {
6091 position.refs.setReference(node);
6092 }
6093 }, [position.refs, setLocalDomReference]);
6094 const setFloating = React25.useCallback((node) => {
6095 setLocalFloatingElement(node);
6096 position.refs.setFloating(node);
6097 }, [position.refs]);
6098 const refs = React25.useMemo(() => ({
6099 ...position.refs,
6100 setReference,
6101 setFloating,
6102 setPositionReference,
6103 domReference: domReferenceRef
6104 }), [position.refs, setReference, setFloating, setPositionReference]);
6105 const elements = React25.useMemo(() => ({
6106 ...position.elements,
6107 domReference: rootContextElements.domReference
6108 }), [position.elements, rootContextElements.domReference]);
6109 const open = rootContext.useState("open");
6110 const floatingId = rootContext.useState("floatingId");
6111 const context = React25.useMemo(() => ({
6112 ...position,
6113 dataRef: rootContext.context.dataRef,
6114 open,
6115 onOpenChange: rootContext.setOpen,
6116 events: rootContext.context.events,
6117 floatingId,
6118 refs,
6119 elements,
6120 nodeId,
6121 rootStore: rootContext
6122 }), [position, refs, elements, nodeId, rootContext, open, floatingId]);
6123 useIsoLayoutEffect(() => {
6124 rootContext.context.dataRef.current.floatingContext = context;
6125 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId);
6126 if (node) {
6127 node.context = context;
6128 }
6129 });
6130 return React25.useMemo(() => ({
6131 ...position,
6132 context,
6133 refs,
6134 elements,
6135 rootStore: rootContext
6136 }), [position, refs, elements, context, rootContext]);
6137 }
6138
6139 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
6140 function useSyncedFloatingRootContext(options) {
6141 const {
6142 popupStore,
6143 treatPopupAsFloatingElement = false,
6144 onOpenChange
6145 } = options;
6146 const floatingId = useId();
6147 const nested = useFloatingParentNodeId() != null;
6148 const open = popupStore.useState("open");
6149 const referenceElement = popupStore.useState("activeTriggerElement");
6150 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
6151 const triggerElements = popupStore.context.triggerElements;
6152 const store = useRefWithInit(() => new FloatingRootStore({
6153 open,
6154 transitionStatus: void 0,
6155 referenceElement,
6156 floatingElement,
6157 triggerElements,
6158 onOpenChange,
6159 floatingId,
6160 syncOnly: true,
6161 nested
6162 })).current;
6163 useIsoLayoutEffect(() => {
6164 const valuesToSync = {
6165 open,
6166 floatingId,
6167 referenceElement,
6168 floatingElement
6169 };
6170 if (isElement(referenceElement)) {
6171 valuesToSync.domReferenceElement = referenceElement;
6172 }
6173 if (store.state.positionReference === store.state.referenceElement) {
6174 valuesToSync.positionReference = referenceElement;
6175 }
6176 store.update(valuesToSync);
6177 }, [open, floatingId, referenceElement, floatingElement, store]);
6178 store.context.onOpenChange = onOpenChange;
6179 store.context.nested = nested;
6180 return store;
6181 }
6182
6183 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFocus.js
6184 var React26 = __toESM(require_react(), 1);
6185 var isMacSafari = isMac && isSafari;
6186 function useFocus(context, props = {}) {
6187 const store = "rootStore" in context ? context.rootStore : context;
6188 const {
6189 events,
6190 dataRef
6191 } = store.context;
6192 const {
6193 enabled = true,
6194 delay
6195 } = props;
6196 const blockFocusRef = React26.useRef(false);
6197 const blockedReferenceRef = React26.useRef(null);
6198 const timeout = useTimeout();
6199 const keyboardModalityRef = React26.useRef(true);
6200 React26.useEffect(() => {
6201 const domReference = store.select("domReferenceElement");
6202 if (!enabled) {
6203 return void 0;
6204 }
6205 const win = getWindow(domReference);
6206 function onBlur() {
6207 const currentDomReference = store.select("domReferenceElement");
6208 if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
6209 blockFocusRef.current = true;
6210 }
6211 }
6212 function onKeyDown() {
6213 keyboardModalityRef.current = true;
6214 }
6215 function onPointerDown() {
6216 keyboardModalityRef.current = false;
6217 }
6218 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
6219 }, [store, enabled]);
6220 React26.useEffect(() => {
6221 if (!enabled) {
6222 return void 0;
6223 }
6224 function onOpenChangeLocal(details) {
6225 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
6226 const referenceElement = store.select("domReferenceElement");
6227 if (isElement(referenceElement)) {
6228 blockedReferenceRef.current = referenceElement;
6229 blockFocusRef.current = true;
6230 }
6231 }
6232 }
6233 events.on("openchange", onOpenChangeLocal);
6234 return () => {
6235 events.off("openchange", onOpenChangeLocal);
6236 };
6237 }, [events, enabled, store]);
6238 const reference = React26.useMemo(() => ({
6239 onMouseLeave() {
6240 blockFocusRef.current = false;
6241 blockedReferenceRef.current = null;
6242 },
6243 onFocus(event) {
6244 const focusTarget = event.currentTarget;
6245 if (blockFocusRef.current) {
6246 if (blockedReferenceRef.current === focusTarget) {
6247 return;
6248 }
6249 blockFocusRef.current = false;
6250 blockedReferenceRef.current = null;
6251 }
6252 const target = getTarget(event.nativeEvent);
6253 if (isElement(target)) {
6254 if (isMacSafari && !event.relatedTarget) {
6255 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
6256 return;
6257 }
6258 } else if (!matchesFocusVisible(target)) {
6259 return;
6260 }
6261 }
6262 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);
6263 const {
6264 nativeEvent,
6265 currentTarget
6266 } = event;
6267 const delayValue = typeof delay === "function" ? delay() : delay;
6268 if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
6269 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6270 return;
6271 }
6272 timeout.start(delayValue, () => {
6273 if (blockFocusRef.current) {
6274 return;
6275 }
6276 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6277 });
6278 },
6279 onBlur(event) {
6280 blockFocusRef.current = false;
6281 blockedReferenceRef.current = null;
6282 const relatedTarget = event.relatedTarget;
6283 const nativeEvent = event.nativeEvent;
6284 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
6285 timeout.start(0, () => {
6286 const domReference = store.select("domReferenceElement");
6287 const activeEl = activeElement(ownerDocument(domReference));
6288 if (!relatedTarget && activeEl === domReference) {
6289 return;
6290 }
6291 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
6292 return;
6293 }
6294 const nextFocusedElement = relatedTarget ?? activeEl;
6295 if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {
6296 return;
6297 }
6298 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
6299 });
6300 }
6301 }), [dataRef, store, timeout, delay]);
6302 return React26.useMemo(() => enabled ? {
6303 reference,
6304 trigger: reference
6305 } : {}, [enabled, reference]);
6306 }
6307
6308 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
6309 var React27 = __toESM(require_react(), 1);
6310
6311 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverInteractionSharedState.js
6312 var HoverInteraction = class _HoverInteraction {
6313 constructor() {
6314 this.pointerType = void 0;
6315 this.interactedInside = false;
6316 this.handler = void 0;
6317 this.blockMouseMove = true;
6318 this.performedPointerEventsMutation = false;
6319 this.pointerEventsScopeElement = null;
6320 this.pointerEventsReferenceElement = null;
6321 this.pointerEventsFloatingElement = null;
6322 this.restTimeoutPending = false;
6323 this.openChangeTimeout = new Timeout();
6324 this.restTimeout = new Timeout();
6325 this.handleCloseOptions = void 0;
6326 }
6327 static create() {
6328 return new _HoverInteraction();
6329 }
6330 dispose = () => {
6331 this.openChangeTimeout.clear();
6332 this.restTimeout.clear();
6333 };
6334 disposeEffect = () => {
6335 return this.dispose;
6336 };
6337 };
6338 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
6339 function clearSafePolygonPointerEventsMutation(instance) {
6340 if (!instance.performedPointerEventsMutation) {
6341 return;
6342 }
6343 const scopeElement = instance.pointerEventsScopeElement;
6344 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
6345 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
6346 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
6347 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
6348 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
6349 }
6350 instance.performedPointerEventsMutation = false;
6351 instance.pointerEventsScopeElement = null;
6352 instance.pointerEventsReferenceElement = null;
6353 instance.pointerEventsFloatingElement = null;
6354 }
6355 function applySafePolygonPointerEventsMutation(instance, options) {
6356 const {
6357 scopeElement,
6358 referenceElement,
6359 floatingElement
6360 } = options;
6361 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
6362 if (existingOwner && existingOwner !== instance) {
6363 clearSafePolygonPointerEventsMutation(existingOwner);
6364 }
6365 clearSafePolygonPointerEventsMutation(instance);
6366 instance.performedPointerEventsMutation = true;
6367 instance.pointerEventsScopeElement = scopeElement;
6368 instance.pointerEventsReferenceElement = referenceElement;
6369 instance.pointerEventsFloatingElement = floatingElement;
6370 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
6371 scopeElement.style.pointerEvents = "none";
6372 referenceElement.style.pointerEvents = "auto";
6373 floatingElement.style.pointerEvents = "auto";
6374 }
6375 function useHoverInteractionSharedState(store) {
6376 const instance = useRefWithInit(HoverInteraction.create).current;
6377 const data = store.context.dataRef.current;
6378 if (!data.hoverInteractionState) {
6379 data.hoverInteractionState = instance;
6380 }
6381 useOnMount(data.hoverInteractionState.disposeEffect);
6382 return data.hoverInteractionState;
6383 }
6384
6385 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
6386 function useHoverFloatingInteraction(context, parameters = {}) {
6387 const store = "rootStore" in context ? context.rootStore : context;
6388 const open = store.useState("open");
6389 const floatingElement = store.useState("floatingElement");
6390 const domReferenceElement = store.useState("domReferenceElement");
6391 const {
6392 dataRef
6393 } = store.context;
6394 const {
6395 enabled = true,
6396 closeDelay: closeDelayProp = 0,
6397 nodeId: nodeIdProp
6398 } = parameters;
6399 const instance = useHoverInteractionSharedState(store);
6400 const tree = useFloatingTree();
6401 const parentId = useFloatingParentNodeId();
6402 const isClickLikeOpenEvent2 = useStableCallback(() => {
6403 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6404 });
6405 const isHoverOpen = useStableCallback(() => {
6406 const type = dataRef.current.openEvent?.type;
6407 return type?.includes("mouse") && type !== "mousedown";
6408 });
6409 const isRelatedTargetInsideEnabledTrigger = useStableCallback((target) => {
6410 return isTargetInsideEnabledTrigger(target, store.context.triggerElements);
6411 });
6412 const closeWithDelay = React27.useCallback((event) => {
6413 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
6414 const close = () => {
6415 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6416 tree?.events.emit("floating.closed", event);
6417 };
6418 if (closeDelay) {
6419 instance.openChangeTimeout.start(closeDelay, close);
6420 } else {
6421 instance.openChangeTimeout.clear();
6422 close();
6423 }
6424 }, [closeDelayProp, store, instance, tree]);
6425 const clearPointerEvents = useStableCallback(() => {
6426 clearSafePolygonPointerEventsMutation(instance);
6427 });
6428 const handleInteractInside = useStableCallback((event) => {
6429 const target = getTarget(event);
6430 if (!isInteractiveElement(target)) {
6431 instance.interactedInside = false;
6432 return;
6433 }
6434 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
6435 });
6436 useIsoLayoutEffect(() => {
6437 if (!open) {
6438 instance.pointerType = void 0;
6439 instance.restTimeoutPending = false;
6440 instance.interactedInside = false;
6441 clearPointerEvents();
6442 }
6443 }, [open, instance, clearPointerEvents]);
6444 React27.useEffect(() => {
6445 return clearPointerEvents;
6446 }, [clearPointerEvents]);
6447 useIsoLayoutEffect(() => {
6448 if (!enabled) {
6449 return void 0;
6450 }
6451 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
6452 const ref = domReferenceElement;
6453 const floatingEl = floatingElement;
6454 const doc = ownerDocument(floatingElement);
6455 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
6456 if (parentFloating) {
6457 parentFloating.style.pointerEvents = "";
6458 }
6459 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? instance.pointerEventsScopeElement ?? parentFloating ?? ref.closest("[data-rootownerid]") ?? doc.body;
6460 applySafePolygonPointerEventsMutation(instance, {
6461 scopeElement,
6462 referenceElement: ref,
6463 floatingElement: floatingEl
6464 });
6465 return () => {
6466 clearPointerEvents();
6467 };
6468 }
6469 return void 0;
6470 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
6471 const childClosedTimeout = useTimeout();
6472 React27.useEffect(() => {
6473 if (!enabled) {
6474 return void 0;
6475 }
6476 function onFloatingMouseEnter() {
6477 instance.openChangeTimeout.clear();
6478 childClosedTimeout.clear();
6479 tree?.events.off("floating.closed", onNodeClosed);
6480 clearPointerEvents();
6481 }
6482 function onFloatingMouseLeave(event) {
6483 if (tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0) {
6484 tree.events.on("floating.closed", onNodeClosed);
6485 return;
6486 }
6487 if (isRelatedTargetInsideEnabledTrigger(event.relatedTarget)) {
6488 return;
6489 }
6490 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
6491 const relatedTarget = event.relatedTarget;
6492 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
6493 if (isMovingIntoDescendantFloating) {
6494 return;
6495 }
6496 if (instance.handler) {
6497 instance.handler(event);
6498 return;
6499 }
6500 clearPointerEvents();
6501 if (!isClickLikeOpenEvent2()) {
6502 closeWithDelay(event);
6503 }
6504 }
6505 function onNodeClosed(event) {
6506 if (!tree || !parentId || getNodeChildren(tree.nodesRef.current, parentId).length > 0) {
6507 return;
6508 }
6509 childClosedTimeout.start(0, () => {
6510 tree.events.off("floating.closed", onNodeClosed);
6511 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6512 tree.events.emit("floating.closed", event);
6513 });
6514 }
6515 const floating = floatingElement;
6516 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
6517 tree?.events.off("floating.closed", onNodeClosed);
6518 });
6519 }, [enabled, floatingElement, store, dataRef, nodeIdProp, isClickLikeOpenEvent2, isRelatedTargetInsideEnabledTrigger, closeWithDelay, clearPointerEvents, handleInteractInside, instance, tree, parentId, childClosedTimeout]);
6520 }
6521
6522 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverReferenceInteraction.js
6523 var React28 = __toESM(require_react(), 1);
6524 var ReactDOM4 = __toESM(require_react_dom(), 1);
6525 var EMPTY_REF = {
6526 current: null
6527 };
6528 function useHoverReferenceInteraction(context, props = {}) {
6529 const store = "rootStore" in context ? context.rootStore : context;
6530 const {
6531 dataRef,
6532 events
6533 } = store.context;
6534 const {
6535 enabled = true,
6536 delay = 0,
6537 handleClose = null,
6538 mouseOnly = false,
6539 restMs = 0,
6540 move = true,
6541 triggerElementRef = EMPTY_REF,
6542 externalTree,
6543 isActiveTrigger = true,
6544 getHandleCloseContext,
6545 isClosing
6546 } = props;
6547 const tree = useFloatingTree(externalTree);
6548 const instance = useHoverInteractionSharedState(store);
6549 const isHoverCloseActiveRef = React28.useRef(false);
6550 const handleCloseRef = useValueAsRef(handleClose);
6551 const delayRef = useValueAsRef(delay);
6552 const restMsRef = useValueAsRef(restMs);
6553 const enabledRef = useValueAsRef(enabled);
6554 const isClosingRef = useValueAsRef(isClosing);
6555 if (isActiveTrigger) {
6556 instance.handleCloseOptions = handleCloseRef.current?.__options;
6557 }
6558 const isClickLikeOpenEvent2 = useStableCallback(() => {
6559 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6560 });
6561 const isRelatedTargetInsideEnabledTrigger = useStableCallback((target) => {
6562 return isTargetInsideEnabledTrigger(target, store.context.triggerElements);
6563 });
6564 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
6565 const allTriggers = store.context.triggerElements;
6566 if (allTriggers.hasElement(currentTarget)) {
6567 return !currentDomReference || !contains(currentDomReference, currentTarget);
6568 }
6569 if (!isElement(target)) {
6570 return false;
6571 }
6572 const targetElement = target;
6573 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
6574 });
6575 const closeWithDelay = useStableCallback((event, runElseBranch = true) => {
6576 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
6577 if (closeDelay) {
6578 instance.openChangeTimeout.start(closeDelay, () => {
6579 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6580 tree?.events.emit("floating.closed", event);
6581 });
6582 } else if (runElseBranch) {
6583 instance.openChangeTimeout.clear();
6584 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6585 tree?.events.emit("floating.closed", event);
6586 }
6587 });
6588 const cleanupMouseMoveHandler = useStableCallback(() => {
6589 if (!instance.handler) {
6590 return;
6591 }
6592 const doc = ownerDocument(store.select("domReferenceElement"));
6593 doc.removeEventListener("mousemove", instance.handler);
6594 instance.handler = void 0;
6595 });
6596 const clearPointerEvents = useStableCallback(() => {
6597 clearSafePolygonPointerEventsMutation(instance);
6598 });
6599 React28.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
6600 React28.useEffect(() => {
6601 if (!enabled) {
6602 return void 0;
6603 }
6604 function onOpenChangeLocal(details) {
6605 if (!details.open) {
6606 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
6607 cleanupMouseMoveHandler();
6608 instance.openChangeTimeout.clear();
6609 instance.restTimeout.clear();
6610 instance.blockMouseMove = true;
6611 instance.restTimeoutPending = false;
6612 } else {
6613 isHoverCloseActiveRef.current = false;
6614 }
6615 }
6616 events.on("openchange", onOpenChangeLocal);
6617 return () => {
6618 events.off("openchange", onOpenChangeLocal);
6619 };
6620 }, [enabled, events, instance, cleanupMouseMoveHandler]);
6621 React28.useEffect(() => {
6622 if (!enabled) {
6623 return void 0;
6624 }
6625 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null);
6626 if (!isElement(trigger)) {
6627 return void 0;
6628 }
6629 function onMouseEnter(event) {
6630 instance.openChangeTimeout.clear();
6631 instance.blockMouseMove = false;
6632 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6633 return;
6634 }
6635 const restMsValue = getRestMs(restMsRef.current);
6636 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
6637 const eventTarget = getTarget(event);
6638 const currentTarget = event.currentTarget ?? null;
6639 const currentDomReference = store.select("domReferenceElement");
6640 let triggerNode = currentTarget;
6641 if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) {
6642 for (const triggerElement of store.context.triggerElements.elements()) {
6643 if (contains(triggerElement, eventTarget)) {
6644 triggerNode = triggerElement;
6645 break;
6646 }
6647 }
6648 }
6649 if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
6650 triggerNode = currentDomReference;
6651 }
6652 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
6653 const isOpen = store.select("open");
6654 const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending";
6655 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
6656 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
6657 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
6658 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
6659 const shouldOpen = !isOpen || isOverInactive;
6660 if (shouldOpenImmediately) {
6661 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6662 return;
6663 }
6664 if (isRestOnlyDelay) {
6665 return;
6666 }
6667 if (openDelay) {
6668 instance.openChangeTimeout.start(openDelay, () => {
6669 if (shouldOpen) {
6670 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6671 }
6672 });
6673 } else if (shouldOpen) {
6674 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6675 }
6676 }
6677 function onMouseLeave(event) {
6678 if (isClickLikeOpenEvent2()) {
6679 clearPointerEvents();
6680 return;
6681 }
6682 cleanupMouseMoveHandler();
6683 const domReferenceElement = store.select("domReferenceElement");
6684 const doc = ownerDocument(domReferenceElement);
6685 instance.restTimeout.clear();
6686 instance.restTimeoutPending = false;
6687 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
6688 const ignoreRelatedTargetTrigger = isRelatedTargetInsideEnabledTrigger(event.relatedTarget);
6689 if (ignoreRelatedTargetTrigger) {
6690 return;
6691 }
6692 if (handleCloseRef.current && handleCloseContextBase) {
6693 if (!store.select("open")) {
6694 instance.openChangeTimeout.clear();
6695 }
6696 const currentTrigger = triggerElementRef.current;
6697 instance.handler = handleCloseRef.current({
6698 ...handleCloseContextBase,
6699 tree,
6700 x: event.clientX,
6701 y: event.clientY,
6702 onClose() {
6703 clearPointerEvents();
6704 cleanupMouseMoveHandler();
6705 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) {
6706 closeWithDelay(event, true);
6707 }
6708 }
6709 });
6710 doc.addEventListener("mousemove", instance.handler);
6711 instance.handler(event);
6712 return;
6713 }
6714 const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true;
6715 if (shouldClose) {
6716 closeWithDelay(event);
6717 }
6718 }
6719 if (move) {
6720 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
6721 once: true
6722 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
6723 }
6724 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
6725 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, closeWithDelay, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, isRelatedTargetInsideEnabledTrigger, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef]);
6726 return React28.useMemo(() => {
6727 if (!enabled) {
6728 return void 0;
6729 }
6730 function setPointerRef(event) {
6731 instance.pointerType = event.pointerType;
6732 }
6733 return {
6734 onPointerDown: setPointerRef,
6735 onPointerEnter: setPointerRef,
6736 onMouseMove(event) {
6737 const {
6738 nativeEvent
6739 } = event;
6740 const trigger = event.currentTarget;
6741 const currentDomReference = store.select("domReferenceElement");
6742 const currentOpen = store.select("open");
6743 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
6744 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6745 return;
6746 }
6747 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
6748 const floatingElement = store.select("floatingElement");
6749 if (floatingElement) {
6750 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
6751 applySafePolygonPointerEventsMutation(instance, {
6752 scopeElement,
6753 referenceElement: trigger,
6754 floatingElement
6755 });
6756 }
6757 }
6758 const restMsValue = getRestMs(restMsRef.current);
6759 if (currentOpen && !isOverInactive || restMsValue === 0) {
6760 return;
6761 }
6762 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
6763 return;
6764 }
6765 instance.restTimeout.clear();
6766 function handleMouseMove() {
6767 instance.restTimeoutPending = false;
6768 if (isClickLikeOpenEvent2()) {
6769 return;
6770 }
6771 const latestOpen = store.select("open");
6772 if (!instance.blockMouseMove && (!latestOpen || isOverInactive)) {
6773 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
6774 }
6775 }
6776 if (instance.pointerType === "touch") {
6777 ReactDOM4.flushSync(() => {
6778 handleMouseMove();
6779 });
6780 } else if (isOverInactive && currentOpen) {
6781 handleMouseMove();
6782 } else {
6783 instance.restTimeoutPending = true;
6784 instance.restTimeout.start(restMsValue, handleMouseMove);
6785 }
6786 }
6787 };
6788 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef]);
6789 }
6790
6791 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useInteractions.js
6792 var React29 = __toESM(require_react(), 1);
6793 function useInteractions(propsList = []) {
6794 const referenceDeps = propsList.map((key) => key?.reference);
6795 const floatingDeps = propsList.map((key) => key?.floating);
6796 const itemDeps = propsList.map((key) => key?.item);
6797 const triggerDeps = propsList.map((key) => key?.trigger);
6798 const getReferenceProps = React29.useCallback(
6799 (userProps) => mergeProps2(userProps, propsList, "reference"),
6800 // eslint-disable-next-line react-hooks/exhaustive-deps
6801 referenceDeps
6802 );
6803 const getFloatingProps = React29.useCallback(
6804 (userProps) => mergeProps2(userProps, propsList, "floating"),
6805 // eslint-disable-next-line react-hooks/exhaustive-deps
6806 floatingDeps
6807 );
6808 const getItemProps = React29.useCallback(
6809 (userProps) => mergeProps2(userProps, propsList, "item"),
6810 // eslint-disable-next-line react-hooks/exhaustive-deps
6811 itemDeps
6812 );
6813 const getTriggerProps = React29.useCallback(
6814 (userProps) => mergeProps2(userProps, propsList, "trigger"),
6815 // eslint-disable-next-line react-hooks/exhaustive-deps
6816 triggerDeps
6817 );
6818 return React29.useMemo(() => ({
6819 getReferenceProps,
6820 getFloatingProps,
6821 getItemProps,
6822 getTriggerProps
6823 }), [getReferenceProps, getFloatingProps, getItemProps, getTriggerProps]);
6824 }
6825 function mergeProps2(userProps, propsList, elementKey) {
6826 const eventHandlers = /* @__PURE__ */ new Map();
6827 const isItem2 = elementKey === "item";
6828 const outputProps = {};
6829 if (elementKey === "floating") {
6830 outputProps.tabIndex = -1;
6831 outputProps[FOCUSABLE_ATTRIBUTE] = "";
6832 }
6833 for (const key in userProps) {
6834 if (isItem2 && userProps) {
6835 if (key === ACTIVE_KEY || key === SELECTED_KEY) {
6836 continue;
6837 }
6838 }
6839 outputProps[key] = userProps[key];
6840 }
6841 for (let i2 = 0; i2 < propsList.length; i2 += 1) {
6842 let props;
6843 const propsOrGetProps = propsList[i2]?.[elementKey];
6844 if (typeof propsOrGetProps === "function") {
6845 props = userProps ? propsOrGetProps(userProps) : null;
6846 } else {
6847 props = propsOrGetProps;
6848 }
6849 if (!props) {
6850 continue;
6851 }
6852 mutablyMergeProps(outputProps, props, isItem2, eventHandlers);
6853 }
6854 mutablyMergeProps(outputProps, userProps, isItem2, eventHandlers);
6855 return outputProps;
6856 }
6857 function mutablyMergeProps(outputProps, props, isItem2, eventHandlers) {
6858 for (const key in props) {
6859 const value = props[key];
6860 if (isItem2 && (key === ACTIVE_KEY || key === SELECTED_KEY)) {
6861 continue;
6862 }
6863 if (!key.startsWith("on")) {
6864 outputProps[key] = value;
6865 } else {
6866 if (!eventHandlers.has(key)) {
6867 eventHandlers.set(key, []);
6868 }
6869 if (typeof value === "function") {
6870 eventHandlers.get(key)?.push(value);
6871 outputProps[key] = (...args) => {
6872 return eventHandlers.get(key)?.map((fn) => fn(...args)).find((val) => val !== void 0);
6873 };
6874 }
6875 }
6876 }
6877 }
6878
6879 // node_modules/@base-ui/react/esm/floating-ui-react/safePolygon.js
6880 var CURSOR_SPEED_THRESHOLD = 0.1;
6881 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
6882 var POLYGON_BUFFER = 0.5;
6883 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
6884 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
6885 }
6886 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
6887 let isInsideValue = false;
6888 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
6889 isInsideValue = !isInsideValue;
6890 }
6891 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
6892 isInsideValue = !isInsideValue;
6893 }
6894 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
6895 isInsideValue = !isInsideValue;
6896 }
6897 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
6898 isInsideValue = !isInsideValue;
6899 }
6900 return isInsideValue;
6901 }
6902 function isInsideRect(pointX, pointY, rect) {
6903 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
6904 }
6905 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
6906 const minX = Math.min(x1, x2);
6907 const maxX = Math.max(x1, x2);
6908 const minY = Math.min(y1, y2);
6909 const maxY = Math.max(y1, y2);
6910 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
6911 }
6912 function safePolygon(options = {}) {
6913 const {
6914 blockPointerEvents = false
6915 } = options;
6916 const timeout = new Timeout();
6917 const fn = ({
6918 x: x2,
6919 y: y2,
6920 placement,
6921 elements,
6922 onClose,
6923 nodeId,
6924 tree
6925 }) => {
6926 const side = placement?.split("-")[0];
6927 let hasLanded = false;
6928 let lastX = null;
6929 let lastY = null;
6930 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
6931 function isCursorMovingSlowly(nextX, nextY) {
6932 const currentTime = performance.now();
6933 const elapsedTime = currentTime - lastCursorTime;
6934 if (lastX === null || lastY === null || elapsedTime === 0) {
6935 lastX = nextX;
6936 lastY = nextY;
6937 lastCursorTime = currentTime;
6938 return false;
6939 }
6940 const deltaX = nextX - lastX;
6941 const deltaY = nextY - lastY;
6942 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
6943 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
6944 lastX = nextX;
6945 lastY = nextY;
6946 lastCursorTime = currentTime;
6947 return distanceSquared < thresholdSquared;
6948 }
6949 function close() {
6950 timeout.clear();
6951 onClose();
6952 }
6953 return function onMouseMove(event) {
6954 timeout.clear();
6955 const domReference = elements.domReference;
6956 const floating = elements.floating;
6957 if (!domReference || !floating || side == null || x2 == null || y2 == null) {
6958 return void 0;
6959 }
6960 const {
6961 clientX,
6962 clientY
6963 } = event;
6964 const target = getTarget(event);
6965 const isLeave = event.type === "mouseleave";
6966 const isOverFloatingEl = contains(floating, target);
6967 const isOverReferenceEl = contains(domReference, target);
6968 if (isOverFloatingEl) {
6969 hasLanded = true;
6970 if (!isLeave) {
6971 return void 0;
6972 }
6973 }
6974 if (isOverReferenceEl) {
6975 hasLanded = false;
6976 if (!isLeave) {
6977 hasLanded = true;
6978 return void 0;
6979 }
6980 }
6981 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
6982 return void 0;
6983 }
6984 function hasOpenChildNode() {
6985 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
6986 }
6987 function closeIfNoOpenChild() {
6988 if (!hasOpenChildNode()) {
6989 close();
6990 }
6991 }
6992 if (hasOpenChildNode()) {
6993 return void 0;
6994 }
6995 const refRect = domReference.getBoundingClientRect();
6996 const rect = floating.getBoundingClientRect();
6997 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2;
6998 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2;
6999 const isFloatingWider = rect.width > refRect.width;
7000 const isFloatingTaller = rect.height > refRect.height;
7001 const left = (isFloatingWider ? refRect : rect).left;
7002 const right = (isFloatingWider ? refRect : rect).right;
7003 const top = (isFloatingTaller ? refRect : rect).top;
7004 const bottom = (isFloatingTaller ? refRect : rect).bottom;
7005 if (side === "top" && y2 >= refRect.bottom - 1 || side === "bottom" && y2 <= refRect.top + 1 || side === "left" && x2 >= refRect.right - 1 || side === "right" && x2 <= refRect.left + 1) {
7006 closeIfNoOpenChild();
7007 return void 0;
7008 }
7009 let isInsideTroughRect = false;
7010 switch (side) {
7011 case "top":
7012 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
7013 break;
7014 case "bottom":
7015 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
7016 break;
7017 case "left":
7018 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
7019 break;
7020 case "right":
7021 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
7022 break;
7023 default:
7024 }
7025 if (isInsideTroughRect) {
7026 return void 0;
7027 }
7028 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
7029 closeIfNoOpenChild();
7030 return void 0;
7031 }
7032 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
7033 closeIfNoOpenChild();
7034 return void 0;
7035 }
7036 let isInsidePolygon = false;
7037 switch (side) {
7038 case "top": {
7039 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7040 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7041 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7042 const cursorPointY = y2 + POLYGON_BUFFER + 1;
7043 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
7044 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
7045 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7046 break;
7047 }
7048 case "bottom": {
7049 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7050 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7051 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7052 const cursorPointY = y2 - POLYGON_BUFFER;
7053 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
7054 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
7055 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7056 break;
7057 }
7058 case "left": {
7059 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7060 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7061 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7062 const cursorPointX = x2 + POLYGON_BUFFER + 1;
7063 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
7064 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
7065 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
7066 break;
7067 }
7068 case "right": {
7069 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7070 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7071 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7072 const cursorPointX = x2 - POLYGON_BUFFER;
7073 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
7074 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
7075 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
7076 break;
7077 }
7078 default:
7079 }
7080 if (!isInsidePolygon) {
7081 closeIfNoOpenChild();
7082 } else if (!hasLanded) {
7083 timeout.start(40, closeIfNoOpenChild);
7084 }
7085 return void 0;
7086 };
7087 };
7088 fn.__options = {
7089 ...options,
7090 blockPointerEvents
7091 };
7092 return fn;
7093 }
7094
7095 // node_modules/@base-ui/react/esm/utils/popupStateMapping.js
7096 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
7097 CommonPopupDataAttributes2["open"] = "data-open";
7098 CommonPopupDataAttributes2["closed"] = "data-closed";
7099 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
7100 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
7101 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
7102 CommonPopupDataAttributes2["side"] = "data-side";
7103 CommonPopupDataAttributes2["align"] = "data-align";
7104 return CommonPopupDataAttributes2;
7105 })({});
7106 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
7107 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
7108 CommonTriggerDataAttributes2["pressed"] = "data-pressed";
7109 return CommonTriggerDataAttributes2;
7110 })({});
7111 var TRIGGER_HOOK = {
7112 [CommonTriggerDataAttributes.popupOpen]: ""
7113 };
7114 var PRESSABLE_TRIGGER_HOOK = {
7115 [CommonTriggerDataAttributes.popupOpen]: "",
7116 [CommonTriggerDataAttributes.pressed]: ""
7117 };
7118 var POPUP_OPEN_HOOK = {
7119 [CommonPopupDataAttributes.open]: ""
7120 };
7121 var POPUP_CLOSED_HOOK = {
7122 [CommonPopupDataAttributes.closed]: ""
7123 };
7124 var ANCHOR_HIDDEN_HOOK = {
7125 [CommonPopupDataAttributes.anchorHidden]: ""
7126 };
7127 var triggerOpenStateMapping = {
7128 open(value) {
7129 if (value) {
7130 return TRIGGER_HOOK;
7131 }
7132 return null;
7133 }
7134 };
7135 var popupStateMapping = {
7136 open(value) {
7137 if (value) {
7138 return POPUP_OPEN_HOOK;
7139 }
7140 return POPUP_CLOSED_HOOK;
7141 },
7142 anchorHidden(value) {
7143 if (value) {
7144 return ANCHOR_HIDDEN_HOOK;
7145 }
7146 return null;
7147 }
7148 };
7149
7150 // node_modules/@base-ui/utils/esm/inertValue.js
7151 function inertValue(value) {
7152 if (isReactVersionAtLeast(19)) {
7153 return value;
7154 }
7155 return value ? "true" : void 0;
7156 }
7157
7158 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
7159 var React30 = __toESM(require_react(), 1);
7160
7161 // node_modules/@base-ui/react/esm/floating-ui-react/middleware/arrow.js
7162 var baseArrow = (options) => ({
7163 name: "arrow",
7164 options,
7165 async fn(state) {
7166 const {
7167 x: x2,
7168 y: y2,
7169 placement,
7170 rects,
7171 platform: platform3,
7172 elements,
7173 middlewareData
7174 } = state;
7175 const {
7176 element,
7177 padding = 0,
7178 offsetParent = "real"
7179 } = evaluate(options, state) || {};
7180 if (element == null) {
7181 return {};
7182 }
7183 const paddingObject = getPaddingObject(padding);
7184 const coords = {
7185 x: x2,
7186 y: y2
7187 };
7188 const axis = getAlignmentAxis(placement);
7189 const length = getAxisLength(axis);
7190 const arrowDimensions = await platform3.getDimensions(element);
7191 const isYAxis = axis === "y";
7192 const minProp = isYAxis ? "top" : "left";
7193 const maxProp = isYAxis ? "bottom" : "right";
7194 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
7195 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
7196 const startDiff = coords[axis] - rects.reference[axis];
7197 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
7198 let clientSize = elements.floating[clientProp] || rects.floating[length];
7199 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
7200 clientSize = elements.floating[clientProp] || rects.floating[length];
7201 }
7202 const centerToReference = endDiff / 2 - startDiff / 2;
7203 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
7204 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
7205 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
7206 const min2 = minPadding;
7207 const max2 = clientSize - arrowDimensions[length] - maxPadding;
7208 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
7209 const offset4 = clamp(min2, center, max2);
7210 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
7211 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
7212 return {
7213 [axis]: coords[axis] + alignmentOffset,
7214 data: {
7215 [axis]: offset4,
7216 centerOffset: center - offset4 - alignmentOffset,
7217 ...shouldAddOffset && {
7218 alignmentOffset
7219 }
7220 },
7221 reset: shouldAddOffset
7222 };
7223 }
7224 });
7225 var arrow4 = (options, deps) => ({
7226 ...baseArrow(options),
7227 options: [options, deps]
7228 });
7229
7230 // node_modules/@base-ui/react/esm/utils/hideMiddleware.js
7231 var hide4 = {
7232 name: "hide",
7233 async fn(state) {
7234 const {
7235 width,
7236 height,
7237 x: x2,
7238 y: y2
7239 } = state.rects.reference;
7240 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0;
7241 const nativeHideResult = await hide3().fn(state);
7242 return {
7243 data: {
7244 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
7245 }
7246 };
7247 }
7248 };
7249
7250 // node_modules/@base-ui/react/esm/utils/adaptiveOriginMiddleware.js
7251 var DEFAULT_SIDES = {
7252 sideX: "left",
7253 sideY: "top"
7254 };
7255 var adaptiveOrigin = {
7256 name: "adaptiveOrigin",
7257 async fn(state) {
7258 const {
7259 x: rawX,
7260 y: rawY,
7261 rects: {
7262 floating: floatRect
7263 },
7264 elements: {
7265 floating
7266 },
7267 platform: platform3,
7268 strategy,
7269 placement
7270 } = state;
7271 const win = getWindow(floating);
7272 const styles = win.getComputedStyle(floating);
7273 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
7274 if (!hasTransition) {
7275 return {
7276 x: rawX,
7277 y: rawY,
7278 data: DEFAULT_SIDES
7279 };
7280 }
7281 const offsetParent = await platform3.getOffsetParent?.(floating);
7282 let offsetDimensions = {
7283 width: 0,
7284 height: 0
7285 };
7286 if (strategy === "fixed" && win?.visualViewport) {
7287 offsetDimensions = {
7288 width: win.visualViewport.width,
7289 height: win.visualViewport.height
7290 };
7291 } else if (offsetParent === win) {
7292 const doc = ownerDocument(floating);
7293 offsetDimensions = {
7294 width: doc.documentElement.clientWidth,
7295 height: doc.documentElement.clientHeight
7296 };
7297 } else if (await platform3.isElement?.(offsetParent)) {
7298 offsetDimensions = await platform3.getDimensions(offsetParent);
7299 }
7300 const currentSide = getSide(placement);
7301 let x2 = rawX;
7302 let y2 = rawY;
7303 if (currentSide === "left") {
7304 x2 = offsetDimensions.width - (rawX + floatRect.width);
7305 }
7306 if (currentSide === "top") {
7307 y2 = offsetDimensions.height - (rawY + floatRect.height);
7308 }
7309 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
7310 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
7311 return {
7312 x: x2,
7313 y: y2,
7314 data: {
7315 sideX,
7316 sideY
7317 }
7318 };
7319 }
7320 };
7321
7322 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
7323 function getLogicalSide(sideParam, renderedSide, isRtl) {
7324 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
7325 const logicalRight = isRtl ? "inline-start" : "inline-end";
7326 const logicalLeft = isRtl ? "inline-end" : "inline-start";
7327 return {
7328 top: "top",
7329 right: isLogicalSideParam ? logicalRight : "right",
7330 bottom: "bottom",
7331 left: isLogicalSideParam ? logicalLeft : "left"
7332 }[renderedSide];
7333 }
7334 function getOffsetData(state, sideParam, isRtl) {
7335 const {
7336 rects,
7337 placement
7338 } = state;
7339 const data = {
7340 side: getLogicalSide(sideParam, getSide(placement), isRtl),
7341 align: getAlignment(placement) || "center",
7342 anchor: {
7343 width: rects.reference.width,
7344 height: rects.reference.height
7345 },
7346 positioner: {
7347 width: rects.floating.width,
7348 height: rects.floating.height
7349 }
7350 };
7351 return data;
7352 }
7353 function useAnchorPositioning(params) {
7354 const {
7355 // Public parameters
7356 anchor,
7357 positionMethod = "absolute",
7358 side: sideParam = "bottom",
7359 sideOffset = 0,
7360 align = "center",
7361 alignOffset = 0,
7362 collisionBoundary,
7363 collisionPadding: collisionPaddingParam = 5,
7364 sticky = false,
7365 arrowPadding = 5,
7366 disableAnchorTracking = false,
7367 // Private parameters
7368 keepMounted = false,
7369 floatingRootContext,
7370 mounted,
7371 collisionAvoidance,
7372 shiftCrossAxis = false,
7373 nodeId,
7374 adaptiveOrigin: adaptiveOrigin2,
7375 lazyFlip = false,
7376 externalTree
7377 } = params;
7378 const [mountSide, setMountSide] = React30.useState(null);
7379 if (!mounted && mountSide !== null) {
7380 setMountSide(null);
7381 }
7382 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
7383 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
7384 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
7385 const anchorFn = typeof anchor === "function" ? anchor : void 0;
7386 const anchorFnCallback = useStableCallback(anchorFn);
7387 const anchorDep = anchorFn ? anchorFnCallback : anchor;
7388 const anchorValueRef = useValueAsRef(anchor);
7389 const mountedRef = useValueAsRef(mounted);
7390 const direction = useDirection();
7391 const isRtl = direction === "rtl";
7392 const side = mountSide || {
7393 top: "top",
7394 right: "right",
7395 bottom: "bottom",
7396 left: "left",
7397 "inline-end": isRtl ? "left" : "right",
7398 "inline-start": isRtl ? "right" : "left"
7399 }[sideParam];
7400 const placement = align === "center" ? side : `${side}-${align}`;
7401 let collisionPadding = collisionPaddingParam;
7402 const bias = 1;
7403 const biasTop = sideParam === "bottom" ? bias : 0;
7404 const biasBottom = sideParam === "top" ? bias : 0;
7405 const biasLeft = sideParam === "right" ? bias : 0;
7406 const biasRight = sideParam === "left" ? bias : 0;
7407 if (typeof collisionPadding === "number") {
7408 collisionPadding = {
7409 top: collisionPadding + biasTop,
7410 right: collisionPadding + biasRight,
7411 bottom: collisionPadding + biasBottom,
7412 left: collisionPadding + biasLeft
7413 };
7414 } else if (collisionPadding) {
7415 collisionPadding = {
7416 top: (collisionPadding.top || 0) + biasTop,
7417 right: (collisionPadding.right || 0) + biasRight,
7418 bottom: (collisionPadding.bottom || 0) + biasBottom,
7419 left: (collisionPadding.left || 0) + biasLeft
7420 };
7421 }
7422 const commonCollisionProps = {
7423 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
7424 padding: collisionPadding
7425 };
7426 const arrowRef = React30.useRef(null);
7427 const sideOffsetRef = useValueAsRef(sideOffset);
7428 const alignOffsetRef = useValueAsRef(alignOffset);
7429 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
7430 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
7431 const middleware = [offset3((state) => {
7432 const data = getOffsetData(state, sideParam, isRtl);
7433 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
7434 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
7435 return {
7436 mainAxis: sideAxis,
7437 crossAxis: alignAxis,
7438 alignmentAxis: alignAxis
7439 };
7440 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam])];
7441 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
7442 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
7443 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
7444 ...commonCollisionProps,
7445 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
7446 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
7447 padding: {
7448 top: collisionPadding.top + bias,
7449 right: collisionPadding.right + bias,
7450 bottom: collisionPadding.bottom + bias,
7451 left: collisionPadding.left + bias
7452 },
7453 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
7454 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
7455 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
7456 });
7457 const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
7458 const html = ownerDocument(data.elements.floating).documentElement;
7459 return {
7460 ...commonCollisionProps,
7461 // Use the Layout Viewport to avoid shifting around when pinch-zooming
7462 // for context menus.
7463 rootBoundary: shiftCrossAxis ? {
7464 x: 0,
7465 y: 0,
7466 width: html.clientWidth,
7467 height: html.clientHeight
7468 } : void 0,
7469 mainAxis: collisionAvoidanceAlign !== "none",
7470 crossAxis: crossAxisShiftEnabled,
7471 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
7472 if (!arrowRef.current) {
7473 return {};
7474 }
7475 const {
7476 width,
7477 height
7478 } = arrowRef.current.getBoundingClientRect();
7479 const sideAxis = getSideAxis(getSide(limitData.placement));
7480 const arrowSize = sideAxis === "y" ? width : height;
7481 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
7482 return {
7483 offset: arrowSize / 2 + offsetAmount / 2
7484 };
7485 })
7486 };
7487 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
7488 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
7489 middleware.push(shiftMiddleware, flipMiddleware);
7490 } else {
7491 middleware.push(flipMiddleware, shiftMiddleware);
7492 }
7493 middleware.push(size3({
7494 ...commonCollisionProps,
7495 apply({
7496 elements: {
7497 floating
7498 },
7499 availableWidth,
7500 availableHeight,
7501 rects
7502 }) {
7503 if (!mountedRef.current) {
7504 return;
7505 }
7506 const floatingStyle = floating.style;
7507 floatingStyle.setProperty("--available-width", `${availableWidth}px`);
7508 floatingStyle.setProperty("--available-height", `${availableHeight}px`);
7509 const dpr = getWindow(floating).devicePixelRatio || 1;
7510 const {
7511 x: x3,
7512 y: y3,
7513 width,
7514 height
7515 } = rects.reference;
7516 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr;
7517 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr;
7518 floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
7519 floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
7520 }
7521 }), arrow4(() => ({
7522 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
7523 // we'll create a fake element.
7524 element: arrowRef.current || ownerDocument(arrowRef.current).createElement("div"),
7525 padding: arrowPadding,
7526 offsetParent: "floating"
7527 }), [arrowPadding]), {
7528 name: "transformOrigin",
7529 fn(state) {
7530 const {
7531 elements: elements2,
7532 middlewareData: middlewareData2,
7533 placement: renderedPlacement2,
7534 rects,
7535 y: y3
7536 } = state;
7537 const currentRenderedSide = getSide(renderedPlacement2);
7538 const currentRenderedAxis = getSideAxis(currentRenderedSide);
7539 const arrowEl = arrowRef.current;
7540 const arrowX = middlewareData2.arrow?.x || 0;
7541 const arrowY = middlewareData2.arrow?.y || 0;
7542 const arrowWidth = arrowEl?.clientWidth || 0;
7543 const arrowHeight = arrowEl?.clientHeight || 0;
7544 const transformX = arrowX + arrowWidth / 2;
7545 const transformY = arrowY + arrowHeight / 2;
7546 const shiftY = Math.abs(middlewareData2.shift?.y || 0);
7547 const halfAnchorHeight = rects.reference.height / 2;
7548 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
7549 const isOverlappingAnchor = shiftY > sideOffsetValue;
7550 const adjacentTransformOrigin = {
7551 top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
7552 bottom: `${transformX}px ${-sideOffsetValue}px`,
7553 left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
7554 right: `${-sideOffsetValue}px ${transformY}px`
7555 }[currentRenderedSide];
7556 const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y3}px`;
7557 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
7558 return {};
7559 }
7560 }, hide4, adaptiveOrigin2);
7561 useIsoLayoutEffect(() => {
7562 if (!mounted && floatingRootContext) {
7563 floatingRootContext.update({
7564 referenceElement: null,
7565 floatingElement: null,
7566 domReferenceElement: null,
7567 positionReference: null
7568 });
7569 }
7570 }, [mounted, floatingRootContext]);
7571 const autoUpdateOptions = React30.useMemo(() => ({
7572 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
7573 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
7574 }), [disableAnchorTracking]);
7575 const {
7576 refs,
7577 elements,
7578 x: x2,
7579 y: y2,
7580 middlewareData,
7581 update: update2,
7582 placement: renderedPlacement,
7583 context,
7584 isPositioned,
7585 floatingStyles: originalFloatingStyles
7586 } = useFloating2({
7587 rootContext: floatingRootContext,
7588 open: keepMounted ? mounted : void 0,
7589 placement,
7590 middleware,
7591 strategy: positionMethod,
7592 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
7593 nodeId,
7594 externalTree
7595 });
7596 const {
7597 sideX,
7598 sideY
7599 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
7600 const resolvedPosition = isPositioned ? positionMethod : "fixed";
7601 const floatingStyles = React30.useMemo(() => {
7602 const base = adaptiveOrigin2 ? {
7603 position: resolvedPosition,
7604 [sideX]: x2,
7605 [sideY]: y2
7606 } : {
7607 position: resolvedPosition,
7608 ...originalFloatingStyles
7609 };
7610 if (!isPositioned) {
7611 base.opacity = 0;
7612 }
7613 return base;
7614 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]);
7615 const registeredPositionReferenceRef = React30.useRef(null);
7616 useIsoLayoutEffect(() => {
7617 if (!mounted) {
7618 return;
7619 }
7620 const anchorValue = anchorValueRef.current;
7621 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
7622 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
7623 const finalAnchor = unwrappedElement || null;
7624 if (finalAnchor !== registeredPositionReferenceRef.current) {
7625 refs.setPositionReference(finalAnchor);
7626 registeredPositionReferenceRef.current = finalAnchor;
7627 }
7628 }, [mounted, refs, anchorDep, anchorValueRef]);
7629 React30.useEffect(() => {
7630 if (!mounted) {
7631 return;
7632 }
7633 const anchorValue = anchorValueRef.current;
7634 if (typeof anchorValue === "function") {
7635 return;
7636 }
7637 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
7638 refs.setPositionReference(anchorValue.current);
7639 registeredPositionReferenceRef.current = anchorValue.current;
7640 }
7641 }, [mounted, refs, anchorDep, anchorValueRef]);
7642 React30.useEffect(() => {
7643 if (keepMounted && mounted && elements.domReference && elements.floating) {
7644 return autoUpdate(elements.domReference, elements.floating, update2, autoUpdateOptions);
7645 }
7646 return void 0;
7647 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
7648 const renderedSide = getSide(renderedPlacement);
7649 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
7650 const renderedAlign = getAlignment(renderedPlacement) || "center";
7651 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
7652 useIsoLayoutEffect(() => {
7653 if (lazyFlip && mounted && isPositioned) {
7654 setMountSide(renderedSide);
7655 }
7656 }, [lazyFlip, mounted, isPositioned, renderedSide]);
7657 const arrowStyles = React30.useMemo(() => ({
7658 position: "absolute",
7659 top: middlewareData.arrow?.y,
7660 left: middlewareData.arrow?.x
7661 }), [middlewareData.arrow]);
7662 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
7663 return React30.useMemo(() => ({
7664 positionerStyles: floatingStyles,
7665 arrowStyles,
7666 arrowRef,
7667 arrowUncentered,
7668 side: logicalRenderedSide,
7669 align: renderedAlign,
7670 physicalSide: renderedSide,
7671 anchorHidden,
7672 refs,
7673 context,
7674 isPositioned,
7675 update: update2
7676 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
7677 }
7678 function isRef(param) {
7679 return param != null && "current" in param;
7680 }
7681
7682 // node_modules/@base-ui/react/esm/utils/getDisabledMountTransitionStyles.js
7683 function getDisabledMountTransitionStyles(transitionStatus) {
7684 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
7685 }
7686
7687 // node_modules/@base-ui/react/esm/utils/usePositioner.js
7688 function usePositioner(componentProps, state, {
7689 styles,
7690 transitionStatus,
7691 props,
7692 refs,
7693 hidden,
7694 inert = false
7695 }) {
7696 const style = {
7697 ...styles
7698 };
7699 if (inert) {
7700 style.pointerEvents = "none";
7701 }
7702 return useRenderElement("div", componentProps, {
7703 state,
7704 ref: refs,
7705 props: [{
7706 role: "presentation",
7707 hidden,
7708 style
7709 }, getDisabledMountTransitionStyles(transitionStatus), props],
7710 stateAttributesMapping: popupStateMapping
7711 });
7712 }
7713
7714 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
7715 var React33 = __toESM(require_react(), 1);
7716 var ReactDOM5 = __toESM(require_react_dom(), 1);
7717
7718 // node_modules/@base-ui/utils/esm/usePreviousValue.js
7719 var React31 = __toESM(require_react(), 1);
7720 function usePreviousValue(value) {
7721 const [state, setState] = React31.useState({
7722 current: value,
7723 previous: null
7724 });
7725 if (value !== state.current) {
7726 setState({
7727 current: value,
7728 previous: state.current
7729 });
7730 }
7731 return state.previous;
7732 }
7733
7734 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7735 var React32 = __toESM(require_react(), 1);
7736
7737 // node_modules/@base-ui/react/esm/utils/getCssDimensions.js
7738 function getCssDimensions2(element) {
7739 const css = getComputedStyle2(element);
7740 let width = parseFloat(css.width) || 0;
7741 let height = parseFloat(css.height) || 0;
7742 const hasOffset = isHTMLElement(element);
7743 const offsetWidth = hasOffset ? element.offsetWidth : width;
7744 const offsetHeight = hasOffset ? element.offsetHeight : height;
7745 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
7746 if (shouldFallback) {
7747 width = offsetWidth;
7748 height = offsetHeight;
7749 }
7750 return {
7751 width,
7752 height
7753 };
7754 }
7755
7756 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7757 var DEFAULT_ENABLED = () => true;
7758 function usePopupAutoResize(parameters) {
7759 const {
7760 popupElement,
7761 positionerElement,
7762 content,
7763 mounted,
7764 enabled = DEFAULT_ENABLED,
7765 onMeasureLayout: onMeasureLayoutParam,
7766 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
7767 side,
7768 direction
7769 } = parameters;
7770 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
7771 const animationFrame = useAnimationFrame();
7772 const committedDimensionsRef = React32.useRef(null);
7773 const liveDimensionsRef = React32.useRef(null);
7774 const isInitialRenderRef = React32.useRef(true);
7775 const restoreAnchoringStylesRef = React32.useRef(NOOP);
7776 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
7777 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
7778 const anchoringStyles = React32.useMemo(() => {
7779 let isOriginSide = side === "top";
7780 let isPhysicalLeft = side === "left";
7781 if (direction === "rtl") {
7782 isOriginSide = isOriginSide || side === "inline-end";
7783 isPhysicalLeft = isPhysicalLeft || side === "inline-end";
7784 } else {
7785 isOriginSide = isOriginSide || side === "inline-start";
7786 isPhysicalLeft = isPhysicalLeft || side === "inline-start";
7787 }
7788 return isOriginSide ? {
7789 position: "absolute",
7790 [side === "top" ? "bottom" : "top"]: "0",
7791 [isPhysicalLeft ? "right" : "left"]: "0"
7792 } : EMPTY_OBJECT;
7793 }, [side, direction]);
7794 useIsoLayoutEffect(() => {
7795 if (!mounted || !enabled() || typeof ResizeObserver !== "function") {
7796 restoreAnchoringStylesRef.current = NOOP;
7797 isInitialRenderRef.current = true;
7798 committedDimensionsRef.current = null;
7799 liveDimensionsRef.current = null;
7800 return void 0;
7801 }
7802 if (!popupElement || !positionerElement) {
7803 return void 0;
7804 }
7805 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
7806 const observer = new ResizeObserver((entries) => {
7807 const entry = entries[0];
7808 if (entry) {
7809 liveDimensionsRef.current = {
7810 width: Math.ceil(entry.borderBoxSize[0].inlineSize),
7811 height: Math.ceil(entry.borderBoxSize[0].blockSize)
7812 };
7813 }
7814 });
7815 observer.observe(popupElement);
7816 setPopupCssSize(popupElement, "auto");
7817 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
7818 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
7819 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
7820 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
7821 "--available-width": "max-content",
7822 "--available-height": "max-content"
7823 });
7824 function restoreMeasurementOverrides() {
7825 restorePopupPosition();
7826 restorePopupTransform();
7827 restorePositionerAvailableSize();
7828 }
7829 function restoreMeasurementOverridesIncludingScale() {
7830 restoreMeasurementOverrides();
7831 restorePopupScale();
7832 }
7833 onMeasureLayout?.();
7834 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
7835 setPositionerCssSize(positionerElement, "max-content");
7836 const dimensions = getCssDimensions2(popupElement);
7837 committedDimensionsRef.current = dimensions;
7838 setPositionerCssSize(positionerElement, dimensions);
7839 restoreMeasurementOverridesIncludingScale();
7840 onMeasureLayoutComplete?.(null, dimensions);
7841 isInitialRenderRef.current = false;
7842 return () => {
7843 observer.disconnect();
7844 restoreAnchoringStylesRef.current();
7845 restoreAnchoringStylesRef.current = NOOP;
7846 };
7847 }
7848 setPopupCssSize(popupElement, "auto");
7849 setPositionerCssSize(positionerElement, "max-content");
7850 const previousDimensions = committedDimensionsRef.current ?? liveDimensionsRef.current;
7851 const newDimensions = getCssDimensions2(popupElement);
7852 committedDimensionsRef.current = newDimensions;
7853 if (!previousDimensions) {
7854 setPositionerCssSize(positionerElement, newDimensions);
7855 restoreMeasurementOverridesIncludingScale();
7856 onMeasureLayoutComplete?.(null, newDimensions);
7857 return () => {
7858 observer.disconnect();
7859 animationFrame.cancel();
7860 restoreAnchoringStylesRef.current();
7861 restoreAnchoringStylesRef.current = NOOP;
7862 };
7863 }
7864 setPopupCssSize(popupElement, previousDimensions);
7865 restoreMeasurementOverridesIncludingScale();
7866 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
7867 setPositionerCssSize(positionerElement, newDimensions);
7868 const abortController = new AbortController();
7869 animationFrame.request(() => {
7870 setPopupCssSize(popupElement, newDimensions);
7871 runOnceAnimationsFinish(() => {
7872 popupElement.style.setProperty("--popup-width", "auto");
7873 popupElement.style.setProperty("--popup-height", "auto");
7874 }, abortController.signal);
7875 });
7876 return () => {
7877 observer.disconnect();
7878 abortController.abort();
7879 animationFrame.cancel();
7880 restoreAnchoringStylesRef.current();
7881 restoreAnchoringStylesRef.current = NOOP;
7882 };
7883 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, enabled, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
7884 }
7885 function overrideElementStyle(element, property, value) {
7886 const originalValue = element.style.getPropertyValue(property);
7887 element.style.setProperty(property, value);
7888 return () => {
7889 element.style.setProperty(property, originalValue);
7890 };
7891 }
7892 function applyElementStyles(element, styles) {
7893 const restorers = [];
7894 for (const [key, value] of Object.entries(styles)) {
7895 restorers.push(overrideElementStyle(element, key, value));
7896 }
7897 return restorers.length ? () => {
7898 restorers.forEach((restore) => restore());
7899 } : NOOP;
7900 }
7901 function setPopupCssSize(popupElement, size4) {
7902 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
7903 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
7904 popupElement.style.setProperty("--popup-width", width);
7905 popupElement.style.setProperty("--popup-height", height);
7906 }
7907 function setPositionerCssSize(positionerElement, size4) {
7908 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
7909 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
7910 positionerElement.style.setProperty("--positioner-width", width);
7911 positionerElement.style.setProperty("--positioner-height", height);
7912 }
7913
7914 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
7915 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
7916 function usePopupViewport(parameters) {
7917 const {
7918 store,
7919 side,
7920 cssVars,
7921 children
7922 } = parameters;
7923 const direction = useDirection();
7924 const activeTrigger = store.useState("activeTriggerElement");
7925 const activeTriggerId = store.useState("activeTriggerId");
7926 const open = store.useState("open");
7927 const payload = store.useState("payload");
7928 const mounted = store.useState("mounted");
7929 const popupElement = store.useState("popupElement");
7930 const positionerElement = store.useState("positionerElement");
7931 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
7932 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
7933 const capturedNodeRef = React33.useRef(null);
7934 const [previousContentNode, setPreviousContentNode] = React33.useState(null);
7935 const [newTriggerOffset, setNewTriggerOffset] = React33.useState(null);
7936 const currentContainerRef = React33.useRef(null);
7937 const previousContainerRef = React33.useRef(null);
7938 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
7939 const cleanupFrame = useAnimationFrame();
7940 const [previousContentDimensions, setPreviousContentDimensions] = React33.useState(null);
7941 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React33.useState(false);
7942 useIsoLayoutEffect(() => {
7943 store.set("hasViewport", true);
7944 return () => {
7945 store.set("hasViewport", false);
7946 };
7947 }, [store]);
7948 const handleMeasureLayout = useStableCallback(() => {
7949 currentContainerRef.current?.style.setProperty("animation", "none");
7950 currentContainerRef.current?.style.setProperty("transition", "none");
7951 previousContainerRef.current?.style.setProperty("display", "none");
7952 });
7953 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
7954 currentContainerRef.current?.style.removeProperty("animation");
7955 currentContainerRef.current?.style.removeProperty("transition");
7956 previousContainerRef.current?.style.removeProperty("display");
7957 if (previousDimensions) {
7958 setPreviousContentDimensions(previousDimensions);
7959 }
7960 });
7961 const lastHandledTriggerRef = React33.useRef(null);
7962 useIsoLayoutEffect(() => {
7963 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
7964 setPreviousContentNode(capturedNodeRef.current);
7965 setShowStartingStyleAttribute(true);
7966 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
7967 setNewTriggerOffset(offset4);
7968 cleanupFrame.request(() => {
7969 ReactDOM5.flushSync(() => {
7970 setShowStartingStyleAttribute(false);
7971 });
7972 onAnimationsFinished(() => {
7973 setPreviousContentNode(null);
7974 setPreviousContentDimensions(null);
7975 capturedNodeRef.current = null;
7976 });
7977 });
7978 lastHandledTriggerRef.current = activeTrigger;
7979 }
7980 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
7981 useIsoLayoutEffect(() => {
7982 const source = currentContainerRef.current;
7983 if (!source) {
7984 return;
7985 }
7986 const wrapper = ownerDocument(source).createElement("div");
7987 for (const child of Array.from(source.childNodes)) {
7988 wrapper.appendChild(child.cloneNode(true));
7989 }
7990 capturedNodeRef.current = wrapper;
7991 });
7992 const isTransitioning = previousContentNode != null;
7993 let childrenToRender;
7994 if (!isTransitioning) {
7995 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", {
7996 "data-current": true,
7997 ref: currentContainerRef,
7998 children
7999 }, currentContentKey);
8000 } else {
8001 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(React33.Fragment, {
8002 children: [/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", {
8003 "data-previous": true,
8004 inert: inertValue(true),
8005 ref: previousContainerRef,
8006 style: {
8007 ...previousContentDimensions ? {
8008 [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
8009 [cssVars.popupHeight]: `${previousContentDimensions.height}px`
8010 } : null,
8011 position: "absolute"
8012 },
8013 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
8014 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", {
8015 "data-current": true,
8016 ref: currentContainerRef,
8017 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
8018 children
8019 }, currentContentKey)]
8020 });
8021 }
8022 useIsoLayoutEffect(() => {
8023 const container = previousContainerRef.current;
8024 if (!container || !previousContentNode) {
8025 return;
8026 }
8027 container.replaceChildren(...Array.from(previousContentNode.childNodes));
8028 }, [previousContentNode]);
8029 usePopupAutoResize({
8030 popupElement,
8031 positionerElement,
8032 mounted,
8033 content: payload,
8034 onMeasureLayout: handleMeasureLayout,
8035 onMeasureLayoutComplete: handleMeasureLayoutComplete,
8036 side,
8037 direction
8038 });
8039 const state = {
8040 activationDirection: getActivationDirection(newTriggerOffset),
8041 transitioning: isTransitioning
8042 };
8043 return {
8044 children: childrenToRender,
8045 state
8046 };
8047 }
8048 function getActivationDirection(offset4) {
8049 if (!offset4) {
8050 return void 0;
8051 }
8052 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
8053 }
8054 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
8055 if (value > tolerance) {
8056 return positiveLabel;
8057 }
8058 if (value < -tolerance) {
8059 return negativeLabel;
8060 }
8061 return "";
8062 }
8063 function calculateRelativePosition(from, to) {
8064 const fromRect = from.getBoundingClientRect();
8065 const toRect = to.getBoundingClientRect();
8066 const fromCenter = {
8067 x: fromRect.left + fromRect.width / 2,
8068 y: fromRect.top + fromRect.height / 2
8069 };
8070 const toCenter = {
8071 x: toRect.left + toRect.width / 2,
8072 y: toRect.top + toRect.height / 2
8073 };
8074 return {
8075 horizontal: toCenter.x - fromCenter.x,
8076 vertical: toCenter.y - fromCenter.y
8077 };
8078 }
8079 function usePopupContentKey(activeTriggerId, payload) {
8080 const [contentKey, setContentKey] = React33.useState(0);
8081 const previousActiveTriggerIdRef = React33.useRef(activeTriggerId);
8082 const previousPayloadRef = React33.useRef(payload);
8083 const pendingPayloadUpdateRef = React33.useRef(false);
8084 useIsoLayoutEffect(() => {
8085 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
8086 const previousPayload = previousPayloadRef.current;
8087 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
8088 const payloadChanged = payload !== previousPayload;
8089 if (triggerIdChanged) {
8090 setContentKey((value) => value + 1);
8091 pendingPayloadUpdateRef.current = !payloadChanged;
8092 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
8093 setContentKey((value) => value + 1);
8094 pendingPayloadUpdateRef.current = false;
8095 }
8096 previousActiveTriggerIdRef.current = activeTriggerId;
8097 previousPayloadRef.current = payload;
8098 }, [activeTriggerId, payload]);
8099 return `${activeTriggerId ?? "current"}-${contentKey}`;
8100 }
8101
8102 // node_modules/@base-ui/react/esm/utils/FloatingPortalLite.js
8103 var React34 = __toESM(require_react(), 1);
8104 var ReactDOM6 = __toESM(require_react_dom(), 1);
8105 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
8106 var FloatingPortalLite = /* @__PURE__ */ React34.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
8107 const {
8108 children,
8109 container,
8110 className,
8111 render: render4,
8112 style,
8113 ...elementProps
8114 } = componentProps;
8115 const {
8116 portalNode,
8117 portalSubtree
8118 } = useFloatingPortalNode({
8119 container,
8120 ref: forwardedRef,
8121 componentProps,
8122 elementProps
8123 });
8124 if (!portalSubtree && !portalNode) {
8125 return null;
8126 }
8127 return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(React34.Fragment, {
8128 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM6.createPortal(children, portalNode)]
8129 });
8130 });
8131 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
8132
8133 // node_modules/@base-ui/react/esm/tooltip/index.parts.js
8134 var index_parts_exports = {};
8135 __export(index_parts_exports, {
8136 Arrow: () => TooltipArrow,
8137 Handle: () => TooltipHandle,
8138 Popup: () => TooltipPopup,
8139 Portal: () => TooltipPortal,
8140 Positioner: () => TooltipPositioner,
8141 Provider: () => TooltipProvider,
8142 Root: () => TooltipRoot,
8143 Trigger: () => TooltipTrigger,
8144 Viewport: () => TooltipViewport,
8145 createHandle: () => createTooltipHandle
8146 });
8147
8148 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
8149 var React37 = __toESM(require_react(), 1);
8150
8151 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRootContext.js
8152 var React35 = __toESM(require_react(), 1);
8153 var TooltipRootContext = /* @__PURE__ */ React35.createContext(void 0);
8154 if (true) TooltipRootContext.displayName = "TooltipRootContext";
8155 function useTooltipRootContext(optional) {
8156 const context = React35.useContext(TooltipRootContext);
8157 if (context === void 0 && !optional) {
8158 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
8159 }
8160 return context;
8161 }
8162
8163 // node_modules/@base-ui/react/esm/tooltip/store/TooltipStore.js
8164 var React36 = __toESM(require_react(), 1);
8165 var ReactDOM7 = __toESM(require_react_dom(), 1);
8166 var selectors2 = {
8167 ...popupStoreSelectors,
8168 disabled: createSelector((state) => state.disabled),
8169 instantType: createSelector((state) => state.instantType),
8170 isInstantPhase: createSelector((state) => state.isInstantPhase),
8171 trackCursorAxis: createSelector((state) => state.trackCursorAxis),
8172 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
8173 lastOpenChangeReason: createSelector((state) => state.openChangeReason),
8174 closeOnClick: createSelector((state) => state.closeOnClick),
8175 closeDelay: createSelector((state) => state.closeDelay),
8176 hasViewport: createSelector((state) => state.hasViewport)
8177 };
8178 var TooltipStore = class _TooltipStore extends ReactStore {
8179 constructor(initialState) {
8180 super({
8181 ...createInitialState(),
8182 ...initialState
8183 }, {
8184 popupRef: /* @__PURE__ */ React36.createRef(),
8185 onOpenChange: void 0,
8186 onOpenChangeComplete: void 0,
8187 triggerElements: new PopupTriggerMap()
8188 }, selectors2);
8189 }
8190 setOpen = (nextOpen, eventDetails) => {
8191 const reason = eventDetails.reason;
8192 const isHover = reason === reason_parts_exports.triggerHover;
8193 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
8194 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
8195 eventDetails.preventUnmountOnClose = () => {
8196 this.set("preventUnmountingOnClose", true);
8197 };
8198 this.context.onOpenChange?.(nextOpen, eventDetails);
8199 if (eventDetails.isCanceled) {
8200 return;
8201 }
8202 this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
8203 const changeState = () => {
8204 const updatedState = {
8205 open: nextOpen,
8206 openChangeReason: reason
8207 };
8208 if (isFocusOpen) {
8209 updatedState.instantType = "focus";
8210 } else if (isDismissClose) {
8211 updatedState.instantType = "dismiss";
8212 } else if (reason === reason_parts_exports.triggerHover) {
8213 updatedState.instantType = void 0;
8214 }
8215 const newTriggerId = eventDetails.trigger?.id ?? null;
8216 if (newTriggerId || nextOpen) {
8217 updatedState.activeTriggerId = newTriggerId;
8218 updatedState.activeTriggerElement = eventDetails.trigger ?? null;
8219 }
8220 this.update(updatedState);
8221 };
8222 if (isHover) {
8223 ReactDOM7.flushSync(changeState);
8224 } else {
8225 changeState();
8226 }
8227 };
8228 static useStore(externalStore, initialState) {
8229 const internalStore = useRefWithInit(() => {
8230 return new _TooltipStore(initialState);
8231 }).current;
8232 const store = externalStore ?? internalStore;
8233 const floatingRootContext = useSyncedFloatingRootContext({
8234 popupStore: store,
8235 onOpenChange: store.setOpen
8236 });
8237 store.state.floatingRootContext = floatingRootContext;
8238 return store;
8239 }
8240 };
8241 function createInitialState() {
8242 return {
8243 ...createInitialPopupStoreState(),
8244 disabled: false,
8245 instantType: void 0,
8246 isInstantPhase: false,
8247 trackCursorAxis: "none",
8248 disableHoverablePopup: false,
8249 openChangeReason: null,
8250 closeOnClick: true,
8251 closeDelay: 0,
8252 hasViewport: false
8253 };
8254 }
8255
8256 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
8257 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
8258 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
8259 const {
8260 disabled: disabled2 = false,
8261 defaultOpen = false,
8262 open: openProp,
8263 disableHoverablePopup = false,
8264 trackCursorAxis = "none",
8265 actionsRef,
8266 onOpenChange,
8267 onOpenChangeComplete,
8268 handle,
8269 triggerId: triggerIdProp,
8270 defaultTriggerId: defaultTriggerIdProp = null,
8271 children
8272 } = props;
8273 const store = TooltipStore.useStore(handle?.store, {
8274 open: defaultOpen,
8275 openProp,
8276 activeTriggerId: defaultTriggerIdProp,
8277 triggerIdProp
8278 });
8279 useOnFirstRender(() => {
8280 if (openProp === void 0 && store.state.open === false && defaultOpen === true) {
8281 store.update({
8282 open: true,
8283 activeTriggerId: defaultTriggerIdProp
8284 });
8285 }
8286 });
8287 store.useControlledProp("openProp", openProp);
8288 store.useControlledProp("triggerIdProp", triggerIdProp);
8289 store.useContextCallback("onOpenChange", onOpenChange);
8290 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
8291 const openState = store.useState("open");
8292 const open = !disabled2 && openState;
8293 const activeTriggerId = store.useState("activeTriggerId");
8294 const payload = store.useState("payload");
8295 store.useSyncedValues({
8296 trackCursorAxis,
8297 disableHoverablePopup
8298 });
8299 useIsoLayoutEffect(() => {
8300 if (openState && disabled2) {
8301 store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
8302 }
8303 }, [openState, disabled2, store]);
8304 store.useSyncedValue("disabled", disabled2);
8305 useImplicitActiveTrigger(store);
8306 const {
8307 forceUnmount,
8308 transitionStatus
8309 } = useOpenStateTransitions(open, store);
8310 const floatingRootContext = store.select("floatingRootContext");
8311 const isInstantPhase = store.useState("isInstantPhase");
8312 const instantType = store.useState("instantType");
8313 const lastOpenChangeReason = store.useState("lastOpenChangeReason");
8314 const previousInstantTypeRef = React37.useRef(null);
8315 useIsoLayoutEffect(() => {
8316 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
8317 if (instantType !== "delay") {
8318 previousInstantTypeRef.current = instantType;
8319 }
8320 store.set("instantType", "delay");
8321 } else if (previousInstantTypeRef.current !== null) {
8322 store.set("instantType", previousInstantTypeRef.current);
8323 previousInstantTypeRef.current = null;
8324 }
8325 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]);
8326 useIsoLayoutEffect(() => {
8327 if (open) {
8328 if (activeTriggerId == null) {
8329 store.set("payload", void 0);
8330 }
8331 }
8332 }, [store, activeTriggerId, open]);
8333 const handleImperativeClose = React37.useCallback(() => {
8334 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
8335 }, [store]);
8336 React37.useImperativeHandle(actionsRef, () => ({
8337 unmount: forceUnmount,
8338 close: handleImperativeClose
8339 }), [forceUnmount, handleImperativeClose]);
8340 const dismiss = useDismiss(floatingRootContext, {
8341 enabled: !disabled2,
8342 referencePress: () => store.select("closeOnClick")
8343 });
8344 const clientPoint = useClientPoint(floatingRootContext, {
8345 enabled: !disabled2 && trackCursorAxis !== "none",
8346 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
8347 });
8348 const {
8349 getReferenceProps,
8350 getFloatingProps,
8351 getTriggerProps
8352 } = useInteractions([dismiss, clientPoint]);
8353 const activeTriggerProps = React37.useMemo(() => getReferenceProps(), [getReferenceProps]);
8354 const inactiveTriggerProps = React37.useMemo(() => getTriggerProps(), [getTriggerProps]);
8355 const popupProps = React37.useMemo(() => getFloatingProps(), [getFloatingProps]);
8356 store.useSyncedValues({
8357 activeTriggerProps,
8358 inactiveTriggerProps,
8359 popupProps
8360 });
8361 return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(TooltipRootContext.Provider, {
8362 value: store,
8363 children: typeof children === "function" ? children({
8364 payload
8365 }) : children
8366 });
8367 });
8368 if (true) TooltipRoot.displayName = "TooltipRoot";
8369
8370 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
8371 var React39 = __toESM(require_react(), 1);
8372
8373 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProviderContext.js
8374 var React38 = __toESM(require_react(), 1);
8375 var TooltipProviderContext = /* @__PURE__ */ React38.createContext(void 0);
8376 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
8377 function useTooltipProviderContext() {
8378 return React38.useContext(TooltipProviderContext);
8379 }
8380
8381 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTriggerDataAttributes.js
8382 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
8383 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
8384 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
8385 return TooltipTriggerDataAttributes2;
8386 })({});
8387
8388 // node_modules/@base-ui/react/esm/tooltip/utils/constants.js
8389 var OPEN_DELAY = 600;
8390
8391 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
8392 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
8393 const {
8394 className,
8395 render: render4,
8396 handle,
8397 payload,
8398 disabled: disabledProp,
8399 delay,
8400 closeOnClick = true,
8401 closeDelay,
8402 id: idProp,
8403 style,
8404 ...elementProps
8405 } = componentProps;
8406 const rootContext = useTooltipRootContext(true);
8407 const store = handle?.store ?? rootContext;
8408 if (!store) {
8409 throw new Error(true ? "Base UI: <Tooltip.Trigger> must be either used within a <Tooltip.Root> component or provided with a handle." : formatErrorMessage_default(82));
8410 }
8411 const thisTriggerId = useBaseUiId(idProp);
8412 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
8413 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
8414 const floatingRootContext = store.useState("floatingRootContext");
8415 const triggerElementRef = React39.useRef(null);
8416 const delayWithDefault = delay ?? OPEN_DELAY;
8417 const closeDelayWithDefault = closeDelay ?? 0;
8418 const {
8419 registerTrigger,
8420 isMountedByThisTrigger
8421 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
8422 payload,
8423 closeOnClick,
8424 closeDelay: closeDelayWithDefault
8425 });
8426 const providerContext = useTooltipProviderContext();
8427 const {
8428 delayRef,
8429 isInstantPhase,
8430 hasProvider
8431 } = useDelayGroup(floatingRootContext, {
8432 open: isOpenedByThisTrigger
8433 });
8434 store.useSyncedValue("isInstantPhase", isInstantPhase);
8435 const rootDisabled = store.useState("disabled");
8436 const disabled2 = disabledProp ?? rootDisabled;
8437 const trackCursorAxis = store.useState("trackCursorAxis");
8438 const disableHoverablePopup = store.useState("disableHoverablePopup");
8439 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
8440 enabled: !disabled2,
8441 mouseOnly: true,
8442 move: false,
8443 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
8444 restMs() {
8445 const providerDelay = providerContext?.delay;
8446 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
8447 let computedRestMs = delayWithDefault;
8448 if (hasProvider) {
8449 if (groupOpenValue !== 0) {
8450 computedRestMs = delay ?? providerDelay ?? delayWithDefault;
8451 } else {
8452 computedRestMs = 0;
8453 }
8454 }
8455 return computedRestMs;
8456 },
8457 delay() {
8458 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
8459 let computedCloseDelay = closeDelayWithDefault;
8460 if (closeDelay == null && hasProvider) {
8461 computedCloseDelay = closeValue;
8462 }
8463 return {
8464 close: computedCloseDelay
8465 };
8466 },
8467 triggerElementRef,
8468 isActiveTrigger: isTriggerActive,
8469 isClosing: () => store.select("transitionStatus") === "ending"
8470 });
8471 const focusProps = useFocus(floatingRootContext, {
8472 enabled: !disabled2
8473 }).reference;
8474 const state = {
8475 open: isOpenedByThisTrigger
8476 };
8477 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
8478 const element = useRenderElement("button", componentProps, {
8479 state,
8480 ref: [forwardedRef, registerTrigger, triggerElementRef],
8481 props: [hoverProps, focusProps, rootTriggerProps, {
8482 onPointerDown() {
8483 store.set("closeOnClick", closeOnClick);
8484 },
8485 id: thisTriggerId,
8486 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0
8487 }, elementProps],
8488 stateAttributesMapping: triggerOpenStateMapping
8489 });
8490 return element;
8491 });
8492 if (true) TooltipTrigger.displayName = "TooltipTrigger";
8493
8494 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
8495 var React41 = __toESM(require_react(), 1);
8496
8497 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortalContext.js
8498 var React40 = __toESM(require_react(), 1);
8499 var TooltipPortalContext = /* @__PURE__ */ React40.createContext(void 0);
8500 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
8501 function useTooltipPortalContext() {
8502 const value = React40.useContext(TooltipPortalContext);
8503 if (value === void 0) {
8504 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
8505 }
8506 return value;
8507 }
8508
8509 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
8510 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
8511 var TooltipPortal = /* @__PURE__ */ React41.forwardRef(function TooltipPortal2(props, forwardedRef) {
8512 const {
8513 keepMounted = false,
8514 ...portalProps
8515 } = props;
8516 const store = useTooltipRootContext();
8517 const mounted = store.useState("mounted");
8518 const shouldRender = mounted || keepMounted;
8519 if (!shouldRender) {
8520 return null;
8521 }
8522 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(TooltipPortalContext.Provider, {
8523 value: keepMounted,
8524 children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(FloatingPortalLite, {
8525 ref: forwardedRef,
8526 ...portalProps
8527 })
8528 });
8529 });
8530 if (true) TooltipPortal.displayName = "TooltipPortal";
8531
8532 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
8533 var React43 = __toESM(require_react(), 1);
8534
8535 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositionerContext.js
8536 var React42 = __toESM(require_react(), 1);
8537 var TooltipPositionerContext = /* @__PURE__ */ React42.createContext(void 0);
8538 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
8539 function useTooltipPositionerContext() {
8540 const context = React42.useContext(TooltipPositionerContext);
8541 if (context === void 0) {
8542 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
8543 }
8544 return context;
8545 }
8546
8547 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
8548 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
8549 var TooltipPositioner = /* @__PURE__ */ React43.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
8550 const {
8551 render: render4,
8552 className,
8553 anchor,
8554 positionMethod = "absolute",
8555 side = "top",
8556 align = "center",
8557 sideOffset = 0,
8558 alignOffset = 0,
8559 collisionBoundary = "clipping-ancestors",
8560 collisionPadding = 5,
8561 arrowPadding = 5,
8562 sticky = false,
8563 disableAnchorTracking = false,
8564 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
8565 style,
8566 ...elementProps
8567 } = componentProps;
8568 const store = useTooltipRootContext();
8569 const keepMounted = useTooltipPortalContext();
8570 const open = store.useState("open");
8571 const mounted = store.useState("mounted");
8572 const trackCursorAxis = store.useState("trackCursorAxis");
8573 const disableHoverablePopup = store.useState("disableHoverablePopup");
8574 const floatingRootContext = store.useState("floatingRootContext");
8575 const instantType = store.useState("instantType");
8576 const transitionStatus = store.useState("transitionStatus");
8577 const hasViewport = store.useState("hasViewport");
8578 const positioning = useAnchorPositioning({
8579 anchor,
8580 positionMethod,
8581 floatingRootContext,
8582 mounted,
8583 side,
8584 sideOffset,
8585 align,
8586 alignOffset,
8587 collisionBoundary,
8588 collisionPadding,
8589 sticky,
8590 arrowPadding,
8591 disableAnchorTracking,
8592 keepMounted,
8593 collisionAvoidance,
8594 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
8595 });
8596 const state = React43.useMemo(() => ({
8597 open,
8598 side: positioning.side,
8599 align: positioning.align,
8600 anchorHidden: positioning.anchorHidden,
8601 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
8602 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
8603 const element = usePositioner(componentProps, state, {
8604 styles: positioning.positionerStyles,
8605 transitionStatus,
8606 props: elementProps,
8607 refs: [forwardedRef, store.useStateSetter("positionerElement")],
8608 hidden: !mounted,
8609 inert: !open || trackCursorAxis === "both" || disableHoverablePopup
8610 });
8611 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(TooltipPositionerContext.Provider, {
8612 value: positioning,
8613 children: element
8614 });
8615 });
8616 if (true) TooltipPositioner.displayName = "TooltipPositioner";
8617
8618 // node_modules/@base-ui/react/esm/tooltip/popup/TooltipPopup.js
8619 var React44 = __toESM(require_react(), 1);
8620 var stateAttributesMapping = {
8621 ...popupStateMapping,
8622 ...transitionStatusMapping
8623 };
8624 var TooltipPopup = /* @__PURE__ */ React44.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
8625 const {
8626 className,
8627 render: render4,
8628 style,
8629 ...elementProps
8630 } = componentProps;
8631 const store = useTooltipRootContext();
8632 const {
8633 side,
8634 align
8635 } = useTooltipPositionerContext();
8636 const open = store.useState("open");
8637 const instantType = store.useState("instantType");
8638 const transitionStatus = store.useState("transitionStatus");
8639 const popupProps = store.useState("popupProps");
8640 const floatingContext = store.useState("floatingRootContext");
8641 useOpenChangeComplete({
8642 open,
8643 ref: store.context.popupRef,
8644 onComplete() {
8645 if (open) {
8646 store.context.onOpenChangeComplete?.(true);
8647 }
8648 }
8649 });
8650 const disabled2 = store.useState("disabled");
8651 const closeDelay = store.useState("closeDelay");
8652 useHoverFloatingInteraction(floatingContext, {
8653 enabled: !disabled2,
8654 closeDelay
8655 });
8656 const state = {
8657 open,
8658 side,
8659 align,
8660 instant: instantType,
8661 transitionStatus
8662 };
8663 const element = useRenderElement("div", componentProps, {
8664 state,
8665 ref: [forwardedRef, store.context.popupRef, store.useStateSetter("popupElement")],
8666 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
8667 stateAttributesMapping
8668 });
8669 return element;
8670 });
8671 if (true) TooltipPopup.displayName = "TooltipPopup";
8672
8673 // node_modules/@base-ui/react/esm/tooltip/arrow/TooltipArrow.js
8674 var React45 = __toESM(require_react(), 1);
8675 var TooltipArrow = /* @__PURE__ */ React45.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
8676 const {
8677 className,
8678 render: render4,
8679 style,
8680 ...elementProps
8681 } = componentProps;
8682 const store = useTooltipRootContext();
8683 const open = store.useState("open");
8684 const instantType = store.useState("instantType");
8685 const {
8686 arrowRef,
8687 side,
8688 align,
8689 arrowUncentered,
8690 arrowStyles
8691 } = useTooltipPositionerContext();
8692 const state = {
8693 open,
8694 side,
8695 align,
8696 uncentered: arrowUncentered,
8697 instant: instantType
8698 };
8699 const element = useRenderElement("div", componentProps, {
8700 state,
8701 ref: [forwardedRef, arrowRef],
8702 props: [{
8703 style: arrowStyles,
8704 "aria-hidden": true
8705 }, elementProps],
8706 stateAttributesMapping: popupStateMapping
8707 });
8708 return element;
8709 });
8710 if (true) TooltipArrow.displayName = "TooltipArrow";
8711
8712 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProvider.js
8713 var React46 = __toESM(require_react(), 1);
8714 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
8715 var TooltipProvider = function TooltipProvider2(props) {
8716 const {
8717 delay,
8718 closeDelay,
8719 timeout = 400
8720 } = props;
8721 const contextValue = React46.useMemo(() => ({
8722 delay,
8723 closeDelay
8724 }), [delay, closeDelay]);
8725 const delayValue = React46.useMemo(() => ({
8726 open: delay,
8727 close: closeDelay
8728 }), [delay, closeDelay]);
8729 return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(TooltipProviderContext.Provider, {
8730 value: contextValue,
8731 children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(FloatingDelayGroup, {
8732 delay: delayValue,
8733 timeoutMs: timeout,
8734 children: props.children
8735 })
8736 });
8737 };
8738 if (true) TooltipProvider.displayName = "TooltipProvider";
8739
8740 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
8741 var React47 = __toESM(require_react(), 1);
8742
8743 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewportCssVars.js
8744 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
8745 TooltipViewportCssVars2["popupWidth"] = "--popup-width";
8746 TooltipViewportCssVars2["popupHeight"] = "--popup-height";
8747 return TooltipViewportCssVars2;
8748 })({});
8749
8750 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
8751 var stateAttributesMapping2 = {
8752 activationDirection: (value) => value ? {
8753 "data-activation-direction": value
8754 } : null
8755 };
8756 var TooltipViewport = /* @__PURE__ */ React47.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
8757 const {
8758 render: render4,
8759 className,
8760 style,
8761 children,
8762 ...elementProps
8763 } = componentProps;
8764 const store = useTooltipRootContext();
8765 const positioner = useTooltipPositionerContext();
8766 const instantType = store.useState("instantType");
8767 const {
8768 children: childrenToRender,
8769 state: viewportState
8770 } = usePopupViewport({
8771 store,
8772 side: positioner.side,
8773 cssVars: TooltipViewportCssVars,
8774 children
8775 });
8776 const state = {
8777 activationDirection: viewportState.activationDirection,
8778 transitioning: viewportState.transitioning,
8779 instant: instantType
8780 };
8781 return useRenderElement("div", componentProps, {
8782 state,
8783 ref: forwardedRef,
8784 props: [elementProps, {
8785 children: childrenToRender
8786 }],
8787 stateAttributesMapping: stateAttributesMapping2
8788 });
8789 });
8790 if (true) TooltipViewport.displayName = "TooltipViewport";
8791
8792 // node_modules/@base-ui/react/esm/tooltip/store/TooltipHandle.js
8793 var TooltipHandle = class {
8794 /**
8795 * Internal store holding the tooltip state.
8796 * @internal
8797 */
8798 constructor() {
8799 this.store = new TooltipStore();
8800 }
8801 /**
8802 * Opens the tooltip and associates it with the trigger with the given ID.
8803 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
8804 *
8805 * This method should only be called in an event handler or an effect (not during rendering).
8806 *
8807 * @param triggerId ID of the trigger to associate with the tooltip.
8808 */
8809 open(triggerId) {
8810 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
8811 if (triggerId && !triggerElement) {
8812 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
8813 }
8814 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
8815 }
8816 /**
8817 * Closes the tooltip.
8818 */
8819 close() {
8820 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
8821 }
8822 /**
8823 * Indicates whether the tooltip is currently open.
8824 */
8825 get isOpen() {
8826 return this.store.state.open;
8827 }
8828 };
8829 function createTooltipHandle() {
8830 return new TooltipHandle();
8831 }
8832
8833 // node_modules/@base-ui/react/esm/use-render/useRender.js
8834 function useRender(params) {
8835 return useRenderElement(params.defaultTagName ?? "div", params, params);
8836 }
8837
8838 // packages/ui/build-module/text/text.mjs
8839 var import_element9 = __toESM(require_element(), 1);
8840 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
8841 function getRuntime() {
8842 const globalScope = globalThis;
8843 if (globalScope.__wpStyleRuntime) {
8844 return globalScope.__wpStyleRuntime;
8845 }
8846 globalScope.__wpStyleRuntime = {
8847 documents: /* @__PURE__ */ new Map(),
8848 styles: /* @__PURE__ */ new Map(),
8849 injectedStyles: /* @__PURE__ */ new WeakMap()
8850 };
8851 if (typeof document !== "undefined") {
8852 registerDocument(document);
8853 }
8854 return globalScope.__wpStyleRuntime;
8855 }
8856 function documentContainsStyleHash(targetDocument, hash) {
8857 if (!targetDocument.head) {
8858 return false;
8859 }
8860 for (const style of targetDocument.head.querySelectorAll(
8861 `style[${STYLE_HASH_ATTRIBUTE}]`
8862 )) {
8863 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
8864 return true;
8865 }
8866 }
8867 return false;
8868 }
8869 function injectStyle(targetDocument, hash, css) {
8870 if (!targetDocument.head) {
8871 return;
8872 }
8873 const runtime = getRuntime();
8874 let injectedStyles = runtime.injectedStyles.get(targetDocument);
8875 if (!injectedStyles) {
8876 injectedStyles = /* @__PURE__ */ new Set();
8877 runtime.injectedStyles.set(targetDocument, injectedStyles);
8878 }
8879 if (injectedStyles.has(hash)) {
8880 return;
8881 }
8882 if (documentContainsStyleHash(targetDocument, hash)) {
8883 injectedStyles.add(hash);
8884 return;
8885 }
8886 const style = targetDocument.createElement("style");
8887 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
8888 style.appendChild(targetDocument.createTextNode(css));
8889 targetDocument.head.appendChild(style);
8890 injectedStyles.add(hash);
8891 }
8892 function registerDocument(targetDocument) {
8893 const runtime = getRuntime();
8894 runtime.documents.set(
8895 targetDocument,
8896 (runtime.documents.get(targetDocument) ?? 0) + 1
8897 );
8898 for (const [hash, css] of runtime.styles) {
8899 injectStyle(targetDocument, hash, css);
8900 }
8901 return () => {
8902 const count = runtime.documents.get(targetDocument);
8903 if (count === void 0) {
8904 return;
8905 }
8906 if (count <= 1) {
8907 runtime.documents.delete(targetDocument);
8908 return;
8909 }
8910 runtime.documents.set(targetDocument, count - 1);
8911 };
8912 }
8913 function registerStyle(hash, css) {
8914 const runtime = getRuntime();
8915 runtime.styles.set(hash, css);
8916 for (const targetDocument of runtime.documents.keys()) {
8917 injectStyle(targetDocument, hash, css);
8918 }
8919 }
8920 if (typeof process === "undefined" || true) {
8921 registerStyle("0c8601dd83", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._83ed8a8da5dd50ea__text{margin:0}._14437cfb77831647__heading-2xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-p-line-height:var(--wpds-typography-line-height-2xl,40px);font-size:var(--wpds-typography-font-size-2xl,32px);line-height:var(--wpds-typography-line-height-2xl,40px)}._14437cfb77831647__heading-2xl,._3c78b7fa9b4072dd__heading-xl{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499)}._3c78b7fa9b4072dd__heading-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-md,24px)}.aa58f227716bcde2__heading-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-lg,15px)}.aa58f227716bcde2__heading-lg,.fc4da56d8dfe52c4__heading-md{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-sm,20px)}.fc4da56d8dfe52c4__heading-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px)}.a9b78c7c82e8dff7__heading-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-xs,11px);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-xs,16px);text-transform:uppercase}._305ff559e52180d5__body-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-xl,32px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-xl,32px)}._305ff559e52180d5__body-xl,.ca1aa3fc2029e958__body-lg{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}.ca1aa3fc2029e958__body-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-lg,15px);line-height:var(--wpds-typography-line-height-md,24px)}._131101940be12424__body-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-sm,20px)}._0e8d87a42c1f75fa__body-sm,._131101940be12424__body-md{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}._0e8d87a42c1f75fa__body-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-size:var(--wpds-typography-font-size-sm,12px);line-height:var(--wpds-typography-line-height-xs,16px)}}');
8922 }
8923 var style_default = { "text": "_83ed8a8da5dd50ea__text", "heading-2xl": "_14437cfb77831647__heading-2xl", "heading-xl": "_3c78b7fa9b4072dd__heading-xl", "heading-lg": "aa58f227716bcde2__heading-lg", "heading-md": "fc4da56d8dfe52c4__heading-md", "heading-sm": "a9b78c7c82e8dff7__heading-sm", "body-xl": "_305ff559e52180d5__body-xl", "body-lg": "ca1aa3fc2029e958__body-lg", "body-md": "_131101940be12424__body-md", "body-sm": "_0e8d87a42c1f75fa__body-sm" };
8924 if (typeof process === "undefined" || true) {
8925 registerStyle("1fb29d3a3c", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,#0000);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 #0000);color:var(--_gcd-input-color,var(--wpds-color-fg-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,#0000);border-color:var(--_gcd-input-border-color-disabled,#0000);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid #0000)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-fg-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid #0000);transition:var(--_gcd-a-transition,none)}");
8926 }
8927 var global_css_defense_default = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a" };
8928 var Text = (0, import_element9.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
8929 const element = useRender({
8930 render: render4,
8931 defaultTagName: "span",
8932 ref,
8933 props: mergeProps(props, {
8934 className: clsx_default(
8935 style_default.text,
8936 global_css_defense_default.heading,
8937 global_css_defense_default.p,
8938 style_default[variant],
8939 className
8940 )
8941 })
8942 });
8943 return element;
8944 });
8945
8946 // packages/ui/build-module/icon/icon.mjs
8947 var import_element10 = __toESM(require_element(), 1);
8948 var import_primitives26 = __toESM(require_primitives(), 1);
8949 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
8950 var Icon = (0, import_element10.forwardRef)(function Icon2({ icon, size: size4 = 24, ...restProps }, ref) {
8951 return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
8952 import_primitives26.SVG,
8953 {
8954 ref,
8955 fill: "currentColor",
8956 ...icon.props,
8957 ...restProps,
8958 width: size4,
8959 height: size4
8960 }
8961 );
8962 });
8963
8964 // packages/ui/build-module/utils/render-slot-with-children.mjs
8965 var import_element11 = __toESM(require_element(), 1);
8966 function renderSlotWithChildren(slot, defaultSlot, children) {
8967 return (0, import_element11.cloneElement)(
8968 slot ?? defaultSlot,
8969 { children }
8970 );
8971 }
8972
8973 // packages/ui/build-module/lock-unlock.mjs
8974 var import_private_apis = __toESM(require_private_apis(), 1);
8975 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
8976 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
8977 "@wordpress/ui"
8978 );
8979
8980 // packages/ui/build-module/stack/stack.mjs
8981 var import_element12 = __toESM(require_element(), 1);
8982 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
8983 function getRuntime2() {
8984 const globalScope = globalThis;
8985 if (globalScope.__wpStyleRuntime) {
8986 return globalScope.__wpStyleRuntime;
8987 }
8988 globalScope.__wpStyleRuntime = {
8989 documents: /* @__PURE__ */ new Map(),
8990 styles: /* @__PURE__ */ new Map(),
8991 injectedStyles: /* @__PURE__ */ new WeakMap()
8992 };
8993 if (typeof document !== "undefined") {
8994 registerDocument2(document);
8995 }
8996 return globalScope.__wpStyleRuntime;
8997 }
8998 function documentContainsStyleHash2(targetDocument, hash) {
8999 if (!targetDocument.head) {
9000 return false;
9001 }
9002 for (const style of targetDocument.head.querySelectorAll(
9003 `style[${STYLE_HASH_ATTRIBUTE2}]`
9004 )) {
9005 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
9006 return true;
9007 }
9008 }
9009 return false;
9010 }
9011 function injectStyle2(targetDocument, hash, css) {
9012 if (!targetDocument.head) {
9013 return;
9014 }
9015 const runtime = getRuntime2();
9016 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9017 if (!injectedStyles) {
9018 injectedStyles = /* @__PURE__ */ new Set();
9019 runtime.injectedStyles.set(targetDocument, injectedStyles);
9020 }
9021 if (injectedStyles.has(hash)) {
9022 return;
9023 }
9024 if (documentContainsStyleHash2(targetDocument, hash)) {
9025 injectedStyles.add(hash);
9026 return;
9027 }
9028 const style = targetDocument.createElement("style");
9029 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
9030 style.appendChild(targetDocument.createTextNode(css));
9031 targetDocument.head.appendChild(style);
9032 injectedStyles.add(hash);
9033 }
9034 function registerDocument2(targetDocument) {
9035 const runtime = getRuntime2();
9036 runtime.documents.set(
9037 targetDocument,
9038 (runtime.documents.get(targetDocument) ?? 0) + 1
9039 );
9040 for (const [hash, css] of runtime.styles) {
9041 injectStyle2(targetDocument, hash, css);
9042 }
9043 return () => {
9044 const count = runtime.documents.get(targetDocument);
9045 if (count === void 0) {
9046 return;
9047 }
9048 if (count <= 1) {
9049 runtime.documents.delete(targetDocument);
9050 return;
9051 }
9052 runtime.documents.set(targetDocument, count - 1);
9053 };
9054 }
9055 function registerStyle2(hash, css) {
9056 const runtime = getRuntime2();
9057 runtime.styles.set(hash, css);
9058 for (const targetDocument of runtime.documents.keys()) {
9059 injectStyle2(targetDocument, hash, css);
9060 }
9061 }
9062 if (typeof process === "undefined" || true) {
9063 registerStyle2("b51ff41489", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._19ce0419607e1896__stack{display:flex}}");
9064 }
9065 var style_default2 = { "stack": "_19ce0419607e1896__stack" };
9066 var gapTokens = {
9067 xs: "var(--wpds-dimension-gap-xs, 4px)",
9068 sm: "var(--wpds-dimension-gap-sm, 8px)",
9069 md: "var(--wpds-dimension-gap-md, 12px)",
9070 lg: "var(--wpds-dimension-gap-lg, 16px)",
9071 xl: "var(--wpds-dimension-gap-xl, 24px)",
9072 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
9073 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
9074 };
9075 var Stack = (0, import_element12.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
9076 const style = {
9077 gap: gap && gapTokens[gap],
9078 alignItems: align,
9079 justifyContent: justify,
9080 flexDirection: direction,
9081 flexWrap: wrap
9082 };
9083 const element = useRender({
9084 render: render4,
9085 ref,
9086 props: mergeProps(props, { style, className: style_default2.stack })
9087 });
9088 return element;
9089 });
9090
9091 // packages/ui/build-module/tooltip/index.mjs
9092 var tooltip_exports = {};
9093 __export(tooltip_exports, {
9094 Popup: () => Popup,
9095 Portal: () => Portal,
9096 Positioner: () => Positioner,
9097 Provider: () => Provider,
9098 Root: () => Root,
9099 Trigger: () => Trigger
9100 });
9101
9102 // packages/ui/build-module/tooltip/popup.mjs
9103 var import_element15 = __toESM(require_element(), 1);
9104 var import_theme = __toESM(require_theme(), 1);
9105
9106 // packages/ui/build-module/tooltip/portal.mjs
9107 var import_element13 = __toESM(require_element(), 1);
9108
9109 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
9110 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
9111 function getRuntime3() {
9112 const globalScope = globalThis;
9113 if (globalScope.__wpStyleRuntime) {
9114 return globalScope.__wpStyleRuntime;
9115 }
9116 globalScope.__wpStyleRuntime = {
9117 documents: /* @__PURE__ */ new Map(),
9118 styles: /* @__PURE__ */ new Map(),
9119 injectedStyles: /* @__PURE__ */ new WeakMap()
9120 };
9121 if (typeof document !== "undefined") {
9122 registerDocument3(document);
9123 }
9124 return globalScope.__wpStyleRuntime;
9125 }
9126 function documentContainsStyleHash3(targetDocument, hash) {
9127 if (!targetDocument.head) {
9128 return false;
9129 }
9130 for (const style of targetDocument.head.querySelectorAll(
9131 `style[${STYLE_HASH_ATTRIBUTE3}]`
9132 )) {
9133 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
9134 return true;
9135 }
9136 }
9137 return false;
9138 }
9139 function injectStyle3(targetDocument, hash, css) {
9140 if (!targetDocument.head) {
9141 return;
9142 }
9143 const runtime = getRuntime3();
9144 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9145 if (!injectedStyles) {
9146 injectedStyles = /* @__PURE__ */ new Set();
9147 runtime.injectedStyles.set(targetDocument, injectedStyles);
9148 }
9149 if (injectedStyles.has(hash)) {
9150 return;
9151 }
9152 if (documentContainsStyleHash3(targetDocument, hash)) {
9153 injectedStyles.add(hash);
9154 return;
9155 }
9156 const style = targetDocument.createElement("style");
9157 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
9158 style.appendChild(targetDocument.createTextNode(css));
9159 targetDocument.head.appendChild(style);
9160 injectedStyles.add(hash);
9161 }
9162 function registerDocument3(targetDocument) {
9163 const runtime = getRuntime3();
9164 runtime.documents.set(
9165 targetDocument,
9166 (runtime.documents.get(targetDocument) ?? 0) + 1
9167 );
9168 for (const [hash, css] of runtime.styles) {
9169 injectStyle3(targetDocument, hash, css);
9170 }
9171 return () => {
9172 const count = runtime.documents.get(targetDocument);
9173 if (count === void 0) {
9174 return;
9175 }
9176 if (count <= 1) {
9177 runtime.documents.delete(targetDocument);
9178 return;
9179 }
9180 runtime.documents.set(targetDocument, count - 1);
9181 };
9182 }
9183 function registerStyle3(hash, css) {
9184 const runtime = getRuntime3();
9185 runtime.styles.set(hash, css);
9186 for (const targetDocument of runtime.documents.keys()) {
9187 injectStyle3(targetDocument, hash, css);
9188 }
9189 }
9190 if (typeof process === "undefined" || true) {
9191 registerStyle3("45eb1fe20f", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;._11fc52b637ff8a7e__slot{inset:0;isolation:isolate;pointer-events:none;position:fixed;z-index:1000000003}@layer wp-ui-utilities{._11fc52b637ff8a7e__slot>*{pointer-events:auto}}");
9192 }
9193 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
9194 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
9195 function resolveOwnerDocument() {
9196 return typeof document === "undefined" ? null : document;
9197 }
9198 function isInWordPressEnvironment() {
9199 let topWp;
9200 try {
9201 topWp = window.top?.wp;
9202 } catch {
9203 }
9204 const wp = topWp ?? window.wp;
9205 return typeof wp?.components === "object" && wp.components !== null;
9206 }
9207 var cachedSlot = null;
9208 function createSlot(ownerDocument2) {
9209 const element = ownerDocument2.createElement("div");
9210 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
9211 if (wp_compat_overlay_slot_default.slot) {
9212 element.classList.add(wp_compat_overlay_slot_default.slot);
9213 }
9214 ownerDocument2.body.appendChild(element);
9215 return element;
9216 }
9217 function getWpCompatOverlaySlot() {
9218 if (typeof window === "undefined") {
9219 return void 0;
9220 }
9221 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
9222 return void 0;
9223 }
9224 const ownerDocument2 = resolveOwnerDocument();
9225 if (!ownerDocument2 || !ownerDocument2.body) {
9226 return void 0;
9227 }
9228 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
9229 return cachedSlot;
9230 }
9231 const existing = ownerDocument2.querySelector(
9232 `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
9233 );
9234 if (existing instanceof HTMLDivElement) {
9235 cachedSlot = existing;
9236 return existing;
9237 }
9238 if (cachedSlot?.isConnected) {
9239 cachedSlot.remove();
9240 }
9241 cachedSlot = createSlot(ownerDocument2);
9242 return cachedSlot;
9243 }
9244
9245 // packages/ui/build-module/tooltip/portal.mjs
9246 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
9247 var Portal = (0, import_element13.forwardRef)(
9248 function TooltipPortal3({ container, ...restProps }, ref) {
9249 return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
9250 index_parts_exports.Portal,
9251 {
9252 container: container ?? getWpCompatOverlaySlot(),
9253 ...restProps,
9254 ref
9255 }
9256 );
9257 }
9258 );
9259
9260 // packages/ui/build-module/tooltip/positioner.mjs
9261 var import_element14 = __toESM(require_element(), 1);
9262 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
9263 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
9264 function getRuntime4() {
9265 const globalScope = globalThis;
9266 if (globalScope.__wpStyleRuntime) {
9267 return globalScope.__wpStyleRuntime;
9268 }
9269 globalScope.__wpStyleRuntime = {
9270 documents: /* @__PURE__ */ new Map(),
9271 styles: /* @__PURE__ */ new Map(),
9272 injectedStyles: /* @__PURE__ */ new WeakMap()
9273 };
9274 if (typeof document !== "undefined") {
9275 registerDocument4(document);
9276 }
9277 return globalScope.__wpStyleRuntime;
9278 }
9279 function documentContainsStyleHash4(targetDocument, hash) {
9280 if (!targetDocument.head) {
9281 return false;
9282 }
9283 for (const style of targetDocument.head.querySelectorAll(
9284 `style[${STYLE_HASH_ATTRIBUTE4}]`
9285 )) {
9286 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
9287 return true;
9288 }
9289 }
9290 return false;
9291 }
9292 function injectStyle4(targetDocument, hash, css) {
9293 if (!targetDocument.head) {
9294 return;
9295 }
9296 const runtime = getRuntime4();
9297 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9298 if (!injectedStyles) {
9299 injectedStyles = /* @__PURE__ */ new Set();
9300 runtime.injectedStyles.set(targetDocument, injectedStyles);
9301 }
9302 if (injectedStyles.has(hash)) {
9303 return;
9304 }
9305 if (documentContainsStyleHash4(targetDocument, hash)) {
9306 injectedStyles.add(hash);
9307 return;
9308 }
9309 const style = targetDocument.createElement("style");
9310 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
9311 style.appendChild(targetDocument.createTextNode(css));
9312 targetDocument.head.appendChild(style);
9313 injectedStyles.add(hash);
9314 }
9315 function registerDocument4(targetDocument) {
9316 const runtime = getRuntime4();
9317 runtime.documents.set(
9318 targetDocument,
9319 (runtime.documents.get(targetDocument) ?? 0) + 1
9320 );
9321 for (const [hash, css] of runtime.styles) {
9322 injectStyle4(targetDocument, hash, css);
9323 }
9324 return () => {
9325 const count = runtime.documents.get(targetDocument);
9326 if (count === void 0) {
9327 return;
9328 }
9329 if (count <= 1) {
9330 runtime.documents.delete(targetDocument);
9331 return;
9332 }
9333 runtime.documents.set(targetDocument, count - 1);
9334 };
9335 }
9336 function registerStyle4(hash, css) {
9337 const runtime = getRuntime4();
9338 runtime.styles.set(hash, css);
9339 for (const targetDocument of runtime.documents.keys()) {
9340 injectStyle4(targetDocument, hash, css);
9341 }
9342 }
9343 if (typeof process === "undefined" || true) {
9344 registerStyle4("e3ae230cea", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}");
9345 }
9346 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
9347 if (typeof process === "undefined" || true) {
9348 registerStyle4("8293efbb49", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-sm,2px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-fg-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}');
9349 }
9350 var style_default3 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9351 var Positioner = (0, import_element14.forwardRef)(
9352 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
9353 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
9354 index_parts_exports.Positioner,
9355 {
9356 ref,
9357 align,
9358 side,
9359 sideOffset,
9360 ...props,
9361 className: clsx_default(
9362 resets_default["box-sizing"],
9363 style_default3.positioner,
9364 className
9365 )
9366 }
9367 );
9368 }
9369 );
9370
9371 // packages/ui/build-module/tooltip/popup.mjs
9372 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
9373 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
9374 function getRuntime5() {
9375 const globalScope = globalThis;
9376 if (globalScope.__wpStyleRuntime) {
9377 return globalScope.__wpStyleRuntime;
9378 }
9379 globalScope.__wpStyleRuntime = {
9380 documents: /* @__PURE__ */ new Map(),
9381 styles: /* @__PURE__ */ new Map(),
9382 injectedStyles: /* @__PURE__ */ new WeakMap()
9383 };
9384 if (typeof document !== "undefined") {
9385 registerDocument5(document);
9386 }
9387 return globalScope.__wpStyleRuntime;
9388 }
9389 function documentContainsStyleHash5(targetDocument, hash) {
9390 if (!targetDocument.head) {
9391 return false;
9392 }
9393 for (const style of targetDocument.head.querySelectorAll(
9394 `style[${STYLE_HASH_ATTRIBUTE5}]`
9395 )) {
9396 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
9397 return true;
9398 }
9399 }
9400 return false;
9401 }
9402 function injectStyle5(targetDocument, hash, css) {
9403 if (!targetDocument.head) {
9404 return;
9405 }
9406 const runtime = getRuntime5();
9407 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9408 if (!injectedStyles) {
9409 injectedStyles = /* @__PURE__ */ new Set();
9410 runtime.injectedStyles.set(targetDocument, injectedStyles);
9411 }
9412 if (injectedStyles.has(hash)) {
9413 return;
9414 }
9415 if (documentContainsStyleHash5(targetDocument, hash)) {
9416 injectedStyles.add(hash);
9417 return;
9418 }
9419 const style = targetDocument.createElement("style");
9420 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
9421 style.appendChild(targetDocument.createTextNode(css));
9422 targetDocument.head.appendChild(style);
9423 injectedStyles.add(hash);
9424 }
9425 function registerDocument5(targetDocument) {
9426 const runtime = getRuntime5();
9427 runtime.documents.set(
9428 targetDocument,
9429 (runtime.documents.get(targetDocument) ?? 0) + 1
9430 );
9431 for (const [hash, css] of runtime.styles) {
9432 injectStyle5(targetDocument, hash, css);
9433 }
9434 return () => {
9435 const count = runtime.documents.get(targetDocument);
9436 if (count === void 0) {
9437 return;
9438 }
9439 if (count <= 1) {
9440 runtime.documents.delete(targetDocument);
9441 return;
9442 }
9443 runtime.documents.set(targetDocument, count - 1);
9444 };
9445 }
9446 function registerStyle5(hash, css) {
9447 const runtime = getRuntime5();
9448 runtime.styles.set(hash, css);
9449 for (const targetDocument of runtime.documents.keys()) {
9450 injectStyle5(targetDocument, hash, css);
9451 }
9452 }
9453 if (typeof process === "undefined" || true) {
9454 registerStyle5("8293efbb49", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-sm,2px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-fg-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}');
9455 }
9456 var style_default4 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9457 var ThemeProvider = unlock(import_theme.privateApis).ThemeProvider;
9458 var Popup = (0, import_element15.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
9459 const popupContent = (
9460 /* This should ideally use whatever dark color makes sense,
9461 * and not be hardcoded to #1e1e1e. The solutions would be to:
9462 * - review the design of the tooltip, in case we want to stop
9463 * hardcoding it to a dark background
9464 * - create new semantic tokens as needed (aliasing either the
9465 * "inverted bg" or "perma-dark bg" private tokens) and have
9466 * Tooltip.Popup use them;
9467 * - remove the hardcoded `bg` setting from the `ThemeProvider`
9468 * below
9469 */
9470 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ThemeProvider, { color: { bg: "#1e1e1e" }, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
9471 index_parts_exports.Popup,
9472 {
9473 ref,
9474 className: clsx_default(style_default4.popup, className),
9475 ...props,
9476 children
9477 }
9478 ) })
9479 );
9480 const positionedPopup = renderSlotWithChildren(
9481 positioner,
9482 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Positioner, {}),
9483 popupContent
9484 );
9485 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Portal, {}), positionedPopup);
9486 });
9487
9488 // packages/ui/build-module/tooltip/trigger.mjs
9489 var import_element16 = __toESM(require_element(), 1);
9490 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
9491 var Trigger = (0, import_element16.forwardRef)(
9492 function TooltipTrigger3(props, ref) {
9493 return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(index_parts_exports.Trigger, { ref, ...props });
9494 }
9495 );
9496
9497 // packages/ui/build-module/tooltip/root.mjs
9498 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
9499 function Root(props) {
9500 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(index_parts_exports.Root, { ...props });
9501 }
9502
9503 // packages/ui/build-module/tooltip/provider.mjs
9504 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
9505 function Provider({ ...props }) {
9506 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(index_parts_exports.Provider, { ...props });
9507 }
9508
9509 // packages/ui/build-module/empty-state/index.mjs
9510 var empty_state_exports = {};
9511 __export(empty_state_exports, {
9512 Actions: () => Actions,
9513 Description: () => Description,
9514 Icon: () => Icon3,
9515 Root: () => Root2,
9516 Title: () => Title,
9517 Visual: () => Visual
9518 });
9519
9520 // packages/ui/build-module/empty-state/root.mjs
9521 var import_element17 = __toESM(require_element(), 1);
9522 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash";
9523 function getRuntime6() {
9524 const globalScope = globalThis;
9525 if (globalScope.__wpStyleRuntime) {
9526 return globalScope.__wpStyleRuntime;
9527 }
9528 globalScope.__wpStyleRuntime = {
9529 documents: /* @__PURE__ */ new Map(),
9530 styles: /* @__PURE__ */ new Map(),
9531 injectedStyles: /* @__PURE__ */ new WeakMap()
9532 };
9533 if (typeof document !== "undefined") {
9534 registerDocument6(document);
9535 }
9536 return globalScope.__wpStyleRuntime;
9537 }
9538 function documentContainsStyleHash6(targetDocument, hash) {
9539 if (!targetDocument.head) {
9540 return false;
9541 }
9542 for (const style of targetDocument.head.querySelectorAll(
9543 `style[${STYLE_HASH_ATTRIBUTE6}]`
9544 )) {
9545 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) {
9546 return true;
9547 }
9548 }
9549 return false;
9550 }
9551 function injectStyle6(targetDocument, hash, css) {
9552 if (!targetDocument.head) {
9553 return;
9554 }
9555 const runtime = getRuntime6();
9556 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9557 if (!injectedStyles) {
9558 injectedStyles = /* @__PURE__ */ new Set();
9559 runtime.injectedStyles.set(targetDocument, injectedStyles);
9560 }
9561 if (injectedStyles.has(hash)) {
9562 return;
9563 }
9564 if (documentContainsStyleHash6(targetDocument, hash)) {
9565 injectedStyles.add(hash);
9566 return;
9567 }
9568 const style = targetDocument.createElement("style");
9569 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash);
9570 style.appendChild(targetDocument.createTextNode(css));
9571 targetDocument.head.appendChild(style);
9572 injectedStyles.add(hash);
9573 }
9574 function registerDocument6(targetDocument) {
9575 const runtime = getRuntime6();
9576 runtime.documents.set(
9577 targetDocument,
9578 (runtime.documents.get(targetDocument) ?? 0) + 1
9579 );
9580 for (const [hash, css] of runtime.styles) {
9581 injectStyle6(targetDocument, hash, css);
9582 }
9583 return () => {
9584 const count = runtime.documents.get(targetDocument);
9585 if (count === void 0) {
9586 return;
9587 }
9588 if (count <= 1) {
9589 runtime.documents.delete(targetDocument);
9590 return;
9591 }
9592 runtime.documents.set(targetDocument, count - 1);
9593 };
9594 }
9595 function registerStyle6(hash, css) {
9596 const runtime = getRuntime6();
9597 runtime.styles.set(hash, css);
9598 for (const targetDocument of runtime.documents.keys()) {
9599 injectStyle6(targetDocument, hash, css);
9600 }
9601 }
9602 if (typeof process === "undefined" || true) {
9603 registerStyle6("6d6361d221", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-fg-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-fg-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}');
9604 }
9605 var style_default5 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9606 var Root2 = (0, import_element17.forwardRef)(
9607 function EmptyStateRoot({ render: render4, ...props }, ref) {
9608 const className = clsx_default(style_default5.root);
9609 const element = useRender({
9610 defaultTagName: "div",
9611 render: render4,
9612 ref,
9613 props: mergeProps({ className }, props)
9614 });
9615 return element;
9616 }
9617 );
9618
9619 // packages/ui/build-module/empty-state/visual.mjs
9620 var import_element18 = __toESM(require_element(), 1);
9621 var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash";
9622 function getRuntime7() {
9623 const globalScope = globalThis;
9624 if (globalScope.__wpStyleRuntime) {
9625 return globalScope.__wpStyleRuntime;
9626 }
9627 globalScope.__wpStyleRuntime = {
9628 documents: /* @__PURE__ */ new Map(),
9629 styles: /* @__PURE__ */ new Map(),
9630 injectedStyles: /* @__PURE__ */ new WeakMap()
9631 };
9632 if (typeof document !== "undefined") {
9633 registerDocument7(document);
9634 }
9635 return globalScope.__wpStyleRuntime;
9636 }
9637 function documentContainsStyleHash7(targetDocument, hash) {
9638 if (!targetDocument.head) {
9639 return false;
9640 }
9641 for (const style of targetDocument.head.querySelectorAll(
9642 `style[${STYLE_HASH_ATTRIBUTE7}]`
9643 )) {
9644 if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) {
9645 return true;
9646 }
9647 }
9648 return false;
9649 }
9650 function injectStyle7(targetDocument, hash, css) {
9651 if (!targetDocument.head) {
9652 return;
9653 }
9654 const runtime = getRuntime7();
9655 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9656 if (!injectedStyles) {
9657 injectedStyles = /* @__PURE__ */ new Set();
9658 runtime.injectedStyles.set(targetDocument, injectedStyles);
9659 }
9660 if (injectedStyles.has(hash)) {
9661 return;
9662 }
9663 if (documentContainsStyleHash7(targetDocument, hash)) {
9664 injectedStyles.add(hash);
9665 return;
9666 }
9667 const style = targetDocument.createElement("style");
9668 style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash);
9669 style.appendChild(targetDocument.createTextNode(css));
9670 targetDocument.head.appendChild(style);
9671 injectedStyles.add(hash);
9672 }
9673 function registerDocument7(targetDocument) {
9674 const runtime = getRuntime7();
9675 runtime.documents.set(
9676 targetDocument,
9677 (runtime.documents.get(targetDocument) ?? 0) + 1
9678 );
9679 for (const [hash, css] of runtime.styles) {
9680 injectStyle7(targetDocument, hash, css);
9681 }
9682 return () => {
9683 const count = runtime.documents.get(targetDocument);
9684 if (count === void 0) {
9685 return;
9686 }
9687 if (count <= 1) {
9688 runtime.documents.delete(targetDocument);
9689 return;
9690 }
9691 runtime.documents.set(targetDocument, count - 1);
9692 };
9693 }
9694 function registerStyle7(hash, css) {
9695 const runtime = getRuntime7();
9696 runtime.styles.set(hash, css);
9697 for (const targetDocument of runtime.documents.keys()) {
9698 injectStyle7(targetDocument, hash, css);
9699 }
9700 }
9701 if (typeof process === "undefined" || true) {
9702 registerStyle7("6d6361d221", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-fg-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-fg-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}');
9703 }
9704 var style_default6 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9705 var Visual = (0, import_element18.forwardRef)(
9706 function EmptyStateVisual({ render: render4, ...props }, ref) {
9707 const className = clsx_default(style_default6.visual);
9708 const element = useRender({
9709 defaultTagName: "div",
9710 render: render4,
9711 ref,
9712 props: mergeProps({ className }, props)
9713 });
9714 return element;
9715 }
9716 );
9717
9718 // packages/ui/build-module/empty-state/icon.mjs
9719 var import_element19 = __toESM(require_element(), 1);
9720 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
9721 var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash";
9722 function getRuntime8() {
9723 const globalScope = globalThis;
9724 if (globalScope.__wpStyleRuntime) {
9725 return globalScope.__wpStyleRuntime;
9726 }
9727 globalScope.__wpStyleRuntime = {
9728 documents: /* @__PURE__ */ new Map(),
9729 styles: /* @__PURE__ */ new Map(),
9730 injectedStyles: /* @__PURE__ */ new WeakMap()
9731 };
9732 if (typeof document !== "undefined") {
9733 registerDocument8(document);
9734 }
9735 return globalScope.__wpStyleRuntime;
9736 }
9737 function documentContainsStyleHash8(targetDocument, hash) {
9738 if (!targetDocument.head) {
9739 return false;
9740 }
9741 for (const style of targetDocument.head.querySelectorAll(
9742 `style[${STYLE_HASH_ATTRIBUTE8}]`
9743 )) {
9744 if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) {
9745 return true;
9746 }
9747 }
9748 return false;
9749 }
9750 function injectStyle8(targetDocument, hash, css) {
9751 if (!targetDocument.head) {
9752 return;
9753 }
9754 const runtime = getRuntime8();
9755 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9756 if (!injectedStyles) {
9757 injectedStyles = /* @__PURE__ */ new Set();
9758 runtime.injectedStyles.set(targetDocument, injectedStyles);
9759 }
9760 if (injectedStyles.has(hash)) {
9761 return;
9762 }
9763 if (documentContainsStyleHash8(targetDocument, hash)) {
9764 injectedStyles.add(hash);
9765 return;
9766 }
9767 const style = targetDocument.createElement("style");
9768 style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash);
9769 style.appendChild(targetDocument.createTextNode(css));
9770 targetDocument.head.appendChild(style);
9771 injectedStyles.add(hash);
9772 }
9773 function registerDocument8(targetDocument) {
9774 const runtime = getRuntime8();
9775 runtime.documents.set(
9776 targetDocument,
9777 (runtime.documents.get(targetDocument) ?? 0) + 1
9778 );
9779 for (const [hash, css] of runtime.styles) {
9780 injectStyle8(targetDocument, hash, css);
9781 }
9782 return () => {
9783 const count = runtime.documents.get(targetDocument);
9784 if (count === void 0) {
9785 return;
9786 }
9787 if (count <= 1) {
9788 runtime.documents.delete(targetDocument);
9789 return;
9790 }
9791 runtime.documents.set(targetDocument, count - 1);
9792 };
9793 }
9794 function registerStyle8(hash, css) {
9795 const runtime = getRuntime8();
9796 runtime.styles.set(hash, css);
9797 for (const targetDocument of runtime.documents.keys()) {
9798 injectStyle8(targetDocument, hash, css);
9799 }
9800 }
9801 if (typeof process === "undefined" || true) {
9802 registerStyle8("6d6361d221", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-fg-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-fg-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}');
9803 }
9804 var style_default7 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9805 var Icon3 = (0, import_element19.forwardRef)(
9806 function EmptyStateIcon({ icon, className, ...restProps }, ref) {
9807 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
9808 Visual,
9809 {
9810 ref,
9811 className: clsx_default(style_default7.icon, className),
9812 ...restProps,
9813 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Icon, { icon })
9814 }
9815 );
9816 }
9817 );
9818
9819 // packages/ui/build-module/empty-state/title.mjs
9820 var import_element20 = __toESM(require_element(), 1);
9821 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
9822 var STYLE_HASH_ATTRIBUTE9 = "data-wp-hash";
9823 function getRuntime9() {
9824 const globalScope = globalThis;
9825 if (globalScope.__wpStyleRuntime) {
9826 return globalScope.__wpStyleRuntime;
9827 }
9828 globalScope.__wpStyleRuntime = {
9829 documents: /* @__PURE__ */ new Map(),
9830 styles: /* @__PURE__ */ new Map(),
9831 injectedStyles: /* @__PURE__ */ new WeakMap()
9832 };
9833 if (typeof document !== "undefined") {
9834 registerDocument9(document);
9835 }
9836 return globalScope.__wpStyleRuntime;
9837 }
9838 function documentContainsStyleHash9(targetDocument, hash) {
9839 if (!targetDocument.head) {
9840 return false;
9841 }
9842 for (const style of targetDocument.head.querySelectorAll(
9843 `style[${STYLE_HASH_ATTRIBUTE9}]`
9844 )) {
9845 if (style.getAttribute(STYLE_HASH_ATTRIBUTE9) === hash) {
9846 return true;
9847 }
9848 }
9849 return false;
9850 }
9851 function injectStyle9(targetDocument, hash, css) {
9852 if (!targetDocument.head) {
9853 return;
9854 }
9855 const runtime = getRuntime9();
9856 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9857 if (!injectedStyles) {
9858 injectedStyles = /* @__PURE__ */ new Set();
9859 runtime.injectedStyles.set(targetDocument, injectedStyles);
9860 }
9861 if (injectedStyles.has(hash)) {
9862 return;
9863 }
9864 if (documentContainsStyleHash9(targetDocument, hash)) {
9865 injectedStyles.add(hash);
9866 return;
9867 }
9868 const style = targetDocument.createElement("style");
9869 style.setAttribute(STYLE_HASH_ATTRIBUTE9, hash);
9870 style.appendChild(targetDocument.createTextNode(css));
9871 targetDocument.head.appendChild(style);
9872 injectedStyles.add(hash);
9873 }
9874 function registerDocument9(targetDocument) {
9875 const runtime = getRuntime9();
9876 runtime.documents.set(
9877 targetDocument,
9878 (runtime.documents.get(targetDocument) ?? 0) + 1
9879 );
9880 for (const [hash, css] of runtime.styles) {
9881 injectStyle9(targetDocument, hash, css);
9882 }
9883 return () => {
9884 const count = runtime.documents.get(targetDocument);
9885 if (count === void 0) {
9886 return;
9887 }
9888 if (count <= 1) {
9889 runtime.documents.delete(targetDocument);
9890 return;
9891 }
9892 runtime.documents.set(targetDocument, count - 1);
9893 };
9894 }
9895 function registerStyle9(hash, css) {
9896 const runtime = getRuntime9();
9897 runtime.styles.set(hash, css);
9898 for (const targetDocument of runtime.documents.keys()) {
9899 injectStyle9(targetDocument, hash, css);
9900 }
9901 }
9902 if (typeof process === "undefined" || true) {
9903 registerStyle9("6d6361d221", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-fg-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-fg-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}');
9904 }
9905 var style_default8 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9906 var DEFAULT_TAG = /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("h2", {});
9907 var Title = (0, import_element20.forwardRef)(
9908 function EmptyStateTitle({ render: render4 = DEFAULT_TAG, className, children, ...props }, ref) {
9909 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
9910 Text,
9911 {
9912 ref,
9913 variant: "heading-lg",
9914 render: render4,
9915 className: clsx_default(style_default8.title, className),
9916 ...props,
9917 children
9918 }
9919 );
9920 }
9921 );
9922
9923 // packages/ui/build-module/empty-state/description.mjs
9924 var import_element21 = __toESM(require_element(), 1);
9925 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
9926 var STYLE_HASH_ATTRIBUTE10 = "data-wp-hash";
9927 function getRuntime10() {
9928 const globalScope = globalThis;
9929 if (globalScope.__wpStyleRuntime) {
9930 return globalScope.__wpStyleRuntime;
9931 }
9932 globalScope.__wpStyleRuntime = {
9933 documents: /* @__PURE__ */ new Map(),
9934 styles: /* @__PURE__ */ new Map(),
9935 injectedStyles: /* @__PURE__ */ new WeakMap()
9936 };
9937 if (typeof document !== "undefined") {
9938 registerDocument10(document);
9939 }
9940 return globalScope.__wpStyleRuntime;
9941 }
9942 function documentContainsStyleHash10(targetDocument, hash) {
9943 if (!targetDocument.head) {
9944 return false;
9945 }
9946 for (const style of targetDocument.head.querySelectorAll(
9947 `style[${STYLE_HASH_ATTRIBUTE10}]`
9948 )) {
9949 if (style.getAttribute(STYLE_HASH_ATTRIBUTE10) === hash) {
9950 return true;
9951 }
9952 }
9953 return false;
9954 }
9955 function injectStyle10(targetDocument, hash, css) {
9956 if (!targetDocument.head) {
9957 return;
9958 }
9959 const runtime = getRuntime10();
9960 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9961 if (!injectedStyles) {
9962 injectedStyles = /* @__PURE__ */ new Set();
9963 runtime.injectedStyles.set(targetDocument, injectedStyles);
9964 }
9965 if (injectedStyles.has(hash)) {
9966 return;
9967 }
9968 if (documentContainsStyleHash10(targetDocument, hash)) {
9969 injectedStyles.add(hash);
9970 return;
9971 }
9972 const style = targetDocument.createElement("style");
9973 style.setAttribute(STYLE_HASH_ATTRIBUTE10, hash);
9974 style.appendChild(targetDocument.createTextNode(css));
9975 targetDocument.head.appendChild(style);
9976 injectedStyles.add(hash);
9977 }
9978 function registerDocument10(targetDocument) {
9979 const runtime = getRuntime10();
9980 runtime.documents.set(
9981 targetDocument,
9982 (runtime.documents.get(targetDocument) ?? 0) + 1
9983 );
9984 for (const [hash, css] of runtime.styles) {
9985 injectStyle10(targetDocument, hash, css);
9986 }
9987 return () => {
9988 const count = runtime.documents.get(targetDocument);
9989 if (count === void 0) {
9990 return;
9991 }
9992 if (count <= 1) {
9993 runtime.documents.delete(targetDocument);
9994 return;
9995 }
9996 runtime.documents.set(targetDocument, count - 1);
9997 };
9998 }
9999 function registerStyle10(hash, css) {
10000 const runtime = getRuntime10();
10001 runtime.styles.set(hash, css);
10002 for (const targetDocument of runtime.documents.keys()) {
10003 injectStyle10(targetDocument, hash, css);
10004 }
10005 }
10006 if (typeof process === "undefined" || true) {
10007 registerStyle10("6d6361d221", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-fg-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-fg-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}');
10008 }
10009 var style_default9 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
10010 var DEFAULT_TAG2 = /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", {});
10011 var Description = (0, import_element21.forwardRef)(function EmptyStateDescription({ render: render4 = DEFAULT_TAG2, className, children, ...props }, ref) {
10012 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
10013 Text,
10014 {
10015 ref,
10016 variant: "body-md",
10017 render: render4,
10018 className: clsx_default(style_default9.description, className),
10019 ...props,
10020 children
10021 }
10022 );
10023 });
10024
10025 // packages/ui/build-module/empty-state/actions.mjs
10026 var import_element22 = __toESM(require_element(), 1);
10027 var STYLE_HASH_ATTRIBUTE11 = "data-wp-hash";
10028 function getRuntime11() {
10029 const globalScope = globalThis;
10030 if (globalScope.__wpStyleRuntime) {
10031 return globalScope.__wpStyleRuntime;
10032 }
10033 globalScope.__wpStyleRuntime = {
10034 documents: /* @__PURE__ */ new Map(),
10035 styles: /* @__PURE__ */ new Map(),
10036 injectedStyles: /* @__PURE__ */ new WeakMap()
10037 };
10038 if (typeof document !== "undefined") {
10039 registerDocument11(document);
10040 }
10041 return globalScope.__wpStyleRuntime;
10042 }
10043 function documentContainsStyleHash11(targetDocument, hash) {
10044 if (!targetDocument.head) {
10045 return false;
10046 }
10047 for (const style of targetDocument.head.querySelectorAll(
10048 `style[${STYLE_HASH_ATTRIBUTE11}]`
10049 )) {
10050 if (style.getAttribute(STYLE_HASH_ATTRIBUTE11) === hash) {
10051 return true;
10052 }
10053 }
10054 return false;
10055 }
10056 function injectStyle11(targetDocument, hash, css) {
10057 if (!targetDocument.head) {
10058 return;
10059 }
10060 const runtime = getRuntime11();
10061 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10062 if (!injectedStyles) {
10063 injectedStyles = /* @__PURE__ */ new Set();
10064 runtime.injectedStyles.set(targetDocument, injectedStyles);
10065 }
10066 if (injectedStyles.has(hash)) {
10067 return;
10068 }
10069 if (documentContainsStyleHash11(targetDocument, hash)) {
10070 injectedStyles.add(hash);
10071 return;
10072 }
10073 const style = targetDocument.createElement("style");
10074 style.setAttribute(STYLE_HASH_ATTRIBUTE11, hash);
10075 style.appendChild(targetDocument.createTextNode(css));
10076 targetDocument.head.appendChild(style);
10077 injectedStyles.add(hash);
10078 }
10079 function registerDocument11(targetDocument) {
10080 const runtime = getRuntime11();
10081 runtime.documents.set(
10082 targetDocument,
10083 (runtime.documents.get(targetDocument) ?? 0) + 1
10084 );
10085 for (const [hash, css] of runtime.styles) {
10086 injectStyle11(targetDocument, hash, css);
10087 }
10088 return () => {
10089 const count = runtime.documents.get(targetDocument);
10090 if (count === void 0) {
10091 return;
10092 }
10093 if (count <= 1) {
10094 runtime.documents.delete(targetDocument);
10095 return;
10096 }
10097 runtime.documents.set(targetDocument, count - 1);
10098 };
10099 }
10100 function registerStyle11(hash, css) {
10101 const runtime = getRuntime11();
10102 runtime.styles.set(hash, css);
10103 for (const targetDocument of runtime.documents.keys()) {
10104 injectStyle11(targetDocument, hash, css);
10105 }
10106 }
10107 if (typeof process === "undefined" || true) {
10108 registerStyle11("6d6361d221", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-fg-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-fg-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}');
10109 }
10110 var style_default10 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
10111 var Actions = (0, import_element22.forwardRef)(
10112 function EmptyStateActions({ render: render4, ...props }, ref) {
10113 const className = clsx_default(style_default10.actions);
10114 const element = useRender({
10115 defaultTagName: "div",
10116 render: render4,
10117 ref,
10118 props: mergeProps({ className }, props)
10119 });
10120 return element;
10121 }
10122 );
10123
10124 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
10125 var import_element23 = __toESM(require_element(), 1);
10126 var STYLE_HASH_ATTRIBUTE12 = "data-wp-hash";
10127 function getRuntime12() {
10128 const globalScope = globalThis;
10129 if (globalScope.__wpStyleRuntime) {
10130 return globalScope.__wpStyleRuntime;
10131 }
10132 globalScope.__wpStyleRuntime = {
10133 documents: /* @__PURE__ */ new Map(),
10134 styles: /* @__PURE__ */ new Map(),
10135 injectedStyles: /* @__PURE__ */ new WeakMap()
10136 };
10137 if (typeof document !== "undefined") {
10138 registerDocument12(document);
10139 }
10140 return globalScope.__wpStyleRuntime;
10141 }
10142 function documentContainsStyleHash12(targetDocument, hash) {
10143 if (!targetDocument.head) {
10144 return false;
10145 }
10146 for (const style of targetDocument.head.querySelectorAll(
10147 `style[${STYLE_HASH_ATTRIBUTE12}]`
10148 )) {
10149 if (style.getAttribute(STYLE_HASH_ATTRIBUTE12) === hash) {
10150 return true;
10151 }
10152 }
10153 return false;
10154 }
10155 function injectStyle12(targetDocument, hash, css) {
10156 if (!targetDocument.head) {
10157 return;
10158 }
10159 const runtime = getRuntime12();
10160 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10161 if (!injectedStyles) {
10162 injectedStyles = /* @__PURE__ */ new Set();
10163 runtime.injectedStyles.set(targetDocument, injectedStyles);
10164 }
10165 if (injectedStyles.has(hash)) {
10166 return;
10167 }
10168 if (documentContainsStyleHash12(targetDocument, hash)) {
10169 injectedStyles.add(hash);
10170 return;
10171 }
10172 const style = targetDocument.createElement("style");
10173 style.setAttribute(STYLE_HASH_ATTRIBUTE12, hash);
10174 style.appendChild(targetDocument.createTextNode(css));
10175 targetDocument.head.appendChild(style);
10176 injectedStyles.add(hash);
10177 }
10178 function registerDocument12(targetDocument) {
10179 const runtime = getRuntime12();
10180 runtime.documents.set(
10181 targetDocument,
10182 (runtime.documents.get(targetDocument) ?? 0) + 1
10183 );
10184 for (const [hash, css] of runtime.styles) {
10185 injectStyle12(targetDocument, hash, css);
10186 }
10187 return () => {
10188 const count = runtime.documents.get(targetDocument);
10189 if (count === void 0) {
10190 return;
10191 }
10192 if (count <= 1) {
10193 runtime.documents.delete(targetDocument);
10194 return;
10195 }
10196 runtime.documents.set(targetDocument, count - 1);
10197 };
10198 }
10199 function registerStyle12(hash, css) {
10200 const runtime = getRuntime12();
10201 runtime.styles.set(hash, css);
10202 for (const targetDocument of runtime.documents.keys()) {
10203 injectStyle12(targetDocument, hash, css);
10204 }
10205 }
10206 if (typeof process === "undefined" || true) {
10207 registerStyle12("c46e8cb841", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.f37b9e2e191ebd66__visually-hidden{word-wrap:normal;border:0;clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-break:normal}}");
10208 }
10209 var style_default11 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
10210 var VisuallyHidden = (0, import_element23.forwardRef)(
10211 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
10212 const element = useRender({
10213 render: render4,
10214 ref,
10215 props: mergeProps(
10216 { className: style_default11["visually-hidden"] },
10217 restProps,
10218 {
10219 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
10220 "data-visually-hidden": ""
10221 }
10222 )
10223 });
10224 return element;
10225 }
10226 );
10227
10228 // packages/ui/build-module/link/link.mjs
10229 var import_element24 = __toESM(require_element(), 1);
10230 var import_i18n = __toESM(require_i18n(), 1);
10231 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
10232 var STYLE_HASH_ATTRIBUTE13 = "data-wp-hash";
10233 function getRuntime13() {
10234 const globalScope = globalThis;
10235 if (globalScope.__wpStyleRuntime) {
10236 return globalScope.__wpStyleRuntime;
10237 }
10238 globalScope.__wpStyleRuntime = {
10239 documents: /* @__PURE__ */ new Map(),
10240 styles: /* @__PURE__ */ new Map(),
10241 injectedStyles: /* @__PURE__ */ new WeakMap()
10242 };
10243 if (typeof document !== "undefined") {
10244 registerDocument13(document);
10245 }
10246 return globalScope.__wpStyleRuntime;
10247 }
10248 function documentContainsStyleHash13(targetDocument, hash) {
10249 if (!targetDocument.head) {
10250 return false;
10251 }
10252 for (const style of targetDocument.head.querySelectorAll(
10253 `style[${STYLE_HASH_ATTRIBUTE13}]`
10254 )) {
10255 if (style.getAttribute(STYLE_HASH_ATTRIBUTE13) === hash) {
10256 return true;
10257 }
10258 }
10259 return false;
10260 }
10261 function injectStyle13(targetDocument, hash, css) {
10262 if (!targetDocument.head) {
10263 return;
10264 }
10265 const runtime = getRuntime13();
10266 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10267 if (!injectedStyles) {
10268 injectedStyles = /* @__PURE__ */ new Set();
10269 runtime.injectedStyles.set(targetDocument, injectedStyles);
10270 }
10271 if (injectedStyles.has(hash)) {
10272 return;
10273 }
10274 if (documentContainsStyleHash13(targetDocument, hash)) {
10275 injectedStyles.add(hash);
10276 return;
10277 }
10278 const style = targetDocument.createElement("style");
10279 style.setAttribute(STYLE_HASH_ATTRIBUTE13, hash);
10280 style.appendChild(targetDocument.createTextNode(css));
10281 targetDocument.head.appendChild(style);
10282 injectedStyles.add(hash);
10283 }
10284 function registerDocument13(targetDocument) {
10285 const runtime = getRuntime13();
10286 runtime.documents.set(
10287 targetDocument,
10288 (runtime.documents.get(targetDocument) ?? 0) + 1
10289 );
10290 for (const [hash, css] of runtime.styles) {
10291 injectStyle13(targetDocument, hash, css);
10292 }
10293 return () => {
10294 const count = runtime.documents.get(targetDocument);
10295 if (count === void 0) {
10296 return;
10297 }
10298 if (count <= 1) {
10299 runtime.documents.delete(targetDocument);
10300 return;
10301 }
10302 runtime.documents.set(targetDocument, count - 1);
10303 };
10304 }
10305 function registerStyle13(hash, css) {
10306 const runtime = getRuntime13();
10307 runtime.styles.set(hash, css);
10308 for (const targetDocument of runtime.documents.keys()) {
10309 injectStyle13(targetDocument, hash, css);
10310 }
10311 }
10312 if (typeof process === "undefined" || true) {
10313 registerStyle13("e3ae230cea", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}");
10314 }
10315 var resets_default2 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
10316 if (typeof process === "undefined" || true) {
10317 registerStyle13("2a5ab8f3a7", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._08e8a2e44959f892__outset-ring--focus,._970d04df7376df67__outset-ring--focus-within-except-active,.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible,.cd83dfc2126a0846__outset-ring--focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active,.ecadb9e080e2dfa5__outset-ring--focus-parent-visible{@media not (prefers-reduced-motion){--_gcd-a-transition:outline 0.1s ease-out;transition:outline .1s ease-out}outline:0 solid #0000;outline-offset:1px}._08e8a2e44959f892__outset-ring--focus:focus,._970d04df7376df67__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible:focus-within:has(:focus-visible),.cd83dfc2126a0846__outset-ring--focus-within:focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible:focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active:focus:not(:active),:focus-visible .ecadb9e080e2dfa5__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9))}}");
10318 }
10319 var focus_default = { "outset-ring--focus": "_08e8a2e44959f892__outset-ring--focus", "outset-ring--focus-except-active": "e25b2bdd7aa21721__outset-ring--focus-except-active", "outset-ring--focus-visible": "d0541bc9dd9dc7b6__outset-ring--focus-visible", "outset-ring--focus-within": "cd83dfc2126a0846__outset-ring--focus-within", "outset-ring--focus-within-except-active": "_970d04df7376df67__outset-ring--focus-within-except-active", "outset-ring--focus-within-visible": "c5cb3ee4bddaa8e4__outset-ring--focus-within-visible", "outset-ring--focus-parent-visible": "ecadb9e080e2dfa5__outset-ring--focus-parent-visible" };
10320 if (typeof process === "undefined" || true) {
10321 registerStyle13("90a23568f8", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.d4250949359b05ce__link{text-decoration-thickness:from-font;text-underline-offset:.2em}.c6055659b8e2cd2c__is-brand,.c6055659b8e2cd2c__is-brand:visited{--_gcd-a-color:var(--wpds-color-fg-interactive-brand,var(--wp-admin-theme-color,#3858e9));color:var(--wpds-color-fg-interactive-brand,var(--wp-admin-theme-color,#3858e9))}.c6055659b8e2cd2c__is-brand:active,.c6055659b8e2cd2c__is-brand:hover{--_gcd-a-color:var(--wpds-color-fg-interactive-brand-active,var(--wp-admin-theme-color,#3858e9));color:var(--wpds-color-fg-interactive-brand-active,var(--wp-admin-theme-color,#3858e9))}._92e0dfcaeee15b88__is-neutral,._92e0dfcaeee15b88__is-neutral:visited{--_gcd-a-color:var(--wpds-color-fg-interactive-neutral,#1e1e1e);color:var(--wpds-color-fg-interactive-neutral,#1e1e1e);text-decoration-color:var(--wpds-color-stroke-interactive-neutral,#8d8d8d)}._92e0dfcaeee15b88__is-neutral:active,._92e0dfcaeee15b88__is-neutral:hover{--_gcd-a-color:var(--wpds-color-fg-interactive-neutral-active,#1e1e1e);color:var(--wpds-color-fg-interactive-neutral-active,#1e1e1e)}.cf122a9bf1035d42__is-unstyled{--_gcd-a-color:inherit;color:inherit;text-decoration:none}._0cb411afac4c86c7__link-icon{display:inline-block;font-weight:var(--wpds-typography-font-weight-regular,400);line-height:1;margin-inline-start:var(--wpds-dimension-padding-xs,4px);text-decoration:none}._0cb411afac4c86c7__link-icon:after{content:"\\2197"}._0cb411afac4c86c7__link-icon:dir(rtl):after{content:"\\2196"}}');
10322 }
10323 var style_default12 = { "link": "d4250949359b05ce__link", "is-brand": "c6055659b8e2cd2c__is-brand", "is-neutral": "_92e0dfcaeee15b88__is-neutral", "is-unstyled": "cf122a9bf1035d42__is-unstyled", "link-icon": "_0cb411afac4c86c7__link-icon" };
10324 if (typeof process === "undefined" || true) {
10325 registerStyle13("1fb29d3a3c", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,#0000);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 #0000);color:var(--_gcd-input-color,var(--wpds-color-fg-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,#0000);border-color:var(--_gcd-input-border-color-disabled,#0000);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid #0000)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-fg-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid #0000);transition:var(--_gcd-a-transition,none)}");
10326 }
10327 var global_css_defense_default2 = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a" };
10328 var Link = (0, import_element24.forwardRef)(function Link2({
10329 children,
10330 variant = "default",
10331 tone = "brand",
10332 openInNewTab = false,
10333 render: render4,
10334 className,
10335 ...props
10336 }, ref) {
10337 const element = useRender({
10338 render: render4,
10339 defaultTagName: "a",
10340 ref,
10341 props: mergeProps(props, {
10342 className: clsx_default(
10343 global_css_defense_default2.a,
10344 resets_default2["box-sizing"],
10345 focus_default["outset-ring--focus"],
10346 variant !== "unstyled" && style_default12.link,
10347 variant !== "unstyled" && style_default12[`is-${tone}`],
10348 variant === "unstyled" && style_default12["is-unstyled"],
10349 className
10350 ),
10351 target: openInNewTab ? "_blank" : void 0,
10352 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_jsx_runtime46.Fragment, { children: [
10353 children,
10354 openInNewTab && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
10355 "span",
10356 {
10357 className: style_default12["link-icon"],
10358 role: "img",
10359 "aria-label": (
10360 /* translators: accessibility text appended to link text */
10361 (0, import_i18n.__)("(opens in a new tab)")
10362 )
10363 }
10364 )
10365 ] })
10366 })
10367 });
10368 return element;
10369 });
10370
10371 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10372 var import_element25 = __toESM(require_element(), 1);
10373
10374 // packages/dataviews/build-module/constants.mjs
10375 var import_i18n2 = __toESM(require_i18n(), 1);
10376 var OPERATOR_IS_ANY = "isAny";
10377 var OPERATOR_IS_NONE = "isNone";
10378 var OPERATOR_IS_ALL = "isAll";
10379 var OPERATOR_IS_NOT_ALL = "isNotAll";
10380 var OPERATOR_BETWEEN = "between";
10381 var OPERATOR_IN_THE_PAST = "inThePast";
10382 var OPERATOR_OVER = "over";
10383 var OPERATOR_IS = "is";
10384 var OPERATOR_IS_NOT = "isNot";
10385 var OPERATOR_LESS_THAN = "lessThan";
10386 var OPERATOR_GREATER_THAN = "greaterThan";
10387 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
10388 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
10389 var OPERATOR_BEFORE = "before";
10390 var OPERATOR_AFTER = "after";
10391 var OPERATOR_BEFORE_INC = "beforeInc";
10392 var OPERATOR_AFTER_INC = "afterInc";
10393 var OPERATOR_CONTAINS = "contains";
10394 var OPERATOR_NOT_CONTAINS = "notContains";
10395 var OPERATOR_STARTS_WITH = "startsWith";
10396 var OPERATOR_ON = "on";
10397 var OPERATOR_NOT_ON = "notOn";
10398 var SORTING_DIRECTIONS = ["asc", "desc"];
10399 var sortArrows = { asc: "\u2191", desc: "\u2193" };
10400 var sortValues = { asc: "ascending", desc: "descending" };
10401 var sortLabels = {
10402 asc: (0, import_i18n2.__)("Sort ascending"),
10403 desc: (0, import_i18n2.__)("Sort descending")
10404 };
10405 var sortIcons = {
10406 asc: arrow_up_default,
10407 desc: arrow_down_default
10408 };
10409 var LAYOUT_TABLE = "table";
10410 var LAYOUT_GRID = "grid";
10411 var LAYOUT_LIST = "list";
10412 var LAYOUT_ACTIVITY = "activity";
10413 var LAYOUT_PICKER_GRID = "pickerGrid";
10414 var LAYOUT_PICKER_TABLE = "pickerTable";
10415
10416 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10417 var DataViewsContext = (0, import_element25.createContext)({
10418 view: { type: LAYOUT_TABLE },
10419 onChangeView: () => {
10420 },
10421 fields: [],
10422 data: [],
10423 paginationInfo: {
10424 totalItems: 0,
10425 totalPages: 0
10426 },
10427 selection: [],
10428 onChangeSelection: () => {
10429 },
10430 setOpenedFilter: () => {
10431 },
10432 openedFilter: null,
10433 getItemId: (item) => item.id,
10434 isItemClickable: () => true,
10435 renderItemLink: void 0,
10436 containerWidth: 0,
10437 containerRef: (0, import_element25.createRef)(),
10438 resizeObserverRef: () => {
10439 },
10440 defaultLayouts: { list: {}, grid: {}, table: {} },
10441 filters: [],
10442 isShowingFilter: false,
10443 setIsShowingFilter: () => {
10444 },
10445 hasInitiallyLoaded: false,
10446 config: {
10447 perPageSizes: []
10448 },
10449 intersectionObserver: null
10450 });
10451 DataViewsContext.displayName = "DataViewsContext";
10452 var dataviews_context_default = DataViewsContext;
10453
10454 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
10455 var import_i18n22 = __toESM(require_i18n(), 1);
10456
10457 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
10458 var import_i18n10 = __toESM(require_i18n(), 1);
10459 var import_components6 = __toESM(require_components(), 1);
10460 var import_element33 = __toESM(require_element(), 1);
10461 var import_keycodes = __toESM(require_keycodes(), 1);
10462
10463 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
10464 var import_components = __toESM(require_components(), 1);
10465 var import_i18n3 = __toESM(require_i18n(), 1);
10466 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
10467 function DataViewsSelectionCheckbox({
10468 selection,
10469 onChangeSelection,
10470 item,
10471 getItemId,
10472 titleField,
10473 disabled: disabled2,
10474 ...extraProps
10475 }) {
10476 const id = getItemId(item);
10477 const isInSelectionArray = selection.includes(id);
10478 const checked = !disabled2 && isInSelectionArray;
10479 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n3.__)("(no title)");
10480 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
10481 import_components.CheckboxControl,
10482 {
10483 className: "dataviews-selection-checkbox",
10484 "aria-label": selectionLabel,
10485 "aria-disabled": disabled2,
10486 checked,
10487 onChange: () => {
10488 if (disabled2) {
10489 return;
10490 }
10491 onChangeSelection(
10492 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
10493 );
10494 },
10495 ...extraProps
10496 }
10497 );
10498 }
10499
10500 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10501 var import_components2 = __toESM(require_components(), 1);
10502 var import_i18n4 = __toESM(require_i18n(), 1);
10503 var import_element26 = __toESM(require_element(), 1);
10504 var import_data = __toESM(require_data(), 1);
10505 var import_compose = __toESM(require_compose(), 1);
10506
10507 // packages/dataviews/build-module/lock-unlock.mjs
10508 var import_private_apis2 = __toESM(require_private_apis(), 1);
10509 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
10510 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
10511 "@wordpress/dataviews"
10512 );
10513
10514 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10515 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
10516 var { Menu, kebabCase } = unlock2(import_components2.privateApis);
10517 function ButtonTrigger({
10518 action,
10519 onClick,
10520 items,
10521 variant
10522 }) {
10523 const label = typeof action.label === "string" ? action.label : action.label(items);
10524 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10525 import_components2.Button,
10526 {
10527 disabled: !!action.disabled,
10528 accessibleWhenDisabled: true,
10529 size: "compact",
10530 variant,
10531 onClick,
10532 children: label
10533 }
10534 );
10535 }
10536 function MenuItemTrigger({
10537 action,
10538 onClick,
10539 items
10540 }) {
10541 const label = typeof action.label === "string" ? action.label : action.label(items);
10542 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Menu.ItemLabel, { children: label }) });
10543 }
10544 function ActionModal({
10545 action,
10546 items,
10547 closeModal
10548 }) {
10549 const label = typeof action.label === "string" ? action.label : action.label(items);
10550 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
10551 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10552 import_components2.Modal,
10553 {
10554 title: modalHeader || label,
10555 __experimentalHideHeader: !!action.hideModalHeader,
10556 onRequestClose: closeModal,
10557 focusOnMount: action.modalFocusOnMount ?? true,
10558 size: action.modalSize || "medium",
10559 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
10560 action.id
10561 )}`,
10562 children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(action.RenderModal, { items, closeModal })
10563 }
10564 );
10565 }
10566 function ActionsMenuGroup({
10567 actions,
10568 item,
10569 registry,
10570 setActiveModalAction
10571 }) {
10572 const { primaryActions, regularActions } = (0, import_element26.useMemo)(() => {
10573 return actions.reduce(
10574 (acc, action) => {
10575 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
10576 return acc;
10577 },
10578 {
10579 primaryActions: [],
10580 regularActions: []
10581 }
10582 );
10583 }, [actions]);
10584 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10585 MenuItemTrigger,
10586 {
10587 action,
10588 onClick: () => {
10589 if ("RenderModal" in action) {
10590 setActiveModalAction(action);
10591 return;
10592 }
10593 action.callback([item], { registry });
10594 },
10595 items: [item]
10596 },
10597 action.id
10598 ));
10599 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(Menu.Group, { children: [
10600 renderActionGroup(primaryActions),
10601 renderActionGroup(regularActions)
10602 ] });
10603 }
10604 function ItemActions({
10605 item,
10606 actions,
10607 isCompact
10608 }) {
10609 const registry = (0, import_data.useRegistry)();
10610 const { primaryActions, eligibleActions } = (0, import_element26.useMemo)(() => {
10611 const _eligibleActions = actions.filter(
10612 (action) => !action.isEligible || action.isEligible(item)
10613 );
10614 const _primaryActions = _eligibleActions.filter(
10615 (action) => action.isPrimary
10616 );
10617 return {
10618 primaryActions: _primaryActions,
10619 eligibleActions: _eligibleActions
10620 };
10621 }, [actions, item]);
10622 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10623 if (isCompact) {
10624 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10625 CompactItemActions,
10626 {
10627 item,
10628 actions: eligibleActions,
10629 isSmall: true,
10630 registry
10631 }
10632 );
10633 }
10634 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
10635 Stack,
10636 {
10637 direction: "row",
10638 justify: "flex-end",
10639 className: "dataviews-item-actions",
10640 style: {
10641 flexShrink: 0,
10642 width: "auto"
10643 },
10644 children: [
10645 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10646 PrimaryActions,
10647 {
10648 item,
10649 actions: primaryActions,
10650 registry
10651 }
10652 ),
10653 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
10654 // there if there are any actions at all.
10655 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10656 CompactItemActions,
10657 {
10658 item,
10659 actions: eligibleActions,
10660 registry
10661 }
10662 )
10663 ]
10664 }
10665 );
10666 }
10667 function CompactItemActions({
10668 item,
10669 actions,
10670 isSmall,
10671 registry
10672 }) {
10673 const [activeModalAction, setActiveModalAction] = (0, import_element26.useState)(
10674 null
10675 );
10676 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(import_jsx_runtime48.Fragment, { children: [
10677 /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(Menu, { placement: "bottom-end", children: [
10678 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10679 Menu.TriggerButton,
10680 {
10681 render: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10682 import_components2.Button,
10683 {
10684 size: isSmall ? "small" : "compact",
10685 icon: more_vertical_default,
10686 label: (0, import_i18n4.__)("Actions"),
10687 accessibleWhenDisabled: true,
10688 disabled: !actions.length,
10689 className: "dataviews-all-actions-button"
10690 }
10691 )
10692 }
10693 ),
10694 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10695 ActionsMenuGroup,
10696 {
10697 actions,
10698 item,
10699 registry,
10700 setActiveModalAction
10701 }
10702 ) })
10703 ] }),
10704 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10705 ActionModal,
10706 {
10707 action: activeModalAction,
10708 items: [item],
10709 closeModal: () => setActiveModalAction(null)
10710 }
10711 )
10712 ] });
10713 }
10714 function PrimaryActions({
10715 item,
10716 actions,
10717 registry,
10718 buttonVariant
10719 }) {
10720 const [activeModalAction, setActiveModalAction] = (0, import_element26.useState)(null);
10721 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10722 if (isMobileViewport) {
10723 return null;
10724 }
10725 if (!Array.isArray(actions) || actions.length === 0) {
10726 return null;
10727 }
10728 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(import_jsx_runtime48.Fragment, { children: [
10729 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10730 ButtonTrigger,
10731 {
10732 action,
10733 onClick: () => {
10734 if ("RenderModal" in action) {
10735 setActiveModalAction(action);
10736 return;
10737 }
10738 action.callback([item], { registry });
10739 },
10740 items: [item],
10741 variant: buttonVariant
10742 },
10743 action.id
10744 )),
10745 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10746 ActionModal,
10747 {
10748 action: activeModalAction,
10749 items: [item],
10750 closeModal: () => setActiveModalAction(null)
10751 }
10752 )
10753 ] });
10754 }
10755
10756 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10757 var import_components3 = __toESM(require_components(), 1);
10758 var import_i18n6 = __toESM(require_i18n(), 1);
10759 var import_element27 = __toESM(require_element(), 1);
10760 var import_data2 = __toESM(require_data(), 1);
10761 var import_compose2 = __toESM(require_compose(), 1);
10762
10763 // packages/dataviews/build-module/utils/get-footer-message.mjs
10764 var import_i18n5 = __toESM(require_i18n(), 1);
10765 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
10766 if (selectionCount > 0) {
10767 return (0, import_i18n5.sprintf)(
10768 /* translators: %d: number of items. */
10769 (0, import_i18n5._n)("%d Item selected", "%d Items selected", selectionCount),
10770 selectionCount
10771 );
10772 }
10773 if (onlyTotalCount || totalItems <= itemsCount) {
10774 return (0, import_i18n5.sprintf)(
10775 /* translators: %d: number of items. */
10776 (0, import_i18n5._n)("%d Item", "%d Items", totalItems),
10777 totalItems
10778 );
10779 }
10780 return (0, import_i18n5.sprintf)(
10781 /* translators: %1$d: number of items. %2$d: total number of items. */
10782 (0, import_i18n5._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
10783 itemsCount,
10784 totalItems
10785 );
10786 }
10787
10788 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10789 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
10790 function ActionWithModal({
10791 action,
10792 items,
10793 ActionTriggerComponent
10794 }) {
10795 const [isModalOpen, setIsModalOpen] = (0, import_element27.useState)(false);
10796 const actionTriggerProps = {
10797 action,
10798 onClick: () => {
10799 setIsModalOpen(true);
10800 },
10801 items
10802 };
10803 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
10804 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(ActionTriggerComponent, { ...actionTriggerProps }),
10805 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10806 ActionModal,
10807 {
10808 action,
10809 items,
10810 closeModal: () => setIsModalOpen(false)
10811 }
10812 )
10813 ] });
10814 }
10815 function useHasAPossibleBulkAction(actions, item) {
10816 return (0, import_element27.useMemo)(() => {
10817 return actions.some((action) => {
10818 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
10819 });
10820 }, [actions, item]);
10821 }
10822 function useSomeItemHasAPossibleBulkAction(actions, data) {
10823 return (0, import_element27.useMemo)(() => {
10824 return data.some((item) => {
10825 return actions.some((action) => {
10826 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
10827 });
10828 });
10829 }, [actions, data]);
10830 }
10831 function BulkSelectionCheckbox({
10832 selection,
10833 onChangeSelection,
10834 data,
10835 actions,
10836 getItemId,
10837 disableSelectAll = false
10838 }) {
10839 const selectableItems = (0, import_element27.useMemo)(() => {
10840 return data.filter((item) => {
10841 return actions.some(
10842 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
10843 );
10844 });
10845 }, [data, actions]);
10846 const selectedItems = data.filter(
10847 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
10848 );
10849 const hasSelection = selection.length > 0;
10850 const areAllSelected = selectedItems.length === selectableItems.length;
10851 if (disableSelectAll) {
10852 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10853 import_components3.CheckboxControl,
10854 {
10855 className: "dataviews-view-table-selection-checkbox",
10856 checked: hasSelection,
10857 disabled: !hasSelection,
10858 onChange: () => {
10859 onChangeSelection([]);
10860 },
10861 "aria-label": (0, import_i18n6.__)("Deselect all")
10862 }
10863 );
10864 }
10865 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10866 import_components3.CheckboxControl,
10867 {
10868 className: "dataviews-view-table-selection-checkbox",
10869 checked: areAllSelected,
10870 indeterminate: !areAllSelected && !!selectedItems.length,
10871 onChange: () => {
10872 if (areAllSelected) {
10873 onChangeSelection([]);
10874 } else {
10875 onChangeSelection(
10876 selectableItems.map((item) => getItemId(item))
10877 );
10878 }
10879 },
10880 "aria-label": areAllSelected ? (0, import_i18n6.__)("Deselect all") : (0, import_i18n6.__)("Select all")
10881 }
10882 );
10883 }
10884 function ActionTrigger({
10885 action,
10886 onClick,
10887 isBusy,
10888 items
10889 }) {
10890 const label = typeof action.label === "string" ? action.label : action.label(items);
10891 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
10892 if (isMobile) {
10893 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10894 import_components3.Button,
10895 {
10896 disabled: isBusy,
10897 accessibleWhenDisabled: true,
10898 label,
10899 icon: action.icon,
10900 size: "compact",
10901 onClick,
10902 isBusy
10903 }
10904 );
10905 }
10906 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10907 import_components3.Button,
10908 {
10909 disabled: isBusy,
10910 accessibleWhenDisabled: true,
10911 size: "compact",
10912 onClick,
10913 isBusy,
10914 children: label
10915 }
10916 );
10917 }
10918 var EMPTY_ARRAY2 = [];
10919 function ActionButton({
10920 action,
10921 selectedItems,
10922 actionInProgress,
10923 setActionInProgress
10924 }) {
10925 const registry = (0, import_data2.useRegistry)();
10926 const selectedEligibleItems = (0, import_element27.useMemo)(() => {
10927 return selectedItems.filter((item) => {
10928 return !action.isEligible || action.isEligible(item);
10929 });
10930 }, [action, selectedItems]);
10931 if ("RenderModal" in action) {
10932 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10933 ActionWithModal,
10934 {
10935 action,
10936 items: selectedEligibleItems,
10937 ActionTriggerComponent: ActionTrigger
10938 },
10939 action.id
10940 );
10941 }
10942 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10943 ActionTrigger,
10944 {
10945 action,
10946 onClick: async () => {
10947 setActionInProgress(action.id);
10948 await action.callback(selectedItems, {
10949 registry
10950 });
10951 setActionInProgress(null);
10952 },
10953 items: selectedEligibleItems,
10954 isBusy: actionInProgress === action.id
10955 },
10956 action.id
10957 );
10958 }
10959 function renderFooterContent(data, actions, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) {
10960 const message2 = getFooterMessage(
10961 selection.length,
10962 data.length,
10963 paginationInfo.totalItems,
10964 isInfiniteScroll
10965 );
10966 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
10967 Stack,
10968 {
10969 direction: "row",
10970 className: "dataviews-bulk-actions-footer__container",
10971 gap: "md",
10972 align: "center",
10973 children: [
10974 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10975 BulkSelectionCheckbox,
10976 {
10977 selection,
10978 onChangeSelection,
10979 data,
10980 actions,
10981 getItemId,
10982 disableSelectAll: isInfiniteScroll
10983 }
10984 ),
10985 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }),
10986 /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
10987 Stack,
10988 {
10989 direction: "row",
10990 className: "dataviews-bulk-actions-footer__action-buttons",
10991 gap: "xs",
10992 children: [
10993 actionsToShow.map((action) => {
10994 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10995 ActionButton,
10996 {
10997 action,
10998 selectedItems,
10999 actionInProgress,
11000 setActionInProgress
11001 },
11002 action.id
11003 );
11004 }),
11005 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11006 import_components3.Button,
11007 {
11008 icon: close_small_default,
11009 showTooltip: true,
11010 tooltipPosition: "top",
11011 size: "compact",
11012 label: (0, import_i18n6.__)("Cancel"),
11013 disabled: !!actionInProgress,
11014 accessibleWhenDisabled: false,
11015 onClick: () => {
11016 onChangeSelection(EMPTY_ARRAY2);
11017 }
11018 }
11019 )
11020 ]
11021 }
11022 )
11023 ]
11024 }
11025 );
11026 }
11027 function FooterContent({
11028 selection,
11029 actions,
11030 onChangeSelection,
11031 data,
11032 getItemId,
11033 isInfiniteScroll,
11034 paginationInfo
11035 }) {
11036 const [actionInProgress, setActionInProgress] = (0, import_element27.useState)(
11037 null
11038 );
11039 const footerContentRef = (0, import_element27.useRef)(void 0);
11040 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
11041 const bulkActions = (0, import_element27.useMemo)(
11042 () => actions.filter((action) => action.supportsBulk),
11043 [actions]
11044 );
11045 const selectableItems = (0, import_element27.useMemo)(() => {
11046 return data.filter((item) => {
11047 return bulkActions.some(
11048 (action) => !action.isEligible || action.isEligible(item)
11049 );
11050 });
11051 }, [data, bulkActions]);
11052 const selectedItems = (0, import_element27.useMemo)(() => {
11053 return data.filter(
11054 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
11055 );
11056 }, [selection, data, getItemId, selectableItems]);
11057 const actionsToShow = (0, import_element27.useMemo)(
11058 () => actions.filter((action) => {
11059 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some(
11060 (item) => !action.isEligible || action.isEligible(item)
11061 );
11062 }),
11063 [actions, selectedItems, isMobile]
11064 );
11065 if (!actionInProgress) {
11066 if (footerContentRef.current) {
11067 footerContentRef.current = void 0;
11068 }
11069 return renderFooterContent(
11070 data,
11071 actions,
11072 getItemId,
11073 isInfiniteScroll,
11074 selection,
11075 actionsToShow,
11076 selectedItems,
11077 actionInProgress,
11078 setActionInProgress,
11079 onChangeSelection,
11080 paginationInfo
11081 );
11082 } else if (!footerContentRef.current) {
11083 footerContentRef.current = renderFooterContent(
11084 data,
11085 actions,
11086 getItemId,
11087 isInfiniteScroll,
11088 selection,
11089 actionsToShow,
11090 selectedItems,
11091 actionInProgress,
11092 setActionInProgress,
11093 onChangeSelection,
11094 paginationInfo
11095 );
11096 }
11097 return footerContentRef.current;
11098 }
11099 function BulkActionsFooter() {
11100 const {
11101 data,
11102 selection,
11103 actions = EMPTY_ARRAY2,
11104 onChangeSelection,
11105 getItemId,
11106 paginationInfo,
11107 view
11108 } = (0, import_element27.useContext)(dataviews_context_default);
11109 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11110 FooterContent,
11111 {
11112 selection,
11113 onChangeSelection,
11114 data,
11115 actions,
11116 getItemId,
11117 isInfiniteScroll: !!view.infiniteScrollEnabled,
11118 paginationInfo
11119 }
11120 );
11121 }
11122
11123 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
11124 var import_i18n7 = __toESM(require_i18n(), 1);
11125 var import_components4 = __toESM(require_components(), 1);
11126 var import_element28 = __toESM(require_element(), 1);
11127
11128 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
11129 function getHideableFields(view, fields) {
11130 const togglableFields = [
11131 view?.titleField,
11132 view?.mediaField,
11133 view?.descriptionField
11134 ].filter(Boolean);
11135 return fields.filter(
11136 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
11137 );
11138 }
11139
11140 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
11141 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
11142 var { Menu: Menu2 } = unlock2(import_components4.privateApis);
11143 function WithMenuSeparators({ children }) {
11144 return import_element28.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_element28.Fragment, { children: [
11145 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Separator, {}),
11146 child
11147 ] }, i2));
11148 }
11149 var _HeaderMenu = (0, import_element28.forwardRef)(function HeaderMenu({
11150 fieldId,
11151 view,
11152 fields,
11153 onChangeView,
11154 onHide,
11155 setOpenedFilter,
11156 canMove = true,
11157 canInsertLeft = true,
11158 canInsertRight = true
11159 }, ref) {
11160 const visibleFieldIds = view.fields ?? [];
11161 const index2 = visibleFieldIds?.indexOf(fieldId);
11162 const isSorted = view.sort?.field === fieldId;
11163 let isHidable = false;
11164 let isSortable = false;
11165 let canAddFilter = false;
11166 let operators = [];
11167 const field = fields.find((f2) => f2.id === fieldId);
11168 const { setIsShowingFilter } = (0, import_element28.useContext)(dataviews_context_default);
11169 if (!field) {
11170 return null;
11171 }
11172 isHidable = field.enableHiding !== false;
11173 isSortable = field.enableSorting !== false;
11174 const header = field.header;
11175 operators = !!field.filterBy && field.filterBy?.operators || [];
11176 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
11177 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
11178 return header;
11179 }
11180 const hiddenFields = getHideableFields(view, fields).filter(
11181 (f2) => !visibleFieldIds.includes(f2.id)
11182 );
11183 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
11184 const isRtl = (0, import_i18n7.isRTL)();
11185 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Menu2, { children: [
11186 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
11187 Menu2.TriggerButton,
11188 {
11189 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11190 import_components4.Button,
11191 {
11192 size: "compact",
11193 className: "dataviews-view-table-header-button",
11194 ref,
11195 variant: "tertiary"
11196 }
11197 ),
11198 children: [
11199 header,
11200 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
11201 ]
11202 }
11203 ),
11204 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(WithMenuSeparators, { children: [
11205 isSortable && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
11206 (direction) => {
11207 const isChecked = view.sort && isSorted && view.sort.direction === direction;
11208 const value = `${fieldId}-${direction}`;
11209 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11210 Menu2.RadioItem,
11211 {
11212 name: "view-table-sorting",
11213 value,
11214 checked: isChecked,
11215 onChange: () => {
11216 onChangeView({
11217 ...view,
11218 sort: {
11219 field: fieldId,
11220 direction
11221 },
11222 showLevels: false
11223 });
11224 },
11225 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
11226 },
11227 value
11228 );
11229 }
11230 ) }),
11231 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11232 Menu2.Item,
11233 {
11234 prefix: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components4.Icon, { icon: funnel_default }),
11235 onClick: () => {
11236 setOpenedFilter(fieldId);
11237 setIsShowingFilter(true);
11238 onChangeView({
11239 ...view,
11240 page: 1,
11241 filters: [
11242 ...view.filters || [],
11243 {
11244 field: fieldId,
11245 value: void 0,
11246 operator: operators[0]
11247 }
11248 ]
11249 });
11250 },
11251 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Add filter") })
11252 }
11253 ) }),
11254 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Menu2.Group, { children: [
11255 canMove && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11256 Menu2.Item,
11257 {
11258 prefix: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components4.Icon, { icon: arrow_left_default }),
11259 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1,
11260 onClick: () => {
11261 const targetIndex = isRtl ? index2 + 1 : index2 - 1;
11262 const newFields = [
11263 ...visibleFieldIds
11264 ];
11265 newFields.splice(index2, 1);
11266 newFields.splice(
11267 targetIndex,
11268 0,
11269 fieldId
11270 );
11271 onChangeView({
11272 ...view,
11273 fields: newFields
11274 });
11275 },
11276 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Move left") })
11277 }
11278 ),
11279 canMove && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11280 Menu2.Item,
11281 {
11282 prefix: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components4.Icon, { icon: arrow_right_default }),
11283 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1,
11284 onClick: () => {
11285 const targetIndex = isRtl ? index2 - 1 : index2 + 1;
11286 const newFields = [
11287 ...visibleFieldIds
11288 ];
11289 newFields.splice(index2, 1);
11290 newFields.splice(
11291 targetIndex,
11292 0,
11293 fieldId
11294 );
11295 onChangeView({
11296 ...view,
11297 fields: newFields
11298 });
11299 },
11300 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Move right") })
11301 }
11302 ),
11303 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Menu2, { children: [
11304 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Insert left") }) }),
11305 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11306 const insertIndex = isRtl ? index2 + 1 : index2;
11307 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11308 Menu2.Item,
11309 {
11310 onClick: () => {
11311 onChangeView({
11312 ...view,
11313 fields: [
11314 ...visibleFieldIds.slice(
11315 0,
11316 insertIndex
11317 ),
11318 hiddenField.id,
11319 ...visibleFieldIds.slice(
11320 insertIndex
11321 )
11322 ]
11323 });
11324 },
11325 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11326 },
11327 hiddenField.id
11328 );
11329 }) })
11330 ] }),
11331 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Menu2, { children: [
11332 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Insert right") }) }),
11333 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11334 const insertIndex = isRtl ? index2 : index2 + 1;
11335 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11336 Menu2.Item,
11337 {
11338 onClick: () => {
11339 onChangeView({
11340 ...view,
11341 fields: [
11342 ...visibleFieldIds.slice(
11343 0,
11344 insertIndex
11345 ),
11346 hiddenField.id,
11347 ...visibleFieldIds.slice(
11348 insertIndex
11349 )
11350 ]
11351 });
11352 },
11353 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11354 },
11355 hiddenField.id
11356 );
11357 }) })
11358 ] }),
11359 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11360 Menu2.Item,
11361 {
11362 prefix: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components4.Icon, { icon: unseen_default }),
11363 onClick: () => {
11364 onHide(field);
11365 onChangeView({
11366 ...view,
11367 fields: visibleFieldIds.filter(
11368 (id) => id !== fieldId
11369 )
11370 });
11371 },
11372 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Hide column") })
11373 }
11374 )
11375 ] })
11376 ] }) })
11377 ] });
11378 });
11379 var ColumnHeaderMenu = _HeaderMenu;
11380 var column_header_menu_default = ColumnHeaderMenu;
11381
11382 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
11383 var import_element29 = __toESM(require_element(), 1);
11384 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
11385 function getClickableItemProps({
11386 item,
11387 isItemClickable,
11388 onClickItem,
11389 className
11390 }) {
11391 if (!isItemClickable(item) || !onClickItem) {
11392 return { className };
11393 }
11394 return {
11395 className: className ? `${className} ${className}--clickable` : void 0,
11396 role: "button",
11397 tabIndex: 0,
11398 onClick: (event) => {
11399 event.stopPropagation();
11400 onClickItem(item);
11401 },
11402 onKeyDown: (event) => {
11403 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11404 event.stopPropagation();
11405 onClickItem(item);
11406 }
11407 }
11408 };
11409 }
11410 function ItemClickWrapper({
11411 item,
11412 isItemClickable,
11413 onClickItem,
11414 renderItemLink,
11415 className,
11416 children,
11417 ...extraProps
11418 }) {
11419 if (!isItemClickable(item)) {
11420 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className, ...extraProps, children });
11421 }
11422 if (renderItemLink) {
11423 const renderedElement = renderItemLink({
11424 item,
11425 className: `${className} ${className}--clickable`,
11426 ...extraProps,
11427 children
11428 });
11429 return (0, import_element29.cloneElement)(renderedElement, {
11430 onClick: (event) => {
11431 event.stopPropagation();
11432 if (renderedElement.props.onClick) {
11433 renderedElement.props.onClick(event);
11434 }
11435 },
11436 onKeyDown: (event) => {
11437 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11438 event.stopPropagation();
11439 if (renderedElement.props.onKeyDown) {
11440 renderedElement.props.onKeyDown(event);
11441 }
11442 }
11443 }
11444 });
11445 }
11446 const clickProps = getClickableItemProps({
11447 item,
11448 isItemClickable,
11449 onClickItem,
11450 className
11451 });
11452 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { ...clickProps, ...extraProps, children });
11453 }
11454
11455 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
11456 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
11457 function ColumnPrimary({
11458 item,
11459 level,
11460 titleField,
11461 mediaField,
11462 descriptionField,
11463 onClickItem,
11464 renderItemLink,
11465 isItemClickable
11466 }) {
11467 return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
11468 mediaField && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
11469 ItemClickWrapper,
11470 {
11471 item,
11472 isItemClickable,
11473 onClickItem,
11474 renderItemLink,
11475 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
11476 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
11477 children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
11478 mediaField.render,
11479 {
11480 item,
11481 field: mediaField,
11482 config: { sizes: "32px" }
11483 }
11484 )
11485 }
11486 ),
11487 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
11488 Stack,
11489 {
11490 direction: "column",
11491 align: "flex-start",
11492 className: "dataviews-view-table__primary-column-content",
11493 children: [
11494 titleField && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
11495 ItemClickWrapper,
11496 {
11497 item,
11498 isItemClickable,
11499 onClickItem,
11500 renderItemLink,
11501 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
11502 children: [
11503 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("span", { className: "dataviews-view-table__level", children: [
11504 Array(level).fill("\u2014").join(" "),
11505 "\xA0"
11506 ] }),
11507 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(titleField.render, { item, field: titleField })
11508 ]
11509 }
11510 ),
11511 descriptionField && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
11512 descriptionField.render,
11513 {
11514 item,
11515 field: descriptionField
11516 }
11517 )
11518 ]
11519 }
11520 )
11521 ] });
11522 }
11523 var column_primary_default = ColumnPrimary;
11524
11525 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
11526 var import_element30 = __toESM(require_element(), 1);
11527 var import_i18n8 = __toESM(require_i18n(), 1);
11528 var isScrolledToEnd = (element) => {
11529 if ((0, import_i18n8.isRTL)()) {
11530 const scrollLeft = Math.abs(element.scrollLeft);
11531 return scrollLeft <= 1;
11532 }
11533 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
11534 };
11535 function useScrollState({
11536 scrollContainerRef,
11537 enabledHorizontal = false
11538 }) {
11539 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element30.useState)(false);
11540 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element30.useState)(false);
11541 const handleScroll = (0, import_element30.useCallback)(() => {
11542 const scrollContainer = scrollContainerRef.current;
11543 if (!scrollContainer) {
11544 return;
11545 }
11546 if (enabledHorizontal) {
11547 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
11548 }
11549 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
11550 }, [scrollContainerRef, enabledHorizontal]);
11551 (0, import_element30.useEffect)(() => {
11552 if (typeof window === "undefined" || !scrollContainerRef.current) {
11553 return () => {
11554 };
11555 }
11556 const scrollContainer = scrollContainerRef.current;
11557 handleScroll();
11558 scrollContainer.addEventListener("scroll", handleScroll);
11559 window.addEventListener("resize", handleScroll);
11560 return () => {
11561 scrollContainer.removeEventListener("scroll", handleScroll);
11562 window.removeEventListener("resize", handleScroll);
11563 };
11564 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
11565 return { isHorizontalScrollEnd, isVerticallyScrolled };
11566 }
11567
11568 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
11569 function getDataByGroup(data, groupByField) {
11570 return data.reduce((groups, item) => {
11571 const groupName = groupByField.getValue({ item });
11572 if (!groups.has(groupName)) {
11573 groups.set(groupName, []);
11574 }
11575 groups.get(groupName)?.push(item);
11576 return groups;
11577 }, /* @__PURE__ */ new Map());
11578 }
11579
11580 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
11581 var import_components5 = __toESM(require_components(), 1);
11582 var import_i18n9 = __toESM(require_i18n(), 1);
11583 var import_element31 = __toESM(require_element(), 1);
11584 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
11585 function FieldItem({
11586 field,
11587 isVisible: isVisible2,
11588 onToggleVisibility
11589 }) {
11590 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_components5.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Stack, { direction: "row", gap: "sm", justify: "flex-start", align: "center", children: [
11591 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_components5.Icon, { icon: check_default }) }),
11592 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
11593 ] }) });
11594 }
11595 function isDefined(item) {
11596 return !!item;
11597 }
11598 function PropertiesSection({
11599 showLabel = true
11600 }) {
11601 const { view, fields, onChangeView } = (0, import_element31.useContext)(dataviews_context_default);
11602 const regularFields = getHideableFields(view, fields);
11603 if (!regularFields?.length) {
11604 return null;
11605 }
11606 const titleField = fields.find((f2) => f2.id === view.titleField);
11607 const previewField = fields.find((f2) => f2.id === view.mediaField);
11608 const descriptionField = fields.find(
11609 (f2) => f2.id === view.descriptionField
11610 );
11611 const lockedFields = [
11612 {
11613 field: titleField,
11614 isVisibleFlag: "showTitle"
11615 },
11616 {
11617 field: previewField,
11618 isVisibleFlag: "showMedia"
11619 },
11620 {
11621 field: descriptionField,
11622 isVisibleFlag: "showDescription"
11623 }
11624 ].filter(({ field }) => isDefined(field));
11625 const visibleFieldIds = view.fields ?? [];
11626 const visibleRegularFieldsCount = regularFields.filter(
11627 (f2) => visibleFieldIds.includes(f2.id)
11628 ).length;
11629 const visibleLockedFields = lockedFields.filter(
11630 ({ isVisibleFlag }) => (
11631 // @ts-expect-error
11632 view[isVisibleFlag] ?? true
11633 )
11634 );
11635 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
11636 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
11637 return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
11638 showLabel && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_components5.BaseControl.VisualLabel, { children: (0, import_i18n9.__)("Properties") }),
11639 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11640 Stack,
11641 {
11642 direction: "column",
11643 className: "dataviews-view-config__properties",
11644 children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_components5.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
11645 lockedFields.map(({ field, isVisibleFlag }) => {
11646 const isVisible2 = view[isVisibleFlag] ?? true;
11647 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
11648 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11649 FieldItem,
11650 {
11651 field: fieldToRender,
11652 isVisible: isVisible2,
11653 onToggleVisibility: () => {
11654 onChangeView({
11655 ...view,
11656 [isVisibleFlag]: !isVisible2
11657 });
11658 }
11659 },
11660 field.id
11661 );
11662 }),
11663 regularFields.map((field) => {
11664 const isVisible2 = visibleFieldIds.includes(field.id);
11665 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
11666 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11667 FieldItem,
11668 {
11669 field: fieldToRender,
11670 isVisible: isVisible2,
11671 onToggleVisibility: () => {
11672 onChangeView({
11673 ...view,
11674 fields: isVisible2 ? visibleFieldIds.filter(
11675 (fieldId) => fieldId !== field.id
11676 ) : [...visibleFieldIds, field.id]
11677 });
11678 }
11679 },
11680 field.id
11681 );
11682 })
11683 ] })
11684 }
11685 )
11686 ] });
11687 }
11688
11689 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
11690 var import_element32 = __toESM(require_element(), 1);
11691 function useDelayedLoading(isLoading, options = { delay: 400 }) {
11692 const [showLoader, setShowLoader] = (0, import_element32.useState)(false);
11693 (0, import_element32.useEffect)(() => {
11694 if (!isLoading) {
11695 return;
11696 }
11697 const timeout = setTimeout(() => {
11698 setShowLoader(true);
11699 }, options.delay);
11700 return () => {
11701 clearTimeout(timeout);
11702 setShowLoader(false);
11703 };
11704 }, [isLoading, options.delay]);
11705 return showLoader;
11706 }
11707
11708 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
11709 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
11710 function getEffectiveAlign(explicitAlign, fieldType) {
11711 if (explicitAlign) {
11712 return explicitAlign;
11713 }
11714 if (fieldType === "integer" || fieldType === "number") {
11715 return "end";
11716 }
11717 return void 0;
11718 }
11719 function TableColumnField({
11720 item,
11721 fields,
11722 column,
11723 align
11724 }) {
11725 const field = fields.find((f2) => f2.id === column);
11726 if (!field) {
11727 return null;
11728 }
11729 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
11730 "dataviews-view-table__cell-align-end": align === "end",
11731 "dataviews-view-table__cell-align-center": align === "center"
11732 });
11733 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(field.render, { item, field }) });
11734 }
11735 function TableRow({
11736 hasBulkActions,
11737 item,
11738 level,
11739 actions,
11740 fields,
11741 id,
11742 view,
11743 titleField,
11744 mediaField,
11745 descriptionField,
11746 selection,
11747 getItemId,
11748 isItemClickable,
11749 onClickItem,
11750 renderItemLink,
11751 onChangeSelection,
11752 isActionsColumnSticky,
11753 posinset
11754 }) {
11755 const { paginationInfo } = (0, import_element33.useContext)(dataviews_context_default);
11756 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
11757 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
11758 const {
11759 showTitle = true,
11760 showMedia = true,
11761 showDescription = true,
11762 infiniteScrollEnabled
11763 } = view;
11764 const isTouchDeviceRef = (0, import_element33.useRef)(false);
11765 const columns = view.fields ?? [];
11766 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
11767 return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
11768 "tr",
11769 {
11770 className: clsx_default("dataviews-view-table__row", {
11771 "is-selected": hasPossibleBulkAction && isSelected2,
11772 "has-bulk-actions": hasPossibleBulkAction
11773 }),
11774 onTouchStart: () => {
11775 isTouchDeviceRef.current = true;
11776 },
11777 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
11778 "aria-posinset": posinset,
11779 role: infiniteScrollEnabled ? "article" : void 0,
11780 onMouseDown: (event) => {
11781 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11782 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
11783 event?.preventDefault();
11784 }
11785 },
11786 onClick: (event) => {
11787 if (!hasPossibleBulkAction) {
11788 return;
11789 }
11790 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11791 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") {
11792 onChangeSelection(
11793 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
11794 );
11795 }
11796 },
11797 children: [
11798 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11799 DataViewsSelectionCheckbox,
11800 {
11801 item,
11802 selection,
11803 onChangeSelection,
11804 getItemId,
11805 titleField,
11806 disabled: !hasPossibleBulkAction
11807 }
11808 ) }) }),
11809 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11810 column_primary_default,
11811 {
11812 item,
11813 level,
11814 titleField: showTitle ? titleField : void 0,
11815 mediaField: showMedia ? mediaField : void 0,
11816 descriptionField: showDescription ? descriptionField : void 0,
11817 isItemClickable,
11818 onClickItem,
11819 renderItemLink
11820 }
11821 ) }),
11822 columns.map((column) => {
11823 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
11824 const field = fields.find((f2) => f2.id === column);
11825 const effectiveAlign = getEffectiveAlign(align, field?.type);
11826 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11827 "td",
11828 {
11829 style: {
11830 width,
11831 maxWidth,
11832 minWidth
11833 },
11834 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11835 TableColumnField,
11836 {
11837 fields,
11838 item,
11839 column,
11840 align: effectiveAlign
11841 }
11842 )
11843 },
11844 column
11845 );
11846 }),
11847 !!actions?.length && // Disable reason: we are not making the element interactive,
11848 // but preventing any click events from bubbling up to the
11849 // table row. This allows us to add a click handler to the row
11850 // itself (to toggle row selection) without erroneously
11851 // intercepting click events from ItemActions.
11852 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11853 "td",
11854 {
11855 className: clsx_default("dataviews-view-table__actions-column", {
11856 "dataviews-view-table__actions-column--sticky": true,
11857 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
11858 }),
11859 onClick: (e2) => e2.stopPropagation(),
11860 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(ItemActions, { item, actions })
11861 }
11862 )
11863 ]
11864 }
11865 );
11866 }
11867 function ViewTable({
11868 actions,
11869 data,
11870 fields,
11871 getItemId,
11872 getItemLevel,
11873 isLoading = false,
11874 onChangeView,
11875 onChangeSelection,
11876 selection,
11877 setOpenedFilter,
11878 onClickItem,
11879 isItemClickable,
11880 renderItemLink,
11881 view,
11882 className,
11883 empty
11884 }) {
11885 const { containerRef } = (0, import_element33.useContext)(dataviews_context_default);
11886 const isDelayedLoading = useDelayedLoading(isLoading);
11887 const headerMenuRefs = (0, import_element33.useRef)(/* @__PURE__ */ new Map());
11888 const headerMenuToFocusRef = (0, import_element33.useRef)(void 0);
11889 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element33.useState)();
11890 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element33.useState)(null);
11891 (0, import_element33.useEffect)(() => {
11892 if (headerMenuToFocusRef.current) {
11893 headerMenuToFocusRef.current.focus();
11894 headerMenuToFocusRef.current = void 0;
11895 }
11896 });
11897 const tableNoticeId = (0, import_element33.useId)();
11898 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
11899 scrollContainerRef: containerRef,
11900 enabledHorizontal: !!actions?.length
11901 });
11902 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
11903 if (nextHeaderMenuToFocus) {
11904 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
11905 setNextHeaderMenuToFocus(void 0);
11906 return;
11907 }
11908 const onHide = (field) => {
11909 const hidden = headerMenuRefs.current.get(field.id);
11910 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
11911 setNextHeaderMenuToFocus(fallback?.node);
11912 };
11913 const handleHeaderContextMenu = (event) => {
11914 event.preventDefault();
11915 event.stopPropagation();
11916 const virtualAnchor = {
11917 getBoundingClientRect: () => ({
11918 x: event.clientX,
11919 y: event.clientY,
11920 top: event.clientY,
11921 left: event.clientX,
11922 right: event.clientX,
11923 bottom: event.clientY,
11924 width: 0,
11925 height: 0,
11926 toJSON: () => ({})
11927 })
11928 };
11929 window.requestAnimationFrame(() => {
11930 setContextMenuAnchor(virtualAnchor);
11931 });
11932 };
11933 const hasData = !!data?.length;
11934 const titleField = fields.find((field) => field.id === view.titleField);
11935 const mediaField = fields.find((field) => field.id === view.mediaField);
11936 const descriptionField = fields.find(
11937 (field) => field.id === view.descriptionField
11938 );
11939 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
11940 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
11941 const { showTitle = true, showMedia = true, showDescription = true } = view;
11942 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
11943 const columns = view.fields ?? [];
11944 const headerMenuRef = (column, index2) => (node) => {
11945 if (node) {
11946 headerMenuRefs.current.set(column, {
11947 node,
11948 fallback: columns[index2 > 0 ? index2 - 1 : 1]
11949 });
11950 } else {
11951 headerMenuRefs.current.delete(column);
11952 }
11953 };
11954 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
11955 const isRtl = (0, import_i18n10.isRTL)();
11956 if (!hasData) {
11957 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11958 "div",
11959 {
11960 className: clsx_default("dataviews-no-results", {
11961 "is-refreshing": isDelayedLoading
11962 }),
11963 id: tableNoticeId,
11964 children: empty
11965 }
11966 );
11967 }
11968 return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(import_jsx_runtime54.Fragment, { children: [
11969 /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
11970 "table",
11971 {
11972 className: clsx_default("dataviews-view-table", className, {
11973 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
11974 view.layout.density
11975 ),
11976 "has-bulk-actions": hasBulkActions,
11977 "is-refreshing": !isInfiniteScroll && isDelayedLoading
11978 }),
11979 "aria-busy": isLoading,
11980 "aria-describedby": tableNoticeId,
11981 role: isInfiniteScroll ? "feed" : void 0,
11982 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
11983 children: [
11984 /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("colgroup", { children: [
11985 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
11986 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
11987 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11988 "col",
11989 {
11990 className: clsx_default(
11991 `dataviews-view-table__col-${column}`,
11992 {
11993 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1
11994 }
11995 )
11996 },
11997 `col-${column}`
11998 )),
11999 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("col", { className: "dataviews-view-table__col-actions" })
12000 ] }),
12001 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12002 import_components6.Popover,
12003 {
12004 anchor: contextMenuAnchor,
12005 onClose: () => setContextMenuAnchor(null),
12006 placement: "bottom-start",
12007 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(PropertiesSection, { showLabel: false })
12008 }
12009 ),
12010 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12011 "thead",
12012 {
12013 className: clsx_default({
12014 "dataviews-view-table__thead--stuck": isVerticallyScrolled
12015 }),
12016 onContextMenu: handleHeaderContextMenu,
12017 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("tr", { className: "dataviews-view-table__row", children: [
12018 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12019 "th",
12020 {
12021 className: "dataviews-view-table__checkbox-column",
12022 scope: "col",
12023 onContextMenu: handleHeaderContextMenu,
12024 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12025 BulkSelectionCheckbox,
12026 {
12027 selection,
12028 onChangeSelection,
12029 data,
12030 actions,
12031 getItemId
12032 }
12033 )
12034 }
12035 ),
12036 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12037 column_header_menu_default,
12038 {
12039 ref: headerMenuRef(
12040 titleField.id,
12041 0
12042 ),
12043 fieldId: titleField.id,
12044 view,
12045 fields,
12046 onChangeView,
12047 onHide,
12048 setOpenedFilter,
12049 canMove: false,
12050 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
12051 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
12052 }
12053 ) }),
12054 columns.map((column, index2) => {
12055 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
12056 const field = fields.find(
12057 (f2) => f2.id === column
12058 );
12059 const effectiveAlign = getEffectiveAlign(
12060 align,
12061 field?.type
12062 );
12063 const canInsertOrMove = view.layout?.enableMoving ?? true;
12064 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12065 "th",
12066 {
12067 style: {
12068 width,
12069 maxWidth,
12070 minWidth,
12071 textAlign: effectiveAlign
12072 },
12073 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
12074 scope: "col",
12075 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12076 column_header_menu_default,
12077 {
12078 ref: headerMenuRef(column, index2),
12079 fieldId: column,
12080 view,
12081 fields,
12082 onChangeView,
12083 onHide,
12084 setOpenedFilter,
12085 canMove: canInsertOrMove,
12086 canInsertLeft: canInsertOrMove,
12087 canInsertRight: canInsertOrMove
12088 }
12089 )
12090 },
12091 column
12092 );
12093 }),
12094 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12095 "th",
12096 {
12097 className: clsx_default(
12098 "dataviews-view-table__actions-column",
12099 {
12100 "dataviews-view-table__actions-column--sticky": true,
12101 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
12102 }
12103 ),
12104 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n10.__)("Actions") })
12105 }
12106 )
12107 ] })
12108 }
12109 ),
12110 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
12111 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("tbody", { children: [
12112 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12113 "td",
12114 {
12115 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
12116 className: "dataviews-view-table__group-header-cell",
12117 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n10.sprintf)(
12118 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12119 (0, import_i18n10.__)("%1$s: %2$s"),
12120 groupField.label,
12121 groupName
12122 )
12123 }
12124 ) }),
12125 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12126 TableRow,
12127 {
12128 item,
12129 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
12130 hasBulkActions,
12131 actions,
12132 fields,
12133 id: getItemId(item) || index2.toString(),
12134 view,
12135 titleField,
12136 mediaField,
12137 descriptionField,
12138 selection,
12139 getItemId,
12140 onChangeSelection,
12141 onClickItem,
12142 renderItemLink,
12143 isItemClickable,
12144 isActionsColumnSticky: !isHorizontalScrollEnd
12145 },
12146 getItemId(item)
12147 ))
12148 ] }, `group-${groupName}`)
12149 ) : /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("tbody", { children: hasData && data.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12150 TableRow,
12151 {
12152 item,
12153 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
12154 hasBulkActions,
12155 actions,
12156 fields,
12157 id: getItemId(item) || index2.toString(),
12158 view,
12159 titleField,
12160 mediaField,
12161 descriptionField,
12162 selection,
12163 getItemId,
12164 onChangeSelection,
12165 onClickItem,
12166 renderItemLink,
12167 isItemClickable,
12168 isActionsColumnSticky: !isHorizontalScrollEnd,
12169 posinset: isInfiniteScroll ? index2 + 1 : void 0
12170 },
12171 getItemId(item)
12172 )) })
12173 ]
12174 }
12175 ),
12176 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-loading", id: tableNoticeId, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components6.Spinner, {}) }) })
12177 ] });
12178 }
12179 var table_default = ViewTable;
12180
12181 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12182 var import_components9 = __toESM(require_components(), 1);
12183 var import_i18n13 = __toESM(require_i18n(), 1);
12184
12185 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
12186 var import_components8 = __toESM(require_components(), 1);
12187 var import_i18n12 = __toESM(require_i18n(), 1);
12188 var import_compose3 = __toESM(require_compose(), 1);
12189 var import_keycodes2 = __toESM(require_keycodes(), 1);
12190 var import_element37 = __toESM(require_element(), 1);
12191
12192 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
12193 var import_components7 = __toESM(require_components(), 1);
12194 var import_i18n11 = __toESM(require_i18n(), 1);
12195 var import_element34 = __toESM(require_element(), 1);
12196 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
12197 var imageSizes = [
12198 {
12199 value: 120,
12200 breakpoint: 1
12201 },
12202 {
12203 value: 170,
12204 breakpoint: 1
12205 },
12206 {
12207 value: 230,
12208 breakpoint: 1
12209 },
12210 {
12211 value: 290,
12212 breakpoint: 1112
12213 // at minimum image width, 4 images display at this container size
12214 },
12215 {
12216 value: 350,
12217 breakpoint: 1636
12218 // at minimum image width, 6 images display at this container size
12219 },
12220 {
12221 value: 430,
12222 breakpoint: 588
12223 // at minimum image width, 2 images display at this container size
12224 }
12225 ];
12226 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
12227 function useGridColumns() {
12228 const context = (0, import_element34.useContext)(dataviews_context_default);
12229 const view = context.view;
12230 return (0, import_element34.useMemo)(() => {
12231 const containerWidth = context.containerWidth;
12232 const gap = 32;
12233 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
12234 const columns = Math.floor(
12235 (containerWidth + gap) / (previewSize + gap)
12236 );
12237 return Math.max(1, columns);
12238 }, [context.containerWidth, view.layout?.previewSize]);
12239 }
12240
12241 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
12242 var import_element35 = __toESM(require_element(), 1);
12243 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
12244 var GridItems = (0, import_element35.forwardRef)(({ className, previewSize, ...props }, ref) => {
12245 return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
12246 "div",
12247 {
12248 ref,
12249 className: clsx_default("dataviews-view-grid-items", className),
12250 style: {
12251 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
12252 },
12253 ...props
12254 }
12255 );
12256 });
12257
12258 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
12259 var import_element36 = __toESM(require_element(), 1);
12260 function useIntersectionObserver(elementRef, posinset) {
12261 const { intersectionObserver } = (0, import_element36.useContext)(dataviews_context_default);
12262 (0, import_element36.useEffect)(() => {
12263 const element = elementRef.current;
12264 if (!element || posinset === void 0 || !intersectionObserver) {
12265 return;
12266 }
12267 intersectionObserver.observe(element);
12268 return () => {
12269 intersectionObserver.unobserve(element);
12270 };
12271 }, [elementRef, intersectionObserver, posinset]);
12272 }
12273 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
12274 const hasData = !!data?.length;
12275 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
12276 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
12277 }
12278
12279 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
12280 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
12281 var { Badge: WCBadge } = unlock2(import_components8.privateApis);
12282 function chunk(array, size4) {
12283 const chunks = [];
12284 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) {
12285 chunks.push(array.slice(i2, i2 + size4));
12286 }
12287 return chunks;
12288 }
12289 var GridItem = (0, import_element37.forwardRef)(
12290 function GridItem2({
12291 view,
12292 selection,
12293 onChangeSelection,
12294 onClickItem,
12295 isItemClickable,
12296 renderItemLink,
12297 getItemId,
12298 item,
12299 actions,
12300 mediaField,
12301 titleField,
12302 descriptionField,
12303 regularFields,
12304 badgeFields,
12305 hasBulkActions,
12306 config,
12307 posinset,
12308 setsize,
12309 ...props
12310 }, forwardedRef) {
12311 const {
12312 showTitle = true,
12313 showMedia = true,
12314 showDescription = true
12315 } = view;
12316 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
12317 const id = getItemId(item);
12318 const elementRef = (0, import_element37.useRef)(null);
12319 const setRefs = (0, import_element37.useCallback)(
12320 (node) => {
12321 elementRef.current = node;
12322 if (typeof forwardedRef === "function") {
12323 forwardedRef(node);
12324 } else if (forwardedRef) {
12325 forwardedRef.current = node;
12326 }
12327 },
12328 [forwardedRef]
12329 );
12330 useIntersectionObserver(elementRef, posinset);
12331 const instanceId = (0, import_compose3.useInstanceId)(GridItem2);
12332 const isSelected2 = selection.includes(id);
12333 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
12334 const rendersMediaField = showMedia && mediaField?.render;
12335 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12336 mediaField.render,
12337 {
12338 item,
12339 field: mediaField,
12340 config
12341 }
12342 ) : mediaPlaceholder;
12343 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(titleField.render, { item, field: titleField }) : null;
12344 let mediaA11yProps;
12345 let titleA11yProps;
12346 if (isItemClickable(item) && onClickItem) {
12347 if (renderedTitleField) {
12348 mediaA11yProps = {
12349 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
12350 };
12351 titleA11yProps = {
12352 id: `dataviews-view-grid__title-field-${instanceId}`
12353 };
12354 } else {
12355 mediaA11yProps = {
12356 "aria-label": (0, import_i18n12.__)("Navigate to item")
12357 };
12358 }
12359 }
12360 return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
12361 Stack,
12362 {
12363 direction: "column",
12364 ...props,
12365 ref: setRefs,
12366 "aria-setsize": setsize,
12367 "aria-posinset": posinset,
12368 className: clsx_default(
12369 props.className,
12370 "dataviews-view-grid__row__gridcell",
12371 "dataviews-view-grid__card",
12372 {
12373 "is-selected": hasBulkAction && isSelected2
12374 }
12375 ),
12376 onClickCapture: (event) => {
12377 props.onClickCapture?.(event);
12378 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) {
12379 event.stopPropagation();
12380 event.preventDefault();
12381 if (!hasBulkAction) {
12382 return;
12383 }
12384 onChangeSelection(
12385 isSelected2 ? selection.filter(
12386 (itemId) => id !== itemId
12387 ) : [...selection, id]
12388 );
12389 }
12390 },
12391 children: [
12392 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12393 ItemClickWrapper,
12394 {
12395 item,
12396 isItemClickable,
12397 onClickItem,
12398 renderItemLink,
12399 className: clsx_default("dataviews-view-grid__media", {
12400 "dataviews-view-grid__media--placeholder": !rendersMediaField
12401 }),
12402 ...mediaA11yProps,
12403 children: renderedMediaField
12404 }
12405 ),
12406 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12407 DataViewsSelectionCheckbox,
12408 {
12409 item,
12410 selection,
12411 onChangeSelection,
12412 getItemId,
12413 titleField,
12414 disabled: !hasBulkAction
12415 }
12416 ),
12417 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12418 ItemActions,
12419 {
12420 item,
12421 actions,
12422 isCompact: true
12423 }
12424 ) }),
12425 showTitle && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12426 ItemClickWrapper,
12427 {
12428 item,
12429 isItemClickable,
12430 onClickItem,
12431 renderItemLink,
12432 className: "dataviews-view-grid__title-field dataviews-title-field",
12433 ...titleA11yProps,
12434 title: titleField?.getValueFormatted({
12435 item,
12436 field: titleField
12437 }) || void 0,
12438 children: renderedTitleField
12439 }
12440 ) }),
12441 /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(Stack, { direction: "column", gap: "xs", children: [
12442 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12443 descriptionField.render,
12444 {
12445 item,
12446 field: descriptionField
12447 }
12448 ),
12449 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12450 Stack,
12451 {
12452 direction: "row",
12453 className: "dataviews-view-grid__badge-fields",
12454 gap: "sm",
12455 wrap: "wrap",
12456 align: "top",
12457 justify: "flex-start",
12458 children: badgeFields.map((field) => {
12459 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12460 WCBadge,
12461 {
12462 className: "dataviews-view-grid__field-value",
12463 children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12464 field.render,
12465 {
12466 item,
12467 field
12468 }
12469 )
12470 },
12471 field.id
12472 );
12473 })
12474 }
12475 ),
12476 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12477 Stack,
12478 {
12479 direction: "column",
12480 className: "dataviews-view-grid__fields",
12481 gap: "xs",
12482 children: regularFields.map((field) => {
12483 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12484 import_components8.Flex,
12485 {
12486 className: "dataviews-view-grid__field",
12487 gap: 1,
12488 justify: "flex-start",
12489 expanded: true,
12490 style: { height: "auto" },
12491 direction: "row",
12492 children: /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_jsx_runtime57.Fragment, { children: [
12493 /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(tooltip_exports.Root, { children: [
12494 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12495 tooltip_exports.Trigger,
12496 {
12497 render: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_components8.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header })
12498 }
12499 ),
12500 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(tooltip_exports.Popup, { children: field.label })
12501 ] }),
12502 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12503 import_components8.FlexItem,
12504 {
12505 className: "dataviews-view-grid__field-value",
12506 style: { maxHeight: "none" },
12507 children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12508 field.render,
12509 {
12510 item,
12511 field
12512 }
12513 )
12514 }
12515 )
12516 ] })
12517 },
12518 field.id
12519 );
12520 })
12521 }
12522 )
12523 ] })
12524 ]
12525 }
12526 );
12527 }
12528 );
12529 function CompositeGrid({
12530 data,
12531 isInfiniteScroll,
12532 className,
12533 inert,
12534 isLoading,
12535 view,
12536 fields,
12537 selection,
12538 onChangeSelection,
12539 onClickItem,
12540 isItemClickable,
12541 renderItemLink,
12542 getItemId,
12543 actions
12544 }) {
12545 const { paginationInfo, resizeObserverRef } = (0, import_element37.useContext)(dataviews_context_default);
12546 const gridColumns = useGridColumns();
12547 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
12548 const titleField = fields.find(
12549 (field) => field.id === view?.titleField
12550 );
12551 const mediaField = fields.find(
12552 (field) => field.id === view?.mediaField
12553 );
12554 const descriptionField = fields.find(
12555 (field) => field.id === view?.descriptionField
12556 );
12557 const otherFields = view.fields ?? [];
12558 const { regularFields, badgeFields } = otherFields.reduce(
12559 (accumulator, fieldId) => {
12560 const field = fields.find((f2) => f2.id === fieldId);
12561 if (!field) {
12562 return accumulator;
12563 }
12564 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
12565 accumulator[key].push(field);
12566 return accumulator;
12567 },
12568 { regularFields: [], badgeFields: [] }
12569 );
12570 const size4 = "900px";
12571 const totalRows = Math.ceil(data.length / gridColumns);
12572 const placeholdersNeeded = usePlaceholdersNeeded(
12573 data,
12574 isInfiniteScroll,
12575 gridColumns
12576 );
12577 return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_jsx_runtime57.Fragment, {
12578 // Render infinite scroll layout (no rows, feed semantics)
12579 children: [
12580 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
12581 import_components8.Composite,
12582 {
12583 render: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12584 GridItems,
12585 {
12586 className: clsx_default(
12587 "dataviews-view-grid-infinite-scroll",
12588 className,
12589 {
12590 [`has-${view.layout?.density}-density`]: view.layout?.density && [
12591 "compact",
12592 "comfortable"
12593 ].includes(view.layout.density)
12594 }
12595 ),
12596 previewSize: view.layout?.previewSize,
12597 "aria-busy": isLoading,
12598 ref: resizeObserverRef
12599 }
12600 ),
12601 role: "feed",
12602 focusWrap: true,
12603 inert,
12604 children: [
12605 Array.from({ length: placeholdersNeeded }).map(
12606 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12607 import_components8.Composite.Item,
12608 {
12609 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12610 Stack,
12611 {
12612 ...props,
12613 direction: "column",
12614 role: "article",
12615 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
12616 }
12617 ),
12618 "aria-hidden": true,
12619 tabIndex: -1
12620 },
12621 `placeholder-${index2}`
12622 )
12623 ),
12624 data.map((item) => {
12625 const itemId = getItemId(item);
12626 const stablePosition = item.position;
12627 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12628 import_components8.Composite.Item,
12629 {
12630 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12631 GridItem,
12632 {
12633 ...props,
12634 id: itemId,
12635 role: "article",
12636 view,
12637 selection,
12638 onChangeSelection,
12639 onClickItem,
12640 isItemClickable,
12641 renderItemLink,
12642 getItemId,
12643 item,
12644 actions,
12645 mediaField,
12646 titleField,
12647 descriptionField,
12648 regularFields,
12649 badgeFields,
12650 hasBulkActions,
12651 posinset: stablePosition,
12652 setsize: paginationInfo.totalItems,
12653 config: {
12654 sizes: size4
12655 }
12656 }
12657 )
12658 },
12659 itemId
12660 );
12661 })
12662 ]
12663 }
12664 ),
12665 // Render standard grid layout (with rows, grid semantics)
12666 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12667 import_components8.Composite,
12668 {
12669 role: "grid",
12670 className: clsx_default("dataviews-view-grid", className, {
12671 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12672 view.layout.density
12673 )
12674 }),
12675 focusWrap: true,
12676 "aria-busy": isLoading,
12677 "aria-rowcount": totalRows,
12678 ref: resizeObserverRef,
12679 inert,
12680 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12681 import_components8.Composite.Row,
12682 {
12683 render: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12684 "div",
12685 {
12686 role: "row",
12687 "aria-rowindex": i2 + 1,
12688 "aria-label": (0, import_i18n12.sprintf)(
12689 /* translators: %d: The row number in the grid */
12690 (0, import_i18n12.__)("Row %d"),
12691 i2 + 1
12692 ),
12693 className: "dataviews-view-grid__row",
12694 style: {
12695 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
12696 }
12697 }
12698 ),
12699 children: row.map((item) => {
12700 const itemId = getItemId(item);
12701 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12702 import_components8.Composite.Item,
12703 {
12704 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12705 GridItem,
12706 {
12707 ...props,
12708 id: itemId,
12709 role: "gridcell",
12710 view,
12711 selection,
12712 onChangeSelection,
12713 onClickItem,
12714 isItemClickable,
12715 renderItemLink,
12716 getItemId,
12717 item,
12718 actions,
12719 mediaField,
12720 titleField,
12721 descriptionField,
12722 regularFields,
12723 badgeFields,
12724 hasBulkActions,
12725 config: {
12726 sizes: size4
12727 }
12728 }
12729 )
12730 },
12731 itemId
12732 );
12733 })
12734 },
12735 i2
12736 ))
12737 }
12738 )
12739 ]
12740 });
12741 }
12742
12743 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12744 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
12745 function ViewGrid({
12746 actions,
12747 data,
12748 fields,
12749 getItemId,
12750 isLoading,
12751 onChangeSelection,
12752 onClickItem,
12753 isItemClickable,
12754 renderItemLink,
12755 selection,
12756 view,
12757 className,
12758 empty
12759 }) {
12760 const isDelayedLoading = useDelayedLoading(!!isLoading);
12761 const hasData = !!data?.length;
12762 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
12763 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
12764 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12765 if (!hasData) {
12766 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12767 "div",
12768 {
12769 className: clsx_default("dataviews-no-results", {
12770 "is-refreshing": isDelayedLoading
12771 }),
12772 children: empty
12773 }
12774 );
12775 }
12776 const gridProps = {
12777 className: clsx_default(className, {
12778 "is-refreshing": !isInfiniteScroll && isDelayedLoading
12779 }),
12780 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
12781 isLoading,
12782 view,
12783 fields,
12784 selection,
12785 onChangeSelection,
12786 onClickItem,
12787 isItemClickable,
12788 renderItemLink,
12789 getItemId,
12790 actions
12791 };
12792 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, {
12793 // Render multiple groups.
12794 children: [
12795 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
12796 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
12797 Stack,
12798 {
12799 direction: "column",
12800 gap: "sm",
12801 children: [
12802 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n13.sprintf)(
12803 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12804 (0, import_i18n13.__)("%1$s: %2$s"),
12805 groupField.label,
12806 groupName
12807 ) }),
12808 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12809 CompositeGrid,
12810 {
12811 ...gridProps,
12812 data: groupItems,
12813 isInfiniteScroll: false
12814 }
12815 )
12816 ]
12817 },
12818 groupName
12819 )
12820 ) }),
12821 // Render a single grid with all data.
12822 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12823 CompositeGrid,
12824 {
12825 ...gridProps,
12826 data,
12827 isInfiniteScroll: !!isInfiniteScroll
12828 }
12829 ),
12830 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components9.Spinner, {}) })
12831 ]
12832 });
12833 }
12834 var grid_default = ViewGrid;
12835
12836 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
12837 var import_compose4 = __toESM(require_compose(), 1);
12838 var import_components10 = __toESM(require_components(), 1);
12839 var import_element38 = __toESM(require_element(), 1);
12840 var import_i18n14 = __toESM(require_i18n(), 1);
12841 var import_data3 = __toESM(require_data(), 1);
12842 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
12843 var { Menu: Menu3 } = unlock2(import_components10.privateApis);
12844 function generateItemWrapperCompositeId(idPrefix) {
12845 return `${idPrefix}-item-wrapper`;
12846 }
12847 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
12848 return `${idPrefix}-primary-action-${primaryActionId}`;
12849 }
12850 function generateDropdownTriggerCompositeId(idPrefix) {
12851 return `${idPrefix}-dropdown`;
12852 }
12853 function PrimaryActionGridCell({
12854 idPrefix,
12855 primaryAction,
12856 item
12857 }) {
12858 const registry = (0, import_data3.useRegistry)();
12859 const [isModalOpen, setIsModalOpen] = (0, import_element38.useState)(false);
12860 const compositeItemId = generatePrimaryActionCompositeId(
12861 idPrefix,
12862 primaryAction.id
12863 );
12864 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
12865 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12866 import_components10.Composite.Item,
12867 {
12868 id: compositeItemId,
12869 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12870 import_components10.Button,
12871 {
12872 disabled: !!primaryAction.disabled,
12873 accessibleWhenDisabled: true,
12874 text: label,
12875 size: "small",
12876 onClick: () => setIsModalOpen(true)
12877 }
12878 ),
12879 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12880 ActionModal,
12881 {
12882 action: primaryAction,
12883 items: [item],
12884 closeModal: () => setIsModalOpen(false)
12885 }
12886 )
12887 }
12888 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12889 import_components10.Composite.Item,
12890 {
12891 id: compositeItemId,
12892 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12893 import_components10.Button,
12894 {
12895 disabled: !!primaryAction.disabled,
12896 accessibleWhenDisabled: true,
12897 size: "small",
12898 onClick: () => {
12899 primaryAction.callback([item], { registry });
12900 },
12901 children: label
12902 }
12903 )
12904 }
12905 ) }, primaryAction.id);
12906 }
12907 function ListItem({
12908 view,
12909 actions,
12910 idPrefix,
12911 isSelected: isSelected2,
12912 item,
12913 titleField,
12914 mediaField,
12915 descriptionField,
12916 onSelect,
12917 otherFields,
12918 onDropdownTriggerKeyDown,
12919 posinset
12920 }) {
12921 const {
12922 showTitle = true,
12923 showMedia = true,
12924 showDescription = true,
12925 infiniteScrollEnabled
12926 } = view;
12927 const itemRef = (0, import_element38.useRef)(null);
12928 const labelId = `${idPrefix}-label`;
12929 const descriptionId = `${idPrefix}-description`;
12930 const registry = (0, import_data3.useRegistry)();
12931 const [isHovered, setIsHovered] = (0, import_element38.useState)(false);
12932 const [activeModalAction, setActiveModalAction] = (0, import_element38.useState)(
12933 null
12934 );
12935 const handleHover = ({ type }) => {
12936 const isHover = type === "mouseenter";
12937 setIsHovered(isHover);
12938 };
12939 const { paginationInfo } = (0, import_element38.useContext)(dataviews_context_default);
12940 (0, import_element38.useEffect)(() => {
12941 if (isSelected2) {
12942 itemRef.current?.scrollIntoView({
12943 behavior: "auto",
12944 block: "nearest",
12945 inline: "nearest"
12946 });
12947 }
12948 }, [isSelected2]);
12949 const { primaryAction, eligibleActions } = (0, import_element38.useMemo)(() => {
12950 const _eligibleActions = actions.filter(
12951 (action) => !action.isEligible || action.isEligible(item)
12952 );
12953 const _primaryActions = _eligibleActions.filter(
12954 (action) => action.isPrimary
12955 );
12956 return {
12957 primaryAction: _primaryActions[0],
12958 eligibleActions: _eligibleActions
12959 };
12960 }, [actions, item]);
12961 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
12962 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12963 mediaField.render,
12964 {
12965 item,
12966 field: mediaField,
12967 config: { sizes: "52px" }
12968 }
12969 ) }) : null;
12970 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(titleField.render, { item, field: titleField }) : null;
12971 const renderDescription = showDescription && descriptionField?.render;
12972 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
12973 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
12974 Stack,
12975 {
12976 direction: "row",
12977 gap: "md",
12978 className: "dataviews-view-list__item-actions",
12979 children: [
12980 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12981 PrimaryActionGridCell,
12982 {
12983 idPrefix,
12984 primaryAction,
12985 item
12986 }
12987 ),
12988 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("div", { role: "gridcell", children: [
12989 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(Menu3, { placement: "bottom-end", children: [
12990 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12991 Menu3.TriggerButton,
12992 {
12993 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12994 import_components10.Composite.Item,
12995 {
12996 id: generateDropdownTriggerCompositeId(
12997 idPrefix
12998 ),
12999 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13000 import_components10.Button,
13001 {
13002 size: "small",
13003 icon: more_vertical_default,
13004 label: (0, import_i18n14.__)("Actions"),
13005 accessibleWhenDisabled: true,
13006 disabled: !actions.length,
13007 onKeyDown: onDropdownTriggerKeyDown
13008 }
13009 )
13010 }
13011 )
13012 }
13013 ),
13014 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13015 ActionsMenuGroup,
13016 {
13017 actions: eligibleActions,
13018 item,
13019 registry,
13020 setActiveModalAction
13021 }
13022 ) })
13023 ] }),
13024 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13025 ActionModal,
13026 {
13027 action: activeModalAction,
13028 items: [item],
13029 closeModal: () => setActiveModalAction(null)
13030 }
13031 )
13032 ] })
13033 ]
13034 }
13035 );
13036 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13037 import_components10.Composite.Row,
13038 {
13039 ref: itemRef,
13040 render: (
13041 /* aria-posinset breaks Composite.Row if passed to it directly. */
13042 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13043 "div",
13044 {
13045 "aria-posinset": posinset,
13046 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
13047 }
13048 )
13049 ),
13050 role: infiniteScrollEnabled ? "article" : "row",
13051 className: clsx_default({
13052 "is-selected": isSelected2,
13053 "is-hovered": isHovered
13054 }),
13055 onMouseEnter: handleHover,
13056 onMouseLeave: handleHover,
13057 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13058 Stack,
13059 {
13060 direction: "row",
13061 className: "dataviews-view-list__item-wrapper",
13062 children: [
13063 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13064 import_components10.Composite.Item,
13065 {
13066 id: generateItemWrapperCompositeId(idPrefix),
13067 "aria-pressed": isSelected2,
13068 "aria-labelledby": labelId,
13069 "aria-describedby": descriptionId,
13070 className: "dataviews-view-list__item",
13071 onClick: () => onSelect(item)
13072 }
13073 ) }),
13074 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13075 Stack,
13076 {
13077 direction: "row",
13078 gap: "md",
13079 justify: "start",
13080 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
13081 style: { flex: 1, minWidth: 0 },
13082 children: [
13083 renderedMediaField,
13084 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13085 Stack,
13086 {
13087 direction: "column",
13088 gap: "xs",
13089 className: "dataviews-view-list__field-wrapper",
13090 children: [
13091 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(Stack, { direction: "row", align: "center", children: [
13092 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13093 "div",
13094 {
13095 className: "dataviews-title-field dataviews-view-list__title-field",
13096 id: labelId,
13097 children: renderedTitleField
13098 }
13099 ),
13100 usedActions
13101 ] }),
13102 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13103 descriptionField.render,
13104 {
13105 item,
13106 field: descriptionField
13107 }
13108 ) }),
13109 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13110 "div",
13111 {
13112 className: "dataviews-view-list__fields",
13113 id: descriptionId,
13114 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13115 "div",
13116 {
13117 className: "dataviews-view-list__field",
13118 children: [
13119 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13120 VisuallyHidden,
13121 {
13122 className: "dataviews-view-list__field-label",
13123 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", {}),
13124 children: field.label
13125 }
13126 ),
13127 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13128 field.render,
13129 {
13130 item,
13131 field
13132 }
13133 ) })
13134 ]
13135 },
13136 field.id
13137 ))
13138 }
13139 )
13140 ]
13141 }
13142 )
13143 ]
13144 }
13145 )
13146 ]
13147 }
13148 )
13149 }
13150 );
13151 }
13152 function isDefined2(item) {
13153 return !!item;
13154 }
13155 function ViewList(props) {
13156 const {
13157 actions,
13158 data,
13159 fields,
13160 getItemId,
13161 isLoading,
13162 onChangeSelection,
13163 selection,
13164 view,
13165 className,
13166 empty
13167 } = props;
13168 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list");
13169 const isDelayedLoading = useDelayedLoading(!!isLoading);
13170 const selectedItem = data?.findLast(
13171 (item) => selection.includes(getItemId(item))
13172 );
13173 const titleField = fields.find((field) => field.id === view.titleField);
13174 const mediaField = fields.find((field) => field.id === view.mediaField);
13175 const descriptionField = fields.find(
13176 (field) => field.id === view.descriptionField
13177 );
13178 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
13179 const onSelect = (item) => onChangeSelection([getItemId(item)]);
13180 const generateCompositeItemIdPrefix = (0, import_element38.useCallback)(
13181 (item) => `${baseId}-${getItemId(item)}`,
13182 [baseId, getItemId]
13183 );
13184 const isActiveCompositeItem = (0, import_element38.useCallback)(
13185 (item, idToCheck) => {
13186 return idToCheck.startsWith(
13187 generateCompositeItemIdPrefix(item)
13188 );
13189 },
13190 [generateCompositeItemIdPrefix]
13191 );
13192 const [activeCompositeId, setActiveCompositeId] = (0, import_element38.useState)(void 0);
13193 const compositeRef = (0, import_element38.useRef)(null);
13194 (0, import_element38.useEffect)(() => {
13195 if (selectedItem) {
13196 setActiveCompositeId(
13197 generateItemWrapperCompositeId(
13198 generateCompositeItemIdPrefix(selectedItem)
13199 )
13200 );
13201 }
13202 }, [selectedItem, generateCompositeItemIdPrefix]);
13203 const activeItemIndex = data.findIndex(
13204 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
13205 );
13206 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex);
13207 const isActiveIdInList = activeItemIndex !== -1;
13208 const selectCompositeItem = (0, import_element38.useCallback)(
13209 (targetIndex, generateCompositeId) => {
13210 const clampedIndex = Math.min(
13211 data.length - 1,
13212 Math.max(0, targetIndex)
13213 );
13214 if (!data[clampedIndex]) {
13215 return;
13216 }
13217 const itemIdPrefix = generateCompositeItemIdPrefix(
13218 data[clampedIndex]
13219 );
13220 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
13221 setActiveCompositeId(targetCompositeItemId);
13222 if (compositeRef.current?.contains(
13223 compositeRef.current.ownerDocument.activeElement
13224 )) {
13225 document.getElementById(targetCompositeItemId)?.focus();
13226 }
13227 },
13228 [data, generateCompositeItemIdPrefix]
13229 );
13230 (0, import_element38.useEffect)(() => {
13231 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
13232 if (!isActiveIdInList && wasActiveIdInList) {
13233 selectCompositeItem(
13234 previousActiveItemIndex,
13235 generateItemWrapperCompositeId
13236 );
13237 }
13238 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
13239 const onDropdownTriggerKeyDown = (0, import_element38.useCallback)(
13240 (event) => {
13241 if (event.key === "ArrowDown") {
13242 event.preventDefault();
13243 selectCompositeItem(
13244 activeItemIndex + 1,
13245 generateDropdownTriggerCompositeId
13246 );
13247 }
13248 if (event.key === "ArrowUp") {
13249 event.preventDefault();
13250 selectCompositeItem(
13251 activeItemIndex - 1,
13252 generateDropdownTriggerCompositeId
13253 );
13254 }
13255 },
13256 [selectCompositeItem, activeItemIndex]
13257 );
13258 const hasData = !!data?.length;
13259 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13260 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13261 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13262 if (!hasData) {
13263 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13264 "div",
13265 {
13266 className: clsx_default("dataviews-no-results", {
13267 "is-refreshing": isDelayedLoading
13268 }),
13269 children: empty
13270 }
13271 );
13272 }
13273 if (hasData && groupField && dataByGroup) {
13274 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13275 import_components10.Composite,
13276 {
13277 ref: compositeRef,
13278 id: `${baseId}`,
13279 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", {}),
13280 className: "dataviews-view-list__group",
13281 role: "grid",
13282 activeId: activeCompositeId,
13283 setActiveId: setActiveCompositeId,
13284 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13285 Stack,
13286 {
13287 direction: "column",
13288 gap: "lg",
13289 className: clsx_default("dataviews-view-list", className),
13290 children: Array.from(dataByGroup.entries()).map(
13291 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13292 Stack,
13293 {
13294 direction: "column",
13295 gap: "sm",
13296 children: [
13297 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n14.sprintf)(
13298 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
13299 (0, import_i18n14.__)("%1$s: %2$s"),
13300 groupField.label,
13301 groupName
13302 ) }),
13303 groupItems.map((item) => {
13304 const id = generateCompositeItemIdPrefix(item);
13305 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13306 ListItem,
13307 {
13308 view,
13309 idPrefix: id,
13310 actions,
13311 item,
13312 isSelected: item === selectedItem,
13313 onSelect,
13314 mediaField,
13315 titleField,
13316 descriptionField,
13317 otherFields,
13318 onDropdownTriggerKeyDown
13319 },
13320 id
13321 );
13322 })
13323 ]
13324 },
13325 groupName
13326 )
13327 )
13328 }
13329 )
13330 }
13331 );
13332 }
13333 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, { children: [
13334 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13335 import_components10.Composite,
13336 {
13337 ref: compositeRef,
13338 id: baseId,
13339 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", {}),
13340 className: clsx_default("dataviews-view-list", className, {
13341 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
13342 view.layout.density
13343 ),
13344 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13345 }),
13346 role: view.infiniteScrollEnabled ? "feed" : "grid",
13347 activeId: activeCompositeId,
13348 setActiveId: setActiveCompositeId,
13349 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
13350 children: data.map((item, index2) => {
13351 const id = generateCompositeItemIdPrefix(item);
13352 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13353 ListItem,
13354 {
13355 view,
13356 idPrefix: id,
13357 actions,
13358 item,
13359 isSelected: item === selectedItem,
13360 onSelect,
13361 mediaField,
13362 titleField,
13363 descriptionField,
13364 otherFields,
13365 onDropdownTriggerKeyDown,
13366 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13367 },
13368 id
13369 );
13370 })
13371 }
13372 ),
13373 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components10.Spinner, {}) })
13374 ] });
13375 }
13376
13377 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13378 var import_components11 = __toESM(require_components(), 1);
13379
13380 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
13381 var import_i18n15 = __toESM(require_i18n(), 1);
13382 var import_element39 = __toESM(require_element(), 1);
13383 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
13384 function ActivityGroup({
13385 groupName,
13386 groupData,
13387 groupField,
13388 showLabel = true,
13389 children
13390 }) {
13391 const groupHeader = showLabel ? (0, import_element39.createInterpolateElement)(
13392 // translators: %s: The label of the field e.g. "Status".
13393 (0, import_i18n15.sprintf)((0, import_i18n15.__)("%s: <groupName />"), groupField.label).trim(),
13394 {
13395 groupName: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13396 groupField.render,
13397 {
13398 item: groupData[0],
13399 field: groupField
13400 }
13401 )
13402 }
13403 ) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(groupField.render, { item: groupData[0], field: groupField });
13404 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13405 Stack,
13406 {
13407 direction: "column",
13408 className: "dataviews-view-activity__group",
13409 children: [
13410 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
13411 children
13412 ]
13413 },
13414 groupName
13415 );
13416 }
13417
13418 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
13419 var import_element40 = __toESM(require_element(), 1);
13420 var import_data4 = __toESM(require_data(), 1);
13421 var import_compose5 = __toESM(require_compose(), 1);
13422 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
13423 function ActivityItem(props) {
13424 const {
13425 view,
13426 actions,
13427 item,
13428 titleField,
13429 mediaField,
13430 descriptionField,
13431 otherFields,
13432 posinset,
13433 onClickItem,
13434 renderItemLink,
13435 isItemClickable
13436 } = props;
13437 const {
13438 showTitle = true,
13439 showMedia = true,
13440 showDescription = true,
13441 infiniteScrollEnabled
13442 } = view;
13443 const itemRef = (0, import_element40.useRef)(null);
13444 const registry = (0, import_data4.useRegistry)();
13445 const { paginationInfo } = (0, import_element40.useContext)(dataviews_context_default);
13446 const { primaryActions, eligibleActions } = (0, import_element40.useMemo)(() => {
13447 const _eligibleActions = actions.filter(
13448 (action) => !action.isEligible || action.isEligible(item)
13449 );
13450 const _primaryActions = _eligibleActions.filter(
13451 (action) => action.isPrimary
13452 );
13453 return {
13454 primaryActions: _primaryActions,
13455 eligibleActions: _eligibleActions
13456 };
13457 }, [actions, item]);
13458 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
13459 const density = view.layout?.density ?? "balanced";
13460 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13461 mediaField.render,
13462 {
13463 item,
13464 field: mediaField,
13465 config: {
13466 sizes: density === "comfortable" ? "32px" : "24px"
13467 }
13468 }
13469 ) : null;
13470 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13471 "span",
13472 {
13473 className: "dataviews-view-activity__item-bullet",
13474 "aria-hidden": "true"
13475 }
13476 ) });
13477 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(titleField.render, { item, field: titleField }) : null;
13478 const verticalGap = (0, import_element40.useMemo)(() => {
13479 switch (density) {
13480 case "comfortable":
13481 return "md";
13482 default:
13483 return "sm";
13484 }
13485 }, [density]);
13486 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13487 "div",
13488 {
13489 ref: itemRef,
13490 role: infiniteScrollEnabled ? "article" : void 0,
13491 "aria-posinset": posinset,
13492 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
13493 className: clsx_default(
13494 "dataviews-view-activity__item",
13495 density === "compact" && "is-compact",
13496 density === "balanced" && "is-balanced",
13497 density === "comfortable" && "is-comfortable"
13498 ),
13499 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
13500 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13501 Stack,
13502 {
13503 direction: "column",
13504 gap: "xs",
13505 align: "center",
13506 className: "dataviews-view-activity__item-type",
13507 children: renderedMediaField
13508 }
13509 ),
13510 /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
13511 Stack,
13512 {
13513 direction: "column",
13514 gap: verticalGap,
13515 align: "flex-start",
13516 className: "dataviews-view-activity__item-content",
13517 children: [
13518 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13519 ItemClickWrapper,
13520 {
13521 item,
13522 isItemClickable,
13523 onClickItem,
13524 renderItemLink,
13525 className: "dataviews-view-activity__item-title",
13526 children: renderedTitleField
13527 }
13528 ),
13529 showDescription && descriptionField && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13530 descriptionField.render,
13531 {
13532 item,
13533 field: descriptionField
13534 }
13535 ) }),
13536 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
13537 "div",
13538 {
13539 className: "dataviews-view-activity__item-field",
13540 children: [
13541 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13542 VisuallyHidden,
13543 {
13544 className: "dataviews-view-activity__item-field-label",
13545 render: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("span", {}),
13546 children: field.label
13547 }
13548 ),
13549 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13550 field.render,
13551 {
13552 item,
13553 field
13554 }
13555 ) })
13556 ]
13557 },
13558 field.id
13559 )) }),
13560 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13561 PrimaryActions,
13562 {
13563 item,
13564 actions: primaryActions,
13565 registry,
13566 buttonVariant: "secondary"
13567 }
13568 )
13569 ]
13570 }
13571 ),
13572 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
13573 // there if there are any actions at all.
13574 isMobileViewport && // At the same time, only show the menu if there are actions to show.
13575 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13576 ItemActions,
13577 {
13578 item,
13579 actions: eligibleActions,
13580 isCompact: true
13581 }
13582 ) })
13583 ] })
13584 }
13585 );
13586 }
13587 var activity_item_default = ActivityItem;
13588
13589 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
13590 var import_react10 = __toESM(require_react(), 1);
13591 function isDefined3(item) {
13592 return !!item;
13593 }
13594 function ActivityItems(props) {
13595 const { data, fields, getItemId, view } = props;
13596 const titleField = fields.find((field) => field.id === view.titleField);
13597 const mediaField = fields.find((field) => field.id === view.mediaField);
13598 const descriptionField = fields.find(
13599 (field) => field.id === view.descriptionField
13600 );
13601 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
13602 return data.map((item, index2) => {
13603 return /* @__PURE__ */ (0, import_react10.createElement)(
13604 activity_item_default,
13605 {
13606 ...props,
13607 key: getItemId(item),
13608 item,
13609 mediaField,
13610 titleField,
13611 descriptionField,
13612 otherFields,
13613 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13614 }
13615 );
13616 });
13617 }
13618
13619 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13620 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
13621 function ViewActivity(props) {
13622 const { empty, data, fields, isLoading, view, className } = props;
13623 const isDelayedLoading = useDelayedLoading(!!isLoading);
13624 const hasData = !!data?.length;
13625 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13626 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13627 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13628 if (!hasData) {
13629 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13630 "div",
13631 {
13632 className: clsx_default("dataviews-no-results", {
13633 "is-refreshing": isDelayedLoading
13634 }),
13635 children: empty
13636 }
13637 );
13638 }
13639 const isInert = !isInfiniteScroll && !!isLoading;
13640 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
13641 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13642 });
13643 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
13644 if (hasData && groupField && dataByGroup) {
13645 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13646 Stack,
13647 {
13648 direction: "column",
13649 gap: "sm",
13650 className: wrapperClassName,
13651 inert: isInert ? "true" : void 0,
13652 children: groupedEntries.map(
13653 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13654 ActivityGroup,
13655 {
13656 groupName,
13657 groupData,
13658 groupField,
13659 showLabel: view.groupBy?.showLabel !== false,
13660 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13661 ActivityItems,
13662 {
13663 ...props,
13664 data: groupData
13665 }
13666 )
13667 },
13668 groupName
13669 )
13670 )
13671 }
13672 );
13673 }
13674 return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_jsx_runtime62.Fragment, { children: [
13675 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13676 "div",
13677 {
13678 className: wrapperClassName,
13679 role: view.infiniteScrollEnabled ? "feed" : void 0,
13680 inert: isInert ? "true" : void 0,
13681 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(ActivityItems, { ...props })
13682 }
13683 ),
13684 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_components11.Spinner, {}) })
13685 ] });
13686 }
13687
13688 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13689 var import_components14 = __toESM(require_components(), 1);
13690 var import_i18n18 = __toESM(require_i18n(), 1);
13691 var import_compose6 = __toESM(require_compose(), 1);
13692 var import_element43 = __toESM(require_element(), 1);
13693
13694 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13695 var import_components13 = __toESM(require_components(), 1);
13696 var import_data5 = __toESM(require_data(), 1);
13697 var import_element42 = __toESM(require_element(), 1);
13698 var import_i18n17 = __toESM(require_i18n(), 1);
13699
13700 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
13701 var import_components12 = __toESM(require_components(), 1);
13702 var import_element41 = __toESM(require_element(), 1);
13703 var import_i18n16 = __toESM(require_i18n(), 1);
13704 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
13705 function DataViewsPagination() {
13706 const {
13707 view,
13708 onChangeView,
13709 paginationInfo: { totalItems = 0, totalPages }
13710 } = (0, import_element41.useContext)(dataviews_context_default);
13711 if (!totalItems || !totalPages || view.infiniteScrollEnabled) {
13712 return null;
13713 }
13714 const currentPage = view.page ?? 1;
13715 const pageSelectOptions = Array.from(Array(totalPages)).map(
13716 (_, i2) => {
13717 const page = i2 + 1;
13718 return {
13719 value: page.toString(),
13720 label: page.toString(),
13721 "aria-label": currentPage === page ? (0, import_i18n16.sprintf)(
13722 // translators: 1: current page number. 2: total number of pages.
13723 (0, import_i18n16.__)("Page %1$d of %2$d"),
13724 currentPage,
13725 totalPages
13726 ) : page.toString()
13727 };
13728 }
13729 );
13730 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(
13731 Stack,
13732 {
13733 direction: "row",
13734 className: "dataviews-pagination",
13735 justify: "end",
13736 align: "center",
13737 gap: "xl",
13738 children: [
13739 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13740 Stack,
13741 {
13742 direction: "row",
13743 justify: "flex-start",
13744 align: "center",
13745 gap: "xs",
13746 className: "dataviews-pagination__page-select",
13747 children: (0, import_element41.createInterpolateElement)(
13748 (0, import_i18n16.sprintf)(
13749 // translators: 1: Current page number, 2: Total number of pages.
13750 (0, import_i18n16._x)(
13751 "<div>Page</div>%1$s<div>of %2$d</div>",
13752 "paging"
13753 ),
13754 "<CurrentPage />",
13755 totalPages
13756 ),
13757 {
13758 div: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { "aria-hidden": true }),
13759 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
13760 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13761 import_components12.SelectControl,
13762 {
13763 "aria-label": (0, import_i18n16.__)("Current page"),
13764 value: currentPage.toString(),
13765 options: pageSelectOptions,
13766 onChange: (newValue) => {
13767 onChangeView({
13768 ...view,
13769 page: +newValue
13770 });
13771 },
13772 size: "small",
13773 variant: "minimal"
13774 }
13775 )
13776 }
13777 )
13778 }
13779 ),
13780 /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
13781 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13782 import_components12.Button,
13783 {
13784 onClick: () => onChangeView({
13785 ...view,
13786 page: currentPage - 1
13787 }),
13788 disabled: currentPage === 1,
13789 accessibleWhenDisabled: true,
13790 label: (0, import_i18n16.__)("Previous page"),
13791 icon: (0, import_i18n16.isRTL)() ? next_default : previous_default,
13792 showTooltip: true,
13793 size: "compact",
13794 tooltipPosition: "top"
13795 }
13796 ),
13797 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13798 import_components12.Button,
13799 {
13800 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
13801 disabled: currentPage >= totalPages,
13802 accessibleWhenDisabled: true,
13803 label: (0, import_i18n16.__)("Next page"),
13804 icon: (0, import_i18n16.isRTL)() ? previous_default : next_default,
13805 showTooltip: true,
13806 size: "compact",
13807 tooltipPosition: "top"
13808 }
13809 )
13810 ] })
13811 ]
13812 }
13813 );
13814 }
13815 var dataviews_pagination_default = (0, import_element41.memo)(DataViewsPagination);
13816
13817 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13818 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
13819 function useIsMultiselectPicker(actions) {
13820 return (0, import_element42.useMemo)(() => {
13821 return actions?.every((action) => action.supportsBulk);
13822 }, [actions]);
13823 }
13824
13825 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13826 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
13827 var { Badge: WCBadge2 } = unlock2(import_components14.privateApis);
13828 function GridItem3({
13829 view,
13830 multiselect,
13831 selection,
13832 onChangeSelection,
13833 getItemId,
13834 item,
13835 mediaField,
13836 titleField,
13837 descriptionField,
13838 regularFields,
13839 badgeFields,
13840 config,
13841 posinset,
13842 setsize
13843 }) {
13844 const { showTitle = true, showMedia = true, showDescription = true } = view;
13845 const id = getItemId(item);
13846 const elementRef = (0, import_element43.useRef)(null);
13847 const isSelected2 = selection.includes(id);
13848 useIntersectionObserver(elementRef, posinset);
13849 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13850 mediaField.render,
13851 {
13852 item,
13853 field: mediaField,
13854 config
13855 }
13856 ) : null;
13857 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(titleField.render, { item, field: titleField }) : null;
13858 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
13859 import_components14.Composite.Item,
13860 {
13861 ref: elementRef,
13862 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n18.__)("(no title)") : void 0,
13863 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(Stack, { direction: "column", children, ...props }),
13864 role: "option",
13865 "aria-posinset": posinset,
13866 "aria-setsize": setsize,
13867 className: clsx_default("dataviews-view-picker-grid__card", {
13868 "is-selected": isSelected2
13869 }),
13870 "aria-selected": isSelected2,
13871 onClick: () => {
13872 if (isSelected2) {
13873 onChangeSelection(
13874 selection.filter((itemId) => id !== itemId)
13875 );
13876 } else {
13877 const newSelection = multiselect ? [...selection, id] : [id];
13878 onChangeSelection(newSelection);
13879 }
13880 },
13881 children: [
13882 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
13883 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13884 DataViewsSelectionCheckbox,
13885 {
13886 item,
13887 selection,
13888 onChangeSelection,
13889 getItemId,
13890 titleField,
13891 disabled: false,
13892 "aria-hidden": true,
13893 tabIndex: -1
13894 }
13895 ),
13896 showTitle && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13897 Stack,
13898 {
13899 direction: "row",
13900 justify: "space-between",
13901 className: "dataviews-view-picker-grid__title-actions",
13902 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
13903 }
13904 ),
13905 /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(Stack, { direction: "column", gap: "xs", children: [
13906 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13907 descriptionField.render,
13908 {
13909 item,
13910 field: descriptionField
13911 }
13912 ),
13913 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13914 Stack,
13915 {
13916 direction: "row",
13917 className: "dataviews-view-picker-grid__badge-fields",
13918 gap: "sm",
13919 wrap: "wrap",
13920 align: "top",
13921 justify: "flex-start",
13922 children: badgeFields.map((field) => {
13923 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13924 WCBadge2,
13925 {
13926 className: "dataviews-view-picker-grid__field-value",
13927 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13928 field.render,
13929 {
13930 item,
13931 field
13932 }
13933 )
13934 },
13935 field.id
13936 );
13937 })
13938 }
13939 ),
13940 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13941 Stack,
13942 {
13943 direction: "column",
13944 className: "dataviews-view-picker-grid__fields",
13945 gap: "xs",
13946 children: regularFields.map((field) => {
13947 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13948 import_components14.Flex,
13949 {
13950 className: "dataviews-view-picker-grid__field",
13951 gap: 1,
13952 justify: "flex-start",
13953 expanded: true,
13954 style: { height: "auto" },
13955 direction: "row",
13956 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_jsx_runtime65.Fragment, { children: [
13957 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_components14.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
13958 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13959 import_components14.FlexItem,
13960 {
13961 className: "dataviews-view-picker-grid__field-value",
13962 style: { maxHeight: "none" },
13963 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13964 field.render,
13965 {
13966 item,
13967 field
13968 }
13969 )
13970 }
13971 )
13972 ] })
13973 },
13974 field.id
13975 );
13976 })
13977 }
13978 )
13979 ] })
13980 ]
13981 },
13982 id
13983 );
13984 }
13985 function GridGroup({
13986 groupName,
13987 groupField,
13988 showLabel = true,
13989 children
13990 }) {
13991 const headerId = (0, import_compose6.useInstanceId)(
13992 GridGroup,
13993 "dataviews-view-picker-grid-group__header"
13994 );
13995 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
13996 Stack,
13997 {
13998 direction: "column",
13999 gap: "sm",
14000 role: "group",
14001 "aria-labelledby": headerId,
14002 children: [
14003 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14004 "h3",
14005 {
14006 className: "dataviews-view-picker-grid-group__header",
14007 id: headerId,
14008 children: showLabel ? (0, import_i18n18.sprintf)(
14009 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14010 (0, import_i18n18.__)("%1$s: %2$s"),
14011 groupField.label,
14012 groupName
14013 ) : groupName
14014 }
14015 ),
14016 children
14017 ]
14018 },
14019 groupName
14020 );
14021 }
14022 function ViewPickerGrid({
14023 actions,
14024 data,
14025 fields,
14026 getItemId,
14027 isLoading,
14028 onChangeSelection,
14029 selection,
14030 view,
14031 className,
14032 empty
14033 }) {
14034 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element43.useContext)(dataviews_context_default);
14035 const titleField = fields.find(
14036 (field) => field.id === view?.titleField
14037 );
14038 const mediaField = fields.find(
14039 (field) => field.id === view?.mediaField
14040 );
14041 const descriptionField = fields.find(
14042 (field) => field.id === view?.descriptionField
14043 );
14044 const otherFields = view.fields ?? [];
14045 const { regularFields, badgeFields } = otherFields.reduce(
14046 (accumulator, fieldId) => {
14047 const field = fields.find((f2) => f2.id === fieldId);
14048 if (!field) {
14049 return accumulator;
14050 }
14051 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
14052 accumulator[key].push(field);
14053 return accumulator;
14054 },
14055 { regularFields: [], badgeFields: [] }
14056 );
14057 const hasData = !!data?.length;
14058 const usedPreviewSize = view.layout?.previewSize;
14059 const isMultiselect = useIsMultiselectPicker(actions);
14060 const size4 = "900px";
14061 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14062 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14063 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
14064 const currentPage = view?.page ?? 1;
14065 const perPage = view?.perPage ?? 0;
14066 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
14067 const gridColumns = useGridColumns();
14068 const placeholdersNeeded = usePlaceholdersNeeded(
14069 data,
14070 isInfiniteScroll,
14071 gridColumns
14072 );
14073 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_jsx_runtime65.Fragment, {
14074 // Render multiple groups.
14075 children: [
14076 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14077 import_components14.Composite,
14078 {
14079 virtualFocus: true,
14080 orientation: "horizontal",
14081 role: "listbox",
14082 "aria-multiselectable": isMultiselect,
14083 className: clsx_default(
14084 "dataviews-view-picker-grid",
14085 className,
14086 {
14087 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14088 view.layout.density
14089 )
14090 }
14091 ),
14092 "aria-label": itemListLabel,
14093 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14094 Stack,
14095 {
14096 direction: "column",
14097 gap: "lg",
14098 children,
14099 ...props
14100 }
14101 ),
14102 children: Array.from(dataByGroup.entries()).map(
14103 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14104 GridGroup,
14105 {
14106 groupName,
14107 groupField,
14108 showLabel: view.groupBy?.showLabel !== false,
14109 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14110 GridItems,
14111 {
14112 previewSize: usedPreviewSize,
14113 style: {
14114 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
14115 },
14116 "aria-busy": isLoading,
14117 ref: resizeObserverRef,
14118 children: groupItems.map((item) => {
14119 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
14120 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14121 GridItem3,
14122 {
14123 view,
14124 multiselect: isMultiselect,
14125 selection,
14126 onChangeSelection,
14127 getItemId,
14128 item,
14129 mediaField,
14130 titleField,
14131 descriptionField,
14132 regularFields,
14133 badgeFields,
14134 config: {
14135 sizes: size4
14136 },
14137 posinset: posInSet,
14138 setsize: setSize
14139 },
14140 getItemId(item)
14141 );
14142 })
14143 }
14144 )
14145 },
14146 groupName
14147 )
14148 )
14149 }
14150 ),
14151 // Render a single grid with all data.
14152 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
14153 import_components14.Composite,
14154 {
14155 render: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14156 GridItems,
14157 {
14158 className: clsx_default(
14159 "dataviews-view-picker-grid",
14160 className,
14161 {
14162 [`has-${view.layout?.density}-density`]: view.layout?.density && [
14163 "compact",
14164 "comfortable"
14165 ].includes(view.layout.density)
14166 }
14167 ),
14168 previewSize: usedPreviewSize,
14169 "aria-busy": isLoading,
14170 ref: resizeObserverRef
14171 }
14172 ),
14173 virtualFocus: true,
14174 orientation: "horizontal",
14175 role: "listbox",
14176 "aria-multiselectable": isMultiselect,
14177 "aria-label": itemListLabel,
14178 children: [
14179 Array.from({ length: placeholdersNeeded }).map(
14180 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14181 import_components14.Composite.Item,
14182 {
14183 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14184 Stack,
14185 {
14186 direction: "column",
14187 children,
14188 ...props
14189 }
14190 ),
14191 role: "option",
14192 "aria-hidden": true,
14193 tabIndex: -1,
14194 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
14195 },
14196 `placeholder-${index2}`
14197 )
14198 ),
14199 data.map((item) => {
14200 const posinset = item.position;
14201 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14202 GridItem3,
14203 {
14204 view,
14205 multiselect: isMultiselect,
14206 selection,
14207 onChangeSelection,
14208 getItemId,
14209 item,
14210 mediaField,
14211 titleField,
14212 descriptionField,
14213 regularFields,
14214 badgeFields,
14215 config: {
14216 sizes: size4
14217 },
14218 posinset,
14219 setsize: setSize
14220 },
14221 getItemId(item)
14222 );
14223 })
14224 ]
14225 }
14226 ),
14227 // Render empty state.
14228 !hasData && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14229 "div",
14230 {
14231 className: clsx_default({
14232 "dataviews-loading": isLoading,
14233 "dataviews-no-results": !isLoading
14234 }),
14235 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_components14.Spinner, {}) }) : empty
14236 }
14237 ),
14238 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_components14.Spinner, {}) })
14239 ]
14240 });
14241 }
14242 var picker_grid_default = ViewPickerGrid;
14243
14244 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
14245 var import_i18n19 = __toESM(require_i18n(), 1);
14246 var import_components15 = __toESM(require_components(), 1);
14247 var import_element44 = __toESM(require_element(), 1);
14248 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
14249 function TableColumnField2({
14250 item,
14251 fields,
14252 column,
14253 align
14254 }) {
14255 const field = fields.find((f2) => f2.id === column);
14256 if (!field) {
14257 return null;
14258 }
14259 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
14260 "dataviews-view-table__cell-align-end": align === "end",
14261 "dataviews-view-table__cell-align-center": align === "center"
14262 });
14263 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(field.render, { item, field }) });
14264 }
14265 function TableRow2({
14266 item,
14267 fields,
14268 id,
14269 view,
14270 titleField,
14271 mediaField,
14272 descriptionField,
14273 selection,
14274 getItemId,
14275 onChangeSelection,
14276 multiselect,
14277 posinset
14278 }) {
14279 const { paginationInfo } = (0, import_element44.useContext)(dataviews_context_default);
14280 const isSelected2 = selection.includes(id);
14281 const [isHovered, setIsHovered] = (0, import_element44.useState)(false);
14282 const elementRef = (0, import_element44.useRef)(null);
14283 useIntersectionObserver(elementRef, posinset);
14284 const {
14285 showTitle = true,
14286 showMedia = true,
14287 showDescription = true,
14288 infiniteScrollEnabled
14289 } = view;
14290 const handleMouseEnter = () => {
14291 setIsHovered(true);
14292 };
14293 const handleMouseLeave = () => {
14294 setIsHovered(false);
14295 };
14296 const columns = view.fields ?? [];
14297 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14298 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14299 import_components15.Composite.Item,
14300 {
14301 ref: elementRef,
14302 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14303 "tr",
14304 {
14305 className: clsx_default("dataviews-view-table__row", {
14306 "is-selected": isSelected2,
14307 "is-hovered": isHovered
14308 }),
14309 onMouseEnter: handleMouseEnter,
14310 onMouseLeave: handleMouseLeave,
14311 children,
14312 ...props
14313 }
14314 ),
14315 "aria-selected": isSelected2,
14316 "aria-setsize": paginationInfo.totalItems || void 0,
14317 "aria-posinset": posinset,
14318 role: infiniteScrollEnabled ? "article" : "option",
14319 onMouseDown: (event) => {
14320 if (event.button !== 0) {
14321 return;
14322 }
14323 event.currentTarget.parentElement?.focus({
14324 preventScroll: true
14325 });
14326 },
14327 onClick: () => {
14328 if (isSelected2) {
14329 onChangeSelection(
14330 selection.filter((itemId) => id !== itemId)
14331 );
14332 } else {
14333 const newSelection = multiselect ? [...selection, id] : [id];
14334 onChangeSelection(newSelection);
14335 }
14336 },
14337 children: [
14338 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14339 "td",
14340 {
14341 className: "dataviews-view-table__checkbox-column",
14342 role: "presentation",
14343 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14344 DataViewsSelectionCheckbox,
14345 {
14346 item,
14347 selection,
14348 onChangeSelection,
14349 getItemId,
14350 titleField,
14351 disabled: false,
14352 "aria-hidden": true,
14353 tabIndex: -1
14354 }
14355 ) })
14356 }
14357 ),
14358 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14359 "td",
14360 {
14361 role: "presentation",
14362 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14363 column_primary_default,
14364 {
14365 item,
14366 titleField: showTitle ? titleField : void 0,
14367 mediaField: showMedia ? mediaField : void 0,
14368 descriptionField: showDescription ? descriptionField : void 0,
14369 isItemClickable: () => false
14370 }
14371 )
14372 }
14373 ),
14374 columns.map((column) => {
14375 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14376 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14377 "td",
14378 {
14379 style: {
14380 width,
14381 maxWidth,
14382 minWidth
14383 },
14384 role: "presentation",
14385 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14386 TableColumnField2,
14387 {
14388 fields,
14389 item,
14390 column,
14391 align
14392 }
14393 )
14394 },
14395 column
14396 );
14397 })
14398 ]
14399 },
14400 id
14401 );
14402 }
14403 function ViewPickerTable({
14404 actions,
14405 data,
14406 fields,
14407 getItemId,
14408 isLoading = false,
14409 onChangeView,
14410 onChangeSelection,
14411 selection,
14412 setOpenedFilter,
14413 view,
14414 className,
14415 empty
14416 }) {
14417 const headerMenuRefs = (0, import_element44.useRef)(/* @__PURE__ */ new Map());
14418 const headerMenuToFocusRef = (0, import_element44.useRef)(void 0);
14419 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element44.useState)();
14420 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
14421 (0, import_element44.useEffect)(() => {
14422 if (headerMenuToFocusRef.current) {
14423 headerMenuToFocusRef.current.focus();
14424 headerMenuToFocusRef.current = void 0;
14425 }
14426 });
14427 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14428 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14429 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
14430 const tableNoticeId = (0, import_element44.useId)();
14431 if (nextHeaderMenuToFocus) {
14432 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
14433 setNextHeaderMenuToFocus(void 0);
14434 return;
14435 }
14436 const onHide = (field) => {
14437 const hidden = headerMenuRefs.current.get(field.id);
14438 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
14439 setNextHeaderMenuToFocus(fallback?.node);
14440 };
14441 const hasData = !!data?.length;
14442 const titleField = fields.find((field) => field.id === view.titleField);
14443 const mediaField = fields.find((field) => field.id === view.mediaField);
14444 const descriptionField = fields.find(
14445 (field) => field.id === view.descriptionField
14446 );
14447 const { showTitle = true, showMedia = true, showDescription = true } = view;
14448 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14449 const columns = view.fields ?? [];
14450 const headerMenuRef = (column, index2) => (node) => {
14451 if (node) {
14452 headerMenuRefs.current.set(column, {
14453 node,
14454 fallback: columns[index2 > 0 ? index2 - 1 : 1]
14455 });
14456 } else {
14457 headerMenuRefs.current.delete(column);
14458 }
14459 };
14460 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
14461 /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14462 "table",
14463 {
14464 className: clsx_default(
14465 "dataviews-view-table",
14466 "dataviews-view-picker-table",
14467 className,
14468 {
14469 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14470 view.layout.density
14471 )
14472 }
14473 ),
14474 "aria-busy": isLoading,
14475 "aria-describedby": tableNoticeId,
14476 role: isInfiniteScroll ? "feed" : "listbox",
14477 children: [
14478 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14479 "tr",
14480 {
14481 className: "dataviews-view-table__row",
14482 role: "presentation",
14483 children: [
14484 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14485 BulkSelectionCheckbox,
14486 {
14487 selection,
14488 onChangeSelection,
14489 data,
14490 actions,
14491 getItemId,
14492 disableSelectAll: isInfiniteScroll
14493 }
14494 ) }),
14495 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14496 column_header_menu_default,
14497 {
14498 ref: headerMenuRef(
14499 titleField.id,
14500 0
14501 ),
14502 fieldId: titleField.id,
14503 view,
14504 fields,
14505 onChangeView,
14506 onHide,
14507 setOpenedFilter,
14508 canMove: false
14509 }
14510 ) }),
14511 columns.map((column, index2) => {
14512 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14513 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14514 "th",
14515 {
14516 style: {
14517 width,
14518 maxWidth,
14519 minWidth,
14520 textAlign: align
14521 },
14522 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
14523 scope: "col",
14524 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14525 column_header_menu_default,
14526 {
14527 ref: headerMenuRef(column, index2),
14528 fieldId: column,
14529 view,
14530 fields,
14531 onChangeView,
14532 onHide,
14533 setOpenedFilter,
14534 canMove: view.layout?.enableMoving ?? true
14535 }
14536 )
14537 },
14538 column
14539 );
14540 })
14541 ]
14542 }
14543 ) }),
14544 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
14545 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14546 import_components15.Composite,
14547 {
14548 virtualFocus: true,
14549 orientation: "vertical",
14550 render: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("tbody", { role: "group" }),
14551 children: [
14552 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14553 "tr",
14554 {
14555 className: "dataviews-view-table__group-header-row",
14556 role: "presentation",
14557 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14558 "td",
14559 {
14560 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
14561 className: "dataviews-view-table__group-header-cell",
14562 role: "presentation",
14563 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n19.sprintf)(
14564 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14565 (0, import_i18n19.__)("%1$s: %2$s"),
14566 groupField.label,
14567 groupName
14568 )
14569 }
14570 )
14571 }
14572 ),
14573 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14574 TableRow2,
14575 {
14576 item,
14577 fields,
14578 id: getItemId(item) || index2.toString(),
14579 view,
14580 titleField,
14581 mediaField,
14582 descriptionField,
14583 selection,
14584 getItemId,
14585 onChangeSelection,
14586 multiselect: isMultiselect
14587 },
14588 getItemId(item)
14589 ))
14590 ]
14591 },
14592 `group-${groupName}`
14593 )
14594 ) : /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14595 import_components15.Composite,
14596 {
14597 render: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("tbody", { role: "presentation" }),
14598 virtualFocus: true,
14599 orientation: "vertical",
14600 children: hasData && data.map((item, index2) => {
14601 const itemId = getItemId(item);
14602 const posinset = item.position;
14603 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14604 TableRow2,
14605 {
14606 item,
14607 fields,
14608 id: itemId || index2.toString(),
14609 view,
14610 titleField,
14611 mediaField,
14612 descriptionField,
14613 selection,
14614 getItemId,
14615 onChangeSelection,
14616 multiselect: isMultiselect,
14617 posinset
14618 },
14619 itemId
14620 );
14621 })
14622 }
14623 )
14624 ]
14625 }
14626 ),
14627 /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14628 "div",
14629 {
14630 className: clsx_default({
14631 "dataviews-loading": isLoading,
14632 "dataviews-no-results": !hasData && !isLoading
14633 }),
14634 id: tableNoticeId,
14635 children: [
14636 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components15.Spinner, {}) }) : empty),
14637 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components15.Spinner, {}) })
14638 ]
14639 }
14640 )
14641 ] });
14642 }
14643 var picker_table_default = ViewPickerTable;
14644
14645 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
14646 var import_components16 = __toESM(require_components(), 1);
14647 var import_i18n20 = __toESM(require_i18n(), 1);
14648 var import_element45 = __toESM(require_element(), 1);
14649 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
14650 function DensityPicker() {
14651 const context = (0, import_element45.useContext)(dataviews_context_default);
14652 const view = context.view;
14653 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14654 import_components16.__experimentalToggleGroupControl,
14655 {
14656 size: "__unstable-large",
14657 label: (0, import_i18n20.__)("Density"),
14658 value: view.layout?.density || "balanced",
14659 onChange: (value) => {
14660 context.onChangeView({
14661 ...view,
14662 layout: {
14663 ...view.layout,
14664 density: value
14665 }
14666 });
14667 },
14668 isBlock: true,
14669 children: [
14670 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14671 import_components16.__experimentalToggleGroupControlOption,
14672 {
14673 value: "comfortable",
14674 label: (0, import_i18n20._x)(
14675 "Comfortable",
14676 "Density option for DataView layout"
14677 )
14678 },
14679 "comfortable"
14680 ),
14681 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14682 import_components16.__experimentalToggleGroupControlOption,
14683 {
14684 value: "balanced",
14685 label: (0, import_i18n20._x)("Balanced", "Density option for DataView layout")
14686 },
14687 "balanced"
14688 ),
14689 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14690 import_components16.__experimentalToggleGroupControlOption,
14691 {
14692 value: "compact",
14693 label: (0, import_i18n20._x)("Compact", "Density option for DataView layout")
14694 },
14695 "compact"
14696 )
14697 ]
14698 }
14699 );
14700 }
14701
14702 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
14703 var import_components17 = __toESM(require_components(), 1);
14704 var import_i18n21 = __toESM(require_i18n(), 1);
14705 var import_element46 = __toESM(require_element(), 1);
14706 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
14707 var imageSizes2 = [
14708 {
14709 value: 120,
14710 breakpoint: 1
14711 },
14712 {
14713 value: 170,
14714 breakpoint: 1
14715 },
14716 {
14717 value: 230,
14718 breakpoint: 1
14719 },
14720 {
14721 value: 290,
14722 breakpoint: 1112
14723 // at minimum image width, 4 images display at this container size
14724 },
14725 {
14726 value: 350,
14727 breakpoint: 1636
14728 // at minimum image width, 6 images display at this container size
14729 },
14730 {
14731 value: 430,
14732 breakpoint: 588
14733 // at minimum image width, 2 images display at this container size
14734 }
14735 ];
14736 function PreviewSizePicker() {
14737 const context = (0, import_element46.useContext)(dataviews_context_default);
14738 const view = context.view;
14739 const breakValues = imageSizes2.filter((size4) => {
14740 return context.containerWidth >= size4.breakpoint;
14741 });
14742 const layoutPreviewSize = view.layout?.previewSize ?? 230;
14743 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
14744 const marks = breakValues.map((size4, index2) => {
14745 return {
14746 value: index2
14747 };
14748 });
14749 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14750 import_components17.RangeControl,
14751 {
14752 __next40pxDefaultSize: true,
14753 showTooltip: false,
14754 label: (0, import_i18n21.__)("Preview size"),
14755 value: previewSizeToUse,
14756 min: 0,
14757 max: breakValues.length - 1,
14758 withInputField: false,
14759 onChange: (value = 0) => {
14760 context.onChangeView({
14761 ...view,
14762 layout: {
14763 ...view.layout,
14764 previewSize: breakValues[value].value
14765 }
14766 });
14767 },
14768 step: 1,
14769 marks
14770 }
14771 );
14772 }
14773
14774 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
14775 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
14776 function GridConfigOptions() {
14777 return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(import_jsx_runtime69.Fragment, { children: [
14778 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(DensityPicker, {}),
14779 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(PreviewSizePicker, {})
14780 ] });
14781 }
14782
14783 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
14784 var VIEW_LAYOUTS = [
14785 {
14786 type: LAYOUT_TABLE,
14787 label: (0, import_i18n22.__)("Table"),
14788 component: table_default,
14789 icon: block_table_default,
14790 viewConfigOptions: DensityPicker
14791 },
14792 {
14793 type: LAYOUT_GRID,
14794 label: (0, import_i18n22.__)("Grid"),
14795 component: grid_default,
14796 icon: category_default,
14797 viewConfigOptions: GridConfigOptions
14798 },
14799 {
14800 type: LAYOUT_LIST,
14801 label: (0, import_i18n22.__)("List"),
14802 component: ViewList,
14803 icon: (0, import_i18n22.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
14804 viewConfigOptions: DensityPicker
14805 },
14806 {
14807 type: LAYOUT_ACTIVITY,
14808 label: (0, import_i18n22.__)("Activity"),
14809 component: ViewActivity,
14810 icon: scheduled_default,
14811 viewConfigOptions: DensityPicker
14812 },
14813 {
14814 type: LAYOUT_PICKER_GRID,
14815 label: (0, import_i18n22.__)("Grid"),
14816 component: picker_grid_default,
14817 icon: category_default,
14818 viewConfigOptions: GridConfigOptions,
14819 isPicker: true
14820 },
14821 {
14822 type: LAYOUT_PICKER_TABLE,
14823 label: (0, import_i18n22.__)("Table"),
14824 component: picker_table_default,
14825 icon: block_table_default,
14826 viewConfigOptions: DensityPicker,
14827 isPicker: true
14828 }
14829 ];
14830
14831 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
14832 var import_element54 = __toESM(require_element(), 1);
14833
14834 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
14835 var import_components20 = __toESM(require_components(), 1);
14836 var import_i18n25 = __toESM(require_i18n(), 1);
14837 var import_element51 = __toESM(require_element(), 1);
14838
14839 // node_modules/@ariakit/core/esm/__chunks/XMCVU3LR.js
14840 function noop4(..._) {
14841 }
14842 function applyState(argument, currentValue) {
14843 if (isUpdater(argument)) {
14844 const value = isLazyValue(currentValue) ? currentValue() : currentValue;
14845 return argument(value);
14846 }
14847 return argument;
14848 }
14849 function isUpdater(argument) {
14850 return typeof argument === "function";
14851 }
14852 function isLazyValue(value) {
14853 return typeof value === "function";
14854 }
14855 function hasOwnProperty(object, prop) {
14856 if (typeof Object.hasOwn === "function") {
14857 return Object.hasOwn(object, prop);
14858 }
14859 return Object.prototype.hasOwnProperty.call(object, prop);
14860 }
14861 function chain(...fns) {
14862 return (...args) => {
14863 for (const fn of fns) {
14864 if (typeof fn === "function") {
14865 fn(...args);
14866 }
14867 }
14868 };
14869 }
14870 function normalizeString(str) {
14871 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
14872 }
14873 function omit(object, keys) {
14874 const result = { ...object };
14875 for (const key of keys) {
14876 if (hasOwnProperty(result, key)) {
14877 delete result[key];
14878 }
14879 }
14880 return result;
14881 }
14882 function pick(object, paths) {
14883 const result = {};
14884 for (const key of paths) {
14885 if (hasOwnProperty(object, key)) {
14886 result[key] = object[key];
14887 }
14888 }
14889 return result;
14890 }
14891 function identity(value) {
14892 return value;
14893 }
14894 function invariant(condition, message2) {
14895 if (condition) return;
14896 if (typeof message2 !== "string") throw new Error("Invariant failed");
14897 throw new Error(message2);
14898 }
14899 function getKeys(obj) {
14900 return Object.keys(obj);
14901 }
14902 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
14903 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
14904 if (result == null) return false;
14905 return !result;
14906 }
14907 function disabledFromProps(props) {
14908 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
14909 }
14910 function removeUndefinedValues(obj) {
14911 const result = {};
14912 for (const key in obj) {
14913 if (obj[key] !== void 0) {
14914 result[key] = obj[key];
14915 }
14916 }
14917 return result;
14918 }
14919 function defaultValue(...values) {
14920 for (const value of values) {
14921 if (value !== void 0) return value;
14922 }
14923 return void 0;
14924 }
14925
14926 // node_modules/@ariakit/react-core/esm/__chunks/YXGXYGQX.js
14927 var import_react11 = __toESM(require_react(), 1);
14928 function setRef(ref, value) {
14929 if (typeof ref === "function") {
14930 ref(value);
14931 } else if (ref) {
14932 ref.current = value;
14933 }
14934 }
14935 function isValidElementWithRef(element) {
14936 if (!element) return false;
14937 if (!(0, import_react11.isValidElement)(element)) return false;
14938 if ("ref" in element.props) return true;
14939 if ("ref" in element) return true;
14940 return false;
14941 }
14942 function getRefProperty(element) {
14943 if (!isValidElementWithRef(element)) return null;
14944 const props = { ...element.props };
14945 return props.ref || element.ref;
14946 }
14947 function mergeProps3(base, overrides) {
14948 const props = { ...base };
14949 for (const key in overrides) {
14950 if (!hasOwnProperty(overrides, key)) continue;
14951 if (key === "className") {
14952 const prop = "className";
14953 props[prop] = base[prop] ? `${base[prop]} ${overrides[prop]}` : overrides[prop];
14954 continue;
14955 }
14956 if (key === "style") {
14957 const prop = "style";
14958 props[prop] = base[prop] ? { ...base[prop], ...overrides[prop] } : overrides[prop];
14959 continue;
14960 }
14961 const overrideValue = overrides[key];
14962 if (typeof overrideValue === "function" && key.startsWith("on")) {
14963 const baseValue = base[key];
14964 if (typeof baseValue === "function") {
14965 props[key] = (...args) => {
14966 overrideValue(...args);
14967 baseValue(...args);
14968 };
14969 continue;
14970 }
14971 }
14972 props[key] = overrideValue;
14973 }
14974 return props;
14975 }
14976
14977 // node_modules/@ariakit/core/esm/__chunks/3DNM6L6E.js
14978 var canUseDOM = checkIsBrowser();
14979 function checkIsBrowser() {
14980 var _a;
14981 return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement);
14982 }
14983 function getDocument(node) {
14984 if (!node) return document;
14985 if ("self" in node) return node.document;
14986 return node.ownerDocument || document;
14987 }
14988 function getActiveElement(node, activeDescendant = false) {
14989 var _a;
14990 const { activeElement: activeElement2 } = getDocument(node);
14991 if (!(activeElement2 == null ? void 0 : activeElement2.nodeName)) {
14992 return null;
14993 }
14994 if (isFrame(activeElement2) && ((_a = activeElement2.contentDocument) == null ? void 0 : _a.body)) {
14995 return getActiveElement(
14996 activeElement2.contentDocument.body,
14997 activeDescendant
14998 );
14999 }
15000 if (activeDescendant) {
15001 const id = activeElement2.getAttribute("aria-activedescendant");
15002 if (id) {
15003 const element = getDocument(activeElement2).getElementById(id);
15004 if (element) {
15005 return element;
15006 }
15007 }
15008 }
15009 return activeElement2;
15010 }
15011 function contains2(parent, child) {
15012 return parent === child || parent.contains(child);
15013 }
15014 function isFrame(element) {
15015 return element.tagName === "IFRAME";
15016 }
15017 function isButton(element) {
15018 const tagName = element.tagName.toLowerCase();
15019 if (tagName === "button") return true;
15020 if (tagName === "input" && element.type) {
15021 return buttonInputTypes.indexOf(element.type) !== -1;
15022 }
15023 return false;
15024 }
15025 var buttonInputTypes = [
15026 "button",
15027 "color",
15028 "file",
15029 "image",
15030 "reset",
15031 "submit"
15032 ];
15033 function isVisible(element) {
15034 if (typeof element.checkVisibility === "function") {
15035 return element.checkVisibility();
15036 }
15037 const htmlElement = element;
15038 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
15039 }
15040 function isTextField(element) {
15041 try {
15042 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
15043 const isTextArea = element.tagName === "TEXTAREA";
15044 return isTextInput || isTextArea || false;
15045 } catch (_error) {
15046 return false;
15047 }
15048 }
15049 function isTextbox(element) {
15050 return element.isContentEditable || isTextField(element);
15051 }
15052 function getTextboxValue(element) {
15053 if (isTextField(element)) {
15054 return element.value;
15055 }
15056 if (element.isContentEditable) {
15057 const range = getDocument(element).createRange();
15058 range.selectNodeContents(element);
15059 return range.toString();
15060 }
15061 return "";
15062 }
15063 function getTextboxSelection(element) {
15064 let start = 0;
15065 let end = 0;
15066 if (isTextField(element)) {
15067 start = element.selectionStart || 0;
15068 end = element.selectionEnd || 0;
15069 } else if (element.isContentEditable) {
15070 const selection = getDocument(element).getSelection();
15071 if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) {
15072 const range = selection.getRangeAt(0);
15073 const nextRange = range.cloneRange();
15074 nextRange.selectNodeContents(element);
15075 nextRange.setEnd(range.startContainer, range.startOffset);
15076 start = nextRange.toString().length;
15077 nextRange.setEnd(range.endContainer, range.endOffset);
15078 end = nextRange.toString().length;
15079 }
15080 }
15081 return { start, end };
15082 }
15083 function getPopupRole(element, fallback) {
15084 const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"];
15085 const role = element == null ? void 0 : element.getAttribute("role");
15086 if (role && allowedPopupRoles.indexOf(role) !== -1) {
15087 return role;
15088 }
15089 return fallback;
15090 }
15091 function getScrollingElement(element) {
15092 if (!element) return null;
15093 const isScrollableOverflow = (overflow) => {
15094 if (overflow === "auto") return true;
15095 if (overflow === "scroll") return true;
15096 return false;
15097 };
15098 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
15099 const { overflowY } = getComputedStyle(element);
15100 if (isScrollableOverflow(overflowY)) return element;
15101 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
15102 const { overflowX } = getComputedStyle(element);
15103 if (isScrollableOverflow(overflowX)) return element;
15104 }
15105 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body;
15106 }
15107 function setSelectionRange(element, ...args) {
15108 if (/text|search|password|tel|url/i.test(element.type)) {
15109 element.setSelectionRange(...args);
15110 }
15111 }
15112 function sortBasedOnDOMPosition(items, getElement) {
15113 const pairs = items.map((item, index2) => [index2, item]);
15114 let isOrderDifferent = false;
15115 pairs.sort(([indexA, a2], [indexB, b2]) => {
15116 const elementA = getElement(a2);
15117 const elementB = getElement(b2);
15118 if (elementA === elementB) return 0;
15119 if (!elementA || !elementB) return 0;
15120 if (isElementPreceding(elementA, elementB)) {
15121 if (indexA > indexB) {
15122 isOrderDifferent = true;
15123 }
15124 return -1;
15125 }
15126 if (indexA < indexB) {
15127 isOrderDifferent = true;
15128 }
15129 return 1;
15130 });
15131 if (isOrderDifferent) {
15132 return pairs.map(([_, item]) => item);
15133 }
15134 return items;
15135 }
15136 function isElementPreceding(a2, b2) {
15137 return Boolean(
15138 b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING
15139 );
15140 }
15141
15142 // node_modules/@ariakit/core/esm/__chunks/SNHYQNEZ.js
15143 function isTouchDevice() {
15144 return canUseDOM && !!navigator.maxTouchPoints;
15145 }
15146 function isApple() {
15147 if (!canUseDOM) return false;
15148 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
15149 }
15150 function isSafari2() {
15151 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
15152 }
15153 function isFirefox2() {
15154 return canUseDOM && /firefox\//i.test(navigator.userAgent);
15155 }
15156
15157 // node_modules/@ariakit/core/esm/utils/events.js
15158 function isPortalEvent(event) {
15159 return Boolean(
15160 event.currentTarget && !contains2(event.currentTarget, event.target)
15161 );
15162 }
15163 function isSelfTarget(event) {
15164 return event.target === event.currentTarget;
15165 }
15166 function isOpeningInNewTab(event) {
15167 const element = event.currentTarget;
15168 if (!element) return false;
15169 const isAppleDevice = isApple();
15170 if (isAppleDevice && !event.metaKey) return false;
15171 if (!isAppleDevice && !event.ctrlKey) return false;
15172 const tagName = element.tagName.toLowerCase();
15173 if (tagName === "a") return true;
15174 if (tagName === "button" && element.type === "submit") return true;
15175 if (tagName === "input" && element.type === "submit") return true;
15176 return false;
15177 }
15178 function isDownloading(event) {
15179 const element = event.currentTarget;
15180 if (!element) return false;
15181 const tagName = element.tagName.toLowerCase();
15182 if (!event.altKey) return false;
15183 if (tagName === "a") return true;
15184 if (tagName === "button" && element.type === "submit") return true;
15185 if (tagName === "input" && element.type === "submit") return true;
15186 return false;
15187 }
15188 function fireBlurEvent(element, eventInit) {
15189 const event = new FocusEvent("blur", eventInit);
15190 const defaultAllowed = element.dispatchEvent(event);
15191 const bubbleInit = { ...eventInit, bubbles: true };
15192 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
15193 return defaultAllowed;
15194 }
15195 function fireKeyboardEvent(element, type, eventInit) {
15196 const event = new KeyboardEvent(type, eventInit);
15197 return element.dispatchEvent(event);
15198 }
15199 function fireClickEvent(element, eventInit) {
15200 const event = new MouseEvent("click", eventInit);
15201 return element.dispatchEvent(event);
15202 }
15203 function isFocusEventOutside(event, container) {
15204 const containerElement = container || event.currentTarget;
15205 const relatedTarget = event.relatedTarget;
15206 return !relatedTarget || !contains2(containerElement, relatedTarget);
15207 }
15208 function queueBeforeEvent(element, type, callback, timeout) {
15209 const createTimer = (callback2) => {
15210 if (timeout) {
15211 const timerId2 = setTimeout(callback2, timeout);
15212 return () => clearTimeout(timerId2);
15213 }
15214 const timerId = requestAnimationFrame(callback2);
15215 return () => cancelAnimationFrame(timerId);
15216 };
15217 const cancelTimer = createTimer(() => {
15218 element.removeEventListener(type, callSync, true);
15219 callback();
15220 });
15221 const callSync = () => {
15222 cancelTimer();
15223 callback();
15224 };
15225 element.addEventListener(type, callSync, { once: true, capture: true });
15226 return cancelTimer;
15227 }
15228 function addGlobalEventListener(type, listener, options, scope = window) {
15229 const children = [];
15230 try {
15231 scope.document.addEventListener(type, listener, options);
15232 for (const frame of Array.from(scope.frames)) {
15233 children.push(addGlobalEventListener(type, listener, options, frame));
15234 }
15235 } catch (e2) {
15236 }
15237 const removeEventListener = () => {
15238 try {
15239 scope.document.removeEventListener(type, listener, options);
15240 } catch (e2) {
15241 }
15242 for (const remove of children) {
15243 remove();
15244 }
15245 };
15246 return removeEventListener;
15247 }
15248
15249 // node_modules/@ariakit/react-core/esm/__chunks/KPHZR4MB.js
15250 var React48 = __toESM(require_react(), 1);
15251 var import_react12 = __toESM(require_react(), 1);
15252 var _React = { ...React48 };
15253 var useReactId = _React.useId;
15254 var useReactDeferredValue = _React.useDeferredValue;
15255 var useReactInsertionEffect = _React.useInsertionEffect;
15256 var useSafeLayoutEffect = canUseDOM ? import_react12.useLayoutEffect : import_react12.useEffect;
15257 function useInitialValue(value) {
15258 const [initialValue] = (0, import_react12.useState)(value);
15259 return initialValue;
15260 }
15261 function useLiveRef(value) {
15262 const ref = (0, import_react12.useRef)(value);
15263 useSafeLayoutEffect(() => {
15264 ref.current = value;
15265 });
15266 return ref;
15267 }
15268 function useEvent(callback) {
15269 const ref = (0, import_react12.useRef)(() => {
15270 throw new Error("Cannot call an event handler while rendering.");
15271 });
15272 if (useReactInsertionEffect) {
15273 useReactInsertionEffect(() => {
15274 ref.current = callback;
15275 });
15276 } else {
15277 ref.current = callback;
15278 }
15279 return (0, import_react12.useCallback)((...args) => {
15280 var _a;
15281 return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args);
15282 }, []);
15283 }
15284 function useTransactionState(callback) {
15285 const [state, setState] = (0, import_react12.useState)(null);
15286 useSafeLayoutEffect(() => {
15287 if (state == null) return;
15288 if (!callback) return;
15289 let prevState = null;
15290 callback((prev) => {
15291 prevState = prev;
15292 return state;
15293 });
15294 return () => {
15295 callback(prevState);
15296 };
15297 }, [state, callback]);
15298 return [state, setState];
15299 }
15300 function useMergeRefs(...refs) {
15301 return (0, import_react12.useMemo)(() => {
15302 if (!refs.some(Boolean)) return;
15303 return (value) => {
15304 for (const ref of refs) {
15305 setRef(ref, value);
15306 }
15307 };
15308 }, refs);
15309 }
15310 function useId4(defaultId) {
15311 if (useReactId) {
15312 const reactId = useReactId();
15313 if (defaultId) return defaultId;
15314 return reactId;
15315 }
15316 const [id, setId] = (0, import_react12.useState)(defaultId);
15317 useSafeLayoutEffect(() => {
15318 if (defaultId || id) return;
15319 const random = Math.random().toString(36).slice(2, 8);
15320 setId(`id-${random}`);
15321 }, [defaultId, id]);
15322 return defaultId || id;
15323 }
15324 function useTagName(refOrElement, type) {
15325 const stringOrUndefined = (type2) => {
15326 if (typeof type2 !== "string") return;
15327 return type2;
15328 };
15329 const [tagName, setTagName] = (0, import_react12.useState)(() => stringOrUndefined(type));
15330 useSafeLayoutEffect(() => {
15331 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
15332 setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type));
15333 }, [refOrElement, type]);
15334 return tagName;
15335 }
15336 function useAttribute(refOrElement, attributeName, defaultValue2) {
15337 const initialValue = useInitialValue(defaultValue2);
15338 const [attribute, setAttribute] = (0, import_react12.useState)(initialValue);
15339 (0, import_react12.useEffect)(() => {
15340 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
15341 if (!element) return;
15342 const callback = () => {
15343 const value = element.getAttribute(attributeName);
15344 setAttribute(value == null ? initialValue : value);
15345 };
15346 const observer = new MutationObserver(callback);
15347 observer.observe(element, { attributeFilter: [attributeName] });
15348 callback();
15349 return () => observer.disconnect();
15350 }, [refOrElement, attributeName, initialValue]);
15351 return attribute;
15352 }
15353 function useUpdateEffect(effect, deps) {
15354 const mounted = (0, import_react12.useRef)(false);
15355 (0, import_react12.useEffect)(() => {
15356 if (mounted.current) {
15357 return effect();
15358 }
15359 mounted.current = true;
15360 }, deps);
15361 (0, import_react12.useEffect)(
15362 () => () => {
15363 mounted.current = false;
15364 },
15365 []
15366 );
15367 }
15368 function useUpdateLayoutEffect(effect, deps) {
15369 const mounted = (0, import_react12.useRef)(false);
15370 useSafeLayoutEffect(() => {
15371 if (mounted.current) {
15372 return effect();
15373 }
15374 mounted.current = true;
15375 }, deps);
15376 useSafeLayoutEffect(
15377 () => () => {
15378 mounted.current = false;
15379 },
15380 []
15381 );
15382 }
15383 function useForceUpdate() {
15384 return (0, import_react12.useReducer)(() => [], []);
15385 }
15386 function useBooleanEvent(booleanOrCallback) {
15387 return useEvent(
15388 typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback
15389 );
15390 }
15391 function useWrapElement(props, callback, deps = []) {
15392 const wrapElement = (0, import_react12.useCallback)(
15393 (element) => {
15394 if (props.wrapElement) {
15395 element = props.wrapElement(element);
15396 }
15397 return callback(element);
15398 },
15399 [...deps, props.wrapElement]
15400 );
15401 return { ...props, wrapElement };
15402 }
15403 function useMetadataProps(props, key, value) {
15404 const parent = props.onLoadedMetadataCapture;
15405 const onLoadedMetadataCapture = (0, import_react12.useMemo)(() => {
15406 return Object.assign(() => {
15407 }, { ...parent, [key]: value });
15408 }, [parent, key, value]);
15409 return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }];
15410 }
15411 var hasInstalledGlobalEventListeners = false;
15412 function useIsMouseMoving() {
15413 (0, import_react12.useEffect)(() => {
15414 if (hasInstalledGlobalEventListeners) return;
15415 addGlobalEventListener("mousemove", setMouseMoving, true);
15416 addGlobalEventListener("mousedown", resetMouseMoving, true);
15417 addGlobalEventListener("mouseup", resetMouseMoving, true);
15418 addGlobalEventListener("keydown", resetMouseMoving, true);
15419 addGlobalEventListener("scroll", resetMouseMoving, true);
15420 hasInstalledGlobalEventListeners = true;
15421 }, []);
15422 const isMouseMoving = useEvent(() => mouseMoving);
15423 return isMouseMoving;
15424 }
15425 var mouseMoving = false;
15426 var previousScreenX = 0;
15427 var previousScreenY = 0;
15428 function hasMouseMovement(event) {
15429 const movementX = event.movementX || event.screenX - previousScreenX;
15430 const movementY = event.movementY || event.screenY - previousScreenY;
15431 previousScreenX = event.screenX;
15432 previousScreenY = event.screenY;
15433 return movementX || movementY || false;
15434 }
15435 function setMouseMoving(event) {
15436 if (!hasMouseMovement(event)) return;
15437 mouseMoving = true;
15438 }
15439 function resetMouseMoving() {
15440 mouseMoving = false;
15441 }
15442
15443 // node_modules/@ariakit/react-core/esm/__chunks/GWSL6KNJ.js
15444 var React49 = __toESM(require_react(), 1);
15445 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
15446 function forwardRef210(render4) {
15447 const Role = React49.forwardRef(
15448 // @ts-ignore Incompatible with React 19 types. Ignore for now.
15449 (props, ref) => render4({ ...props, ref })
15450 );
15451 Role.displayName = render4.displayName || render4.name;
15452 return Role;
15453 }
15454 function memo22(Component, propsAreEqual) {
15455 return React49.memo(Component, propsAreEqual);
15456 }
15457 function createElement3(Type, props) {
15458 const { wrapElement, render: render4, ...rest } = props;
15459 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
15460 let element;
15461 if (React49.isValidElement(render4)) {
15462 const renderProps = {
15463 // @ts-ignore Incompatible with React 19 types. Ignore for now.
15464 ...render4.props,
15465 ref: mergedRef
15466 };
15467 element = React49.cloneElement(render4, mergeProps3(rest, renderProps));
15468 } else if (render4) {
15469 element = render4(rest);
15470 } else {
15471 element = /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Type, { ...rest });
15472 }
15473 if (wrapElement) {
15474 return wrapElement(element);
15475 }
15476 return element;
15477 }
15478 function createHook(useProps) {
15479 const useRole = (props = {}) => {
15480 return useProps(props);
15481 };
15482 useRole.displayName = useProps.name;
15483 return useRole;
15484 }
15485 function createStoreContext(providers = [], scopedProviders = []) {
15486 const context = React49.createContext(void 0);
15487 const scopedContext = React49.createContext(void 0);
15488 const useContext210 = () => React49.useContext(context);
15489 const useScopedContext = (onlyScoped = false) => {
15490 const scoped = React49.useContext(scopedContext);
15491 const store = useContext210();
15492 if (onlyScoped) return scoped;
15493 return scoped || store;
15494 };
15495 const useProviderContext = () => {
15496 const scoped = React49.useContext(scopedContext);
15497 const store = useContext210();
15498 if (scoped && scoped === store) return;
15499 return store;
15500 };
15501 const ContextProvider = (props) => {
15502 return providers.reduceRight(
15503 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Provider2, { ...props, children }),
15504 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(context.Provider, { ...props })
15505 );
15506 };
15507 const ScopedContextProvider = (props) => {
15508 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ContextProvider, { ...props, children: scopedProviders.reduceRight(
15509 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Provider2, { ...props, children }),
15510 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(scopedContext.Provider, { ...props })
15511 ) });
15512 };
15513 return {
15514 context,
15515 scopedContext,
15516 useContext: useContext210,
15517 useScopedContext,
15518 useProviderContext,
15519 ContextProvider,
15520 ScopedContextProvider
15521 };
15522 }
15523
15524 // node_modules/@ariakit/react-core/esm/__chunks/SMPCIMZM.js
15525 var ctx = createStoreContext();
15526 var useCollectionContext = ctx.useContext;
15527 var useCollectionScopedContext = ctx.useScopedContext;
15528 var useCollectionProviderContext = ctx.useProviderContext;
15529 var CollectionContextProvider = ctx.ContextProvider;
15530 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
15531
15532 // node_modules/@ariakit/react-core/esm/__chunks/AVVXDJMZ.js
15533 var import_react13 = __toESM(require_react(), 1);
15534 var ctx2 = createStoreContext(
15535 [CollectionContextProvider],
15536 [CollectionScopedContextProvider]
15537 );
15538 var useCompositeContext = ctx2.useContext;
15539 var useCompositeScopedContext = ctx2.useScopedContext;
15540 var useCompositeProviderContext = ctx2.useProviderContext;
15541 var CompositeContextProvider = ctx2.ContextProvider;
15542 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
15543 var CompositeItemContext = (0, import_react13.createContext)(
15544 void 0
15545 );
15546 var CompositeRowContext = (0, import_react13.createContext)(
15547 void 0
15548 );
15549
15550 // node_modules/@ariakit/react-core/esm/__chunks/5VQZOHHZ.js
15551 function findFirstEnabledItem(items, excludeId) {
15552 return items.find((item) => {
15553 if (excludeId) {
15554 return !item.disabled && item.id !== excludeId;
15555 }
15556 return !item.disabled;
15557 });
15558 }
15559 function getEnabledItem(store, id) {
15560 if (!id) return null;
15561 return store.item(id) || null;
15562 }
15563 function groupItemsByRows(items) {
15564 const rows = [];
15565 for (const item of items) {
15566 const row = rows.find((currentRow) => {
15567 var _a;
15568 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
15569 });
15570 if (row) {
15571 row.push(item);
15572 } else {
15573 rows.push([item]);
15574 }
15575 }
15576 return rows;
15577 }
15578 function selectTextField(element, collapseToEnd = false) {
15579 if (isTextField(element)) {
15580 element.setSelectionRange(
15581 collapseToEnd ? element.value.length : 0,
15582 element.value.length
15583 );
15584 } else if (element.isContentEditable) {
15585 const selection = getDocument(element).getSelection();
15586 selection == null ? void 0 : selection.selectAllChildren(element);
15587 if (collapseToEnd) {
15588 selection == null ? void 0 : selection.collapseToEnd();
15589 }
15590 }
15591 }
15592 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
15593 function focusSilently(element) {
15594 element[FOCUS_SILENTLY] = true;
15595 element.focus({ preventScroll: true });
15596 }
15597 function silentlyFocused(element) {
15598 const isSilentlyFocused = element[FOCUS_SILENTLY];
15599 delete element[FOCUS_SILENTLY];
15600 return isSilentlyFocused;
15601 }
15602 function isItem(store, element, exclude) {
15603 if (!element) return false;
15604 if (element === exclude) return false;
15605 const item = store.item(element.id);
15606 if (!item) return false;
15607 if (exclude && item.element === exclude) return false;
15608 return true;
15609 }
15610
15611 // node_modules/@ariakit/react-core/esm/__chunks/Z2O3VLAQ.js
15612 var import_react14 = __toESM(require_react(), 1);
15613 var TagName = "div";
15614 var useCollectionItem = createHook(
15615 function useCollectionItem2({
15616 store,
15617 shouldRegisterItem = true,
15618 getItem = identity,
15619 // @ts-expect-error This prop may come from a collection renderer.
15620 element,
15621 ...props
15622 }) {
15623 const context = useCollectionContext();
15624 store = store || context;
15625 const id = useId4(props.id);
15626 const ref = (0, import_react14.useRef)(element);
15627 (0, import_react14.useEffect)(() => {
15628 const element2 = ref.current;
15629 if (!id) return;
15630 if (!element2) return;
15631 if (!shouldRegisterItem) return;
15632 const item = getItem({ id, element: element2 });
15633 return store == null ? void 0 : store.renderItem(item);
15634 }, [id, shouldRegisterItem, getItem, store]);
15635 props = {
15636 ...props,
15637 ref: useMergeRefs(ref, props.ref)
15638 };
15639 return removeUndefinedValues(props);
15640 }
15641 );
15642 var CollectionItem = forwardRef210(function CollectionItem2(props) {
15643 const htmlProps = useCollectionItem(props);
15644 return createElement3(TagName, htmlProps);
15645 });
15646
15647 // node_modules/@ariakit/react-core/esm/__chunks/SWN3JYXT.js
15648 var import_react15 = __toESM(require_react(), 1);
15649 var FocusableContext = (0, import_react15.createContext)(true);
15650
15651 // node_modules/@ariakit/core/esm/utils/focus.js
15652 var selector = "input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], summary, iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false'])";
15653 function isFocusable(element) {
15654 if (!element.matches(selector)) return false;
15655 if (!isVisible(element)) return false;
15656 if (element.closest("[inert]")) return false;
15657 return true;
15658 }
15659 function getClosestFocusable(element) {
15660 while (element && !isFocusable(element)) {
15661 element = element.closest(selector);
15662 }
15663 return element || null;
15664 }
15665 function hasFocus(element) {
15666 const activeElement2 = getActiveElement(element);
15667 if (!activeElement2) return false;
15668 if (activeElement2 === element) return true;
15669 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15670 if (!activeDescendant) return false;
15671 return activeDescendant === element.id;
15672 }
15673 function hasFocusWithin(element) {
15674 const activeElement2 = getActiveElement(element);
15675 if (!activeElement2) return false;
15676 if (contains2(element, activeElement2)) return true;
15677 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15678 if (!activeDescendant) return false;
15679 if (!("id" in element)) return false;
15680 if (activeDescendant === element.id) return true;
15681 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
15682 }
15683 function focusIfNeeded(element) {
15684 if (!hasFocusWithin(element) && isFocusable(element)) {
15685 element.focus();
15686 }
15687 }
15688 function focusIntoView(element, options) {
15689 if (!("scrollIntoView" in element)) {
15690 element.focus();
15691 } else {
15692 element.focus({ preventScroll: true });
15693 element.scrollIntoView({ block: "nearest", inline: "nearest", ...options });
15694 }
15695 }
15696
15697 // node_modules/@ariakit/react-core/esm/__chunks/U6HHPQDW.js
15698 var import_react16 = __toESM(require_react(), 1);
15699 var TagName2 = "div";
15700 var isSafariBrowser = isSafari2();
15701 var alwaysFocusVisibleInputTypes = [
15702 "text",
15703 "search",
15704 "url",
15705 "tel",
15706 "email",
15707 "password",
15708 "number",
15709 "date",
15710 "month",
15711 "week",
15712 "time",
15713 "datetime",
15714 "datetime-local"
15715 ];
15716 var safariFocusAncestorSymbol = /* @__PURE__ */ Symbol("safariFocusAncestor");
15717 function markSafariFocusAncestor(element, value) {
15718 if (!element) return;
15719 element[safariFocusAncestorSymbol] = value;
15720 }
15721 function isAlwaysFocusVisible(element) {
15722 const { tagName, readOnly, type } = element;
15723 if (tagName === "TEXTAREA" && !readOnly) return true;
15724 if (tagName === "SELECT" && !readOnly) return true;
15725 if (tagName === "INPUT" && !readOnly) {
15726 return alwaysFocusVisibleInputTypes.includes(type);
15727 }
15728 if (element.isContentEditable) return true;
15729 const role = element.getAttribute("role");
15730 if (role === "combobox" && element.dataset.name) {
15731 return true;
15732 }
15733 return false;
15734 }
15735 function getLabels(element) {
15736 if ("labels" in element) {
15737 return element.labels;
15738 }
15739 return null;
15740 }
15741 function isNativeCheckboxOrRadio(element) {
15742 const tagName = element.tagName.toLowerCase();
15743 if (tagName === "input" && element.type) {
15744 return element.type === "radio" || element.type === "checkbox";
15745 }
15746 return false;
15747 }
15748 function isNativeTabbable(tagName) {
15749 if (!tagName) return true;
15750 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
15751 }
15752 function supportsDisabledAttribute(tagName) {
15753 if (!tagName) return true;
15754 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
15755 }
15756 function getTabIndex2(focusable2, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) {
15757 if (!focusable2) {
15758 return tabIndexProp;
15759 }
15760 if (trulyDisabled) {
15761 if (nativeTabbable && !supportsDisabled) {
15762 return -1;
15763 }
15764 return;
15765 }
15766 if (nativeTabbable) {
15767 return tabIndexProp;
15768 }
15769 return tabIndexProp || 0;
15770 }
15771 function useDisableEvent(onEvent, disabled2) {
15772 return useEvent((event) => {
15773 onEvent == null ? void 0 : onEvent(event);
15774 if (event.defaultPrevented) return;
15775 if (disabled2) {
15776 event.stopPropagation();
15777 event.preventDefault();
15778 }
15779 });
15780 }
15781 var hasInstalledGlobalEventListeners2 = false;
15782 var isKeyboardModality = true;
15783 function onGlobalMouseDown(event) {
15784 const target = event.target;
15785 if (target && "hasAttribute" in target) {
15786 if (!target.hasAttribute("data-focus-visible")) {
15787 isKeyboardModality = false;
15788 }
15789 }
15790 }
15791 function onGlobalKeyDown(event) {
15792 if (event.metaKey) return;
15793 if (event.ctrlKey) return;
15794 if (event.altKey) return;
15795 isKeyboardModality = true;
15796 }
15797 var useFocusable = createHook(
15798 function useFocusable2({
15799 focusable: focusable2 = true,
15800 accessibleWhenDisabled,
15801 autoFocus,
15802 onFocusVisible,
15803 ...props
15804 }) {
15805 const ref = (0, import_react16.useRef)(null);
15806 (0, import_react16.useEffect)(() => {
15807 if (!focusable2) return;
15808 if (hasInstalledGlobalEventListeners2) return;
15809 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
15810 addGlobalEventListener("keydown", onGlobalKeyDown, true);
15811 hasInstalledGlobalEventListeners2 = true;
15812 }, [focusable2]);
15813 if (isSafariBrowser) {
15814 (0, import_react16.useEffect)(() => {
15815 if (!focusable2) return;
15816 const element = ref.current;
15817 if (!element) return;
15818 if (!isNativeCheckboxOrRadio(element)) return;
15819 const labels = getLabels(element);
15820 if (!labels) return;
15821 const onMouseUp = () => queueMicrotask(() => element.focus());
15822 for (const label of labels) {
15823 label.addEventListener("mouseup", onMouseUp);
15824 }
15825 return () => {
15826 for (const label of labels) {
15827 label.removeEventListener("mouseup", onMouseUp);
15828 }
15829 };
15830 }, [focusable2]);
15831 }
15832 const disabled2 = focusable2 && disabledFromProps(props);
15833 const trulyDisabled = !!disabled2 && !accessibleWhenDisabled;
15834 const [focusVisible, setFocusVisible] = (0, import_react16.useState)(false);
15835 (0, import_react16.useEffect)(() => {
15836 if (!focusable2) return;
15837 if (trulyDisabled && focusVisible) {
15838 setFocusVisible(false);
15839 }
15840 }, [focusable2, trulyDisabled, focusVisible]);
15841 (0, import_react16.useEffect)(() => {
15842 if (!focusable2) return;
15843 if (!focusVisible) return;
15844 const element = ref.current;
15845 if (!element) return;
15846 if (typeof IntersectionObserver === "undefined") return;
15847 const observer = new IntersectionObserver(() => {
15848 if (!isFocusable(element)) {
15849 setFocusVisible(false);
15850 }
15851 });
15852 observer.observe(element);
15853 return () => observer.disconnect();
15854 }, [focusable2, focusVisible]);
15855 const onKeyPressCapture = useDisableEvent(
15856 props.onKeyPressCapture,
15857 disabled2
15858 );
15859 const onMouseDownCapture = useDisableEvent(
15860 props.onMouseDownCapture,
15861 disabled2
15862 );
15863 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
15864 const onMouseDownProp = props.onMouseDown;
15865 const onMouseDown = useEvent((event) => {
15866 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
15867 if (event.defaultPrevented) return;
15868 if (!focusable2) return;
15869 const element = event.currentTarget;
15870 if (!isSafariBrowser) return;
15871 if (isPortalEvent(event)) return;
15872 if (!isButton(element) && !isNativeCheckboxOrRadio(element)) return;
15873 let receivedFocus = false;
15874 const onFocus = () => {
15875 receivedFocus = true;
15876 };
15877 const options = { capture: true, once: true };
15878 element.addEventListener("focusin", onFocus, options);
15879 const focusableContainer = getClosestFocusable(element.parentElement);
15880 markSafariFocusAncestor(focusableContainer, true);
15881 queueBeforeEvent(element, "mouseup", () => {
15882 element.removeEventListener("focusin", onFocus, true);
15883 markSafariFocusAncestor(focusableContainer, false);
15884 if (receivedFocus) return;
15885 focusIfNeeded(element);
15886 });
15887 });
15888 const handleFocusVisible = (event, currentTarget) => {
15889 if (currentTarget) {
15890 event.currentTarget = currentTarget;
15891 }
15892 if (!focusable2) return;
15893 const element = event.currentTarget;
15894 if (!element) return;
15895 if (!hasFocus(element)) return;
15896 onFocusVisible == null ? void 0 : onFocusVisible(event);
15897 if (event.defaultPrevented) return;
15898 element.dataset.focusVisible = "true";
15899 setFocusVisible(true);
15900 };
15901 const onKeyDownCaptureProp = props.onKeyDownCapture;
15902 const onKeyDownCapture = useEvent((event) => {
15903 onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event);
15904 if (event.defaultPrevented) return;
15905 if (!focusable2) return;
15906 if (focusVisible) return;
15907 if (event.metaKey) return;
15908 if (event.altKey) return;
15909 if (event.ctrlKey) return;
15910 if (!isSelfTarget(event)) return;
15911 const element = event.currentTarget;
15912 const applyFocusVisible = () => handleFocusVisible(event, element);
15913 queueBeforeEvent(element, "focusout", applyFocusVisible);
15914 });
15915 const onFocusCaptureProp = props.onFocusCapture;
15916 const onFocusCapture = useEvent((event) => {
15917 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
15918 if (event.defaultPrevented) return;
15919 if (!focusable2) return;
15920 if (!isSelfTarget(event)) {
15921 setFocusVisible(false);
15922 return;
15923 }
15924 const element = event.currentTarget;
15925 const applyFocusVisible = () => handleFocusVisible(event, element);
15926 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) {
15927 queueBeforeEvent(event.target, "focusout", applyFocusVisible);
15928 } else {
15929 setFocusVisible(false);
15930 }
15931 });
15932 const onBlurProp = props.onBlur;
15933 const onBlur = useEvent((event) => {
15934 onBlurProp == null ? void 0 : onBlurProp(event);
15935 if (!focusable2) return;
15936 if (!isFocusEventOutside(event)) return;
15937 event.currentTarget.removeAttribute("data-focus-visible");
15938 setFocusVisible(false);
15939 });
15940 const autoFocusOnShow = (0, import_react16.useContext)(FocusableContext);
15941 const autoFocusRef = useEvent((element) => {
15942 if (!focusable2) return;
15943 if (!autoFocus) return;
15944 if (!element) return;
15945 if (!autoFocusOnShow) return;
15946 queueMicrotask(() => {
15947 if (hasFocus(element)) return;
15948 if (!isFocusable(element)) return;
15949 element.focus();
15950 });
15951 });
15952 const tagName = useTagName(ref);
15953 const nativeTabbable = focusable2 && isNativeTabbable(tagName);
15954 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName);
15955 const styleProp = props.style;
15956 const style = (0, import_react16.useMemo)(() => {
15957 if (trulyDisabled) {
15958 return { pointerEvents: "none", ...styleProp };
15959 }
15960 return styleProp;
15961 }, [trulyDisabled, styleProp]);
15962 props = {
15963 "data-focus-visible": focusable2 && focusVisible || void 0,
15964 "data-autofocus": autoFocus || void 0,
15965 "aria-disabled": disabled2 || void 0,
15966 ...props,
15967 ref: useMergeRefs(ref, autoFocusRef, props.ref),
15968 style,
15969 tabIndex: getTabIndex2(
15970 focusable2,
15971 trulyDisabled,
15972 nativeTabbable,
15973 supportsDisabled,
15974 props.tabIndex
15975 ),
15976 disabled: supportsDisabled && trulyDisabled ? true : void 0,
15977 // TODO: Test Focusable contentEditable.
15978 contentEditable: disabled2 ? void 0 : props.contentEditable,
15979 onKeyPressCapture,
15980 onClickCapture,
15981 onMouseDownCapture,
15982 onMouseDown,
15983 onKeyDownCapture,
15984 onFocusCapture,
15985 onBlur
15986 };
15987 return removeUndefinedValues(props);
15988 }
15989 );
15990 var Focusable = forwardRef210(function Focusable2(props) {
15991 const htmlProps = useFocusable(props);
15992 return createElement3(TagName2, htmlProps);
15993 });
15994
15995 // node_modules/@ariakit/react-core/esm/__chunks/PZ3OL7I2.js
15996 var import_react17 = __toESM(require_react(), 1);
15997 var TagName3 = "button";
15998 function isNativeClick(event) {
15999 if (!event.isTrusted) return false;
16000 const element = event.currentTarget;
16001 if (event.key === "Enter") {
16002 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
16003 }
16004 if (event.key === " ") {
16005 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
16006 }
16007 return false;
16008 }
16009 var symbol = /* @__PURE__ */ Symbol("command");
16010 var useCommand = createHook(
16011 function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
16012 const ref = (0, import_react17.useRef)(null);
16013 const [isNativeButton, setIsNativeButton] = (0, import_react17.useState)(false);
16014 (0, import_react17.useEffect)(() => {
16015 if (!ref.current) return;
16016 setIsNativeButton(isButton(ref.current));
16017 }, []);
16018 const [active, setActive] = (0, import_react17.useState)(false);
16019 const activeRef = (0, import_react17.useRef)(false);
16020 const disabled2 = disabledFromProps(props);
16021 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
16022 const onKeyDownProp = props.onKeyDown;
16023 const onKeyDown = useEvent((event) => {
16024 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
16025 const element = event.currentTarget;
16026 if (event.defaultPrevented) return;
16027 if (isDuplicate) return;
16028 if (disabled2) return;
16029 if (!isSelfTarget(event)) return;
16030 if (isTextField(element)) return;
16031 if (element.isContentEditable) return;
16032 const isEnter = clickOnEnter && event.key === "Enter";
16033 const isSpace = clickOnSpace && event.key === " ";
16034 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
16035 const shouldPreventSpace = event.key === " " && !clickOnSpace;
16036 if (shouldPreventEnter || shouldPreventSpace) {
16037 event.preventDefault();
16038 return;
16039 }
16040 if (isEnter || isSpace) {
16041 const nativeClick = isNativeClick(event);
16042 if (isEnter) {
16043 if (!nativeClick) {
16044 event.preventDefault();
16045 const { view, ...eventInit } = event;
16046 const click = () => fireClickEvent(element, eventInit);
16047 if (isFirefox2()) {
16048 queueBeforeEvent(element, "keyup", click);
16049 } else {
16050 queueMicrotask(click);
16051 }
16052 }
16053 } else if (isSpace) {
16054 activeRef.current = true;
16055 if (!nativeClick) {
16056 event.preventDefault();
16057 setActive(true);
16058 }
16059 }
16060 }
16061 });
16062 const onKeyUpProp = props.onKeyUp;
16063 const onKeyUp = useEvent((event) => {
16064 onKeyUpProp == null ? void 0 : onKeyUpProp(event);
16065 if (event.defaultPrevented) return;
16066 if (isDuplicate) return;
16067 if (disabled2) return;
16068 if (event.metaKey) return;
16069 const isSpace = clickOnSpace && event.key === " ";
16070 if (activeRef.current && isSpace) {
16071 activeRef.current = false;
16072 if (!isNativeClick(event)) {
16073 event.preventDefault();
16074 setActive(false);
16075 const element = event.currentTarget;
16076 const { view, ...eventInit } = event;
16077 queueMicrotask(() => fireClickEvent(element, eventInit));
16078 }
16079 }
16080 });
16081 props = {
16082 "data-active": active || void 0,
16083 type: isNativeButton ? "button" : void 0,
16084 ...metadataProps,
16085 ...props,
16086 ref: useMergeRefs(ref, props.ref),
16087 onKeyDown,
16088 onKeyUp
16089 };
16090 props = useFocusable(props);
16091 return props;
16092 }
16093 );
16094 var Command = forwardRef210(function Command2(props) {
16095 const htmlProps = useCommand(props);
16096 return createElement3(TagName3, htmlProps);
16097 });
16098
16099 // node_modules/@ariakit/core/esm/__chunks/SXKM4CGU.js
16100 function getInternal(store, key) {
16101 const internals = store.__unstableInternals;
16102 invariant(internals, "Invalid store");
16103 return internals[key];
16104 }
16105 function createStore(initialState, ...stores) {
16106 let state = initialState;
16107 let prevStateBatch = state;
16108 let lastUpdate = /* @__PURE__ */ Symbol();
16109 let destroy = noop4;
16110 const instances = /* @__PURE__ */ new Set();
16111 const updatedKeys = /* @__PURE__ */ new Set();
16112 const setups = /* @__PURE__ */ new Set();
16113 const listeners = /* @__PURE__ */ new Set();
16114 const batchListeners = /* @__PURE__ */ new Set();
16115 const disposables = /* @__PURE__ */ new WeakMap();
16116 const listenerKeys = /* @__PURE__ */ new WeakMap();
16117 const storeSetup = (callback) => {
16118 setups.add(callback);
16119 return () => setups.delete(callback);
16120 };
16121 const storeInit = () => {
16122 const initialized = instances.size;
16123 const instance = /* @__PURE__ */ Symbol();
16124 instances.add(instance);
16125 const maybeDestroy = () => {
16126 instances.delete(instance);
16127 if (instances.size) return;
16128 destroy();
16129 };
16130 if (initialized) return maybeDestroy;
16131 const desyncs = getKeys(state).map(
16132 (key) => chain(
16133 ...stores.map((store) => {
16134 var _a;
16135 const storeState = (_a = store == null ? void 0 : store.getState) == null ? void 0 : _a.call(store);
16136 if (!storeState) return;
16137 if (!hasOwnProperty(storeState, key)) return;
16138 return sync(store, [key], (state2) => {
16139 setState(
16140 key,
16141 state2[key],
16142 // @ts-expect-error - Not public API. This is just to prevent
16143 // infinite loops.
16144 true
16145 );
16146 });
16147 })
16148 )
16149 );
16150 const teardowns = [];
16151 for (const setup2 of setups) {
16152 teardowns.push(setup2());
16153 }
16154 const cleanups = stores.map(init);
16155 destroy = chain(...desyncs, ...teardowns, ...cleanups);
16156 return maybeDestroy;
16157 };
16158 const sub = (keys, listener, set2 = listeners) => {
16159 set2.add(listener);
16160 listenerKeys.set(listener, keys);
16161 return () => {
16162 var _a;
16163 (_a = disposables.get(listener)) == null ? void 0 : _a();
16164 disposables.delete(listener);
16165 listenerKeys.delete(listener);
16166 set2.delete(listener);
16167 };
16168 };
16169 const storeSubscribe = (keys, listener) => sub(keys, listener);
16170 const storeSync = (keys, listener) => {
16171 disposables.set(listener, listener(state, state));
16172 return sub(keys, listener);
16173 };
16174 const storeBatch = (keys, listener) => {
16175 disposables.set(listener, listener(state, prevStateBatch));
16176 return sub(keys, listener, batchListeners);
16177 };
16178 const storePick = (keys) => createStore(pick(state, keys), finalStore);
16179 const storeOmit = (keys) => createStore(omit(state, keys), finalStore);
16180 const getState = () => state;
16181 const setState = (key, value, fromStores = false) => {
16182 var _a;
16183 if (!hasOwnProperty(state, key)) return;
16184 const nextValue = applyState(value, state[key]);
16185 if (nextValue === state[key]) return;
16186 if (!fromStores) {
16187 for (const store of stores) {
16188 (_a = store == null ? void 0 : store.setState) == null ? void 0 : _a.call(store, key, nextValue);
16189 }
16190 }
16191 const prevState = state;
16192 state = { ...state, [key]: nextValue };
16193 const thisUpdate = /* @__PURE__ */ Symbol();
16194 lastUpdate = thisUpdate;
16195 updatedKeys.add(key);
16196 const run = (listener, prev, uKeys) => {
16197 var _a2;
16198 const keys = listenerKeys.get(listener);
16199 const updated = (k) => uKeys ? uKeys.has(k) : k === key;
16200 if (!keys || keys.some(updated)) {
16201 (_a2 = disposables.get(listener)) == null ? void 0 : _a2();
16202 disposables.set(listener, listener(state, prev));
16203 }
16204 };
16205 for (const listener of listeners) {
16206 run(listener, prevState);
16207 }
16208 queueMicrotask(() => {
16209 if (lastUpdate !== thisUpdate) return;
16210 const snapshot = state;
16211 for (const listener of batchListeners) {
16212 run(listener, prevStateBatch, updatedKeys);
16213 }
16214 prevStateBatch = snapshot;
16215 updatedKeys.clear();
16216 });
16217 };
16218 const finalStore = {
16219 getState,
16220 setState,
16221 __unstableInternals: {
16222 setup: storeSetup,
16223 init: storeInit,
16224 subscribe: storeSubscribe,
16225 sync: storeSync,
16226 batch: storeBatch,
16227 pick: storePick,
16228 omit: storeOmit
16229 }
16230 };
16231 return finalStore;
16232 }
16233 function setup(store, ...args) {
16234 if (!store) return;
16235 return getInternal(store, "setup")(...args);
16236 }
16237 function init(store, ...args) {
16238 if (!store) return;
16239 return getInternal(store, "init")(...args);
16240 }
16241 function subscribe(store, ...args) {
16242 if (!store) return;
16243 return getInternal(store, "subscribe")(...args);
16244 }
16245 function sync(store, ...args) {
16246 if (!store) return;
16247 return getInternal(store, "sync")(...args);
16248 }
16249 function batch(store, ...args) {
16250 if (!store) return;
16251 return getInternal(store, "batch")(...args);
16252 }
16253 function omit2(store, ...args) {
16254 if (!store) return;
16255 return getInternal(store, "omit")(...args);
16256 }
16257 function pick2(store, ...args) {
16258 if (!store) return;
16259 return getInternal(store, "pick")(...args);
16260 }
16261 function mergeStore(...stores) {
16262 var _a;
16263 const initialState = {};
16264 for (const store2 of stores) {
16265 const nextState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2);
16266 if (nextState) {
16267 Object.assign(initialState, nextState);
16268 }
16269 }
16270 const store = createStore(initialState, ...stores);
16271 return Object.assign({}, ...stores, store);
16272 }
16273 function throwOnConflictingProps(props, store) {
16274 if (false) return;
16275 if (!store) return;
16276 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
16277 var _a;
16278 const stateKey = key.replace("default", "");
16279 return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}${stateKey.slice(1)}`;
16280 });
16281 if (!defaultKeys.length) return;
16282 const storeState = store.getState();
16283 const conflictingProps = defaultKeys.filter(
16284 (key) => hasOwnProperty(storeState, key)
16285 );
16286 if (!conflictingProps.length) return;
16287 throw new Error(
16288 `Passing a store prop in conjunction with a default state is not supported.
16289
16290 const store = useSelectStore();
16291 <SelectProvider store={store} defaultValue="Apple" />
16292 ^ ^
16293
16294 Instead, pass the default state to the topmost store:
16295
16296 const store = useSelectStore({ defaultValue: "Apple" });
16297 <SelectProvider store={store} />
16298
16299 See https://github.com/ariakit/ariakit/pull/2745 for more details.
16300
16301 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
16302 `
16303 );
16304 }
16305
16306 // node_modules/@ariakit/react-core/esm/__chunks/Q5W46E73.js
16307 var React50 = __toESM(require_react(), 1);
16308 var import_shim2 = __toESM(require_shim(), 1);
16309 var { useSyncExternalStore: useSyncExternalStore2 } = import_shim2.default;
16310 var noopSubscribe = () => () => {
16311 };
16312 function useStoreState(store, keyOrSelector = identity) {
16313 const storeSubscribe = React50.useCallback(
16314 (callback) => {
16315 if (!store) return noopSubscribe();
16316 return subscribe(store, null, callback);
16317 },
16318 [store]
16319 );
16320 const getSnapshot = () => {
16321 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
16322 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
16323 const state = store == null ? void 0 : store.getState();
16324 if (selector2) return selector2(state);
16325 if (!state) return;
16326 if (!key) return;
16327 if (!hasOwnProperty(state, key)) return;
16328 return state[key];
16329 };
16330 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot);
16331 }
16332 function useStoreStateObject(store, object) {
16333 const objRef = React50.useRef(
16334 {}
16335 );
16336 const storeSubscribe = React50.useCallback(
16337 (callback) => {
16338 if (!store) return noopSubscribe();
16339 return subscribe(store, null, callback);
16340 },
16341 [store]
16342 );
16343 const getSnapshot = () => {
16344 const state = store == null ? void 0 : store.getState();
16345 let updated = false;
16346 const obj = objRef.current;
16347 for (const prop in object) {
16348 const keyOrSelector = object[prop];
16349 if (typeof keyOrSelector === "function") {
16350 const value = keyOrSelector(state);
16351 if (value !== obj[prop]) {
16352 obj[prop] = value;
16353 updated = true;
16354 }
16355 }
16356 if (typeof keyOrSelector === "string") {
16357 if (!state) continue;
16358 if (!hasOwnProperty(state, keyOrSelector)) continue;
16359 const value = state[keyOrSelector];
16360 if (value !== obj[prop]) {
16361 obj[prop] = value;
16362 updated = true;
16363 }
16364 }
16365 }
16366 if (updated) {
16367 objRef.current = { ...obj };
16368 }
16369 return objRef.current;
16370 };
16371 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot);
16372 }
16373 function useStoreProps(store, props, key, setKey) {
16374 const value = hasOwnProperty(props, key) ? props[key] : void 0;
16375 const setValue = setKey ? props[setKey] : void 0;
16376 const propsRef = useLiveRef({ value, setValue });
16377 useSafeLayoutEffect(() => {
16378 return sync(store, [key], (state, prev) => {
16379 const { value: value2, setValue: setValue2 } = propsRef.current;
16380 if (!setValue2) return;
16381 if (state[key] === prev[key]) return;
16382 if (state[key] === value2) return;
16383 setValue2(state[key]);
16384 });
16385 }, [store, key]);
16386 useSafeLayoutEffect(() => {
16387 if (value === void 0) return;
16388 store.setState(key, value);
16389 return batch(store, [key], () => {
16390 if (value === void 0) return;
16391 store.setState(key, value);
16392 });
16393 });
16394 }
16395 function useStore2(createStore2, props) {
16396 const [store, setStore] = React50.useState(() => createStore2(props));
16397 useSafeLayoutEffect(() => init(store), [store]);
16398 const useState210 = React50.useCallback(
16399 (keyOrSelector) => useStoreState(store, keyOrSelector),
16400 [store]
16401 );
16402 const memoizedStore = React50.useMemo(
16403 () => ({ ...store, useState: useState210 }),
16404 [store, useState210]
16405 );
16406 const updateStore = useEvent(() => {
16407 setStore((store2) => createStore2({ ...props, ...store2.getState() }));
16408 });
16409 return [memoizedStore, updateStore];
16410 }
16411
16412 // node_modules/@ariakit/react-core/esm/__chunks/WZWDIE3S.js
16413 var import_react18 = __toESM(require_react(), 1);
16414 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
16415 var TagName4 = "button";
16416 function isEditableElement(element) {
16417 if (isTextbox(element)) return true;
16418 return element.tagName === "INPUT" && !isButton(element);
16419 }
16420 function getNextPageOffset(scrollingElement, pageUp = false) {
16421 const height = scrollingElement.clientHeight;
16422 const { top } = scrollingElement.getBoundingClientRect();
16423 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
16424 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
16425 if (scrollingElement.tagName === "HTML") {
16426 return pageOffset + scrollingElement.scrollTop;
16427 }
16428 return pageOffset;
16429 }
16430 function getItemOffset(itemElement, pageUp = false) {
16431 const { top } = itemElement.getBoundingClientRect();
16432 if (pageUp) {
16433 return top + itemElement.clientHeight;
16434 }
16435 return top;
16436 }
16437 function findNextPageItemId(element, store, next, pageUp = false) {
16438 var _a;
16439 if (!store) return;
16440 if (!next) return;
16441 const { renderedItems } = store.getState();
16442 const scrollingElement = getScrollingElement(element);
16443 if (!scrollingElement) return;
16444 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
16445 let id;
16446 let prevDifference;
16447 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
16448 const previousId = id;
16449 id = next(i2);
16450 if (!id) break;
16451 if (id === previousId) continue;
16452 const itemElement = (_a = getEnabledItem(store, id)) == null ? void 0 : _a.element;
16453 if (!itemElement) continue;
16454 const itemOffset = getItemOffset(itemElement, pageUp);
16455 const difference = itemOffset - nextPageOffset;
16456 const absDifference = Math.abs(difference);
16457 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
16458 if (prevDifference !== void 0 && prevDifference < absDifference) {
16459 id = previousId;
16460 }
16461 break;
16462 }
16463 prevDifference = absDifference;
16464 }
16465 return id;
16466 }
16467 function targetIsAnotherItem(event, store) {
16468 if (isSelfTarget(event)) return false;
16469 return isItem(store, event.target);
16470 }
16471 var useCompositeItem = createHook(
16472 function useCompositeItem2({
16473 store,
16474 rowId: rowIdProp,
16475 preventScrollOnKeyDown = false,
16476 moveOnKeyPress = true,
16477 tabbable: tabbable2 = false,
16478 getItem: getItemProp,
16479 "aria-setsize": ariaSetSizeProp,
16480 "aria-posinset": ariaPosInSetProp,
16481 ...props
16482 }) {
16483 const context = useCompositeContext();
16484 store = store || context;
16485 const id = useId4(props.id);
16486 const ref = (0, import_react18.useRef)(null);
16487 const row = (0, import_react18.useContext)(CompositeRowContext);
16488 const disabled2 = disabledFromProps(props);
16489 const trulyDisabled = disabled2 && !props.accessibleWhenDisabled;
16490 const {
16491 rowId,
16492 baseElement,
16493 isActiveItem,
16494 ariaSetSize,
16495 ariaPosInSet,
16496 isTabbable
16497 } = useStoreStateObject(store, {
16498 rowId(state) {
16499 if (rowIdProp) return rowIdProp;
16500 if (!state) return;
16501 if (!(row == null ? void 0 : row.baseElement)) return;
16502 if (row.baseElement !== state.baseElement) return;
16503 return row.id;
16504 },
16505 baseElement(state) {
16506 return (state == null ? void 0 : state.baseElement) || void 0;
16507 },
16508 isActiveItem(state) {
16509 return !!state && state.activeId === id;
16510 },
16511 ariaSetSize(state) {
16512 if (ariaSetSizeProp != null) return ariaSetSizeProp;
16513 if (!state) return;
16514 if (!(row == null ? void 0 : row.ariaSetSize)) return;
16515 if (row.baseElement !== state.baseElement) return;
16516 return row.ariaSetSize;
16517 },
16518 ariaPosInSet(state) {
16519 if (ariaPosInSetProp != null) return ariaPosInSetProp;
16520 if (!state) return;
16521 if (!(row == null ? void 0 : row.ariaPosInSet)) return;
16522 if (row.baseElement !== state.baseElement) return;
16523 const itemsInRow = state.renderedItems.filter(
16524 (item) => item.rowId === rowId
16525 );
16526 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
16527 },
16528 isTabbable(state) {
16529 if (!(state == null ? void 0 : state.renderedItems.length)) return true;
16530 if (state.virtualFocus) return false;
16531 if (tabbable2) return true;
16532 if (state.activeId === null) return false;
16533 const item = store == null ? void 0 : store.item(state.activeId);
16534 if (item == null ? void 0 : item.disabled) return true;
16535 if (!(item == null ? void 0 : item.element)) return true;
16536 return state.activeId === id;
16537 }
16538 });
16539 const getItem = (0, import_react18.useCallback)(
16540 (item) => {
16541 var _a;
16542 const nextItem = {
16543 ...item,
16544 id: id || item.id,
16545 rowId,
16546 disabled: !!trulyDisabled,
16547 children: (_a = item.element) == null ? void 0 : _a.textContent
16548 };
16549 if (getItemProp) {
16550 return getItemProp(nextItem);
16551 }
16552 return nextItem;
16553 },
16554 [id, rowId, trulyDisabled, getItemProp]
16555 );
16556 const onFocusProp = props.onFocus;
16557 const hasFocusedComposite = (0, import_react18.useRef)(false);
16558 const onFocus = useEvent((event) => {
16559 onFocusProp == null ? void 0 : onFocusProp(event);
16560 if (event.defaultPrevented) return;
16561 if (isPortalEvent(event)) return;
16562 if (!id) return;
16563 if (!store) return;
16564 if (targetIsAnotherItem(event, store)) return;
16565 const { virtualFocus, baseElement: baseElement2 } = store.getState();
16566 store.setActiveId(id);
16567 if (isTextbox(event.currentTarget)) {
16568 selectTextField(event.currentTarget);
16569 }
16570 if (!virtualFocus) return;
16571 if (!isSelfTarget(event)) return;
16572 if (isEditableElement(event.currentTarget)) return;
16573 if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) return;
16574 if (isSafari2() && event.currentTarget.hasAttribute("data-autofocus")) {
16575 event.currentTarget.scrollIntoView({
16576 block: "nearest",
16577 inline: "nearest"
16578 });
16579 }
16580 hasFocusedComposite.current = true;
16581 const fromComposite = event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget);
16582 if (fromComposite) {
16583 focusSilently(baseElement2);
16584 } else {
16585 baseElement2.focus();
16586 }
16587 });
16588 const onBlurCaptureProp = props.onBlurCapture;
16589 const onBlurCapture = useEvent((event) => {
16590 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
16591 if (event.defaultPrevented) return;
16592 const state = store == null ? void 0 : store.getState();
16593 if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) {
16594 hasFocusedComposite.current = false;
16595 event.preventDefault();
16596 event.stopPropagation();
16597 }
16598 });
16599 const onKeyDownProp = props.onKeyDown;
16600 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
16601 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
16602 const onKeyDown = useEvent((event) => {
16603 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
16604 if (event.defaultPrevented) return;
16605 if (!isSelfTarget(event)) return;
16606 if (!store) return;
16607 const { currentTarget } = event;
16608 const state = store.getState();
16609 const item = store.item(id);
16610 const isGrid2 = !!(item == null ? void 0 : item.rowId);
16611 const isVertical = state.orientation !== "horizontal";
16612 const isHorizontal = state.orientation !== "vertical";
16613 const canHomeEnd = () => {
16614 if (isGrid2) return true;
16615 if (isHorizontal) return true;
16616 if (!state.baseElement) return true;
16617 if (!isTextField(state.baseElement)) return true;
16618 return false;
16619 };
16620 const keyMap = {
16621 ArrowUp: (isGrid2 || isVertical) && store.up,
16622 ArrowRight: (isGrid2 || isHorizontal) && store.next,
16623 ArrowDown: (isGrid2 || isVertical) && store.down,
16624 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
16625 Home: () => {
16626 if (!canHomeEnd()) return;
16627 if (!isGrid2 || event.ctrlKey) {
16628 return store == null ? void 0 : store.first();
16629 }
16630 return store == null ? void 0 : store.previous(-1);
16631 },
16632 End: () => {
16633 if (!canHomeEnd()) return;
16634 if (!isGrid2 || event.ctrlKey) {
16635 return store == null ? void 0 : store.last();
16636 }
16637 return store == null ? void 0 : store.next(-1);
16638 },
16639 PageUp: () => {
16640 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.up, true);
16641 },
16642 PageDown: () => {
16643 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.down);
16644 }
16645 };
16646 const action = keyMap[event.key];
16647 if (action) {
16648 if (isTextbox(currentTarget)) {
16649 const selection = getTextboxSelection(currentTarget);
16650 const isLeft = isHorizontal && event.key === "ArrowLeft";
16651 const isRight = isHorizontal && event.key === "ArrowRight";
16652 const isUp = isVertical && event.key === "ArrowUp";
16653 const isDown = isVertical && event.key === "ArrowDown";
16654 if (isRight || isDown) {
16655 const { length: valueLength } = getTextboxValue(currentTarget);
16656 if (selection.end !== valueLength) return;
16657 } else if ((isLeft || isUp) && selection.start !== 0) return;
16658 }
16659 const nextId = action();
16660 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
16661 if (!moveOnKeyPressProp(event)) return;
16662 event.preventDefault();
16663 store.move(nextId);
16664 }
16665 }
16666 });
16667 const providerValue = (0, import_react18.useMemo)(
16668 () => ({ id, baseElement }),
16669 [id, baseElement]
16670 );
16671 props = useWrapElement(
16672 props,
16673 (element) => /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }),
16674 [providerValue]
16675 );
16676 props = {
16677 id,
16678 "data-active-item": isActiveItem || void 0,
16679 ...props,
16680 ref: useMergeRefs(ref, props.ref),
16681 tabIndex: isTabbable ? props.tabIndex : -1,
16682 onFocus,
16683 onBlurCapture,
16684 onKeyDown
16685 };
16686 props = useCommand(props);
16687 props = useCollectionItem({
16688 store,
16689 ...props,
16690 getItem,
16691 shouldRegisterItem: id ? props.shouldRegisterItem : false
16692 });
16693 return removeUndefinedValues({
16694 ...props,
16695 "aria-setsize": ariaSetSize,
16696 "aria-posinset": ariaPosInSet
16697 });
16698 }
16699 );
16700 var CompositeItem = memo22(
16701 forwardRef210(function CompositeItem2(props) {
16702 const htmlProps = useCompositeItem(props);
16703 return createElement3(TagName4, htmlProps);
16704 })
16705 );
16706
16707 // node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js
16708 function toArray(arg) {
16709 if (Array.isArray(arg)) {
16710 return arg;
16711 }
16712 return typeof arg !== "undefined" ? [arg] : [];
16713 }
16714 function flatten2DArray(array) {
16715 const flattened = [];
16716 for (const row of array) {
16717 flattened.push(...row);
16718 }
16719 return flattened;
16720 }
16721 function reverseArray(array) {
16722 return array.slice().reverse();
16723 }
16724
16725 // node_modules/@ariakit/react-core/esm/__chunks/ZMWF7ASR.js
16726 var import_react19 = __toESM(require_react(), 1);
16727 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
16728 var TagName5 = "div";
16729 function isGrid(items) {
16730 return items.some((item) => !!item.rowId);
16731 }
16732 function isPrintableKey(event) {
16733 const target = event.target;
16734 if (target && !isTextField(target)) return false;
16735 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
16736 }
16737 function isModifierKey(event) {
16738 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
16739 }
16740 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
16741 return useEvent((event) => {
16742 var _a;
16743 onKeyboardEvent == null ? void 0 : onKeyboardEvent(event);
16744 if (event.defaultPrevented) return;
16745 if (event.isPropagationStopped()) return;
16746 if (!isSelfTarget(event)) return;
16747 if (isModifierKey(event)) return;
16748 if (isPrintableKey(event)) return;
16749 const state = store.getState();
16750 const activeElement2 = (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.element;
16751 if (!activeElement2) return;
16752 const { view, ...eventInit } = event;
16753 const previousElement = previousElementRef == null ? void 0 : previousElementRef.current;
16754 if (activeElement2 !== previousElement) {
16755 activeElement2.focus();
16756 }
16757 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) {
16758 event.preventDefault();
16759 }
16760 if (event.currentTarget.contains(activeElement2)) {
16761 event.stopPropagation();
16762 }
16763 });
16764 }
16765 function findFirstEnabledItemInTheLastRow(items) {
16766 return findFirstEnabledItem(
16767 flatten2DArray(reverseArray(groupItemsByRows(items)))
16768 );
16769 }
16770 function useScheduleFocus(store) {
16771 const [scheduled, setScheduled] = (0, import_react19.useState)(false);
16772 const schedule = (0, import_react19.useCallback)(() => setScheduled(true), []);
16773 const activeItem = store.useState(
16774 (state) => getEnabledItem(store, state.activeId)
16775 );
16776 (0, import_react19.useEffect)(() => {
16777 const activeElement2 = activeItem == null ? void 0 : activeItem.element;
16778 if (!scheduled) return;
16779 if (!activeElement2) return;
16780 setScheduled(false);
16781 activeElement2.focus({ preventScroll: true });
16782 }, [activeItem, scheduled]);
16783 return schedule;
16784 }
16785 var useComposite = createHook(
16786 function useComposite2({
16787 store,
16788 composite = true,
16789 focusOnMove = composite,
16790 moveOnKeyPress = true,
16791 ...props
16792 }) {
16793 const context = useCompositeProviderContext();
16794 store = store || context;
16795 invariant(
16796 store,
16797 "Composite must receive a `store` prop or be wrapped in a CompositeProvider component."
16798 );
16799 const ref = (0, import_react19.useRef)(null);
16800 const previousElementRef = (0, import_react19.useRef)(null);
16801 const scheduleFocus = useScheduleFocus(store);
16802 const moves = store.useState("moves");
16803 const [, setBaseElement] = useTransactionState(
16804 composite ? store.setBaseElement : null
16805 );
16806 (0, import_react19.useEffect)(() => {
16807 var _a;
16808 if (!store) return;
16809 if (!moves) return;
16810 if (!composite) return;
16811 if (!focusOnMove) return;
16812 const { activeId: activeId2 } = store.getState();
16813 const itemElement = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
16814 if (!itemElement) return;
16815 focusIntoView(itemElement);
16816 }, [store, moves, composite, focusOnMove]);
16817 useSafeLayoutEffect(() => {
16818 if (!store) return;
16819 if (!moves) return;
16820 if (!composite) return;
16821 const { baseElement, activeId: activeId2 } = store.getState();
16822 const isSelfAcive = activeId2 === null;
16823 if (!isSelfAcive) return;
16824 if (!baseElement) return;
16825 const previousElement = previousElementRef.current;
16826 previousElementRef.current = null;
16827 if (previousElement) {
16828 fireBlurEvent(previousElement, { relatedTarget: baseElement });
16829 }
16830 if (!hasFocus(baseElement)) {
16831 baseElement.focus();
16832 }
16833 }, [store, moves, composite]);
16834 const activeId = store.useState("activeId");
16835 const virtualFocus = store.useState("virtualFocus");
16836 useSafeLayoutEffect(() => {
16837 var _a;
16838 if (!store) return;
16839 if (!composite) return;
16840 if (!virtualFocus) return;
16841 const previousElement = previousElementRef.current;
16842 previousElementRef.current = null;
16843 if (!previousElement) return;
16844 const activeElement2 = (_a = getEnabledItem(store, activeId)) == null ? void 0 : _a.element;
16845 const relatedTarget = activeElement2 || getActiveElement(previousElement);
16846 if (relatedTarget === previousElement) return;
16847 fireBlurEvent(previousElement, { relatedTarget });
16848 }, [store, activeId, virtualFocus, composite]);
16849 const onKeyDownCapture = useKeyboardEventProxy(
16850 store,
16851 props.onKeyDownCapture,
16852 previousElementRef
16853 );
16854 const onKeyUpCapture = useKeyboardEventProxy(
16855 store,
16856 props.onKeyUpCapture,
16857 previousElementRef
16858 );
16859 const onFocusCaptureProp = props.onFocusCapture;
16860 const onFocusCapture = useEvent((event) => {
16861 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
16862 if (event.defaultPrevented) return;
16863 if (!store) return;
16864 const { virtualFocus: virtualFocus2 } = store.getState();
16865 if (!virtualFocus2) return;
16866 const previousActiveElement = event.relatedTarget;
16867 const isSilentlyFocused = silentlyFocused(event.currentTarget);
16868 if (isSelfTarget(event) && isSilentlyFocused) {
16869 event.stopPropagation();
16870 previousElementRef.current = previousActiveElement;
16871 }
16872 });
16873 const onFocusProp = props.onFocus;
16874 const onFocus = useEvent((event) => {
16875 onFocusProp == null ? void 0 : onFocusProp(event);
16876 if (event.defaultPrevented) return;
16877 if (!composite) return;
16878 if (!store) return;
16879 const { relatedTarget } = event;
16880 const { virtualFocus: virtualFocus2 } = store.getState();
16881 if (virtualFocus2) {
16882 if (isSelfTarget(event) && !isItem(store, relatedTarget)) {
16883 queueMicrotask(scheduleFocus);
16884 }
16885 } else if (isSelfTarget(event)) {
16886 store.setActiveId(null);
16887 }
16888 });
16889 const onBlurCaptureProp = props.onBlurCapture;
16890 const onBlurCapture = useEvent((event) => {
16891 var _a;
16892 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
16893 if (event.defaultPrevented) return;
16894 if (!store) return;
16895 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
16896 if (!virtualFocus2) return;
16897 const activeElement2 = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
16898 const nextActiveElement = event.relatedTarget;
16899 const nextActiveElementIsItem = isItem(store, nextActiveElement);
16900 const previousElement = previousElementRef.current;
16901 previousElementRef.current = null;
16902 if (isSelfTarget(event) && nextActiveElementIsItem) {
16903 if (nextActiveElement === activeElement2) {
16904 if (previousElement && previousElement !== nextActiveElement) {
16905 fireBlurEvent(previousElement, event);
16906 }
16907 } else if (activeElement2) {
16908 fireBlurEvent(activeElement2, event);
16909 } else if (previousElement) {
16910 fireBlurEvent(previousElement, event);
16911 }
16912 event.stopPropagation();
16913 } else {
16914 const targetIsItem = isItem(store, event.target);
16915 if (!targetIsItem && activeElement2) {
16916 fireBlurEvent(activeElement2, event);
16917 }
16918 }
16919 });
16920 const onKeyDownProp = props.onKeyDown;
16921 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
16922 const onKeyDown = useEvent((event) => {
16923 var _a;
16924 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
16925 if (event.nativeEvent.isComposing) return;
16926 if (event.defaultPrevented) return;
16927 if (!store) return;
16928 if (!isSelfTarget(event)) return;
16929 const { orientation, renderedItems, activeId: activeId2 } = store.getState();
16930 const activeItem = getEnabledItem(store, activeId2);
16931 if ((_a = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a.isConnected) return;
16932 const isVertical = orientation !== "horizontal";
16933 const isHorizontal = orientation !== "vertical";
16934 const grid = isGrid(renderedItems);
16935 const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End";
16936 if (isHorizontalKey && isTextField(event.currentTarget)) return;
16937 const up = () => {
16938 if (grid) {
16939 const item = findFirstEnabledItemInTheLastRow(renderedItems);
16940 return item == null ? void 0 : item.id;
16941 }
16942 return store == null ? void 0 : store.last();
16943 };
16944 const keyMap = {
16945 ArrowUp: (grid || isVertical) && up,
16946 ArrowRight: (grid || isHorizontal) && store.first,
16947 ArrowDown: (grid || isVertical) && store.first,
16948 ArrowLeft: (grid || isHorizontal) && store.last,
16949 Home: store.first,
16950 End: store.last,
16951 PageUp: store.first,
16952 PageDown: store.last
16953 };
16954 const action = keyMap[event.key];
16955 if (action) {
16956 const id = action();
16957 if (id !== void 0) {
16958 if (!moveOnKeyPressProp(event)) return;
16959 event.preventDefault();
16960 store.move(id);
16961 }
16962 }
16963 });
16964 props = useWrapElement(
16965 props,
16966 (element) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(CompositeContextProvider, { value: store, children: element }),
16967 [store]
16968 );
16969 const activeDescendant = store.useState((state) => {
16970 var _a;
16971 if (!store) return;
16972 if (!composite) return;
16973 if (!state.virtualFocus) return;
16974 return (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.id;
16975 });
16976 props = {
16977 "aria-activedescendant": activeDescendant,
16978 ...props,
16979 ref: useMergeRefs(ref, setBaseElement, props.ref),
16980 onKeyDownCapture,
16981 onKeyUpCapture,
16982 onFocusCapture,
16983 onFocus,
16984 onBlurCapture,
16985 onKeyDown
16986 };
16987 const focusable2 = store.useState(
16988 (state) => composite && (state.virtualFocus || state.activeId === null)
16989 );
16990 props = useFocusable({ focusable: focusable2, ...props });
16991 return props;
16992 }
16993 );
16994 var Composite5 = forwardRef210(function Composite22(props) {
16995 const htmlProps = useComposite(props);
16996 return createElement3(TagName5, htmlProps);
16997 });
16998
16999 // node_modules/@ariakit/react-core/esm/__chunks/LVDQFHCH.js
17000 var ctx3 = createStoreContext();
17001 var useDisclosureContext = ctx3.useContext;
17002 var useDisclosureScopedContext = ctx3.useScopedContext;
17003 var useDisclosureProviderContext = ctx3.useProviderContext;
17004 var DisclosureContextProvider = ctx3.ContextProvider;
17005 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
17006
17007 // node_modules/@ariakit/react-core/esm/__chunks/A62MDFCW.js
17008 var import_react20 = __toESM(require_react(), 1);
17009 var ctx4 = createStoreContext(
17010 [DisclosureContextProvider],
17011 [DisclosureScopedContextProvider]
17012 );
17013 var useDialogContext = ctx4.useContext;
17014 var useDialogScopedContext = ctx4.useScopedContext;
17015 var useDialogProviderContext = ctx4.useProviderContext;
17016 var DialogContextProvider = ctx4.ContextProvider;
17017 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
17018 var DialogHeadingContext = (0, import_react20.createContext)(void 0);
17019 var DialogDescriptionContext = (0, import_react20.createContext)(void 0);
17020
17021 // node_modules/@ariakit/react-core/esm/__chunks/6B3RXHKP.js
17022 var import_react21 = __toESM(require_react(), 1);
17023 var import_react_dom4 = __toESM(require_react_dom(), 1);
17024 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
17025 var TagName6 = "div";
17026 function afterTimeout(timeoutMs, cb) {
17027 const timeoutId = setTimeout(cb, timeoutMs);
17028 return () => clearTimeout(timeoutId);
17029 }
17030 function afterPaint2(cb) {
17031 let raf = requestAnimationFrame(() => {
17032 raf = requestAnimationFrame(cb);
17033 });
17034 return () => cancelAnimationFrame(raf);
17035 }
17036 function parseCSSTime(...times) {
17037 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => {
17038 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3;
17039 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier;
17040 if (currentTime > longestTime) return currentTime;
17041 return longestTime;
17042 }, 0);
17043 }
17044 function isHidden(mounted, hidden, alwaysVisible) {
17045 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
17046 }
17047 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, ...props }) {
17048 const context = useDisclosureProviderContext();
17049 store = store || context;
17050 invariant(
17051 store,
17052 "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component."
17053 );
17054 const ref = (0, import_react21.useRef)(null);
17055 const id = useId4(props.id);
17056 const [transition, setTransition] = (0, import_react21.useState)(null);
17057 const open = store.useState("open");
17058 const mounted = store.useState("mounted");
17059 const animated = store.useState("animated");
17060 const contentElement = store.useState("contentElement");
17061 const otherElement = useStoreState(store.disclosure, "contentElement");
17062 useSafeLayoutEffect(() => {
17063 if (!ref.current) return;
17064 store == null ? void 0 : store.setContentElement(ref.current);
17065 }, [store]);
17066 useSafeLayoutEffect(() => {
17067 let previousAnimated;
17068 store == null ? void 0 : store.setState("animated", (animated2) => {
17069 previousAnimated = animated2;
17070 return true;
17071 });
17072 return () => {
17073 if (previousAnimated === void 0) return;
17074 store == null ? void 0 : store.setState("animated", previousAnimated);
17075 };
17076 }, [store]);
17077 useSafeLayoutEffect(() => {
17078 if (!animated) return;
17079 if (!(contentElement == null ? void 0 : contentElement.isConnected)) {
17080 setTransition(null);
17081 return;
17082 }
17083 return afterPaint2(() => {
17084 setTransition(open ? "enter" : mounted ? "leave" : null);
17085 });
17086 }, [animated, contentElement, open, mounted]);
17087 useSafeLayoutEffect(() => {
17088 if (!store) return;
17089 if (!animated) return;
17090 if (!transition) return;
17091 if (!contentElement) return;
17092 const stopAnimation = () => store == null ? void 0 : store.setState("animating", false);
17093 const stopAnimationSync = () => (0, import_react_dom4.flushSync)(stopAnimation);
17094 if (transition === "leave" && open) return;
17095 if (transition === "enter" && !open) return;
17096 if (typeof animated === "number") {
17097 const timeout2 = animated;
17098 return afterTimeout(timeout2, stopAnimationSync);
17099 }
17100 const {
17101 transitionDuration,
17102 animationDuration,
17103 transitionDelay,
17104 animationDelay
17105 } = getComputedStyle(contentElement);
17106 const {
17107 transitionDuration: transitionDuration2 = "0",
17108 animationDuration: animationDuration2 = "0",
17109 transitionDelay: transitionDelay2 = "0",
17110 animationDelay: animationDelay2 = "0"
17111 } = otherElement ? getComputedStyle(otherElement) : {};
17112 const delay = parseCSSTime(
17113 transitionDelay,
17114 animationDelay,
17115 transitionDelay2,
17116 animationDelay2
17117 );
17118 const duration = parseCSSTime(
17119 transitionDuration,
17120 animationDuration,
17121 transitionDuration2,
17122 animationDuration2
17123 );
17124 const timeout = delay + duration;
17125 if (!timeout) {
17126 if (transition === "enter") {
17127 store.setState("animated", false);
17128 }
17129 stopAnimation();
17130 return;
17131 }
17132 const frameRate = 1e3 / 60;
17133 const maxTimeout = Math.max(timeout - frameRate, 0);
17134 return afterTimeout(maxTimeout, stopAnimationSync);
17135 }, [store, animated, contentElement, otherElement, open, transition]);
17136 props = useWrapElement(
17137 props,
17138 (element) => /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DialogScopedContextProvider, { value: store, children: element }),
17139 [store]
17140 );
17141 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
17142 const styleProp = props.style;
17143 const style = (0, import_react21.useMemo)(() => {
17144 if (hidden) {
17145 return { ...styleProp, display: "none" };
17146 }
17147 return styleProp;
17148 }, [hidden, styleProp]);
17149 props = {
17150 id,
17151 "data-open": open || void 0,
17152 "data-enter": transition === "enter" || void 0,
17153 "data-leave": transition === "leave" || void 0,
17154 hidden,
17155 ...props,
17156 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref),
17157 style
17158 };
17159 return removeUndefinedValues(props);
17160 });
17161 var DisclosureContentImpl = forwardRef210(function DisclosureContentImpl2(props) {
17162 const htmlProps = useDisclosureContent(props);
17163 return createElement3(TagName6, htmlProps);
17164 });
17165 var DisclosureContent = forwardRef210(function DisclosureContent2({
17166 unmountOnHide,
17167 ...props
17168 }) {
17169 const context = useDisclosureProviderContext();
17170 const store = props.store || context;
17171 const mounted = useStoreState(
17172 store,
17173 (state) => !unmountOnHide || (state == null ? void 0 : state.mounted)
17174 );
17175 if (mounted === false) return null;
17176 return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DisclosureContentImpl, { ...props });
17177 });
17178
17179 // node_modules/@ariakit/core/esm/__chunks/75BJEVSH.js
17180 function createDisclosureStore(props = {}) {
17181 const store = mergeStore(
17182 props.store,
17183 omit2(props.disclosure, ["contentElement", "disclosureElement"])
17184 );
17185 throwOnConflictingProps(props, store);
17186 const syncState = store == null ? void 0 : store.getState();
17187 const open = defaultValue(
17188 props.open,
17189 syncState == null ? void 0 : syncState.open,
17190 props.defaultOpen,
17191 false
17192 );
17193 const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false);
17194 const initialState = {
17195 open,
17196 animated,
17197 animating: !!animated && open,
17198 mounted: open,
17199 contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null),
17200 disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null)
17201 };
17202 const disclosure = createStore(initialState, store);
17203 setup(
17204 disclosure,
17205 () => sync(disclosure, ["animated", "animating"], (state) => {
17206 if (state.animated) return;
17207 disclosure.setState("animating", false);
17208 })
17209 );
17210 setup(
17211 disclosure,
17212 () => subscribe(disclosure, ["open"], () => {
17213 if (!disclosure.getState().animated) return;
17214 disclosure.setState("animating", true);
17215 })
17216 );
17217 setup(
17218 disclosure,
17219 () => sync(disclosure, ["open", "animating"], (state) => {
17220 disclosure.setState("mounted", state.open || state.animating);
17221 })
17222 );
17223 return {
17224 ...disclosure,
17225 disclosure: props.disclosure,
17226 setOpen: (value) => disclosure.setState("open", value),
17227 show: () => disclosure.setState("open", true),
17228 hide: () => disclosure.setState("open", false),
17229 toggle: () => disclosure.setState("open", (open2) => !open2),
17230 stopAnimation: () => disclosure.setState("animating", false),
17231 setContentElement: (value) => disclosure.setState("contentElement", value),
17232 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
17233 };
17234 }
17235
17236 // node_modules/@ariakit/react-core/esm/__chunks/WLZ6H5FH.js
17237 function useDisclosureStoreProps(store, update2, props) {
17238 useUpdateEffect(update2, [props.store, props.disclosure]);
17239 useStoreProps(store, props, "open", "setOpen");
17240 useStoreProps(store, props, "mounted", "setMounted");
17241 useStoreProps(store, props, "animated");
17242 return Object.assign(store, { disclosure: props.disclosure });
17243 }
17244
17245 // node_modules/@ariakit/react-core/esm/__chunks/JMU4N4M5.js
17246 var ctx5 = createStoreContext(
17247 [DialogContextProvider],
17248 [DialogScopedContextProvider]
17249 );
17250 var usePopoverContext = ctx5.useContext;
17251 var usePopoverScopedContext = ctx5.useScopedContext;
17252 var usePopoverProviderContext = ctx5.useProviderContext;
17253 var PopoverContextProvider = ctx5.ContextProvider;
17254 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
17255
17256 // node_modules/@ariakit/core/esm/__chunks/N5XGANPW.js
17257 function getCommonParent(items) {
17258 var _a;
17259 const firstItem = items.find((item) => !!item.element);
17260 const lastItem = [...items].reverse().find((item) => !!item.element);
17261 let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement;
17262 while (parentElement && (lastItem == null ? void 0 : lastItem.element)) {
17263 const parent = parentElement;
17264 if (lastItem && parent.contains(lastItem.element)) {
17265 return parentElement;
17266 }
17267 parentElement = parentElement.parentElement;
17268 }
17269 return getDocument(parentElement).body;
17270 }
17271 function getPrivateStore(store) {
17272 return store == null ? void 0 : store.__unstablePrivateStore;
17273 }
17274 function createCollectionStore(props = {}) {
17275 var _a;
17276 throwOnConflictingProps(props, props.store);
17277 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
17278 const items = defaultValue(
17279 props.items,
17280 syncState == null ? void 0 : syncState.items,
17281 props.defaultItems,
17282 []
17283 );
17284 const itemsMap = new Map(items.map((item) => [item.id, item]));
17285 const initialState = {
17286 items,
17287 renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, [])
17288 };
17289 const syncPrivateStore = getPrivateStore(props.store);
17290 const privateStore = createStore(
17291 { items, renderedItems: initialState.renderedItems },
17292 syncPrivateStore
17293 );
17294 const collection = createStore(initialState, props.store);
17295 const sortItems = (renderedItems) => {
17296 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
17297 privateStore.setState("renderedItems", sortedItems);
17298 collection.setState("renderedItems", sortedItems);
17299 };
17300 setup(collection, () => init(privateStore));
17301 setup(privateStore, () => {
17302 return batch(privateStore, ["items"], (state) => {
17303 collection.setState("items", state.items);
17304 });
17305 });
17306 setup(privateStore, () => {
17307 return batch(privateStore, ["renderedItems"], (state) => {
17308 let firstRun = true;
17309 let raf = requestAnimationFrame(() => {
17310 const { renderedItems } = collection.getState();
17311 if (state.renderedItems === renderedItems) return;
17312 sortItems(state.renderedItems);
17313 });
17314 if (typeof IntersectionObserver !== "function") {
17315 return () => cancelAnimationFrame(raf);
17316 }
17317 const ioCallback = () => {
17318 if (firstRun) {
17319 firstRun = false;
17320 return;
17321 }
17322 cancelAnimationFrame(raf);
17323 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
17324 };
17325 const root = getCommonParent(state.renderedItems);
17326 const observer = new IntersectionObserver(ioCallback, { root });
17327 for (const item of state.renderedItems) {
17328 if (!item.element) continue;
17329 observer.observe(item.element);
17330 }
17331 return () => {
17332 cancelAnimationFrame(raf);
17333 observer.disconnect();
17334 };
17335 });
17336 });
17337 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
17338 let prevItem;
17339 setItems((items2) => {
17340 const index2 = items2.findIndex(({ id }) => id === item.id);
17341 const nextItems = items2.slice();
17342 if (index2 !== -1) {
17343 prevItem = items2[index2];
17344 const nextItem = { ...prevItem, ...item };
17345 nextItems[index2] = nextItem;
17346 itemsMap.set(item.id, nextItem);
17347 } else {
17348 nextItems.push(item);
17349 itemsMap.set(item.id, item);
17350 }
17351 return nextItems;
17352 });
17353 const unmergeItem = () => {
17354 setItems((items2) => {
17355 if (!prevItem) {
17356 if (canDeleteFromMap) {
17357 itemsMap.delete(item.id);
17358 }
17359 return items2.filter(({ id }) => id !== item.id);
17360 }
17361 const index2 = items2.findIndex(({ id }) => id === item.id);
17362 if (index2 === -1) return items2;
17363 const nextItems = items2.slice();
17364 nextItems[index2] = prevItem;
17365 itemsMap.set(item.id, prevItem);
17366 return nextItems;
17367 });
17368 };
17369 return unmergeItem;
17370 };
17371 const registerItem = (item) => mergeItem(
17372 item,
17373 (getItems) => privateStore.setState("items", getItems),
17374 true
17375 );
17376 return {
17377 ...collection,
17378 registerItem,
17379 renderItem: (item) => chain(
17380 registerItem(item),
17381 mergeItem(
17382 item,
17383 (getItems) => privateStore.setState("renderedItems", getItems)
17384 )
17385 ),
17386 item: (id) => {
17387 if (!id) return null;
17388 let item = itemsMap.get(id);
17389 if (!item) {
17390 const { items: items2 } = privateStore.getState();
17391 item = items2.find((item2) => item2.id === id);
17392 if (item) {
17393 itemsMap.set(id, item);
17394 }
17395 }
17396 return item || null;
17397 },
17398 // @ts-expect-error Internal
17399 __unstablePrivateStore: privateStore
17400 };
17401 }
17402
17403 // node_modules/@ariakit/react-core/esm/__chunks/GVAFFF2B.js
17404 function useCollectionStoreProps(store, update2, props) {
17405 useUpdateEffect(update2, [props.store]);
17406 useStoreProps(store, props, "items", "setItems");
17407 return store;
17408 }
17409
17410 // node_modules/@ariakit/core/esm/__chunks/RVTIKFRL.js
17411 var NULL_ITEM = { id: null };
17412 function findFirstEnabledItem2(items, excludeId) {
17413 return items.find((item) => {
17414 if (excludeId) {
17415 return !item.disabled && item.id !== excludeId;
17416 }
17417 return !item.disabled;
17418 });
17419 }
17420 function getEnabledItems(items, excludeId) {
17421 return items.filter((item) => {
17422 if (excludeId) {
17423 return !item.disabled && item.id !== excludeId;
17424 }
17425 return !item.disabled;
17426 });
17427 }
17428 function getItemsInRow(items, rowId) {
17429 return items.filter((item) => item.rowId === rowId);
17430 }
17431 function flipItems(items, activeId, shouldInsertNullItem = false) {
17432 const index2 = items.findIndex((item) => item.id === activeId);
17433 return [
17434 ...items.slice(index2 + 1),
17435 ...shouldInsertNullItem ? [NULL_ITEM] : [],
17436 ...items.slice(0, index2)
17437 ];
17438 }
17439 function groupItemsByRows2(items) {
17440 const rows = [];
17441 for (const item of items) {
17442 const row = rows.find((currentRow) => {
17443 var _a;
17444 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
17445 });
17446 if (row) {
17447 row.push(item);
17448 } else {
17449 rows.push([item]);
17450 }
17451 }
17452 return rows;
17453 }
17454 function getMaxRowLength(array) {
17455 let maxLength = 0;
17456 for (const { length } of array) {
17457 if (length > maxLength) {
17458 maxLength = length;
17459 }
17460 }
17461 return maxLength;
17462 }
17463 function createEmptyItem(rowId) {
17464 return {
17465 id: "__EMPTY_ITEM__",
17466 disabled: true,
17467 rowId
17468 };
17469 }
17470 function normalizeRows(rows, activeId, focusShift) {
17471 const maxLength = getMaxRowLength(rows);
17472 for (const row of rows) {
17473 for (let i2 = 0; i2 < maxLength; i2 += 1) {
17474 const item = row[i2];
17475 if (!item || focusShift && item.disabled) {
17476 const isFirst = i2 === 0;
17477 const previousItem = isFirst && focusShift ? findFirstEnabledItem2(row) : row[i2 - 1];
17478 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId);
17479 }
17480 }
17481 }
17482 return rows;
17483 }
17484 function verticalizeItems(items) {
17485 const rows = groupItemsByRows2(items);
17486 const maxLength = getMaxRowLength(rows);
17487 const verticalized = [];
17488 for (let i2 = 0; i2 < maxLength; i2 += 1) {
17489 for (const row of rows) {
17490 const item = row[i2];
17491 if (item) {
17492 verticalized.push({
17493 ...item,
17494 // If there's no rowId, it means that it's not a grid composite, but
17495 // a single row instead. So, instead of verticalizing it, that is,
17496 // assigning a different rowId based on the column index, we keep it
17497 // undefined so they will be part of the same row. This is useful
17498 // when using up/down on one-dimensional composites.
17499 rowId: item.rowId ? `${i2}` : void 0
17500 });
17501 }
17502 }
17503 }
17504 return verticalized;
17505 }
17506 function createCompositeStore(props = {}) {
17507 var _a;
17508 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
17509 const collection = createCollectionStore(props);
17510 const activeId = defaultValue(
17511 props.activeId,
17512 syncState == null ? void 0 : syncState.activeId,
17513 props.defaultActiveId
17514 );
17515 const initialState = {
17516 ...collection.getState(),
17517 id: defaultValue(
17518 props.id,
17519 syncState == null ? void 0 : syncState.id,
17520 `id-${Math.random().toString(36).slice(2, 8)}`
17521 ),
17522 activeId,
17523 baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null),
17524 includesBaseElement: defaultValue(
17525 props.includesBaseElement,
17526 syncState == null ? void 0 : syncState.includesBaseElement,
17527 activeId === null
17528 ),
17529 moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0),
17530 orientation: defaultValue(
17531 props.orientation,
17532 syncState == null ? void 0 : syncState.orientation,
17533 "both"
17534 ),
17535 rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false),
17536 virtualFocus: defaultValue(
17537 props.virtualFocus,
17538 syncState == null ? void 0 : syncState.virtualFocus,
17539 false
17540 ),
17541 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false),
17542 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false),
17543 focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false)
17544 };
17545 const composite = createStore(initialState, collection, props.store);
17546 setup(
17547 composite,
17548 () => sync(composite, ["renderedItems", "activeId"], (state) => {
17549 composite.setState("activeId", (activeId2) => {
17550 var _a2;
17551 if (activeId2 !== void 0) return activeId2;
17552 return (_a2 = findFirstEnabledItem2(state.renderedItems)) == null ? void 0 : _a2.id;
17553 });
17554 })
17555 );
17556 const getNextId = (direction = "next", options = {}) => {
17557 var _a2, _b;
17558 const defaultState = composite.getState();
17559 const {
17560 skip = 0,
17561 activeId: activeId2 = defaultState.activeId,
17562 focusShift = defaultState.focusShift,
17563 focusLoop = defaultState.focusLoop,
17564 focusWrap = defaultState.focusWrap,
17565 includesBaseElement = defaultState.includesBaseElement,
17566 renderedItems = defaultState.renderedItems,
17567 rtl = defaultState.rtl
17568 } = options;
17569 const isVerticalDirection = direction === "up" || direction === "down";
17570 const isNextDirection = direction === "next" || direction === "down";
17571 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
17572 const canShift = focusShift && !skip;
17573 let items = !isVerticalDirection ? renderedItems : flatten2DArray(
17574 normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift)
17575 );
17576 items = canReverse ? reverseArray(items) : items;
17577 items = isVerticalDirection ? verticalizeItems(items) : items;
17578 if (activeId2 == null) {
17579 return (_a2 = findFirstEnabledItem2(items)) == null ? void 0 : _a2.id;
17580 }
17581 const activeItem = items.find((item) => item.id === activeId2);
17582 if (!activeItem) {
17583 return (_b = findFirstEnabledItem2(items)) == null ? void 0 : _b.id;
17584 }
17585 const isGrid2 = items.some((item) => item.rowId);
17586 const activeIndex = items.indexOf(activeItem);
17587 const nextItems = items.slice(activeIndex + 1);
17588 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
17589 if (skip) {
17590 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
17591 const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one.
17592 nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1];
17593 return nextItem2 == null ? void 0 : nextItem2.id;
17594 }
17595 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
17596 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
17597 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
17598 if (canLoop) {
17599 const loopItems = canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId);
17600 const sortedItems = flipItems(loopItems, activeId2, hasNullItem);
17601 const nextItem2 = findFirstEnabledItem2(sortedItems, activeId2);
17602 return nextItem2 == null ? void 0 : nextItem2.id;
17603 }
17604 if (canWrap) {
17605 const nextItem2 = findFirstEnabledItem2(
17606 // We can use nextItems, which contains all the next items, including
17607 // items from other rows, to wrap between rows. However, if there is a
17608 // null item (the composite container), we'll only use the next items in
17609 // the row. So moving next from the last item will focus on the
17610 // composite container. On grid composites, horizontal navigation never
17611 // focuses on the composite container, only vertical.
17612 hasNullItem ? nextItemsInRow : nextItems,
17613 activeId2
17614 );
17615 const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id;
17616 return nextId;
17617 }
17618 const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2);
17619 if (!nextItem && hasNullItem) {
17620 return null;
17621 }
17622 return nextItem == null ? void 0 : nextItem.id;
17623 };
17624 return {
17625 ...collection,
17626 ...composite,
17627 setBaseElement: (element) => composite.setState("baseElement", element),
17628 setActiveId: (id) => composite.setState("activeId", id),
17629 move: (id) => {
17630 if (id === void 0) return;
17631 composite.setState("activeId", id);
17632 composite.setState("moves", (moves) => moves + 1);
17633 },
17634 first: () => {
17635 var _a2;
17636 return (_a2 = findFirstEnabledItem2(composite.getState().renderedItems)) == null ? void 0 : _a2.id;
17637 },
17638 last: () => {
17639 var _a2;
17640 return (_a2 = findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id;
17641 },
17642 next: (options) => {
17643 if (options !== void 0 && typeof options === "number") {
17644 options = { skip: options };
17645 }
17646 return getNextId("next", options);
17647 },
17648 previous: (options) => {
17649 if (options !== void 0 && typeof options === "number") {
17650 options = { skip: options };
17651 }
17652 return getNextId("previous", options);
17653 },
17654 down: (options) => {
17655 if (options !== void 0 && typeof options === "number") {
17656 options = { skip: options };
17657 }
17658 return getNextId("down", options);
17659 },
17660 up: (options) => {
17661 if (options !== void 0 && typeof options === "number") {
17662 options = { skip: options };
17663 }
17664 return getNextId("up", options);
17665 }
17666 };
17667 }
17668
17669 // node_modules/@ariakit/react-core/esm/__chunks/IQYAUKXT.js
17670 function useCompositeStoreOptions(props) {
17671 const id = useId4(props.id);
17672 return { id, ...props };
17673 }
17674 function useCompositeStoreProps(store, update2, props) {
17675 store = useCollectionStoreProps(store, update2, props);
17676 useStoreProps(store, props, "activeId", "setActiveId");
17677 useStoreProps(store, props, "includesBaseElement");
17678 useStoreProps(store, props, "virtualFocus");
17679 useStoreProps(store, props, "orientation");
17680 useStoreProps(store, props, "rtl");
17681 useStoreProps(store, props, "focusLoop");
17682 useStoreProps(store, props, "focusWrap");
17683 useStoreProps(store, props, "focusShift");
17684 return store;
17685 }
17686
17687 // node_modules/@ariakit/react-core/esm/__chunks/CVCFNOHX.js
17688 var import_react22 = __toESM(require_react(), 1);
17689 var ComboboxListRoleContext = (0, import_react22.createContext)(
17690 void 0
17691 );
17692 var ctx6 = createStoreContext(
17693 [PopoverContextProvider, CompositeContextProvider],
17694 [PopoverScopedContextProvider, CompositeScopedContextProvider]
17695 );
17696 var useComboboxContext = ctx6.useContext;
17697 var useComboboxScopedContext = ctx6.useScopedContext;
17698 var useComboboxProviderContext = ctx6.useProviderContext;
17699 var ComboboxContextProvider = ctx6.ContextProvider;
17700 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
17701 var ComboboxItemValueContext = (0, import_react22.createContext)(
17702 void 0
17703 );
17704 var ComboboxItemCheckedContext = (0, import_react22.createContext)(false);
17705
17706 // node_modules/@ariakit/core/esm/__chunks/KMAUV3TY.js
17707 function createDialogStore(props = {}) {
17708 return createDisclosureStore(props);
17709 }
17710
17711 // node_modules/@ariakit/react-core/esm/__chunks/4NYSH4UO.js
17712 function useDialogStoreProps(store, update2, props) {
17713 return useDisclosureStoreProps(store, update2, props);
17714 }
17715
17716 // node_modules/@ariakit/core/esm/__chunks/BFGNM53A.js
17717 function createPopoverStore({
17718 popover: otherPopover,
17719 ...props
17720 } = {}) {
17721 const store = mergeStore(
17722 props.store,
17723 omit2(otherPopover, [
17724 "arrowElement",
17725 "anchorElement",
17726 "contentElement",
17727 "popoverElement",
17728 "disclosureElement"
17729 ])
17730 );
17731 throwOnConflictingProps(props, store);
17732 const syncState = store == null ? void 0 : store.getState();
17733 const dialog = createDialogStore({ ...props, store });
17734 const placement = defaultValue(
17735 props.placement,
17736 syncState == null ? void 0 : syncState.placement,
17737 "bottom"
17738 );
17739 const initialState = {
17740 ...dialog.getState(),
17741 placement,
17742 currentPlacement: placement,
17743 anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null),
17744 popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null),
17745 arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null),
17746 rendered: /* @__PURE__ */ Symbol("rendered")
17747 };
17748 const popover = createStore(initialState, dialog, store);
17749 return {
17750 ...dialog,
17751 ...popover,
17752 setAnchorElement: (element) => popover.setState("anchorElement", element),
17753 setPopoverElement: (element) => popover.setState("popoverElement", element),
17754 setArrowElement: (element) => popover.setState("arrowElement", element),
17755 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
17756 };
17757 }
17758
17759 // node_modules/@ariakit/react-core/esm/__chunks/B6FLPFJM.js
17760 function usePopoverStoreProps(store, update2, props) {
17761 useUpdateEffect(update2, [props.popover]);
17762 useStoreProps(store, props, "placement");
17763 return useDialogStoreProps(store, update2, props);
17764 }
17765
17766 // node_modules/@ariakit/react-core/esm/__chunks/4POTBZ2J.js
17767 var TagName7 = "div";
17768 var usePopoverAnchor = createHook(
17769 function usePopoverAnchor2({ store, ...props }) {
17770 const context = usePopoverProviderContext();
17771 store = store || context;
17772 props = {
17773 ...props,
17774 ref: useMergeRefs(store == null ? void 0 : store.setAnchorElement, props.ref)
17775 };
17776 return props;
17777 }
17778 );
17779 var PopoverAnchor = forwardRef210(function PopoverAnchor2(props) {
17780 const htmlProps = usePopoverAnchor(props);
17781 return createElement3(TagName7, htmlProps);
17782 });
17783
17784 // node_modules/@ariakit/react-core/esm/__chunks/X6LNAU2F.js
17785 var import_react23 = __toESM(require_react(), 1);
17786 var TagName8 = "div";
17787 function getMouseDestination(event) {
17788 const relatedTarget = event.relatedTarget;
17789 if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) {
17790 return relatedTarget;
17791 }
17792 return null;
17793 }
17794 function hoveringInside(event) {
17795 const nextElement = getMouseDestination(event);
17796 if (!nextElement) return false;
17797 return contains2(event.currentTarget, nextElement);
17798 }
17799 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
17800 function movingToAnotherItem(event) {
17801 let dest = getMouseDestination(event);
17802 if (!dest) return false;
17803 do {
17804 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
17805 dest = dest.parentElement;
17806 } while (dest);
17807 return false;
17808 }
17809 var useCompositeHover = createHook(
17810 function useCompositeHover2({
17811 store,
17812 focusOnHover = true,
17813 blurOnHoverEnd = !!focusOnHover,
17814 ...props
17815 }) {
17816 const context = useCompositeContext();
17817 store = store || context;
17818 invariant(
17819 store,
17820 "CompositeHover must be wrapped in a Composite component."
17821 );
17822 const isMouseMoving = useIsMouseMoving();
17823 const onMouseMoveProp = props.onMouseMove;
17824 const focusOnHoverProp = useBooleanEvent(focusOnHover);
17825 const onMouseMove = useEvent((event) => {
17826 onMouseMoveProp == null ? void 0 : onMouseMoveProp(event);
17827 if (event.defaultPrevented) return;
17828 if (!isMouseMoving()) return;
17829 if (!focusOnHoverProp(event)) return;
17830 if (!hasFocusWithin(event.currentTarget)) {
17831 const baseElement = store == null ? void 0 : store.getState().baseElement;
17832 if (baseElement && !hasFocus(baseElement)) {
17833 baseElement.focus();
17834 }
17835 }
17836 store == null ? void 0 : store.setActiveId(event.currentTarget.id);
17837 });
17838 const onMouseLeaveProp = props.onMouseLeave;
17839 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
17840 const onMouseLeave = useEvent((event) => {
17841 var _a;
17842 onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event);
17843 if (event.defaultPrevented) return;
17844 if (!isMouseMoving()) return;
17845 if (hoveringInside(event)) return;
17846 if (movingToAnotherItem(event)) return;
17847 if (!focusOnHoverProp(event)) return;
17848 if (!blurOnHoverEndProp(event)) return;
17849 store == null ? void 0 : store.setActiveId(null);
17850 (_a = store == null ? void 0 : store.getState().baseElement) == null ? void 0 : _a.focus();
17851 });
17852 const ref = (0, import_react23.useCallback)((element) => {
17853 if (!element) return;
17854 element[symbol2] = true;
17855 }, []);
17856 props = {
17857 ...props,
17858 ref: useMergeRefs(ref, props.ref),
17859 onMouseMove,
17860 onMouseLeave
17861 };
17862 return removeUndefinedValues(props);
17863 }
17864 );
17865 var CompositeHover = memo22(
17866 forwardRef210(function CompositeHover2(props) {
17867 const htmlProps = useCompositeHover(props);
17868 return createElement3(TagName8, htmlProps);
17869 })
17870 );
17871
17872 // node_modules/@ariakit/react-core/esm/combobox/combobox.js
17873 var import_react24 = __toESM(require_react(), 1);
17874 var TagName9 = "input";
17875 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
17876 if (!autoSelect) return false;
17877 const firstItem = items.find((item) => !item.disabled && item.value);
17878 return (firstItem == null ? void 0 : firstItem.value) === activeValue;
17879 }
17880 function hasCompletionString(value, activeValue) {
17881 if (!activeValue) return false;
17882 if (value == null) return false;
17883 value = normalizeString(value);
17884 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0;
17885 }
17886 function isInputEvent(event) {
17887 return event.type === "input";
17888 }
17889 function isAriaAutoCompleteValue(value) {
17890 return value === "inline" || value === "list" || value === "both" || value === "none";
17891 }
17892 function getDefaultAutoSelectId(items) {
17893 const item = items.find((item2) => {
17894 var _a;
17895 if (item2.disabled) return false;
17896 return ((_a = item2.element) == null ? void 0 : _a.getAttribute("role")) !== "tab";
17897 });
17898 return item == null ? void 0 : item.id;
17899 }
17900 var useCombobox = createHook(
17901 function useCombobox2({
17902 store,
17903 focusable: focusable2 = true,
17904 autoSelect: autoSelectProp = false,
17905 getAutoSelectId,
17906 setValueOnChange,
17907 showMinLength = 0,
17908 showOnChange,
17909 showOnMouseDown,
17910 showOnClick = showOnMouseDown,
17911 showOnKeyDown,
17912 showOnKeyPress = showOnKeyDown,
17913 blurActiveItemOnClick,
17914 setValueOnClick = true,
17915 moveOnKeyPress = true,
17916 autoComplete = "list",
17917 ...props
17918 }) {
17919 const context = useComboboxProviderContext();
17920 store = store || context;
17921 invariant(
17922 store,
17923 "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component."
17924 );
17925 const ref = (0, import_react24.useRef)(null);
17926 const [valueUpdated, forceValueUpdate] = useForceUpdate();
17927 const canAutoSelectRef = (0, import_react24.useRef)(false);
17928 const composingRef = (0, import_react24.useRef)(false);
17929 const autoSelect = store.useState(
17930 (state) => state.virtualFocus && autoSelectProp
17931 );
17932 const inline4 = autoComplete === "inline" || autoComplete === "both";
17933 const [canInline, setCanInline] = (0, import_react24.useState)(inline4);
17934 useUpdateLayoutEffect(() => {
17935 if (!inline4) return;
17936 setCanInline(true);
17937 }, [inline4]);
17938 const storeValue = store.useState("value");
17939 const prevSelectedValueRef = (0, import_react24.useRef)(void 0);
17940 (0, import_react24.useEffect)(() => {
17941 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
17942 prevSelectedValueRef.current = prev.selectedValue;
17943 });
17944 }, []);
17945 const inlineActiveValue = store.useState((state) => {
17946 var _a;
17947 if (!inline4) return;
17948 if (!canInline) return;
17949 if (state.activeValue && Array.isArray(state.selectedValue)) {
17950 if (state.selectedValue.includes(state.activeValue)) return;
17951 if ((_a = prevSelectedValueRef.current) == null ? void 0 : _a.includes(state.activeValue)) return;
17952 }
17953 return state.activeValue;
17954 });
17955 const items = store.useState("renderedItems");
17956 const open = store.useState("open");
17957 const contentElement = store.useState("contentElement");
17958 const value = (0, import_react24.useMemo)(() => {
17959 if (!inline4) return storeValue;
17960 if (!canInline) return storeValue;
17961 const firstItemAutoSelected = isFirstItemAutoSelected(
17962 items,
17963 inlineActiveValue,
17964 autoSelect
17965 );
17966 if (firstItemAutoSelected) {
17967 if (hasCompletionString(storeValue, inlineActiveValue)) {
17968 const slice = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || "";
17969 return storeValue + slice;
17970 }
17971 return storeValue;
17972 }
17973 return inlineActiveValue || storeValue;
17974 }, [inline4, canInline, items, inlineActiveValue, autoSelect, storeValue]);
17975 (0, import_react24.useEffect)(() => {
17976 const element = ref.current;
17977 if (!element) return;
17978 const onCompositeItemMove = () => setCanInline(true);
17979 element.addEventListener("combobox-item-move", onCompositeItemMove);
17980 return () => {
17981 element.removeEventListener("combobox-item-move", onCompositeItemMove);
17982 };
17983 }, []);
17984 (0, import_react24.useEffect)(() => {
17985 if (!inline4) return;
17986 if (!canInline) return;
17987 if (!inlineActiveValue) return;
17988 const firstItemAutoSelected = isFirstItemAutoSelected(
17989 items,
17990 inlineActiveValue,
17991 autoSelect
17992 );
17993 if (!firstItemAutoSelected) return;
17994 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
17995 let cleanup = noop4;
17996 queueMicrotask(() => {
17997 const element = ref.current;
17998 if (!element) return;
17999 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
18000 const nextStart = storeValue.length;
18001 const nextEnd = inlineActiveValue.length;
18002 setSelectionRange(element, nextStart, nextEnd);
18003 cleanup = () => {
18004 if (!hasFocus(element)) return;
18005 const { start, end } = getTextboxSelection(element);
18006 if (start !== nextStart) return;
18007 if (end !== nextEnd) return;
18008 setSelectionRange(element, prevStart, prevEnd);
18009 };
18010 });
18011 return () => cleanup();
18012 }, [
18013 valueUpdated,
18014 inline4,
18015 canInline,
18016 inlineActiveValue,
18017 items,
18018 autoSelect,
18019 storeValue
18020 ]);
18021 const scrollingElementRef = (0, import_react24.useRef)(null);
18022 const getAutoSelectIdProp = useEvent(getAutoSelectId);
18023 const autoSelectIdRef = (0, import_react24.useRef)(null);
18024 (0, import_react24.useEffect)(() => {
18025 if (!open) return;
18026 if (!contentElement) return;
18027 const scrollingElement = getScrollingElement(contentElement);
18028 if (!scrollingElement) return;
18029 scrollingElementRef.current = scrollingElement;
18030 const onUserScroll = () => {
18031 canAutoSelectRef.current = false;
18032 };
18033 const onScroll = () => {
18034 if (!store) return;
18035 if (!canAutoSelectRef.current) return;
18036 const { activeId } = store.getState();
18037 if (activeId === null) return;
18038 if (activeId === autoSelectIdRef.current) return;
18039 canAutoSelectRef.current = false;
18040 };
18041 const options = { passive: true, capture: true };
18042 scrollingElement.addEventListener("wheel", onUserScroll, options);
18043 scrollingElement.addEventListener("touchmove", onUserScroll, options);
18044 scrollingElement.addEventListener("scroll", onScroll, options);
18045 return () => {
18046 scrollingElement.removeEventListener("wheel", onUserScroll, true);
18047 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
18048 scrollingElement.removeEventListener("scroll", onScroll, true);
18049 };
18050 }, [open, contentElement, store]);
18051 useSafeLayoutEffect(() => {
18052 if (!storeValue) return;
18053 if (composingRef.current) return;
18054 canAutoSelectRef.current = true;
18055 }, [storeValue]);
18056 useSafeLayoutEffect(() => {
18057 if (autoSelect !== "always" && open) return;
18058 canAutoSelectRef.current = open;
18059 }, [autoSelect, open]);
18060 const resetValueOnSelect = store.useState("resetValueOnSelect");
18061 useUpdateEffect(() => {
18062 var _a, _b;
18063 const canAutoSelect = canAutoSelectRef.current;
18064 if (!store) return;
18065 if (!open) return;
18066 if (!canAutoSelect && !resetValueOnSelect) return;
18067 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
18068 if (baseElement && !hasFocus(baseElement)) return;
18069 if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) {
18070 const observer = new MutationObserver(forceValueUpdate);
18071 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
18072 return () => observer.disconnect();
18073 }
18074 if (autoSelect && canAutoSelect) {
18075 const userAutoSelectId = getAutoSelectIdProp(items);
18076 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : (_a = getDefaultAutoSelectId(items)) != null ? _a : store.first();
18077 autoSelectIdRef.current = autoSelectId;
18078 store.move(autoSelectId != null ? autoSelectId : null);
18079 } else {
18080 const element = (_b = store.item(activeId || store.first())) == null ? void 0 : _b.element;
18081 if (element && "scrollIntoView" in element) {
18082 element.scrollIntoView({ block: "nearest", inline: "nearest" });
18083 }
18084 }
18085 return;
18086 }, [
18087 store,
18088 open,
18089 valueUpdated,
18090 storeValue,
18091 autoSelect,
18092 resetValueOnSelect,
18093 getAutoSelectIdProp,
18094 items
18095 ]);
18096 (0, import_react24.useEffect)(() => {
18097 if (!inline4) return;
18098 const combobox = ref.current;
18099 if (!combobox) return;
18100 const elements = [combobox, contentElement].filter(
18101 (value2) => !!value2
18102 );
18103 const onBlur2 = (event) => {
18104 if (elements.every((el) => isFocusEventOutside(event, el))) {
18105 store == null ? void 0 : store.setValue(value);
18106 }
18107 };
18108 for (const element of elements) {
18109 element.addEventListener("focusout", onBlur2);
18110 }
18111 return () => {
18112 for (const element of elements) {
18113 element.removeEventListener("focusout", onBlur2);
18114 }
18115 };
18116 }, [inline4, contentElement, store, value]);
18117 const canShow = (event) => {
18118 const currentTarget = event.currentTarget;
18119 return currentTarget.value.length >= showMinLength;
18120 };
18121 const onChangeProp = props.onChange;
18122 const showOnChangeProp = useBooleanEvent(showOnChange != null ? showOnChange : canShow);
18123 const setValueOnChangeProp = useBooleanEvent(
18124 // If the combobox is combined with tags, the value will be set by the tag
18125 // input component.
18126 setValueOnChange != null ? setValueOnChange : !store.tag
18127 );
18128 const onChange = useEvent((event) => {
18129 onChangeProp == null ? void 0 : onChangeProp(event);
18130 if (event.defaultPrevented) return;
18131 if (!store) return;
18132 const currentTarget = event.currentTarget;
18133 const { value: value2, selectionStart, selectionEnd } = currentTarget;
18134 const nativeEvent = event.nativeEvent;
18135 canAutoSelectRef.current = true;
18136 if (isInputEvent(nativeEvent)) {
18137 if (nativeEvent.isComposing) {
18138 canAutoSelectRef.current = false;
18139 composingRef.current = true;
18140 }
18141 if (inline4) {
18142 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
18143 const caretAtEnd = selectionStart === value2.length;
18144 setCanInline(textInserted && caretAtEnd);
18145 }
18146 }
18147 if (setValueOnChangeProp(event)) {
18148 const isSameValue = value2 === store.getState().value;
18149 store.setValue(value2);
18150 queueMicrotask(() => {
18151 setSelectionRange(currentTarget, selectionStart, selectionEnd);
18152 });
18153 if (inline4 && autoSelect && isSameValue) {
18154 forceValueUpdate();
18155 }
18156 }
18157 if (showOnChangeProp(event)) {
18158 store.show();
18159 }
18160 if (!autoSelect || !canAutoSelectRef.current) {
18161 store.setActiveId(null);
18162 }
18163 });
18164 const onCompositionEndProp = props.onCompositionEnd;
18165 const onCompositionEnd = useEvent((event) => {
18166 canAutoSelectRef.current = true;
18167 composingRef.current = false;
18168 onCompositionEndProp == null ? void 0 : onCompositionEndProp(event);
18169 if (event.defaultPrevented) return;
18170 if (!autoSelect) return;
18171 forceValueUpdate();
18172 });
18173 const onMouseDownProp = props.onMouseDown;
18174 const blurActiveItemOnClickProp = useBooleanEvent(
18175 blurActiveItemOnClick != null ? blurActiveItemOnClick : (() => !!(store == null ? void 0 : store.getState().includesBaseElement))
18176 );
18177 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18178 const showOnClickProp = useBooleanEvent(showOnClick != null ? showOnClick : canShow);
18179 const onMouseDown = useEvent((event) => {
18180 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
18181 if (event.defaultPrevented) return;
18182 if (event.button) return;
18183 if (event.ctrlKey) return;
18184 if (!store) return;
18185 if (blurActiveItemOnClickProp(event)) {
18186 store.setActiveId(null);
18187 }
18188 if (setValueOnClickProp(event)) {
18189 store.setValue(value);
18190 }
18191 if (showOnClickProp(event)) {
18192 queueBeforeEvent(event.currentTarget, "mouseup", store.show);
18193 }
18194 });
18195 const onKeyDownProp = props.onKeyDown;
18196 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress != null ? showOnKeyPress : canShow);
18197 const onKeyDown = useEvent((event) => {
18198 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
18199 if (!event.repeat) {
18200 canAutoSelectRef.current = false;
18201 }
18202 if (event.defaultPrevented) return;
18203 if (event.ctrlKey) return;
18204 if (event.altKey) return;
18205 if (event.shiftKey) return;
18206 if (event.metaKey) return;
18207 if (!store) return;
18208 const { open: open2 } = store.getState();
18209 if (open2) return;
18210 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
18211 if (showOnKeyPressProp(event)) {
18212 event.preventDefault();
18213 store.show();
18214 }
18215 }
18216 });
18217 const onBlurProp = props.onBlur;
18218 const onBlur = useEvent((event) => {
18219 canAutoSelectRef.current = false;
18220 onBlurProp == null ? void 0 : onBlurProp(event);
18221 if (event.defaultPrevented) return;
18222 });
18223 const id = useId4(props.id);
18224 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
18225 const isActiveItem = store.useState((state) => state.activeId === null);
18226 props = {
18227 id,
18228 role: "combobox",
18229 "aria-autocomplete": ariaAutoComplete,
18230 "aria-haspopup": getPopupRole(contentElement, "listbox"),
18231 "aria-expanded": open,
18232 "aria-controls": contentElement == null ? void 0 : contentElement.id,
18233 "data-active-item": isActiveItem || void 0,
18234 value,
18235 ...props,
18236 ref: useMergeRefs(ref, props.ref),
18237 onChange,
18238 onCompositionEnd,
18239 onMouseDown,
18240 onKeyDown,
18241 onBlur
18242 };
18243 props = useComposite({
18244 store,
18245 focusable: focusable2,
18246 ...props,
18247 // Enable inline autocomplete when the user moves from the combobox input
18248 // to an item.
18249 moveOnKeyPress: (event) => {
18250 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
18251 if (inline4) setCanInline(true);
18252 return true;
18253 }
18254 });
18255 props = usePopoverAnchor({ store, ...props });
18256 return { autoComplete: "off", ...props };
18257 }
18258 );
18259 var Combobox = forwardRef210(function Combobox2(props) {
18260 const htmlProps = useCombobox(props);
18261 return createElement3(TagName9, htmlProps);
18262 });
18263
18264 // node_modules/@ariakit/react-core/esm/__chunks/IBXZ2LQC.js
18265 var import_react25 = __toESM(require_react(), 1);
18266 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
18267 var TagName10 = "div";
18268 function isSelected(storeValue, itemValue) {
18269 if (itemValue == null) return;
18270 if (storeValue == null) return false;
18271 if (Array.isArray(storeValue)) {
18272 return storeValue.includes(itemValue);
18273 }
18274 return storeValue === itemValue;
18275 }
18276 function getItemRole(popupRole) {
18277 var _a;
18278 const itemRoleByPopupRole = {
18279 menu: "menuitem",
18280 listbox: "option",
18281 tree: "treeitem"
18282 };
18283 const key = popupRole;
18284 return (_a = itemRoleByPopupRole[key]) != null ? _a : "option";
18285 }
18286 var useComboboxItem = createHook(
18287 function useComboboxItem2({
18288 store,
18289 value,
18290 hideOnClick,
18291 setValueOnClick,
18292 selectValueOnClick = true,
18293 resetValueOnSelect,
18294 focusOnHover = false,
18295 moveOnKeyPress = true,
18296 getItem: getItemProp,
18297 ...props
18298 }) {
18299 var _a;
18300 const context = useComboboxScopedContext();
18301 store = store || context;
18302 invariant(
18303 store,
18304 "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component."
18305 );
18306 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
18307 resetValueOnSelectState: "resetValueOnSelect",
18308 multiSelectable(state) {
18309 return Array.isArray(state.selectedValue);
18310 },
18311 selected(state) {
18312 return isSelected(state.selectedValue, value);
18313 }
18314 });
18315 const getItem = (0, import_react25.useCallback)(
18316 (item) => {
18317 const nextItem = { ...item, value };
18318 if (getItemProp) {
18319 return getItemProp(nextItem);
18320 }
18321 return nextItem;
18322 },
18323 [value, getItemProp]
18324 );
18325 setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable;
18326 hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable;
18327 const onClickProp = props.onClick;
18328 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18329 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
18330 const resetValueOnSelectProp = useBooleanEvent(
18331 (_a = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a : multiSelectable
18332 );
18333 const hideOnClickProp = useBooleanEvent(hideOnClick);
18334 const onClick = useEvent((event) => {
18335 onClickProp == null ? void 0 : onClickProp(event);
18336 if (event.defaultPrevented) return;
18337 if (isDownloading(event)) return;
18338 if (isOpeningInNewTab(event)) return;
18339 if (value != null) {
18340 if (selectValueOnClickProp(event)) {
18341 if (resetValueOnSelectProp(event)) {
18342 store == null ? void 0 : store.resetValue();
18343 }
18344 store == null ? void 0 : store.setSelectedValue((prevValue) => {
18345 if (!Array.isArray(prevValue)) return value;
18346 if (prevValue.includes(value)) {
18347 return prevValue.filter((v2) => v2 !== value);
18348 }
18349 return [...prevValue, value];
18350 });
18351 }
18352 if (setValueOnClickProp(event)) {
18353 store == null ? void 0 : store.setValue(value);
18354 }
18355 }
18356 if (hideOnClickProp(event)) {
18357 store == null ? void 0 : store.hide();
18358 }
18359 });
18360 const onKeyDownProp = props.onKeyDown;
18361 const onKeyDown = useEvent((event) => {
18362 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
18363 if (event.defaultPrevented) return;
18364 const baseElement = store == null ? void 0 : store.getState().baseElement;
18365 if (!baseElement) return;
18366 if (hasFocus(baseElement)) return;
18367 const printable = event.key.length === 1;
18368 if (printable || event.key === "Backspace" || event.key === "Delete") {
18369 queueMicrotask(() => baseElement.focus());
18370 if (isTextField(baseElement)) {
18371 store == null ? void 0 : store.setValue(baseElement.value);
18372 }
18373 }
18374 });
18375 if (multiSelectable && selected != null) {
18376 props = {
18377 "aria-selected": selected,
18378 ...props
18379 };
18380 }
18381 props = useWrapElement(
18382 props,
18383 (element) => /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }),
18384 [value, selected]
18385 );
18386 const popupRole = (0, import_react25.useContext)(ComboboxListRoleContext);
18387 props = {
18388 role: getItemRole(popupRole),
18389 children: value,
18390 ...props,
18391 onClick,
18392 onKeyDown
18393 };
18394 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
18395 props = useCompositeItem({
18396 store,
18397 ...props,
18398 getItem,
18399 // Dispatch a custom event on the combobox input when moving to an item
18400 // with the keyboard so the Combobox component can enable inline
18401 // autocompletion.
18402 moveOnKeyPress: (event) => {
18403 if (!moveOnKeyPressProp(event)) return false;
18404 const moveEvent = new Event("combobox-item-move");
18405 const baseElement = store == null ? void 0 : store.getState().baseElement;
18406 baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent);
18407 return true;
18408 }
18409 });
18410 props = useCompositeHover({ store, focusOnHover, ...props });
18411 return props;
18412 }
18413 );
18414 var ComboboxItem = memo22(
18415 forwardRef210(function ComboboxItem2(props) {
18416 const htmlProps = useComboboxItem(props);
18417 return createElement3(TagName10, htmlProps);
18418 })
18419 );
18420
18421 // node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js
18422 var import_react26 = __toESM(require_react(), 1);
18423 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
18424 var TagName11 = "span";
18425 function normalizeValue(value) {
18426 return normalizeString(value).toLowerCase();
18427 }
18428 function getOffsets(string, values) {
18429 const offsets = [];
18430 for (const value of values) {
18431 let pos = 0;
18432 const length = value.length;
18433 while (string.indexOf(value, pos) !== -1) {
18434 const index2 = string.indexOf(value, pos);
18435 if (index2 !== -1) {
18436 offsets.push([index2, length]);
18437 }
18438 pos = index2 + 1;
18439 }
18440 }
18441 return offsets;
18442 }
18443 function filterOverlappingOffsets(offsets) {
18444 return offsets.filter(([offset4, length], i2, arr) => {
18445 return !arr.some(
18446 ([o2, l2], j2) => j2 !== i2 && o2 <= offset4 && o2 + l2 >= offset4 + length
18447 );
18448 });
18449 }
18450 function sortOffsets(offsets) {
18451 return offsets.sort(([a2], [b2]) => a2 - b2);
18452 }
18453 function splitValue(itemValue, userValue) {
18454 if (!itemValue) return itemValue;
18455 if (!userValue) return itemValue;
18456 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue);
18457 const parts = [];
18458 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
18459 "span",
18460 {
18461 "data-autocomplete-value": autocomplete ? "" : void 0,
18462 "data-user-value": autocomplete ? void 0 : "",
18463 children: value
18464 },
18465 parts.length
18466 );
18467 const offsets = sortOffsets(
18468 filterOverlappingOffsets(
18469 // Convert userValues into a set to avoid duplicates
18470 getOffsets(normalizeValue(itemValue), new Set(userValues))
18471 )
18472 );
18473 if (!offsets.length) {
18474 parts.push(span(itemValue, true));
18475 return parts;
18476 }
18477 const [firstOffset] = offsets[0];
18478 const values = [
18479 itemValue.slice(0, firstOffset),
18480 ...offsets.flatMap(([offset4, length], i2) => {
18481 var _a;
18482 const value = itemValue.slice(offset4, offset4 + length);
18483 const nextOffset = (_a = offsets[i2 + 1]) == null ? void 0 : _a[0];
18484 const nextValue = itemValue.slice(offset4 + length, nextOffset);
18485 return [value, nextValue];
18486 })
18487 ];
18488 values.forEach((value, i2) => {
18489 if (!value) return;
18490 parts.push(span(value, i2 % 2 === 0));
18491 });
18492 return parts;
18493 }
18494 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
18495 const context = useComboboxScopedContext();
18496 store = store || context;
18497 const itemContext = (0, import_react26.useContext)(ComboboxItemValueContext);
18498 const itemValue = value != null ? value : itemContext;
18499 const inputValue = useStoreState(store, (state) => userValue != null ? userValue : state == null ? void 0 : state.value);
18500 const children = (0, import_react26.useMemo)(() => {
18501 if (!itemValue) return;
18502 if (!inputValue) return itemValue;
18503 return splitValue(itemValue, inputValue);
18504 }, [itemValue, inputValue]);
18505 props = {
18506 children,
18507 ...props
18508 };
18509 return removeUndefinedValues(props);
18510 });
18511 var ComboboxItemValue = forwardRef210(function ComboboxItemValue2(props) {
18512 const htmlProps = useComboboxItemValue(props);
18513 return createElement3(TagName11, htmlProps);
18514 });
18515
18516 // node_modules/@ariakit/react-core/esm/combobox/combobox-label.js
18517 var TagName12 = "label";
18518 var useComboboxLabel = createHook(
18519 function useComboboxLabel2({ store, ...props }) {
18520 const context = useComboboxProviderContext();
18521 store = store || context;
18522 invariant(
18523 store,
18524 "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component."
18525 );
18526 const comboboxId = store.useState((state) => {
18527 var _a;
18528 return (_a = state.baseElement) == null ? void 0 : _a.id;
18529 });
18530 props = {
18531 htmlFor: comboboxId,
18532 ...props
18533 };
18534 return removeUndefinedValues(props);
18535 }
18536 );
18537 var ComboboxLabel = memo22(
18538 forwardRef210(function ComboboxLabel2(props) {
18539 const htmlProps = useComboboxLabel(props);
18540 return createElement3(TagName12, htmlProps);
18541 })
18542 );
18543
18544 // node_modules/@ariakit/react-core/esm/__chunks/2G6YEJT4.js
18545 var import_react27 = __toESM(require_react(), 1);
18546 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
18547 var TagName13 = "div";
18548 var useComboboxList = createHook(
18549 function useComboboxList2({ store, alwaysVisible, ...props }) {
18550 const scopedContext = useComboboxScopedContext(true);
18551 const context = useComboboxContext();
18552 store = store || context;
18553 const scopedContextSameStore = !!store && store === scopedContext;
18554 invariant(
18555 store,
18556 "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component."
18557 );
18558 const ref = (0, import_react27.useRef)(null);
18559 const id = useId4(props.id);
18560 const mounted = store.useState("mounted");
18561 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
18562 const style = hidden ? { ...props.style, display: "none" } : props.style;
18563 const multiSelectable = store.useState(
18564 (state) => Array.isArray(state.selectedValue)
18565 );
18566 const role = useAttribute(ref, "role", props.role);
18567 const isCompositeRole = role === "listbox" || role === "tree" || role === "grid";
18568 const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0;
18569 const [hasListboxInside, setHasListboxInside] = (0, import_react27.useState)(false);
18570 const contentElement = store.useState("contentElement");
18571 useSafeLayoutEffect(() => {
18572 if (!mounted) return;
18573 const element = ref.current;
18574 if (!element) return;
18575 if (contentElement !== element) return;
18576 const callback = () => {
18577 setHasListboxInside(!!element.querySelector("[role='listbox']"));
18578 };
18579 const observer = new MutationObserver(callback);
18580 observer.observe(element, {
18581 subtree: true,
18582 childList: true,
18583 attributeFilter: ["role"]
18584 });
18585 callback();
18586 return () => observer.disconnect();
18587 }, [mounted, contentElement]);
18588 if (!hasListboxInside) {
18589 props = {
18590 role: "listbox",
18591 "aria-multiselectable": ariaMultiSelectable,
18592 ...props
18593 };
18594 }
18595 props = useWrapElement(
18596 props,
18597 (element) => /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(ComboboxScopedContextProvider, { value: store, children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(ComboboxListRoleContext.Provider, { value: role, children: element }) }),
18598 [store, role]
18599 );
18600 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
18601 props = {
18602 id,
18603 hidden,
18604 ...props,
18605 ref: useMergeRefs(setContentElement, ref, props.ref),
18606 style
18607 };
18608 return removeUndefinedValues(props);
18609 }
18610 );
18611 var ComboboxList = forwardRef210(function ComboboxList2(props) {
18612 const htmlProps = useComboboxList(props);
18613 return createElement3(TagName13, htmlProps);
18614 });
18615
18616 // node_modules/@ariakit/react-core/esm/__chunks/XSIEPKGA.js
18617 var import_react28 = __toESM(require_react(), 1);
18618 var TagValueContext = (0, import_react28.createContext)(null);
18619 var TagRemoveIdContext = (0, import_react28.createContext)(
18620 null
18621 );
18622 var ctx7 = createStoreContext(
18623 [CompositeContextProvider],
18624 [CompositeScopedContextProvider]
18625 );
18626 var useTagContext = ctx7.useContext;
18627 var useTagScopedContext = ctx7.useScopedContext;
18628 var useTagProviderContext = ctx7.useProviderContext;
18629 var TagContextProvider = ctx7.ContextProvider;
18630 var TagScopedContextProvider = ctx7.ScopedContextProvider;
18631
18632 // node_modules/@ariakit/core/esm/combobox/combobox-store.js
18633 var isTouchSafari = isSafari2() && isTouchDevice();
18634 function createComboboxStore({
18635 tag,
18636 ...props
18637 } = {}) {
18638 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
18639 throwOnConflictingProps(props, store);
18640 const tagState = tag == null ? void 0 : tag.getState();
18641 const syncState = store == null ? void 0 : store.getState();
18642 const activeId = defaultValue(
18643 props.activeId,
18644 syncState == null ? void 0 : syncState.activeId,
18645 props.defaultActiveId,
18646 null
18647 );
18648 const composite = createCompositeStore({
18649 ...props,
18650 activeId,
18651 includesBaseElement: defaultValue(
18652 props.includesBaseElement,
18653 syncState == null ? void 0 : syncState.includesBaseElement,
18654 true
18655 ),
18656 orientation: defaultValue(
18657 props.orientation,
18658 syncState == null ? void 0 : syncState.orientation,
18659 "vertical"
18660 ),
18661 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true),
18662 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true),
18663 virtualFocus: defaultValue(
18664 props.virtualFocus,
18665 syncState == null ? void 0 : syncState.virtualFocus,
18666 true
18667 )
18668 });
18669 const popover = createPopoverStore({
18670 ...props,
18671 placement: defaultValue(
18672 props.placement,
18673 syncState == null ? void 0 : syncState.placement,
18674 "bottom-start"
18675 )
18676 });
18677 const value = defaultValue(
18678 props.value,
18679 syncState == null ? void 0 : syncState.value,
18680 props.defaultValue,
18681 ""
18682 );
18683 const selectedValue = defaultValue(
18684 props.selectedValue,
18685 syncState == null ? void 0 : syncState.selectedValue,
18686 tagState == null ? void 0 : tagState.values,
18687 props.defaultSelectedValue,
18688 ""
18689 );
18690 const multiSelectable = Array.isArray(selectedValue);
18691 const initialState = {
18692 ...composite.getState(),
18693 ...popover.getState(),
18694 value,
18695 selectedValue,
18696 resetValueOnSelect: defaultValue(
18697 props.resetValueOnSelect,
18698 syncState == null ? void 0 : syncState.resetValueOnSelect,
18699 multiSelectable
18700 ),
18701 resetValueOnHide: defaultValue(
18702 props.resetValueOnHide,
18703 syncState == null ? void 0 : syncState.resetValueOnHide,
18704 multiSelectable && !tag
18705 ),
18706 activeValue: syncState == null ? void 0 : syncState.activeValue
18707 };
18708 const combobox = createStore(initialState, composite, popover, store);
18709 if (isTouchSafari) {
18710 setup(
18711 combobox,
18712 () => sync(combobox, ["virtualFocus"], () => {
18713 combobox.setState("virtualFocus", false);
18714 })
18715 );
18716 }
18717 setup(combobox, () => {
18718 if (!tag) return;
18719 return chain(
18720 sync(combobox, ["selectedValue"], (state) => {
18721 if (!Array.isArray(state.selectedValue)) return;
18722 tag.setValues(state.selectedValue);
18723 }),
18724 sync(tag, ["values"], (state) => {
18725 combobox.setState("selectedValue", state.values);
18726 })
18727 );
18728 });
18729 setup(
18730 combobox,
18731 () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
18732 if (!state.resetValueOnHide) return;
18733 if (state.mounted) return;
18734 combobox.setState("value", value);
18735 })
18736 );
18737 setup(
18738 combobox,
18739 () => sync(combobox, ["open"], (state) => {
18740 if (state.open) return;
18741 combobox.setState("activeId", activeId);
18742 combobox.setState("moves", 0);
18743 })
18744 );
18745 setup(
18746 combobox,
18747 () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
18748 if (state.moves === prevState.moves) {
18749 combobox.setState("activeValue", void 0);
18750 }
18751 })
18752 );
18753 setup(
18754 combobox,
18755 () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
18756 if (state.moves === prev.moves) return;
18757 const { activeId: activeId2 } = combobox.getState();
18758 const activeItem = composite.item(activeId2);
18759 combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value);
18760 })
18761 );
18762 return {
18763 ...popover,
18764 ...composite,
18765 ...combobox,
18766 tag,
18767 setValue: (value2) => combobox.setState("value", value2),
18768 resetValue: () => combobox.setState("value", initialState.value),
18769 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
18770 };
18771 }
18772
18773 // node_modules/@ariakit/react-core/esm/__chunks/SVN33SY6.js
18774 function useComboboxStoreOptions(props) {
18775 const tag = useTagContext();
18776 props = {
18777 ...props,
18778 tag: props.tag !== void 0 ? props.tag : tag
18779 };
18780 return useCompositeStoreOptions(props);
18781 }
18782 function useComboboxStoreProps(store, update2, props) {
18783 useUpdateEffect(update2, [props.tag]);
18784 useStoreProps(store, props, "value", "setValue");
18785 useStoreProps(store, props, "selectedValue", "setSelectedValue");
18786 useStoreProps(store, props, "resetValueOnHide");
18787 useStoreProps(store, props, "resetValueOnSelect");
18788 return Object.assign(
18789 useCompositeStoreProps(
18790 usePopoverStoreProps(store, update2, props),
18791 update2,
18792 props
18793 ),
18794 { tag: props.tag }
18795 );
18796 }
18797 function useComboboxStore(props = {}) {
18798 props = useComboboxStoreOptions(props);
18799 const [store, update2] = useStore2(createComboboxStore, props);
18800 return useComboboxStoreProps(store, update2, props);
18801 }
18802
18803 // node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js
18804 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
18805 function ComboboxProvider(props = {}) {
18806 const store = useComboboxStore(props);
18807 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(ComboboxContextProvider, { value: store, children: props.children });
18808 }
18809
18810 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
18811 var import_remove_accents = __toESM(require_remove_accents(), 1);
18812 var import_compose7 = __toESM(require_compose(), 1);
18813 var import_i18n23 = __toESM(require_i18n(), 1);
18814 var import_element48 = __toESM(require_element(), 1);
18815 var import_components18 = __toESM(require_components(), 1);
18816
18817 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
18818 var EMPTY_ARRAY3 = [];
18819 var getCurrentValue = (filterDefinition, currentFilter) => {
18820 if (filterDefinition.singleSelection) {
18821 return currentFilter?.value;
18822 }
18823 if (Array.isArray(currentFilter?.value)) {
18824 return currentFilter.value;
18825 }
18826 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
18827 return [currentFilter.value];
18828 }
18829 return EMPTY_ARRAY3;
18830 };
18831
18832 // packages/dataviews/build-module/hooks/use-elements.mjs
18833 var import_element47 = __toESM(require_element(), 1);
18834 var EMPTY_ARRAY4 = [];
18835 function useElements({
18836 elements,
18837 getElements
18838 }) {
18839 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
18840 const [records, setRecords] = (0, import_element47.useState)(staticElements);
18841 const [isLoading, setIsLoading] = (0, import_element47.useState)(false);
18842 (0, import_element47.useEffect)(() => {
18843 if (!getElements) {
18844 setRecords(staticElements);
18845 return;
18846 }
18847 let cancelled = false;
18848 setIsLoading(true);
18849 getElements().then((fetchedElements) => {
18850 if (!cancelled) {
18851 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
18852 setRecords(dynamicElements);
18853 }
18854 }).catch(() => {
18855 if (!cancelled) {
18856 setRecords(staticElements);
18857 }
18858 }).finally(() => {
18859 if (!cancelled) {
18860 setIsLoading(false);
18861 }
18862 });
18863 return () => {
18864 cancelled = true;
18865 };
18866 }, [getElements, staticElements]);
18867 return {
18868 elements: records,
18869 isLoading
18870 };
18871 }
18872
18873 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
18874 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
18875 function normalizeSearchInput(input = "") {
18876 return (0, import_remove_accents.default)(input.trim().toLowerCase());
18877 }
18878 var getNewValue = (filterDefinition, currentFilter, value) => {
18879 if (filterDefinition.singleSelection) {
18880 return value;
18881 }
18882 if (Array.isArray(currentFilter?.value)) {
18883 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
18884 }
18885 return [value];
18886 };
18887 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
18888 return `${prefix}-${filterElementValue}`;
18889 }
18890 var MultiSelectionOption = ({ selected }) => {
18891 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
18892 "span",
18893 {
18894 className: clsx_default(
18895 "dataviews-filters__search-widget-listitem-multi-selection",
18896 { "is-selected": selected }
18897 ),
18898 children: selected && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components18.Icon, { icon: check_default })
18899 }
18900 );
18901 };
18902 var SingleSelectionOption = ({ selected }) => {
18903 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
18904 "span",
18905 {
18906 className: clsx_default(
18907 "dataviews-filters__search-widget-listitem-single-selection",
18908 { "is-selected": selected }
18909 )
18910 }
18911 );
18912 };
18913 function ListBox({ view, filter, onChangeView }) {
18914 const baseId = (0, import_compose7.useInstanceId)(ListBox, "dataviews-filter-list-box");
18915 const [activeCompositeId, setActiveCompositeId] = (0, import_element48.useState)(
18916 // When there are one or less operators, the first item is set as active
18917 // (by setting the initial `activeId` to `undefined`).
18918 // With 2 or more operators, the focus is moved on the operators control
18919 // (by setting the initial `activeId` to `null`), meaning that there won't
18920 // be an active item initially. Focus is then managed via the
18921 // `onFocusVisible` callback.
18922 filter.operators?.length === 1 ? void 0 : null
18923 );
18924 const currentFilter = view.filters?.find(
18925 (f2) => f2.field === filter.field
18926 );
18927 const currentValue = getCurrentValue(filter, currentFilter);
18928 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
18929 import_components18.Composite,
18930 {
18931 virtualFocus: true,
18932 focusLoop: true,
18933 activeId: activeCompositeId,
18934 setActiveId: setActiveCompositeId,
18935 role: "listbox",
18936 className: "dataviews-filters__search-widget-listbox",
18937 "aria-label": (0, import_i18n23.sprintf)(
18938 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
18939 (0, import_i18n23.__)("List of: %1$s"),
18940 filter.name
18941 ),
18942 onFocusVisible: () => {
18943 if (!activeCompositeId && filter.elements.length) {
18944 setActiveCompositeId(
18945 generateFilterElementCompositeItemId(
18946 baseId,
18947 filter.elements[0].value
18948 )
18949 );
18950 }
18951 },
18952 render: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components18.Composite.Typeahead, {}),
18953 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
18954 import_components18.Composite.Hover,
18955 {
18956 render: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
18957 import_components18.Composite.Item,
18958 {
18959 id: generateFilterElementCompositeItemId(
18960 baseId,
18961 element.value
18962 ),
18963 render: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
18964 "div",
18965 {
18966 "aria-label": element.label,
18967 role: "option",
18968 className: "dataviews-filters__search-widget-listitem"
18969 }
18970 ),
18971 onClick: () => {
18972 const newFilters = currentFilter ? [
18973 ...(view.filters ?? []).map(
18974 (_filter) => {
18975 if (_filter.field === filter.field) {
18976 return {
18977 ..._filter,
18978 operator: currentFilter.operator || filter.operators[0],
18979 value: getNewValue(
18980 filter,
18981 currentFilter,
18982 element.value
18983 )
18984 };
18985 }
18986 return _filter;
18987 }
18988 )
18989 ] : [
18990 ...view.filters ?? [],
18991 {
18992 field: filter.field,
18993 operator: filter.operators[0],
18994 value: getNewValue(
18995 filter,
18996 currentFilter,
18997 element.value
18998 )
18999 }
19000 ];
19001 onChangeView({
19002 ...view,
19003 page: 1,
19004 filters: newFilters
19005 });
19006 }
19007 }
19008 ),
19009 children: [
19010 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
19011 SingleSelectionOption,
19012 {
19013 selected: currentValue === element.value
19014 }
19015 ),
19016 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
19017 MultiSelectionOption,
19018 {
19019 selected: currentValue.includes(element.value)
19020 }
19021 ),
19022 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
19023 "span",
19024 {
19025 className: "dataviews-filters__search-widget-listitem-value",
19026 title: element.label,
19027 children: element.label
19028 }
19029 )
19030 ]
19031 },
19032 element.value
19033 ))
19034 }
19035 );
19036 }
19037 function ComboboxList22({ view, filter, onChangeView }) {
19038 const [searchValue, setSearchValue] = (0, import_element48.useState)("");
19039 const deferredSearchValue = (0, import_element48.useDeferredValue)(searchValue);
19040 const currentFilter = view.filters?.find(
19041 (_filter) => _filter.field === filter.field
19042 );
19043 const currentValue = getCurrentValue(filter, currentFilter);
19044 const matches = (0, import_element48.useMemo)(() => {
19045 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
19046 return filter.elements.filter(
19047 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
19048 );
19049 }, [filter.elements, deferredSearchValue]);
19050 return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
19051 ComboboxProvider,
19052 {
19053 selectedValue: currentValue,
19054 setSelectedValue: (value) => {
19055 const newFilters = currentFilter ? [
19056 ...(view.filters ?? []).map((_filter) => {
19057 if (_filter.field === filter.field) {
19058 return {
19059 ..._filter,
19060 operator: currentFilter.operator || filter.operators[0],
19061 value
19062 };
19063 }
19064 return _filter;
19065 })
19066 ] : [
19067 ...view.filters ?? [],
19068 {
19069 field: filter.field,
19070 operator: filter.operators[0],
19071 value
19072 }
19073 ];
19074 onChangeView({
19075 ...view,
19076 page: 1,
19077 filters: newFilters
19078 });
19079 },
19080 setValue: setSearchValue,
19081 children: [
19082 /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
19083 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(ComboboxLabel, {}), children: (0, import_i18n23.__)("Search items") }),
19084 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
19085 Combobox,
19086 {
19087 autoSelect: "always",
19088 placeholder: (0, import_i18n23.__)("Search"),
19089 className: "dataviews-filters__search-widget-filter-combobox__input"
19090 }
19091 ),
19092 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components18.Icon, { icon: search_default }) })
19093 ] }),
19094 /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
19095 ComboboxList,
19096 {
19097 className: "dataviews-filters__search-widget-filter-combobox-list",
19098 alwaysVisible: true,
19099 children: [
19100 matches.map((element) => {
19101 return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
19102 ComboboxItem,
19103 {
19104 resetValueOnSelect: false,
19105 value: element.value,
19106 className: "dataviews-filters__search-widget-listitem",
19107 hideOnClick: false,
19108 setValueOnClick: false,
19109 focusOnHover: true,
19110 children: [
19111 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
19112 SingleSelectionOption,
19113 {
19114 selected: currentValue === element.value
19115 }
19116 ),
19117 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
19118 MultiSelectionOption,
19119 {
19120 selected: currentValue.includes(
19121 element.value
19122 )
19123 }
19124 ),
19125 /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
19126 "span",
19127 {
19128 className: "dataviews-filters__search-widget-listitem-value",
19129 title: element.label,
19130 children: [
19131 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
19132 ComboboxItemValue,
19133 {
19134 className: "dataviews-filters__search-widget-filter-combobox-item-value",
19135 value: element.label
19136 }
19137 ),
19138 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
19139 ]
19140 }
19141 )
19142 ]
19143 },
19144 element.value
19145 );
19146 }),
19147 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("p", { children: (0, import_i18n23.__)("No results found") })
19148 ]
19149 }
19150 )
19151 ]
19152 }
19153 );
19154 }
19155 function SearchWidget(props) {
19156 const { elements, isLoading } = useElements({
19157 elements: props.filter.elements,
19158 getElements: props.filter.getElements
19159 });
19160 if (isLoading) {
19161 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components18.Spinner, {}) });
19162 }
19163 if (elements.length === 0) {
19164 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n23.__)("No elements found") });
19165 }
19166 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
19167 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
19168 }
19169
19170 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
19171 var import_es6 = __toESM(require_es6(), 1);
19172 var import_compose8 = __toESM(require_compose(), 1);
19173 var import_element49 = __toESM(require_element(), 1);
19174 var import_components19 = __toESM(require_components(), 1);
19175 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
19176 function InputWidget({
19177 filter,
19178 view,
19179 onChangeView,
19180 fields
19181 }) {
19182 const currentFilter = view.filters?.find(
19183 (f2) => f2.field === filter.field
19184 );
19185 const currentValue = getCurrentValue(filter, currentFilter);
19186 const field = (0, import_element49.useMemo)(() => {
19187 const currentField = fields.find((f2) => f2.id === filter.field);
19188 if (currentField) {
19189 return {
19190 ...currentField,
19191 // Deactivate validation for filters.
19192 isValid: {},
19193 // Filter controls are always enabled.
19194 isDisabled: () => false,
19195 // Filter controls are always visible.
19196 isVisible: () => true,
19197 // Configure getValue/setValue as if Item was a plain object.
19198 getValue: ({ item }) => item[currentField.id],
19199 setValue: ({ value }) => ({
19200 [currentField.id]: value
19201 })
19202 };
19203 }
19204 return currentField;
19205 }, [fields, filter.field]);
19206 const data = (0, import_element49.useMemo)(() => {
19207 return (view.filters ?? []).reduce(
19208 (acc, activeFilter) => {
19209 acc[activeFilter.field] = activeFilter.value;
19210 return acc;
19211 },
19212 {}
19213 );
19214 }, [view.filters]);
19215 const handleChange = (0, import_compose8.useEvent)((updatedData) => {
19216 if (!field || !currentFilter) {
19217 return;
19218 }
19219 const nextValue = field.getValue({ item: updatedData });
19220 if ((0, import_es6.default)(nextValue, currentValue)) {
19221 return;
19222 }
19223 onChangeView({
19224 ...view,
19225 filters: (view.filters ?? []).map(
19226 (_filter) => _filter.field === filter.field ? {
19227 ..._filter,
19228 operator: currentFilter.operator || filter.operators[0],
19229 // Consider empty strings as undefined:
19230 //
19231 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
19232 // - empty string as value means "search empty string": returns only the records that have an empty string as value
19233 //
19234 // In practice, this means the filter will not be able to find an empty string as the value.
19235 value: nextValue === "" ? void 0 : nextValue
19236 } : _filter
19237 )
19238 });
19239 });
19240 if (!field || !field.Edit || !currentFilter) {
19241 return null;
19242 }
19243 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19244 import_components19.Flex,
19245 {
19246 className: "dataviews-filters__user-input-widget",
19247 gap: 2.5,
19248 direction: "column",
19249 children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19250 field.Edit,
19251 {
19252 hideLabelFromVision: true,
19253 data,
19254 field,
19255 operator: currentFilter.operator,
19256 onChange: handleChange
19257 }
19258 )
19259 }
19260 );
19261 }
19262
19263 // node_modules/date-fns/constants.js
19264 var daysInYear = 365.2425;
19265 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
19266 var minTime = -maxTime;
19267 var millisecondsInWeek = 6048e5;
19268 var millisecondsInDay = 864e5;
19269 var secondsInHour = 3600;
19270 var secondsInDay = secondsInHour * 24;
19271 var secondsInWeek = secondsInDay * 7;
19272 var secondsInYear = secondsInDay * daysInYear;
19273 var secondsInMonth = secondsInYear / 12;
19274 var secondsInQuarter = secondsInMonth * 3;
19275 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
19276
19277 // node_modules/date-fns/constructFrom.js
19278 function constructFrom(date, value) {
19279 if (typeof date === "function") return date(value);
19280 if (date && typeof date === "object" && constructFromSymbol in date)
19281 return date[constructFromSymbol](value);
19282 if (date instanceof Date) return new date.constructor(value);
19283 return new Date(value);
19284 }
19285
19286 // node_modules/date-fns/toDate.js
19287 function toDate(argument, context) {
19288 return constructFrom(context || argument, argument);
19289 }
19290
19291 // node_modules/date-fns/addDays.js
19292 function addDays(date, amount, options) {
19293 const _date = toDate(date, options?.in);
19294 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19295 if (!amount) return _date;
19296 _date.setDate(_date.getDate() + amount);
19297 return _date;
19298 }
19299
19300 // node_modules/date-fns/addMonths.js
19301 function addMonths(date, amount, options) {
19302 const _date = toDate(date, options?.in);
19303 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19304 if (!amount) {
19305 return _date;
19306 }
19307 const dayOfMonth = _date.getDate();
19308 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
19309 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
19310 const daysInMonth = endOfDesiredMonth.getDate();
19311 if (dayOfMonth >= daysInMonth) {
19312 return endOfDesiredMonth;
19313 } else {
19314 _date.setFullYear(
19315 endOfDesiredMonth.getFullYear(),
19316 endOfDesiredMonth.getMonth(),
19317 dayOfMonth
19318 );
19319 return _date;
19320 }
19321 }
19322
19323 // node_modules/date-fns/_lib/defaultOptions.js
19324 var defaultOptions = {};
19325 function getDefaultOptions() {
19326 return defaultOptions;
19327 }
19328
19329 // node_modules/date-fns/startOfWeek.js
19330 function startOfWeek(date, options) {
19331 const defaultOptions2 = getDefaultOptions();
19332 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
19333 const _date = toDate(date, options?.in);
19334 const day = _date.getDay();
19335 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
19336 _date.setDate(_date.getDate() - diff);
19337 _date.setHours(0, 0, 0, 0);
19338 return _date;
19339 }
19340
19341 // node_modules/date-fns/startOfISOWeek.js
19342 function startOfISOWeek(date, options) {
19343 return startOfWeek(date, { ...options, weekStartsOn: 1 });
19344 }
19345
19346 // node_modules/date-fns/getISOWeekYear.js
19347 function getISOWeekYear(date, options) {
19348 const _date = toDate(date, options?.in);
19349 const year = _date.getFullYear();
19350 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
19351 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
19352 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
19353 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
19354 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
19355 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
19356 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
19357 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
19358 if (_date.getTime() >= startOfNextYear.getTime()) {
19359 return year + 1;
19360 } else if (_date.getTime() >= startOfThisYear.getTime()) {
19361 return year;
19362 } else {
19363 return year - 1;
19364 }
19365 }
19366
19367 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
19368 function getTimezoneOffsetInMilliseconds(date) {
19369 const _date = toDate(date);
19370 const utcDate = new Date(
19371 Date.UTC(
19372 _date.getFullYear(),
19373 _date.getMonth(),
19374 _date.getDate(),
19375 _date.getHours(),
19376 _date.getMinutes(),
19377 _date.getSeconds(),
19378 _date.getMilliseconds()
19379 )
19380 );
19381 utcDate.setUTCFullYear(_date.getFullYear());
19382 return +date - +utcDate;
19383 }
19384
19385 // node_modules/date-fns/_lib/normalizeDates.js
19386 function normalizeDates(context, ...dates) {
19387 const normalize = constructFrom.bind(
19388 null,
19389 context || dates.find((date) => typeof date === "object")
19390 );
19391 return dates.map(normalize);
19392 }
19393
19394 // node_modules/date-fns/startOfDay.js
19395 function startOfDay(date, options) {
19396 const _date = toDate(date, options?.in);
19397 _date.setHours(0, 0, 0, 0);
19398 return _date;
19399 }
19400
19401 // node_modules/date-fns/differenceInCalendarDays.js
19402 function differenceInCalendarDays(laterDate, earlierDate, options) {
19403 const [laterDate_, earlierDate_] = normalizeDates(
19404 options?.in,
19405 laterDate,
19406 earlierDate
19407 );
19408 const laterStartOfDay = startOfDay(laterDate_);
19409 const earlierStartOfDay = startOfDay(earlierDate_);
19410 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
19411 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
19412 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
19413 }
19414
19415 // node_modules/date-fns/startOfISOWeekYear.js
19416 function startOfISOWeekYear(date, options) {
19417 const year = getISOWeekYear(date, options);
19418 const fourthOfJanuary = constructFrom(options?.in || date, 0);
19419 fourthOfJanuary.setFullYear(year, 0, 4);
19420 fourthOfJanuary.setHours(0, 0, 0, 0);
19421 return startOfISOWeek(fourthOfJanuary);
19422 }
19423
19424 // node_modules/date-fns/addWeeks.js
19425 function addWeeks(date, amount, options) {
19426 return addDays(date, amount * 7, options);
19427 }
19428
19429 // node_modules/date-fns/addYears.js
19430 function addYears(date, amount, options) {
19431 return addMonths(date, amount * 12, options);
19432 }
19433
19434 // node_modules/date-fns/isDate.js
19435 function isDate(value) {
19436 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
19437 }
19438
19439 // node_modules/date-fns/isValid.js
19440 function isValid(date) {
19441 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
19442 }
19443
19444 // node_modules/date-fns/startOfMonth.js
19445 function startOfMonth(date, options) {
19446 const _date = toDate(date, options?.in);
19447 _date.setDate(1);
19448 _date.setHours(0, 0, 0, 0);
19449 return _date;
19450 }
19451
19452 // node_modules/date-fns/startOfYear.js
19453 function startOfYear(date, options) {
19454 const date_ = toDate(date, options?.in);
19455 date_.setFullYear(date_.getFullYear(), 0, 1);
19456 date_.setHours(0, 0, 0, 0);
19457 return date_;
19458 }
19459
19460 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js
19461 var formatDistanceLocale = {
19462 lessThanXSeconds: {
19463 one: "less than a second",
19464 other: "less than {{count}} seconds"
19465 },
19466 xSeconds: {
19467 one: "1 second",
19468 other: "{{count}} seconds"
19469 },
19470 halfAMinute: "half a minute",
19471 lessThanXMinutes: {
19472 one: "less than a minute",
19473 other: "less than {{count}} minutes"
19474 },
19475 xMinutes: {
19476 one: "1 minute",
19477 other: "{{count}} minutes"
19478 },
19479 aboutXHours: {
19480 one: "about 1 hour",
19481 other: "about {{count}} hours"
19482 },
19483 xHours: {
19484 one: "1 hour",
19485 other: "{{count}} hours"
19486 },
19487 xDays: {
19488 one: "1 day",
19489 other: "{{count}} days"
19490 },
19491 aboutXWeeks: {
19492 one: "about 1 week",
19493 other: "about {{count}} weeks"
19494 },
19495 xWeeks: {
19496 one: "1 week",
19497 other: "{{count}} weeks"
19498 },
19499 aboutXMonths: {
19500 one: "about 1 month",
19501 other: "about {{count}} months"
19502 },
19503 xMonths: {
19504 one: "1 month",
19505 other: "{{count}} months"
19506 },
19507 aboutXYears: {
19508 one: "about 1 year",
19509 other: "about {{count}} years"
19510 },
19511 xYears: {
19512 one: "1 year",
19513 other: "{{count}} years"
19514 },
19515 overXYears: {
19516 one: "over 1 year",
19517 other: "over {{count}} years"
19518 },
19519 almostXYears: {
19520 one: "almost 1 year",
19521 other: "almost {{count}} years"
19522 }
19523 };
19524 var formatDistance = (token, count, options) => {
19525 let result;
19526 const tokenValue = formatDistanceLocale[token];
19527 if (typeof tokenValue === "string") {
19528 result = tokenValue;
19529 } else if (count === 1) {
19530 result = tokenValue.one;
19531 } else {
19532 result = tokenValue.other.replace("{{count}}", count.toString());
19533 }
19534 if (options?.addSuffix) {
19535 if (options.comparison && options.comparison > 0) {
19536 return "in " + result;
19537 } else {
19538 return result + " ago";
19539 }
19540 }
19541 return result;
19542 };
19543
19544 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js
19545 function buildFormatLongFn(args) {
19546 return (options = {}) => {
19547 const width = options.width ? String(options.width) : args.defaultWidth;
19548 const format6 = args.formats[width] || args.formats[args.defaultWidth];
19549 return format6;
19550 };
19551 }
19552
19553 // node_modules/date-fns/locale/en-US/_lib/formatLong.js
19554 var dateFormats = {
19555 full: "EEEE, MMMM do, y",
19556 long: "MMMM do, y",
19557 medium: "MMM d, y",
19558 short: "MM/dd/yyyy"
19559 };
19560 var timeFormats = {
19561 full: "h:mm:ss a zzzz",
19562 long: "h:mm:ss a z",
19563 medium: "h:mm:ss a",
19564 short: "h:mm a"
19565 };
19566 var dateTimeFormats = {
19567 full: "{{date}} 'at' {{time}}",
19568 long: "{{date}} 'at' {{time}}",
19569 medium: "{{date}}, {{time}}",
19570 short: "{{date}}, {{time}}"
19571 };
19572 var formatLong = {
19573 date: buildFormatLongFn({
19574 formats: dateFormats,
19575 defaultWidth: "full"
19576 }),
19577 time: buildFormatLongFn({
19578 formats: timeFormats,
19579 defaultWidth: "full"
19580 }),
19581 dateTime: buildFormatLongFn({
19582 formats: dateTimeFormats,
19583 defaultWidth: "full"
19584 })
19585 };
19586
19587 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js
19588 var formatRelativeLocale = {
19589 lastWeek: "'last' eeee 'at' p",
19590 yesterday: "'yesterday at' p",
19591 today: "'today at' p",
19592 tomorrow: "'tomorrow at' p",
19593 nextWeek: "eeee 'at' p",
19594 other: "P"
19595 };
19596 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
19597
19598 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js
19599 function buildLocalizeFn(args) {
19600 return (value, options) => {
19601 const context = options?.context ? String(options.context) : "standalone";
19602 let valuesArray;
19603 if (context === "formatting" && args.formattingValues) {
19604 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
19605 const width = options?.width ? String(options.width) : defaultWidth;
19606 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
19607 } else {
19608 const defaultWidth = args.defaultWidth;
19609 const width = options?.width ? String(options.width) : args.defaultWidth;
19610 valuesArray = args.values[width] || args.values[defaultWidth];
19611 }
19612 const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
19613 return valuesArray[index2];
19614 };
19615 }
19616
19617 // node_modules/date-fns/locale/en-US/_lib/localize.js
19618 var eraValues = {
19619 narrow: ["B", "A"],
19620 abbreviated: ["BC", "AD"],
19621 wide: ["Before Christ", "Anno Domini"]
19622 };
19623 var quarterValues = {
19624 narrow: ["1", "2", "3", "4"],
19625 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
19626 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
19627 };
19628 var monthValues = {
19629 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
19630 abbreviated: [
19631 "Jan",
19632 "Feb",
19633 "Mar",
19634 "Apr",
19635 "May",
19636 "Jun",
19637 "Jul",
19638 "Aug",
19639 "Sep",
19640 "Oct",
19641 "Nov",
19642 "Dec"
19643 ],
19644 wide: [
19645 "January",
19646 "February",
19647 "March",
19648 "April",
19649 "May",
19650 "June",
19651 "July",
19652 "August",
19653 "September",
19654 "October",
19655 "November",
19656 "December"
19657 ]
19658 };
19659 var dayValues = {
19660 narrow: ["S", "M", "T", "W", "T", "F", "S"],
19661 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
19662 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
19663 wide: [
19664 "Sunday",
19665 "Monday",
19666 "Tuesday",
19667 "Wednesday",
19668 "Thursday",
19669 "Friday",
19670 "Saturday"
19671 ]
19672 };
19673 var dayPeriodValues = {
19674 narrow: {
19675 am: "a",
19676 pm: "p",
19677 midnight: "mi",
19678 noon: "n",
19679 morning: "morning",
19680 afternoon: "afternoon",
19681 evening: "evening",
19682 night: "night"
19683 },
19684 abbreviated: {
19685 am: "AM",
19686 pm: "PM",
19687 midnight: "midnight",
19688 noon: "noon",
19689 morning: "morning",
19690 afternoon: "afternoon",
19691 evening: "evening",
19692 night: "night"
19693 },
19694 wide: {
19695 am: "a.m.",
19696 pm: "p.m.",
19697 midnight: "midnight",
19698 noon: "noon",
19699 morning: "morning",
19700 afternoon: "afternoon",
19701 evening: "evening",
19702 night: "night"
19703 }
19704 };
19705 var formattingDayPeriodValues = {
19706 narrow: {
19707 am: "a",
19708 pm: "p",
19709 midnight: "mi",
19710 noon: "n",
19711 morning: "in the morning",
19712 afternoon: "in the afternoon",
19713 evening: "in the evening",
19714 night: "at night"
19715 },
19716 abbreviated: {
19717 am: "AM",
19718 pm: "PM",
19719 midnight: "midnight",
19720 noon: "noon",
19721 morning: "in the morning",
19722 afternoon: "in the afternoon",
19723 evening: "in the evening",
19724 night: "at night"
19725 },
19726 wide: {
19727 am: "a.m.",
19728 pm: "p.m.",
19729 midnight: "midnight",
19730 noon: "noon",
19731 morning: "in the morning",
19732 afternoon: "in the afternoon",
19733 evening: "in the evening",
19734 night: "at night"
19735 }
19736 };
19737 var ordinalNumber = (dirtyNumber, _options) => {
19738 const number = Number(dirtyNumber);
19739 const rem100 = number % 100;
19740 if (rem100 > 20 || rem100 < 10) {
19741 switch (rem100 % 10) {
19742 case 1:
19743 return number + "st";
19744 case 2:
19745 return number + "nd";
19746 case 3:
19747 return number + "rd";
19748 }
19749 }
19750 return number + "th";
19751 };
19752 var localize = {
19753 ordinalNumber,
19754 era: buildLocalizeFn({
19755 values: eraValues,
19756 defaultWidth: "wide"
19757 }),
19758 quarter: buildLocalizeFn({
19759 values: quarterValues,
19760 defaultWidth: "wide",
19761 argumentCallback: (quarter) => quarter - 1
19762 }),
19763 month: buildLocalizeFn({
19764 values: monthValues,
19765 defaultWidth: "wide"
19766 }),
19767 day: buildLocalizeFn({
19768 values: dayValues,
19769 defaultWidth: "wide"
19770 }),
19771 dayPeriod: buildLocalizeFn({
19772 values: dayPeriodValues,
19773 defaultWidth: "wide",
19774 formattingValues: formattingDayPeriodValues,
19775 defaultFormattingWidth: "wide"
19776 })
19777 };
19778
19779 // node_modules/date-fns/locale/_lib/buildMatchFn.js
19780 function buildMatchFn(args) {
19781 return (string, options = {}) => {
19782 const width = options.width;
19783 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
19784 const matchResult = string.match(matchPattern);
19785 if (!matchResult) {
19786 return null;
19787 }
19788 const matchedString = matchResult[0];
19789 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
19790 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
19791 // [TODO] -- I challenge you to fix the type
19792 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
19793 );
19794 let value;
19795 value = args.valueCallback ? args.valueCallback(key) : key;
19796 value = options.valueCallback ? (
19797 // [TODO] -- I challenge you to fix the type
19798 options.valueCallback(value)
19799 ) : value;
19800 const rest = string.slice(matchedString.length);
19801 return { value, rest };
19802 };
19803 }
19804 function findKey(object, predicate) {
19805 for (const key in object) {
19806 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
19807 return key;
19808 }
19809 }
19810 return void 0;
19811 }
19812 function findIndex(array, predicate) {
19813 for (let key = 0; key < array.length; key++) {
19814 if (predicate(array[key])) {
19815 return key;
19816 }
19817 }
19818 return void 0;
19819 }
19820
19821 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
19822 function buildMatchPatternFn(args) {
19823 return (string, options = {}) => {
19824 const matchResult = string.match(args.matchPattern);
19825 if (!matchResult) return null;
19826 const matchedString = matchResult[0];
19827 const parseResult = string.match(args.parsePattern);
19828 if (!parseResult) return null;
19829 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
19830 value = options.valueCallback ? options.valueCallback(value) : value;
19831 const rest = string.slice(matchedString.length);
19832 return { value, rest };
19833 };
19834 }
19835
19836 // node_modules/date-fns/locale/en-US/_lib/match.js
19837 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
19838 var parseOrdinalNumberPattern = /\d+/i;
19839 var matchEraPatterns = {
19840 narrow: /^(b|a)/i,
19841 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
19842 wide: /^(before christ|before common era|anno domini|common era)/i
19843 };
19844 var parseEraPatterns = {
19845 any: [/^b/i, /^(a|c)/i]
19846 };
19847 var matchQuarterPatterns = {
19848 narrow: /^[1234]/i,
19849 abbreviated: /^q[1234]/i,
19850 wide: /^[1234](th|st|nd|rd)? quarter/i
19851 };
19852 var parseQuarterPatterns = {
19853 any: [/1/i, /2/i, /3/i, /4/i]
19854 };
19855 var matchMonthPatterns = {
19856 narrow: /^[jfmasond]/i,
19857 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
19858 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
19859 };
19860 var parseMonthPatterns = {
19861 narrow: [
19862 /^j/i,
19863 /^f/i,
19864 /^m/i,
19865 /^a/i,
19866 /^m/i,
19867 /^j/i,
19868 /^j/i,
19869 /^a/i,
19870 /^s/i,
19871 /^o/i,
19872 /^n/i,
19873 /^d/i
19874 ],
19875 any: [
19876 /^ja/i,
19877 /^f/i,
19878 /^mar/i,
19879 /^ap/i,
19880 /^may/i,
19881 /^jun/i,
19882 /^jul/i,
19883 /^au/i,
19884 /^s/i,
19885 /^o/i,
19886 /^n/i,
19887 /^d/i
19888 ]
19889 };
19890 var matchDayPatterns = {
19891 narrow: /^[smtwf]/i,
19892 short: /^(su|mo|tu|we|th|fr|sa)/i,
19893 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
19894 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
19895 };
19896 var parseDayPatterns = {
19897 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
19898 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
19899 };
19900 var matchDayPeriodPatterns = {
19901 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
19902 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
19903 };
19904 var parseDayPeriodPatterns = {
19905 any: {
19906 am: /^a/i,
19907 pm: /^p/i,
19908 midnight: /^mi/i,
19909 noon: /^no/i,
19910 morning: /morning/i,
19911 afternoon: /afternoon/i,
19912 evening: /evening/i,
19913 night: /night/i
19914 }
19915 };
19916 var match = {
19917 ordinalNumber: buildMatchPatternFn({
19918 matchPattern: matchOrdinalNumberPattern,
19919 parsePattern: parseOrdinalNumberPattern,
19920 valueCallback: (value) => parseInt(value, 10)
19921 }),
19922 era: buildMatchFn({
19923 matchPatterns: matchEraPatterns,
19924 defaultMatchWidth: "wide",
19925 parsePatterns: parseEraPatterns,
19926 defaultParseWidth: "any"
19927 }),
19928 quarter: buildMatchFn({
19929 matchPatterns: matchQuarterPatterns,
19930 defaultMatchWidth: "wide",
19931 parsePatterns: parseQuarterPatterns,
19932 defaultParseWidth: "any",
19933 valueCallback: (index2) => index2 + 1
19934 }),
19935 month: buildMatchFn({
19936 matchPatterns: matchMonthPatterns,
19937 defaultMatchWidth: "wide",
19938 parsePatterns: parseMonthPatterns,
19939 defaultParseWidth: "any"
19940 }),
19941 day: buildMatchFn({
19942 matchPatterns: matchDayPatterns,
19943 defaultMatchWidth: "wide",
19944 parsePatterns: parseDayPatterns,
19945 defaultParseWidth: "any"
19946 }),
19947 dayPeriod: buildMatchFn({
19948 matchPatterns: matchDayPeriodPatterns,
19949 defaultMatchWidth: "any",
19950 parsePatterns: parseDayPeriodPatterns,
19951 defaultParseWidth: "any"
19952 })
19953 };
19954
19955 // node_modules/date-fns/locale/en-US.js
19956 var enUS = {
19957 code: "en-US",
19958 formatDistance,
19959 formatLong,
19960 formatRelative,
19961 localize,
19962 match,
19963 options: {
19964 weekStartsOn: 0,
19965 firstWeekContainsDate: 1
19966 }
19967 };
19968
19969 // node_modules/date-fns/getDayOfYear.js
19970 function getDayOfYear(date, options) {
19971 const _date = toDate(date, options?.in);
19972 const diff = differenceInCalendarDays(_date, startOfYear(_date));
19973 const dayOfYear = diff + 1;
19974 return dayOfYear;
19975 }
19976
19977 // node_modules/date-fns/getISOWeek.js
19978 function getISOWeek(date, options) {
19979 const _date = toDate(date, options?.in);
19980 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
19981 return Math.round(diff / millisecondsInWeek) + 1;
19982 }
19983
19984 // node_modules/date-fns/getWeekYear.js
19985 function getWeekYear(date, options) {
19986 const _date = toDate(date, options?.in);
19987 const year = _date.getFullYear();
19988 const defaultOptions2 = getDefaultOptions();
19989 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
19990 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
19991 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
19992 firstWeekOfNextYear.setHours(0, 0, 0, 0);
19993 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
19994 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
19995 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
19996 firstWeekOfThisYear.setHours(0, 0, 0, 0);
19997 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
19998 if (+_date >= +startOfNextYear) {
19999 return year + 1;
20000 } else if (+_date >= +startOfThisYear) {
20001 return year;
20002 } else {
20003 return year - 1;
20004 }
20005 }
20006
20007 // node_modules/date-fns/startOfWeekYear.js
20008 function startOfWeekYear(date, options) {
20009 const defaultOptions2 = getDefaultOptions();
20010 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20011 const year = getWeekYear(date, options);
20012 const firstWeek = constructFrom(options?.in || date, 0);
20013 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
20014 firstWeek.setHours(0, 0, 0, 0);
20015 const _date = startOfWeek(firstWeek, options);
20016 return _date;
20017 }
20018
20019 // node_modules/date-fns/getWeek.js
20020 function getWeek(date, options) {
20021 const _date = toDate(date, options?.in);
20022 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
20023 return Math.round(diff / millisecondsInWeek) + 1;
20024 }
20025
20026 // node_modules/date-fns/_lib/addLeadingZeros.js
20027 function addLeadingZeros(number, targetLength) {
20028 const sign = number < 0 ? "-" : "";
20029 const output = Math.abs(number).toString().padStart(targetLength, "0");
20030 return sign + output;
20031 }
20032
20033 // node_modules/date-fns/_lib/format/lightFormatters.js
20034 var lightFormatters = {
20035 // Year
20036 y(date, token) {
20037 const signedYear = date.getFullYear();
20038 const year = signedYear > 0 ? signedYear : 1 - signedYear;
20039 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
20040 },
20041 // Month
20042 M(date, token) {
20043 const month = date.getMonth();
20044 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
20045 },
20046 // Day of the month
20047 d(date, token) {
20048 return addLeadingZeros(date.getDate(), token.length);
20049 },
20050 // AM or PM
20051 a(date, token) {
20052 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
20053 switch (token) {
20054 case "a":
20055 case "aa":
20056 return dayPeriodEnumValue.toUpperCase();
20057 case "aaa":
20058 return dayPeriodEnumValue;
20059 case "aaaaa":
20060 return dayPeriodEnumValue[0];
20061 case "aaaa":
20062 default:
20063 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
20064 }
20065 },
20066 // Hour [1-12]
20067 h(date, token) {
20068 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
20069 },
20070 // Hour [0-23]
20071 H(date, token) {
20072 return addLeadingZeros(date.getHours(), token.length);
20073 },
20074 // Minute
20075 m(date, token) {
20076 return addLeadingZeros(date.getMinutes(), token.length);
20077 },
20078 // Second
20079 s(date, token) {
20080 return addLeadingZeros(date.getSeconds(), token.length);
20081 },
20082 // Fraction of second
20083 S(date, token) {
20084 const numberOfDigits = token.length;
20085 const milliseconds = date.getMilliseconds();
20086 const fractionalSeconds = Math.trunc(
20087 milliseconds * Math.pow(10, numberOfDigits - 3)
20088 );
20089 return addLeadingZeros(fractionalSeconds, token.length);
20090 }
20091 };
20092
20093 // node_modules/date-fns/_lib/format/formatters.js
20094 var dayPeriodEnum = {
20095 am: "am",
20096 pm: "pm",
20097 midnight: "midnight",
20098 noon: "noon",
20099 morning: "morning",
20100 afternoon: "afternoon",
20101 evening: "evening",
20102 night: "night"
20103 };
20104 var formatters = {
20105 // Era
20106 G: function(date, token, localize2) {
20107 const era = date.getFullYear() > 0 ? 1 : 0;
20108 switch (token) {
20109 // AD, BC
20110 case "G":
20111 case "GG":
20112 case "GGG":
20113 return localize2.era(era, { width: "abbreviated" });
20114 // A, B
20115 case "GGGGG":
20116 return localize2.era(era, { width: "narrow" });
20117 // Anno Domini, Before Christ
20118 case "GGGG":
20119 default:
20120 return localize2.era(era, { width: "wide" });
20121 }
20122 },
20123 // Year
20124 y: function(date, token, localize2) {
20125 if (token === "yo") {
20126 const signedYear = date.getFullYear();
20127 const year = signedYear > 0 ? signedYear : 1 - signedYear;
20128 return localize2.ordinalNumber(year, { unit: "year" });
20129 }
20130 return lightFormatters.y(date, token);
20131 },
20132 // Local week-numbering year
20133 Y: function(date, token, localize2, options) {
20134 const signedWeekYear = getWeekYear(date, options);
20135 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
20136 if (token === "YY") {
20137 const twoDigitYear = weekYear % 100;
20138 return addLeadingZeros(twoDigitYear, 2);
20139 }
20140 if (token === "Yo") {
20141 return localize2.ordinalNumber(weekYear, { unit: "year" });
20142 }
20143 return addLeadingZeros(weekYear, token.length);
20144 },
20145 // ISO week-numbering year
20146 R: function(date, token) {
20147 const isoWeekYear = getISOWeekYear(date);
20148 return addLeadingZeros(isoWeekYear, token.length);
20149 },
20150 // Extended year. This is a single number designating the year of this calendar system.
20151 // The main difference between `y` and `u` localizers are B.C. years:
20152 // | Year | `y` | `u` |
20153 // |------|-----|-----|
20154 // | AC 1 | 1 | 1 |
20155 // | BC 1 | 1 | 0 |
20156 // | BC 2 | 2 | -1 |
20157 // Also `yy` always returns the last two digits of a year,
20158 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
20159 u: function(date, token) {
20160 const year = date.getFullYear();
20161 return addLeadingZeros(year, token.length);
20162 },
20163 // Quarter
20164 Q: function(date, token, localize2) {
20165 const quarter = Math.ceil((date.getMonth() + 1) / 3);
20166 switch (token) {
20167 // 1, 2, 3, 4
20168 case "Q":
20169 return String(quarter);
20170 // 01, 02, 03, 04
20171 case "QQ":
20172 return addLeadingZeros(quarter, 2);
20173 // 1st, 2nd, 3rd, 4th
20174 case "Qo":
20175 return localize2.ordinalNumber(quarter, { unit: "quarter" });
20176 // Q1, Q2, Q3, Q4
20177 case "QQQ":
20178 return localize2.quarter(quarter, {
20179 width: "abbreviated",
20180 context: "formatting"
20181 });
20182 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20183 case "QQQQQ":
20184 return localize2.quarter(quarter, {
20185 width: "narrow",
20186 context: "formatting"
20187 });
20188 // 1st quarter, 2nd quarter, ...
20189 case "QQQQ":
20190 default:
20191 return localize2.quarter(quarter, {
20192 width: "wide",
20193 context: "formatting"
20194 });
20195 }
20196 },
20197 // Stand-alone quarter
20198 q: function(date, token, localize2) {
20199 const quarter = Math.ceil((date.getMonth() + 1) / 3);
20200 switch (token) {
20201 // 1, 2, 3, 4
20202 case "q":
20203 return String(quarter);
20204 // 01, 02, 03, 04
20205 case "qq":
20206 return addLeadingZeros(quarter, 2);
20207 // 1st, 2nd, 3rd, 4th
20208 case "qo":
20209 return localize2.ordinalNumber(quarter, { unit: "quarter" });
20210 // Q1, Q2, Q3, Q4
20211 case "qqq":
20212 return localize2.quarter(quarter, {
20213 width: "abbreviated",
20214 context: "standalone"
20215 });
20216 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20217 case "qqqqq":
20218 return localize2.quarter(quarter, {
20219 width: "narrow",
20220 context: "standalone"
20221 });
20222 // 1st quarter, 2nd quarter, ...
20223 case "qqqq":
20224 default:
20225 return localize2.quarter(quarter, {
20226 width: "wide",
20227 context: "standalone"
20228 });
20229 }
20230 },
20231 // Month
20232 M: function(date, token, localize2) {
20233 const month = date.getMonth();
20234 switch (token) {
20235 case "M":
20236 case "MM":
20237 return lightFormatters.M(date, token);
20238 // 1st, 2nd, ..., 12th
20239 case "Mo":
20240 return localize2.ordinalNumber(month + 1, { unit: "month" });
20241 // Jan, Feb, ..., Dec
20242 case "MMM":
20243 return localize2.month(month, {
20244 width: "abbreviated",
20245 context: "formatting"
20246 });
20247 // J, F, ..., D
20248 case "MMMMM":
20249 return localize2.month(month, {
20250 width: "narrow",
20251 context: "formatting"
20252 });
20253 // January, February, ..., December
20254 case "MMMM":
20255 default:
20256 return localize2.month(month, { width: "wide", context: "formatting" });
20257 }
20258 },
20259 // Stand-alone month
20260 L: function(date, token, localize2) {
20261 const month = date.getMonth();
20262 switch (token) {
20263 // 1, 2, ..., 12
20264 case "L":
20265 return String(month + 1);
20266 // 01, 02, ..., 12
20267 case "LL":
20268 return addLeadingZeros(month + 1, 2);
20269 // 1st, 2nd, ..., 12th
20270 case "Lo":
20271 return localize2.ordinalNumber(month + 1, { unit: "month" });
20272 // Jan, Feb, ..., Dec
20273 case "LLL":
20274 return localize2.month(month, {
20275 width: "abbreviated",
20276 context: "standalone"
20277 });
20278 // J, F, ..., D
20279 case "LLLLL":
20280 return localize2.month(month, {
20281 width: "narrow",
20282 context: "standalone"
20283 });
20284 // January, February, ..., December
20285 case "LLLL":
20286 default:
20287 return localize2.month(month, { width: "wide", context: "standalone" });
20288 }
20289 },
20290 // Local week of year
20291 w: function(date, token, localize2, options) {
20292 const week = getWeek(date, options);
20293 if (token === "wo") {
20294 return localize2.ordinalNumber(week, { unit: "week" });
20295 }
20296 return addLeadingZeros(week, token.length);
20297 },
20298 // ISO week of year
20299 I: function(date, token, localize2) {
20300 const isoWeek = getISOWeek(date);
20301 if (token === "Io") {
20302 return localize2.ordinalNumber(isoWeek, { unit: "week" });
20303 }
20304 return addLeadingZeros(isoWeek, token.length);
20305 },
20306 // Day of the month
20307 d: function(date, token, localize2) {
20308 if (token === "do") {
20309 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
20310 }
20311 return lightFormatters.d(date, token);
20312 },
20313 // Day of year
20314 D: function(date, token, localize2) {
20315 const dayOfYear = getDayOfYear(date);
20316 if (token === "Do") {
20317 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
20318 }
20319 return addLeadingZeros(dayOfYear, token.length);
20320 },
20321 // Day of week
20322 E: function(date, token, localize2) {
20323 const dayOfWeek = date.getDay();
20324 switch (token) {
20325 // Tue
20326 case "E":
20327 case "EE":
20328 case "EEE":
20329 return localize2.day(dayOfWeek, {
20330 width: "abbreviated",
20331 context: "formatting"
20332 });
20333 // T
20334 case "EEEEE":
20335 return localize2.day(dayOfWeek, {
20336 width: "narrow",
20337 context: "formatting"
20338 });
20339 // Tu
20340 case "EEEEEE":
20341 return localize2.day(dayOfWeek, {
20342 width: "short",
20343 context: "formatting"
20344 });
20345 // Tuesday
20346 case "EEEE":
20347 default:
20348 return localize2.day(dayOfWeek, {
20349 width: "wide",
20350 context: "formatting"
20351 });
20352 }
20353 },
20354 // Local day of week
20355 e: function(date, token, localize2, options) {
20356 const dayOfWeek = date.getDay();
20357 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20358 switch (token) {
20359 // Numerical value (Nth day of week with current locale or weekStartsOn)
20360 case "e":
20361 return String(localDayOfWeek);
20362 // Padded numerical value
20363 case "ee":
20364 return addLeadingZeros(localDayOfWeek, 2);
20365 // 1st, 2nd, ..., 7th
20366 case "eo":
20367 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20368 case "eee":
20369 return localize2.day(dayOfWeek, {
20370 width: "abbreviated",
20371 context: "formatting"
20372 });
20373 // T
20374 case "eeeee":
20375 return localize2.day(dayOfWeek, {
20376 width: "narrow",
20377 context: "formatting"
20378 });
20379 // Tu
20380 case "eeeeee":
20381 return localize2.day(dayOfWeek, {
20382 width: "short",
20383 context: "formatting"
20384 });
20385 // Tuesday
20386 case "eeee":
20387 default:
20388 return localize2.day(dayOfWeek, {
20389 width: "wide",
20390 context: "formatting"
20391 });
20392 }
20393 },
20394 // Stand-alone local day of week
20395 c: function(date, token, localize2, options) {
20396 const dayOfWeek = date.getDay();
20397 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20398 switch (token) {
20399 // Numerical value (same as in `e`)
20400 case "c":
20401 return String(localDayOfWeek);
20402 // Padded numerical value
20403 case "cc":
20404 return addLeadingZeros(localDayOfWeek, token.length);
20405 // 1st, 2nd, ..., 7th
20406 case "co":
20407 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20408 case "ccc":
20409 return localize2.day(dayOfWeek, {
20410 width: "abbreviated",
20411 context: "standalone"
20412 });
20413 // T
20414 case "ccccc":
20415 return localize2.day(dayOfWeek, {
20416 width: "narrow",
20417 context: "standalone"
20418 });
20419 // Tu
20420 case "cccccc":
20421 return localize2.day(dayOfWeek, {
20422 width: "short",
20423 context: "standalone"
20424 });
20425 // Tuesday
20426 case "cccc":
20427 default:
20428 return localize2.day(dayOfWeek, {
20429 width: "wide",
20430 context: "standalone"
20431 });
20432 }
20433 },
20434 // ISO day of week
20435 i: function(date, token, localize2) {
20436 const dayOfWeek = date.getDay();
20437 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
20438 switch (token) {
20439 // 2
20440 case "i":
20441 return String(isoDayOfWeek);
20442 // 02
20443 case "ii":
20444 return addLeadingZeros(isoDayOfWeek, token.length);
20445 // 2nd
20446 case "io":
20447 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
20448 // Tue
20449 case "iii":
20450 return localize2.day(dayOfWeek, {
20451 width: "abbreviated",
20452 context: "formatting"
20453 });
20454 // T
20455 case "iiiii":
20456 return localize2.day(dayOfWeek, {
20457 width: "narrow",
20458 context: "formatting"
20459 });
20460 // Tu
20461 case "iiiiii":
20462 return localize2.day(dayOfWeek, {
20463 width: "short",
20464 context: "formatting"
20465 });
20466 // Tuesday
20467 case "iiii":
20468 default:
20469 return localize2.day(dayOfWeek, {
20470 width: "wide",
20471 context: "formatting"
20472 });
20473 }
20474 },
20475 // AM or PM
20476 a: function(date, token, localize2) {
20477 const hours = date.getHours();
20478 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
20479 switch (token) {
20480 case "a":
20481 case "aa":
20482 return localize2.dayPeriod(dayPeriodEnumValue, {
20483 width: "abbreviated",
20484 context: "formatting"
20485 });
20486 case "aaa":
20487 return localize2.dayPeriod(dayPeriodEnumValue, {
20488 width: "abbreviated",
20489 context: "formatting"
20490 }).toLowerCase();
20491 case "aaaaa":
20492 return localize2.dayPeriod(dayPeriodEnumValue, {
20493 width: "narrow",
20494 context: "formatting"
20495 });
20496 case "aaaa":
20497 default:
20498 return localize2.dayPeriod(dayPeriodEnumValue, {
20499 width: "wide",
20500 context: "formatting"
20501 });
20502 }
20503 },
20504 // AM, PM, midnight, noon
20505 b: function(date, token, localize2) {
20506 const hours = date.getHours();
20507 let dayPeriodEnumValue;
20508 if (hours === 12) {
20509 dayPeriodEnumValue = dayPeriodEnum.noon;
20510 } else if (hours === 0) {
20511 dayPeriodEnumValue = dayPeriodEnum.midnight;
20512 } else {
20513 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
20514 }
20515 switch (token) {
20516 case "b":
20517 case "bb":
20518 return localize2.dayPeriod(dayPeriodEnumValue, {
20519 width: "abbreviated",
20520 context: "formatting"
20521 });
20522 case "bbb":
20523 return localize2.dayPeriod(dayPeriodEnumValue, {
20524 width: "abbreviated",
20525 context: "formatting"
20526 }).toLowerCase();
20527 case "bbbbb":
20528 return localize2.dayPeriod(dayPeriodEnumValue, {
20529 width: "narrow",
20530 context: "formatting"
20531 });
20532 case "bbbb":
20533 default:
20534 return localize2.dayPeriod(dayPeriodEnumValue, {
20535 width: "wide",
20536 context: "formatting"
20537 });
20538 }
20539 },
20540 // in the morning, in the afternoon, in the evening, at night
20541 B: function(date, token, localize2) {
20542 const hours = date.getHours();
20543 let dayPeriodEnumValue;
20544 if (hours >= 17) {
20545 dayPeriodEnumValue = dayPeriodEnum.evening;
20546 } else if (hours >= 12) {
20547 dayPeriodEnumValue = dayPeriodEnum.afternoon;
20548 } else if (hours >= 4) {
20549 dayPeriodEnumValue = dayPeriodEnum.morning;
20550 } else {
20551 dayPeriodEnumValue = dayPeriodEnum.night;
20552 }
20553 switch (token) {
20554 case "B":
20555 case "BB":
20556 case "BBB":
20557 return localize2.dayPeriod(dayPeriodEnumValue, {
20558 width: "abbreviated",
20559 context: "formatting"
20560 });
20561 case "BBBBB":
20562 return localize2.dayPeriod(dayPeriodEnumValue, {
20563 width: "narrow",
20564 context: "formatting"
20565 });
20566 case "BBBB":
20567 default:
20568 return localize2.dayPeriod(dayPeriodEnumValue, {
20569 width: "wide",
20570 context: "formatting"
20571 });
20572 }
20573 },
20574 // Hour [1-12]
20575 h: function(date, token, localize2) {
20576 if (token === "ho") {
20577 let hours = date.getHours() % 12;
20578 if (hours === 0) hours = 12;
20579 return localize2.ordinalNumber(hours, { unit: "hour" });
20580 }
20581 return lightFormatters.h(date, token);
20582 },
20583 // Hour [0-23]
20584 H: function(date, token, localize2) {
20585 if (token === "Ho") {
20586 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
20587 }
20588 return lightFormatters.H(date, token);
20589 },
20590 // Hour [0-11]
20591 K: function(date, token, localize2) {
20592 const hours = date.getHours() % 12;
20593 if (token === "Ko") {
20594 return localize2.ordinalNumber(hours, { unit: "hour" });
20595 }
20596 return addLeadingZeros(hours, token.length);
20597 },
20598 // Hour [1-24]
20599 k: function(date, token, localize2) {
20600 let hours = date.getHours();
20601 if (hours === 0) hours = 24;
20602 if (token === "ko") {
20603 return localize2.ordinalNumber(hours, { unit: "hour" });
20604 }
20605 return addLeadingZeros(hours, token.length);
20606 },
20607 // Minute
20608 m: function(date, token, localize2) {
20609 if (token === "mo") {
20610 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
20611 }
20612 return lightFormatters.m(date, token);
20613 },
20614 // Second
20615 s: function(date, token, localize2) {
20616 if (token === "so") {
20617 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
20618 }
20619 return lightFormatters.s(date, token);
20620 },
20621 // Fraction of second
20622 S: function(date, token) {
20623 return lightFormatters.S(date, token);
20624 },
20625 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
20626 X: function(date, token, _localize) {
20627 const timezoneOffset = date.getTimezoneOffset();
20628 if (timezoneOffset === 0) {
20629 return "Z";
20630 }
20631 switch (token) {
20632 // Hours and optional minutes
20633 case "X":
20634 return formatTimezoneWithOptionalMinutes(timezoneOffset);
20635 // Hours, minutes and optional seconds without `:` delimiter
20636 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20637 // so this token always has the same output as `XX`
20638 case "XXXX":
20639 case "XX":
20640 return formatTimezone(timezoneOffset);
20641 // Hours, minutes and optional seconds with `:` delimiter
20642 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20643 // so this token always has the same output as `XXX`
20644 case "XXXXX":
20645 case "XXX":
20646 // Hours and minutes with `:` delimiter
20647 default:
20648 return formatTimezone(timezoneOffset, ":");
20649 }
20650 },
20651 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
20652 x: function(date, token, _localize) {
20653 const timezoneOffset = date.getTimezoneOffset();
20654 switch (token) {
20655 // Hours and optional minutes
20656 case "x":
20657 return formatTimezoneWithOptionalMinutes(timezoneOffset);
20658 // Hours, minutes and optional seconds without `:` delimiter
20659 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20660 // so this token always has the same output as `xx`
20661 case "xxxx":
20662 case "xx":
20663 return formatTimezone(timezoneOffset);
20664 // Hours, minutes and optional seconds with `:` delimiter
20665 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20666 // so this token always has the same output as `xxx`
20667 case "xxxxx":
20668 case "xxx":
20669 // Hours and minutes with `:` delimiter
20670 default:
20671 return formatTimezone(timezoneOffset, ":");
20672 }
20673 },
20674 // Timezone (GMT)
20675 O: function(date, token, _localize) {
20676 const timezoneOffset = date.getTimezoneOffset();
20677 switch (token) {
20678 // Short
20679 case "O":
20680 case "OO":
20681 case "OOO":
20682 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
20683 // Long
20684 case "OOOO":
20685 default:
20686 return "GMT" + formatTimezone(timezoneOffset, ":");
20687 }
20688 },
20689 // Timezone (specific non-location)
20690 z: function(date, token, _localize) {
20691 const timezoneOffset = date.getTimezoneOffset();
20692 switch (token) {
20693 // Short
20694 case "z":
20695 case "zz":
20696 case "zzz":
20697 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
20698 // Long
20699 case "zzzz":
20700 default:
20701 return "GMT" + formatTimezone(timezoneOffset, ":");
20702 }
20703 },
20704 // Seconds timestamp
20705 t: function(date, token, _localize) {
20706 const timestamp = Math.trunc(+date / 1e3);
20707 return addLeadingZeros(timestamp, token.length);
20708 },
20709 // Milliseconds timestamp
20710 T: function(date, token, _localize) {
20711 return addLeadingZeros(+date, token.length);
20712 }
20713 };
20714 function formatTimezoneShort(offset4, delimiter = "") {
20715 const sign = offset4 > 0 ? "-" : "+";
20716 const absOffset = Math.abs(offset4);
20717 const hours = Math.trunc(absOffset / 60);
20718 const minutes = absOffset % 60;
20719 if (minutes === 0) {
20720 return sign + String(hours);
20721 }
20722 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
20723 }
20724 function formatTimezoneWithOptionalMinutes(offset4, delimiter) {
20725 if (offset4 % 60 === 0) {
20726 const sign = offset4 > 0 ? "-" : "+";
20727 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2);
20728 }
20729 return formatTimezone(offset4, delimiter);
20730 }
20731 function formatTimezone(offset4, delimiter = "") {
20732 const sign = offset4 > 0 ? "-" : "+";
20733 const absOffset = Math.abs(offset4);
20734 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
20735 const minutes = addLeadingZeros(absOffset % 60, 2);
20736 return sign + hours + delimiter + minutes;
20737 }
20738
20739 // node_modules/date-fns/_lib/format/longFormatters.js
20740 var dateLongFormatter = (pattern, formatLong2) => {
20741 switch (pattern) {
20742 case "P":
20743 return formatLong2.date({ width: "short" });
20744 case "PP":
20745 return formatLong2.date({ width: "medium" });
20746 case "PPP":
20747 return formatLong2.date({ width: "long" });
20748 case "PPPP":
20749 default:
20750 return formatLong2.date({ width: "full" });
20751 }
20752 };
20753 var timeLongFormatter = (pattern, formatLong2) => {
20754 switch (pattern) {
20755 case "p":
20756 return formatLong2.time({ width: "short" });
20757 case "pp":
20758 return formatLong2.time({ width: "medium" });
20759 case "ppp":
20760 return formatLong2.time({ width: "long" });
20761 case "pppp":
20762 default:
20763 return formatLong2.time({ width: "full" });
20764 }
20765 };
20766 var dateTimeLongFormatter = (pattern, formatLong2) => {
20767 const matchResult = pattern.match(/(P+)(p+)?/) || [];
20768 const datePattern = matchResult[1];
20769 const timePattern = matchResult[2];
20770 if (!timePattern) {
20771 return dateLongFormatter(pattern, formatLong2);
20772 }
20773 let dateTimeFormat;
20774 switch (datePattern) {
20775 case "P":
20776 dateTimeFormat = formatLong2.dateTime({ width: "short" });
20777 break;
20778 case "PP":
20779 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
20780 break;
20781 case "PPP":
20782 dateTimeFormat = formatLong2.dateTime({ width: "long" });
20783 break;
20784 case "PPPP":
20785 default:
20786 dateTimeFormat = formatLong2.dateTime({ width: "full" });
20787 break;
20788 }
20789 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
20790 };
20791 var longFormatters = {
20792 p: timeLongFormatter,
20793 P: dateTimeLongFormatter
20794 };
20795
20796 // node_modules/date-fns/_lib/protectedTokens.js
20797 var dayOfYearTokenRE = /^D+$/;
20798 var weekYearTokenRE = /^Y+$/;
20799 var throwTokens = ["D", "DD", "YY", "YYYY"];
20800 function isProtectedDayOfYearToken(token) {
20801 return dayOfYearTokenRE.test(token);
20802 }
20803 function isProtectedWeekYearToken(token) {
20804 return weekYearTokenRE.test(token);
20805 }
20806 function warnOrThrowProtectedError(token, format6, input) {
20807 const _message = message(token, format6, input);
20808 console.warn(_message);
20809 if (throwTokens.includes(token)) throw new RangeError(_message);
20810 }
20811 function message(token, format6, input) {
20812 const subject = token[0] === "Y" ? "years" : "days of the month";
20813 return `Use \`${token.toLowerCase()}\` instead of \`${token}\` (in \`${format6}\`) for formatting ${subject} to the input \`${input}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;
20814 }
20815
20816 // node_modules/date-fns/format.js
20817 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
20818 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
20819 var escapedStringRegExp = /^'([^]*?)'?$/;
20820 var doubleQuoteRegExp = /''/g;
20821 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
20822 function format(date, formatStr, options) {
20823 const defaultOptions2 = getDefaultOptions();
20824 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
20825 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20826 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
20827 const originalDate = toDate(date, options?.in);
20828 if (!isValid(originalDate)) {
20829 throw new RangeError("Invalid time value");
20830 }
20831 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
20832 const firstCharacter = substring[0];
20833 if (firstCharacter === "p" || firstCharacter === "P") {
20834 const longFormatter = longFormatters[firstCharacter];
20835 return longFormatter(substring, locale.formatLong);
20836 }
20837 return substring;
20838 }).join("").match(formattingTokensRegExp).map((substring) => {
20839 if (substring === "''") {
20840 return { isToken: false, value: "'" };
20841 }
20842 const firstCharacter = substring[0];
20843 if (firstCharacter === "'") {
20844 return { isToken: false, value: cleanEscapedString(substring) };
20845 }
20846 if (formatters[firstCharacter]) {
20847 return { isToken: true, value: substring };
20848 }
20849 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
20850 throw new RangeError(
20851 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
20852 );
20853 }
20854 return { isToken: false, value: substring };
20855 });
20856 if (locale.localize.preprocessor) {
20857 parts = locale.localize.preprocessor(originalDate, parts);
20858 }
20859 const formatterOptions = {
20860 firstWeekContainsDate,
20861 weekStartsOn,
20862 locale
20863 };
20864 return parts.map((part) => {
20865 if (!part.isToken) return part.value;
20866 const token = part.value;
20867 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
20868 warnOrThrowProtectedError(token, formatStr, String(date));
20869 }
20870 const formatter = formatters[token[0]];
20871 return formatter(originalDate, token, locale.localize, formatterOptions);
20872 }).join("");
20873 }
20874 function cleanEscapedString(input) {
20875 const matched = input.match(escapedStringRegExp);
20876 if (!matched) {
20877 return input;
20878 }
20879 return matched[1].replace(doubleQuoteRegExp, "'");
20880 }
20881
20882 // node_modules/date-fns/subDays.js
20883 function subDays(date, amount, options) {
20884 return addDays(date, -amount, options);
20885 }
20886
20887 // node_modules/date-fns/subMonths.js
20888 function subMonths(date, amount, options) {
20889 return addMonths(date, -amount, options);
20890 }
20891
20892 // node_modules/date-fns/subWeeks.js
20893 function subWeeks(date, amount, options) {
20894 return addWeeks(date, -amount, options);
20895 }
20896
20897 // node_modules/date-fns/subYears.js
20898 function subYears(date, amount, options) {
20899 return addYears(date, -amount, options);
20900 }
20901
20902 // packages/dataviews/build-module/utils/operators.mjs
20903 var import_i18n24 = __toESM(require_i18n(), 1);
20904 var import_element50 = __toESM(require_element(), 1);
20905 var import_date = __toESM(require_date(), 1);
20906 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
20907 var filterTextWrappers = {
20908 Name: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
20909 Value: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
20910 };
20911 function getRelativeDate(value, unit) {
20912 switch (unit) {
20913 case "days":
20914 return subDays(/* @__PURE__ */ new Date(), value);
20915 case "weeks":
20916 return subWeeks(/* @__PURE__ */ new Date(), value);
20917 case "months":
20918 return subMonths(/* @__PURE__ */ new Date(), value);
20919 case "years":
20920 return subYears(/* @__PURE__ */ new Date(), value);
20921 default:
20922 return /* @__PURE__ */ new Date();
20923 }
20924 }
20925 var isNoneOperatorDefinition = {
20926 /* translators: DataViews operator name */
20927 label: (0, import_i18n24.__)("Is none of"),
20928 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
20929 (0, import_i18n24.sprintf)(
20930 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
20931 (0, import_i18n24.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
20932 filter.name,
20933 activeElements.map((element) => element.label).join(", ")
20934 ),
20935 filterTextWrappers
20936 ),
20937 filter: ((item, field, filterValue) => {
20938 if (!filterValue?.length) {
20939 return true;
20940 }
20941 const fieldValue = field.getValue({ item });
20942 if (Array.isArray(fieldValue)) {
20943 return !filterValue.some(
20944 (fv) => fieldValue.includes(fv)
20945 );
20946 } else if (typeof fieldValue === "string") {
20947 return !filterValue.includes(fieldValue);
20948 }
20949 return false;
20950 }),
20951 selection: "multi"
20952 };
20953 var OPERATORS = [
20954 {
20955 name: OPERATOR_IS_ANY,
20956 /* translators: DataViews operator name */
20957 label: (0, import_i18n24.__)("Includes"),
20958 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
20959 (0, import_i18n24.sprintf)(
20960 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
20961 (0, import_i18n24.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
20962 filter.name,
20963 activeElements.map((element) => element.label).join(", ")
20964 ),
20965 filterTextWrappers
20966 ),
20967 filter(item, field, filterValue) {
20968 if (!filterValue?.length) {
20969 return true;
20970 }
20971 const fieldValue = field.getValue({ item });
20972 if (Array.isArray(fieldValue)) {
20973 return filterValue.some(
20974 (fv) => fieldValue.includes(fv)
20975 );
20976 } else if (typeof fieldValue === "string") {
20977 return filterValue.includes(fieldValue);
20978 }
20979 return false;
20980 },
20981 selection: "multi"
20982 },
20983 {
20984 name: OPERATOR_IS_NONE,
20985 ...isNoneOperatorDefinition
20986 },
20987 {
20988 name: OPERATOR_IS_ALL,
20989 /* translators: DataViews operator name */
20990 label: (0, import_i18n24.__)("Includes all"),
20991 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
20992 (0, import_i18n24.sprintf)(
20993 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
20994 (0, import_i18n24.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
20995 filter.name,
20996 activeElements.map((element) => element.label).join(", ")
20997 ),
20998 filterTextWrappers
20999 ),
21000 filter(item, field, filterValue) {
21001 if (!filterValue?.length) {
21002 return true;
21003 }
21004 return filterValue.every((value) => {
21005 return field.getValue({ item })?.includes(value);
21006 });
21007 },
21008 selection: "multi"
21009 },
21010 {
21011 name: OPERATOR_IS_NOT_ALL,
21012 ...isNoneOperatorDefinition
21013 },
21014 {
21015 name: OPERATOR_BETWEEN,
21016 /* translators: DataViews operator name */
21017 label: (0, import_i18n24.__)("Between (inc)"),
21018 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21019 (0, import_i18n24.sprintf)(
21020 /* translators: 1: Filter name (e.g. "Item count"). 2: Filter value min. 3: Filter value max. e.g.: "Item count between (inc): 10 and 180". */
21021 (0, import_i18n24.__)(
21022 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
21023 ),
21024 filter.name,
21025 activeElements[0].label[0],
21026 activeElements[0].label[1]
21027 ),
21028 filterTextWrappers
21029 ),
21030 filter(item, field, filterValue) {
21031 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
21032 return true;
21033 }
21034 const fieldValue = field.getValue({ item });
21035 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
21036 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
21037 }
21038 return false;
21039 },
21040 selection: "custom"
21041 },
21042 {
21043 name: OPERATOR_IN_THE_PAST,
21044 /* translators: DataViews operator name */
21045 label: (0, import_i18n24.__)("In the past"),
21046 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21047 (0, import_i18n24.sprintf)(
21048 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
21049 (0, import_i18n24.__)(
21050 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
21051 ),
21052 filter.name,
21053 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
21054 ),
21055 filterTextWrappers
21056 ),
21057 filter(item, field, filterValue) {
21058 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
21059 return true;
21060 }
21061 const targetDate = getRelativeDate(
21062 filterValue.value,
21063 filterValue.unit
21064 );
21065 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21066 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
21067 },
21068 selection: "custom"
21069 },
21070 {
21071 name: OPERATOR_OVER,
21072 /* translators: DataViews operator name */
21073 label: (0, import_i18n24.__)("Over"),
21074 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21075 (0, import_i18n24.sprintf)(
21076 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
21077 (0, import_i18n24.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
21078 filter.name,
21079 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
21080 ),
21081 filterTextWrappers
21082 ),
21083 filter(item, field, filterValue) {
21084 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
21085 return true;
21086 }
21087 const targetDate = getRelativeDate(
21088 filterValue.value,
21089 filterValue.unit
21090 );
21091 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21092 return fieldValue < targetDate;
21093 },
21094 selection: "custom"
21095 },
21096 {
21097 name: OPERATOR_IS,
21098 /* translators: DataViews operator name */
21099 label: (0, import_i18n24.__)("Is"),
21100 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21101 (0, import_i18n24.sprintf)(
21102 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
21103 (0, import_i18n24.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21104 filter.name,
21105 activeElements[0].label
21106 ),
21107 filterTextWrappers
21108 ),
21109 filter(item, field, filterValue) {
21110 return filterValue === field.getValue({ item }) || filterValue === void 0;
21111 },
21112 selection: "single"
21113 },
21114 {
21115 name: OPERATOR_IS_NOT,
21116 /* translators: DataViews operator name */
21117 label: (0, import_i18n24.__)("Is not"),
21118 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21119 (0, import_i18n24.sprintf)(
21120 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
21121 (0, import_i18n24.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21122 filter.name,
21123 activeElements[0].label
21124 ),
21125 filterTextWrappers
21126 ),
21127 filter(item, field, filterValue) {
21128 return filterValue !== field.getValue({ item });
21129 },
21130 selection: "single"
21131 },
21132 {
21133 name: OPERATOR_LESS_THAN,
21134 /* translators: DataViews operator name */
21135 label: (0, import_i18n24.__)("Less than"),
21136 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21137 (0, import_i18n24.sprintf)(
21138 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
21139 (0, import_i18n24.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
21140 filter.name,
21141 activeElements[0].label
21142 ),
21143 filterTextWrappers
21144 ),
21145 filter(item, field, filterValue) {
21146 if (filterValue === void 0) {
21147 return true;
21148 }
21149 const fieldValue = field.getValue({ item });
21150 return fieldValue < filterValue;
21151 },
21152 selection: "single"
21153 },
21154 {
21155 name: OPERATOR_GREATER_THAN,
21156 /* translators: DataViews operator name */
21157 label: (0, import_i18n24.__)("Greater than"),
21158 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21159 (0, import_i18n24.sprintf)(
21160 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
21161 (0, import_i18n24.__)(
21162 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
21163 ),
21164 filter.name,
21165 activeElements[0].label
21166 ),
21167 filterTextWrappers
21168 ),
21169 filter(item, field, filterValue) {
21170 if (filterValue === void 0) {
21171 return true;
21172 }
21173 const fieldValue = field.getValue({ item });
21174 return fieldValue > filterValue;
21175 },
21176 selection: "single"
21177 },
21178 {
21179 name: OPERATOR_LESS_THAN_OR_EQUAL,
21180 /* translators: DataViews operator name */
21181 label: (0, import_i18n24.__)("Less than or equal"),
21182 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21183 (0, import_i18n24.sprintf)(
21184 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
21185 (0, import_i18n24.__)(
21186 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
21187 ),
21188 filter.name,
21189 activeElements[0].label
21190 ),
21191 filterTextWrappers
21192 ),
21193 filter(item, field, filterValue) {
21194 if (filterValue === void 0) {
21195 return true;
21196 }
21197 const fieldValue = field.getValue({ item });
21198 return fieldValue <= filterValue;
21199 },
21200 selection: "single"
21201 },
21202 {
21203 name: OPERATOR_GREATER_THAN_OR_EQUAL,
21204 /* translators: DataViews operator name */
21205 label: (0, import_i18n24.__)("Greater than or equal"),
21206 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21207 (0, import_i18n24.sprintf)(
21208 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
21209 (0, import_i18n24.__)(
21210 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
21211 ),
21212 filter.name,
21213 activeElements[0].label
21214 ),
21215 filterTextWrappers
21216 ),
21217 filter(item, field, filterValue) {
21218 if (filterValue === void 0) {
21219 return true;
21220 }
21221 const fieldValue = field.getValue({ item });
21222 return fieldValue >= filterValue;
21223 },
21224 selection: "single"
21225 },
21226 {
21227 name: OPERATOR_BEFORE,
21228 /* translators: DataViews operator name */
21229 label: (0, import_i18n24.__)("Before"),
21230 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21231 (0, import_i18n24.sprintf)(
21232 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
21233 (0, import_i18n24.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
21234 filter.name,
21235 activeElements[0].label
21236 ),
21237 filterTextWrappers
21238 ),
21239 filter(item, field, filterValue) {
21240 if (filterValue === void 0) {
21241 return true;
21242 }
21243 const filterDate = (0, import_date.getDate)(filterValue);
21244 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21245 return fieldDate < filterDate;
21246 },
21247 selection: "single"
21248 },
21249 {
21250 name: OPERATOR_AFTER,
21251 /* translators: DataViews operator name */
21252 label: (0, import_i18n24.__)("After"),
21253 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21254 (0, import_i18n24.sprintf)(
21255 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
21256 (0, import_i18n24.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
21257 filter.name,
21258 activeElements[0].label
21259 ),
21260 filterTextWrappers
21261 ),
21262 filter(item, field, filterValue) {
21263 if (filterValue === void 0) {
21264 return true;
21265 }
21266 const filterDate = (0, import_date.getDate)(filterValue);
21267 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21268 return fieldDate > filterDate;
21269 },
21270 selection: "single"
21271 },
21272 {
21273 name: OPERATOR_BEFORE_INC,
21274 /* translators: DataViews operator name */
21275 label: (0, import_i18n24.__)("Before (inc)"),
21276 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21277 (0, import_i18n24.sprintf)(
21278 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
21279 (0, import_i18n24.__)(
21280 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
21281 ),
21282 filter.name,
21283 activeElements[0].label
21284 ),
21285 filterTextWrappers
21286 ),
21287 filter(item, field, filterValue) {
21288 if (filterValue === void 0) {
21289 return true;
21290 }
21291 const filterDate = (0, import_date.getDate)(filterValue);
21292 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21293 return fieldDate <= filterDate;
21294 },
21295 selection: "single"
21296 },
21297 {
21298 name: OPERATOR_AFTER_INC,
21299 /* translators: DataViews operator name */
21300 label: (0, import_i18n24.__)("After (inc)"),
21301 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21302 (0, import_i18n24.sprintf)(
21303 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
21304 (0, import_i18n24.__)(
21305 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
21306 ),
21307 filter.name,
21308 activeElements[0].label
21309 ),
21310 filterTextWrappers
21311 ),
21312 filter(item, field, filterValue) {
21313 if (filterValue === void 0) {
21314 return true;
21315 }
21316 const filterDate = (0, import_date.getDate)(filterValue);
21317 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21318 return fieldDate >= filterDate;
21319 },
21320 selection: "single"
21321 },
21322 {
21323 name: OPERATOR_CONTAINS,
21324 /* translators: DataViews operator name */
21325 label: (0, import_i18n24.__)("Contains"),
21326 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21327 (0, import_i18n24.sprintf)(
21328 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
21329 (0, import_i18n24.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
21330 filter.name,
21331 activeElements[0].label
21332 ),
21333 filterTextWrappers
21334 ),
21335 filter(item, field, filterValue) {
21336 if (filterValue === void 0) {
21337 return true;
21338 }
21339 const fieldValue = field.getValue({ item });
21340 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21341 },
21342 selection: "single"
21343 },
21344 {
21345 name: OPERATOR_NOT_CONTAINS,
21346 /* translators: DataViews operator name */
21347 label: (0, import_i18n24.__)("Doesn't contain"),
21348 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21349 (0, import_i18n24.sprintf)(
21350 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
21351 (0, import_i18n24.__)(
21352 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
21353 ),
21354 filter.name,
21355 activeElements[0].label
21356 ),
21357 filterTextWrappers
21358 ),
21359 filter(item, field, filterValue) {
21360 if (filterValue === void 0) {
21361 return true;
21362 }
21363 const fieldValue = field.getValue({ item });
21364 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21365 },
21366 selection: "single"
21367 },
21368 {
21369 name: OPERATOR_STARTS_WITH,
21370 /* translators: DataViews operator name */
21371 label: (0, import_i18n24.__)("Starts with"),
21372 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21373 (0, import_i18n24.sprintf)(
21374 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
21375 (0, import_i18n24.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
21376 filter.name,
21377 activeElements[0].label
21378 ),
21379 filterTextWrappers
21380 ),
21381 filter(item, field, filterValue) {
21382 if (filterValue === void 0) {
21383 return true;
21384 }
21385 const fieldValue = field.getValue({ item });
21386 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
21387 },
21388 selection: "single"
21389 },
21390 {
21391 name: OPERATOR_ON,
21392 /* translators: DataViews operator name */
21393 label: (0, import_i18n24.__)("On"),
21394 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21395 (0, import_i18n24.sprintf)(
21396 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
21397 (0, import_i18n24.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21398 filter.name,
21399 activeElements[0].label
21400 ),
21401 filterTextWrappers
21402 ),
21403 filter(item, field, filterValue) {
21404 if (filterValue === void 0) {
21405 return true;
21406 }
21407 const filterDate = (0, import_date.getDate)(filterValue);
21408 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21409 return filterDate.getTime() === fieldDate.getTime();
21410 },
21411 selection: "single"
21412 },
21413 {
21414 name: OPERATOR_NOT_ON,
21415 /* translators: DataViews operator name */
21416 label: (0, import_i18n24.__)("Not on"),
21417 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21418 (0, import_i18n24.sprintf)(
21419 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
21420 (0, import_i18n24.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21421 filter.name,
21422 activeElements[0].label
21423 ),
21424 filterTextWrappers
21425 ),
21426 filter(item, field, filterValue) {
21427 if (filterValue === void 0) {
21428 return true;
21429 }
21430 const filterDate = (0, import_date.getDate)(filterValue);
21431 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21432 return filterDate.getTime() !== fieldDate.getTime();
21433 },
21434 selection: "single"
21435 }
21436 ];
21437 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
21438 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
21439 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
21440 (op) => op.name === name
21441 );
21442 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
21443
21444 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
21445 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
21446 var ENTER = "Enter";
21447 var SPACE = " ";
21448 var FilterText = ({
21449 activeElements,
21450 filterInView,
21451 filter
21452 }) => {
21453 if (activeElements === void 0 || activeElements.length === 0) {
21454 return filter.name;
21455 }
21456 const operator = getOperatorByName(filterInView?.operator);
21457 if (operator !== void 0) {
21458 return operator.filterText(filter, activeElements);
21459 }
21460 return (0, import_i18n25.sprintf)(
21461 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
21462 (0, import_i18n25.__)("Unknown status for %1$s"),
21463 filter.name
21464 );
21465 };
21466 function OperatorSelector({
21467 filter,
21468 view,
21469 onChangeView
21470 }) {
21471 const operatorOptions = filter.operators?.map((operator) => ({
21472 value: operator,
21473 label: getOperatorByName(operator)?.label || operator
21474 }));
21475 const currentFilter = view.filters?.find(
21476 (_filter) => _filter.field === filter.field
21477 );
21478 const value = currentFilter?.operator || filter.operators[0];
21479 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(
21480 Stack,
21481 {
21482 direction: "row",
21483 gap: "sm",
21484 justify: "flex-start",
21485 className: "dataviews-filters__summary-operators-container",
21486 align: "center",
21487 children: [
21488 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_components20.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
21489 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
21490 import_components20.SelectControl,
21491 {
21492 className: "dataviews-filters__summary-operators-filter-select",
21493 label: (0, import_i18n25.__)("Conditions"),
21494 value,
21495 options: operatorOptions,
21496 onChange: (newValue) => {
21497 const newOperator = newValue;
21498 const currentOperator = currentFilter?.operator;
21499 const newFilters = currentFilter ? [
21500 ...(view.filters ?? []).map(
21501 (_filter) => {
21502 if (_filter.field === filter.field) {
21503 const currentOpSelectionModel = getOperatorByName(
21504 currentOperator
21505 )?.selection;
21506 const newOpSelectionModel = getOperatorByName(
21507 newOperator
21508 )?.selection;
21509 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
21510 currentOpSelectionModel,
21511 newOpSelectionModel
21512 ].includes("custom");
21513 return {
21514 ..._filter,
21515 value: shouldResetValue ? void 0 : _filter.value,
21516 operator: newOperator
21517 };
21518 }
21519 return _filter;
21520 }
21521 )
21522 ] : [
21523 ...view.filters ?? [],
21524 {
21525 field: filter.field,
21526 operator: newOperator,
21527 value: void 0
21528 }
21529 ];
21530 onChangeView({
21531 ...view,
21532 page: 1,
21533 filters: newFilters
21534 });
21535 },
21536 size: "small",
21537 variant: "minimal",
21538 hideLabelFromVision: true
21539 }
21540 )
21541 ]
21542 }
21543 );
21544 }
21545 function Filter({
21546 addFilterRef,
21547 openedFilter,
21548 fields,
21549 ...commonProps
21550 }) {
21551 const toggleRef = (0, import_element51.useRef)(null);
21552 const { filter, view, onChangeView } = commonProps;
21553 const filterInView = view.filters?.find(
21554 (f2) => f2.field === filter.field
21555 );
21556 let activeElements = [];
21557 const field = (0, import_element51.useMemo)(() => {
21558 const currentField = fields.find((f2) => f2.id === filter.field);
21559 if (currentField) {
21560 return {
21561 ...currentField,
21562 // Configure getValue as if Item was a plain object.
21563 // See related input-widget.tsx
21564 getValue: ({ item }) => item[currentField.id]
21565 };
21566 }
21567 return currentField;
21568 }, [fields, filter.field]);
21569 const { elements } = useElements({
21570 elements: filter.elements,
21571 getElements: filter.getElements
21572 });
21573 if (elements.length > 0) {
21574 activeElements = elements.filter((element) => {
21575 if (filter.singleSelection) {
21576 return element.value === filterInView?.value;
21577 }
21578 return filterInView?.value?.includes(element.value);
21579 });
21580 } else if (Array.isArray(filterInView?.value)) {
21581 const label = filterInView.value.map((v2) => {
21582 const formattedValue = field?.getValueFormatted({
21583 item: { [field.id]: v2 },
21584 field
21585 });
21586 return formattedValue || String(v2);
21587 });
21588 activeElements = [
21589 {
21590 value: filterInView.value,
21591 // @ts-ignore
21592 label
21593 }
21594 ];
21595 } else if (typeof filterInView?.value === "object") {
21596 activeElements = [
21597 { value: filterInView.value, label: filterInView.value }
21598 ];
21599 } else if (filterInView?.value !== void 0) {
21600 const label = field !== void 0 ? field.getValueFormatted({
21601 item: { [field.id]: filterInView.value },
21602 field
21603 }) : String(filterInView.value);
21604 activeElements = [
21605 {
21606 value: filterInView.value,
21607 label
21608 }
21609 ];
21610 }
21611 const isPrimary = filter.isPrimary;
21612 const isLocked = filterInView?.isLocked;
21613 const hasValues = !isLocked && filterInView?.value !== void 0;
21614 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
21615 const resetOrRemoveLabel = isPrimary ? (0, import_i18n25.__)("Reset") : (0, import_i18n25.__)("Remove");
21616 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
21617 import_components20.Dropdown,
21618 {
21619 defaultOpen: openedFilter === filter.field,
21620 contentClassName: "dataviews-filters__summary-popover",
21621 popoverProps: { placement: "bottom-start", role: "dialog" },
21622 onClose: () => {
21623 toggleRef.current?.focus();
21624 },
21625 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
21626 /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(tooltip_exports.Root, { children: [
21627 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
21628 tooltip_exports.Trigger,
21629 {
21630 render: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
21631 "div",
21632 {
21633 className: clsx_default(
21634 "dataviews-filters__summary-chip",
21635 {
21636 "has-reset": canResetOrRemove,
21637 "has-values": hasValues,
21638 "is-not-clickable": isLocked
21639 }
21640 ),
21641 role: "button",
21642 tabIndex: isLocked ? -1 : 0,
21643 onClick: () => {
21644 if (!isLocked) {
21645 onToggle();
21646 }
21647 },
21648 onKeyDown: (event) => {
21649 if (!isLocked && [ENTER, SPACE].includes(
21650 event.key
21651 )) {
21652 onToggle();
21653 event.preventDefault();
21654 }
21655 },
21656 "aria-disabled": isLocked,
21657 "aria-pressed": isOpen,
21658 "aria-expanded": isOpen,
21659 ref: toggleRef,
21660 children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
21661 FilterText,
21662 {
21663 activeElements,
21664 filterInView,
21665 filter
21666 }
21667 )
21668 }
21669 )
21670 }
21671 ),
21672 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(tooltip_exports.Popup, { children: (0, import_i18n25.sprintf)(
21673 /* translators: 1: Filter name. */
21674 (0, import_i18n25.__)("Filter by: %1$s"),
21675 filter.name.toLowerCase()
21676 ) })
21677 ] }),
21678 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(tooltip_exports.Root, { children: [
21679 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
21680 tooltip_exports.Trigger,
21681 {
21682 render: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
21683 "button",
21684 {
21685 className: clsx_default(
21686 "dataviews-filters__summary-chip-remove",
21687 { "has-values": hasValues }
21688 ),
21689 "aria-label": resetOrRemoveLabel,
21690 onClick: () => {
21691 onChangeView({
21692 ...view,
21693 page: 1,
21694 filters: view.filters?.filter(
21695 (_filter) => _filter.field !== filter.field
21696 )
21697 });
21698 if (!isPrimary) {
21699 addFilterRef.current?.focus();
21700 } else {
21701 toggleRef.current?.focus();
21702 }
21703 },
21704 children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_components20.Icon, { icon: close_small_default })
21705 }
21706 )
21707 }
21708 ),
21709 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel })
21710 ] })
21711 ] }),
21712 renderContent: () => {
21713 return /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
21714 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(OperatorSelector, { ...commonProps }),
21715 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
21716 SearchWidget,
21717 {
21718 ...commonProps,
21719 filter: {
21720 ...commonProps.filter,
21721 elements
21722 }
21723 }
21724 ) : /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(InputWidget, { ...commonProps, fields })
21725 ] });
21726 }
21727 }
21728 );
21729 }
21730
21731 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
21732 var import_components21 = __toESM(require_components(), 1);
21733 var import_i18n26 = __toESM(require_i18n(), 1);
21734 var import_element52 = __toESM(require_element(), 1);
21735 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
21736 var { Menu: Menu4 } = unlock2(import_components21.privateApis);
21737 function AddFilterMenu({
21738 filters,
21739 view,
21740 onChangeView,
21741 setOpenedFilter,
21742 triggerProps
21743 }) {
21744 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
21745 return /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(Menu4, { children: [
21746 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Menu4.TriggerButton, { ...triggerProps }),
21747 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
21748 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21749 Menu4.Item,
21750 {
21751 onClick: () => {
21752 setOpenedFilter(filter.field);
21753 onChangeView({
21754 ...view,
21755 page: 1,
21756 filters: [
21757 ...view.filters || [],
21758 {
21759 field: filter.field,
21760 value: void 0,
21761 operator: filter.operators[0]
21762 }
21763 ]
21764 });
21765 },
21766 children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Menu4.ItemLabel, { children: filter.name })
21767 },
21768 filter.field
21769 );
21770 }) })
21771 ] });
21772 }
21773 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
21774 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
21775 return null;
21776 }
21777 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
21778 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21779 AddFilterMenu,
21780 {
21781 triggerProps: {
21782 render: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21783 import_components21.Button,
21784 {
21785 accessibleWhenDisabled: true,
21786 size: "compact",
21787 className: "dataviews-filters-button",
21788 variant: "tertiary",
21789 disabled: !inactiveFilters.length,
21790 ref
21791 }
21792 ),
21793 children: (0, import_i18n26.__)("Add filter")
21794 },
21795 ...{ filters, view, onChangeView, setOpenedFilter }
21796 }
21797 );
21798 }
21799 var add_filter_default = (0, import_element52.forwardRef)(AddFilter);
21800
21801 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
21802 var import_components22 = __toESM(require_components(), 1);
21803 var import_i18n27 = __toESM(require_i18n(), 1);
21804 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
21805 function ResetFilter({
21806 filters,
21807 view,
21808 onChangeView
21809 }) {
21810 const isPrimary = (field) => filters.some(
21811 (_filter) => _filter.field === field && _filter.isPrimary
21812 );
21813 const isDisabled = !view.search && !view.filters?.some(
21814 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
21815 );
21816 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21817 import_components22.Button,
21818 {
21819 disabled: isDisabled,
21820 accessibleWhenDisabled: true,
21821 size: "compact",
21822 variant: "tertiary",
21823 className: "dataviews-filters__reset-button",
21824 onClick: () => {
21825 onChangeView({
21826 ...view,
21827 page: 1,
21828 search: "",
21829 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
21830 });
21831 },
21832 children: (0, import_i18n27.__)("Reset")
21833 }
21834 );
21835 }
21836
21837 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
21838 var import_element53 = __toESM(require_element(), 1);
21839 function useFilters(fields, view) {
21840 return (0, import_element53.useMemo)(() => {
21841 const filters = [];
21842 fields.forEach((field) => {
21843 if (field.filterBy === false || !field.hasElements && !field.Edit) {
21844 return;
21845 }
21846 const operators = field.filterBy.operators;
21847 const isPrimary = !!field.filterBy?.isPrimary;
21848 const isLocked = view.filters?.some(
21849 (f2) => f2.field === field.id && !!f2.isLocked
21850 ) ?? false;
21851 filters.push({
21852 field: field.id,
21853 name: field.label,
21854 elements: field.elements,
21855 getElements: field.getElements,
21856 hasElements: field.hasElements,
21857 singleSelection: operators.some(
21858 (op) => isSingleSelectionOperator(op)
21859 ),
21860 operators,
21861 isVisible: isLocked || isPrimary || !!view.filters?.some(
21862 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
21863 ),
21864 isPrimary,
21865 isLocked
21866 });
21867 });
21868 filters.sort((a2, b2) => {
21869 if (a2.isLocked && !b2.isLocked) {
21870 return -1;
21871 }
21872 if (!a2.isLocked && b2.isLocked) {
21873 return 1;
21874 }
21875 if (a2.isPrimary && !b2.isPrimary) {
21876 return -1;
21877 }
21878 if (!a2.isPrimary && b2.isPrimary) {
21879 return 1;
21880 }
21881 return a2.name.localeCompare(b2.name);
21882 });
21883 return filters;
21884 }, [fields, view]);
21885 }
21886 var use_filters_default = useFilters;
21887
21888 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
21889 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
21890 function Filters({ className }) {
21891 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element54.useContext)(dataviews_context_default);
21892 const addFilterRef = (0, import_element54.useRef)(null);
21893 const filters = use_filters_default(fields, view);
21894 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21895 add_filter_default,
21896 {
21897 filters,
21898 view,
21899 onChangeView,
21900 ref: addFilterRef,
21901 setOpenedFilter
21902 },
21903 "add-filter"
21904 );
21905 const visibleFilters = filters.filter((filter) => filter.isVisible);
21906 if (visibleFilters.length === 0) {
21907 return null;
21908 }
21909 const filterComponents = [
21910 ...visibleFilters.map((filter) => {
21911 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21912 Filter,
21913 {
21914 filter,
21915 view,
21916 fields,
21917 onChangeView,
21918 addFilterRef,
21919 openedFilter
21920 },
21921 filter.field
21922 );
21923 }),
21924 addFilter
21925 ];
21926 filterComponents.push(
21927 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21928 ResetFilter,
21929 {
21930 filters,
21931 view,
21932 onChangeView
21933 },
21934 "reset-filters"
21935 )
21936 );
21937 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21938 Stack,
21939 {
21940 direction: "row",
21941 justify: "flex-start",
21942 gap: "sm",
21943 style: { width: "fit-content" },
21944 wrap: "wrap",
21945 className,
21946 children: filterComponents
21947 }
21948 );
21949 }
21950 var filters_default = (0, import_element54.memo)(Filters);
21951
21952 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
21953 var import_element55 = __toESM(require_element(), 1);
21954 var import_components23 = __toESM(require_components(), 1);
21955 var import_i18n28 = __toESM(require_i18n(), 1);
21956 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
21957 function FiltersToggle() {
21958 const {
21959 filters,
21960 view,
21961 onChangeView,
21962 setOpenedFilter,
21963 isShowingFilter,
21964 setIsShowingFilter
21965 } = (0, import_element55.useContext)(dataviews_context_default);
21966 const buttonRef = (0, import_element55.useRef)(null);
21967 const onChangeViewWithFilterVisibility = (0, import_element55.useCallback)(
21968 (_view) => {
21969 onChangeView(_view);
21970 setIsShowingFilter(true);
21971 },
21972 [onChangeView, setIsShowingFilter]
21973 );
21974 if (filters.length === 0) {
21975 return null;
21976 }
21977 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
21978 const addFilterButtonProps = {
21979 label: (0, import_i18n28.__)("Add filter"),
21980 "aria-expanded": false,
21981 isPressed: false
21982 };
21983 const toggleFiltersButtonProps = {
21984 label: (0, import_i18n28._x)("Filter", "verb"),
21985 "aria-expanded": isShowingFilter,
21986 isPressed: isShowingFilter,
21987 onClick: () => {
21988 if (!isShowingFilter) {
21989 setOpenedFilter(null);
21990 }
21991 setIsShowingFilter(!isShowingFilter);
21992 }
21993 };
21994 const hasPrimaryOrLockedFilters = filters.some(
21995 (filter) => filter.isPrimary || filter.isLocked
21996 );
21997 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
21998 import_components23.Button,
21999 {
22000 ref: buttonRef,
22001 className: "dataviews-filters__visibility-toggle",
22002 size: "compact",
22003 icon: funnel_default,
22004 disabled: hasPrimaryOrLockedFilters,
22005 accessibleWhenDisabled: true,
22006 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
22007 }
22008 );
22009 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
22010 AddFilterMenu,
22011 {
22012 filters,
22013 view,
22014 onChangeView: onChangeViewWithFilterVisibility,
22015 setOpenedFilter,
22016 triggerProps: { render: buttonComponent }
22017 }
22018 ) : /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
22019 FilterVisibilityToggle,
22020 {
22021 buttonRef,
22022 filtersCount: view.filters?.length,
22023 children: buttonComponent
22024 }
22025 ) });
22026 }
22027 function FilterVisibilityToggle({
22028 buttonRef,
22029 filtersCount,
22030 children
22031 }) {
22032 (0, import_element55.useEffect)(
22033 () => () => {
22034 buttonRef.current?.focus();
22035 },
22036 [buttonRef]
22037 );
22038 return /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(import_jsx_runtime85.Fragment, { children: [
22039 children,
22040 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
22041 ] });
22042 }
22043 var toggle_default = FiltersToggle;
22044
22045 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
22046 var import_element56 = __toESM(require_element(), 1);
22047 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
22048 function FiltersToggled(props) {
22049 const { isShowingFilter } = (0, import_element56.useContext)(dataviews_context_default);
22050 if (!isShowingFilter) {
22051 return null;
22052 }
22053 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(filters_default, { ...props });
22054 }
22055 var filters_toggled_default = FiltersToggled;
22056
22057 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
22058 var import_element57 = __toESM(require_element(), 1);
22059 var import_components24 = __toESM(require_components(), 1);
22060 var import_i18n29 = __toESM(require_i18n(), 1);
22061 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
22062 function DataViewsLayout({ className }) {
22063 const {
22064 actions = [],
22065 data,
22066 fields,
22067 getItemId,
22068 getItemLevel,
22069 hasInitiallyLoaded,
22070 isLoading,
22071 view,
22072 onChangeView,
22073 selection,
22074 onChangeSelection,
22075 setOpenedFilter,
22076 onClickItem,
22077 isItemClickable,
22078 renderItemLink,
22079 defaultLayouts,
22080 containerRef,
22081 empty = /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("p", { children: (0, import_i18n29.__)("No results") })
22082 } = (0, import_element57.useContext)(dataviews_context_default);
22083 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
22084 delay: 200
22085 });
22086 if (!hasInitiallyLoaded) {
22087 if (!isDelayedInitialLoading) {
22088 return null;
22089 }
22090 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(import_components24.Spinner, {}) }) });
22091 }
22092 const ViewComponent = VIEW_LAYOUTS.find(
22093 (v2) => v2.type === view.type && defaultLayouts[v2.type]
22094 )?.component;
22095 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22096 ViewComponent,
22097 {
22098 className,
22099 actions,
22100 data,
22101 fields,
22102 getItemId,
22103 getItemLevel,
22104 isLoading,
22105 onChangeView,
22106 onChangeSelection,
22107 selection,
22108 setOpenedFilter,
22109 onClickItem,
22110 renderItemLink,
22111 isItemClickable,
22112 view,
22113 empty
22114 }
22115 ) });
22116 }
22117
22118 // packages/dataviews/build-module/components/dataviews-footer/index.mjs
22119 var import_element58 = __toESM(require_element(), 1);
22120 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
22121 var EMPTY_ARRAY5 = [];
22122 function DataViewsFooter() {
22123 const {
22124 view,
22125 paginationInfo: { totalItems = 0, totalPages },
22126 data,
22127 actions = EMPTY_ARRAY5,
22128 isLoading,
22129 hasInitiallyLoaded
22130 } = (0, import_element58.useContext)(dataviews_context_default);
22131 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length;
22132 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
22133 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type);
22134 if (!isRefreshing && (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions)) {
22135 return null;
22136 }
22137 return (!!totalItems || isRefreshing) && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22138 "div",
22139 {
22140 className: "dataviews-footer",
22141 inert: isRefreshing ? "true" : void 0,
22142 children: /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(
22143 Stack,
22144 {
22145 direction: "row",
22146 justify: "end",
22147 align: "center",
22148 className: clsx_default("dataviews-footer__content", {
22149 "is-refreshing": isDelayedRefreshing
22150 }),
22151 gap: "sm",
22152 children: [
22153 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(BulkActionsFooter, {}),
22154 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(dataviews_pagination_default, {})
22155 ]
22156 }
22157 )
22158 }
22159 );
22160 }
22161
22162 // packages/dataviews/build-module/components/dataviews-search/index.mjs
22163 var import_i18n30 = __toESM(require_i18n(), 1);
22164 var import_element59 = __toESM(require_element(), 1);
22165 var import_components25 = __toESM(require_components(), 1);
22166 var import_compose9 = __toESM(require_compose(), 1);
22167 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
22168 var DataViewsSearch = (0, import_element59.memo)(function Search({ label }) {
22169 const { view, onChangeView } = (0, import_element59.useContext)(dataviews_context_default);
22170 const [search, setSearch, debouncedSearch] = (0, import_compose9.useDebouncedInput)(
22171 view.search
22172 );
22173 (0, import_element59.useEffect)(() => {
22174 if (view.search !== debouncedSearch) {
22175 setSearch(view.search ?? "");
22176 }
22177 }, [view.search, setSearch]);
22178 const onChangeViewRef = (0, import_element59.useRef)(onChangeView);
22179 const viewRef = (0, import_element59.useRef)(view);
22180 (0, import_element59.useEffect)(() => {
22181 onChangeViewRef.current = onChangeView;
22182 viewRef.current = view;
22183 }, [onChangeView, view]);
22184 (0, import_element59.useEffect)(() => {
22185 if (debouncedSearch !== viewRef.current?.search) {
22186 onChangeViewRef.current({
22187 ...viewRef.current,
22188 page: view.page ? 1 : void 0,
22189 startPosition: view.startPosition ? 1 : void 0,
22190 search: debouncedSearch
22191 });
22192 }
22193 }, [debouncedSearch]);
22194 const searchLabel = label || (0, import_i18n30.__)("Search");
22195 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22196 import_components25.SearchControl,
22197 {
22198 className: "dataviews-search",
22199 onChange: setSearch,
22200 value: search,
22201 label: searchLabel,
22202 placeholder: searchLabel,
22203 size: "compact"
22204 }
22205 );
22206 });
22207 var dataviews_search_default = DataViewsSearch;
22208
22209 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
22210 var import_components26 = __toESM(require_components(), 1);
22211 var import_i18n31 = __toESM(require_i18n(), 1);
22212 var import_element60 = __toESM(require_element(), 1);
22213 var import_warning = __toESM(require_warning(), 1);
22214 var import_compose10 = __toESM(require_compose(), 1);
22215 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
22216 var { Menu: Menu5 } = unlock2(import_components26.privateApis);
22217 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
22218 className: "dataviews-config__popover",
22219 placement: "bottom-end",
22220 offset: 9
22221 };
22222 function ViewTypeMenu() {
22223 const { view, onChangeView, defaultLayouts } = (0, import_element60.useContext)(dataviews_context_default);
22224 const availableLayouts = Object.keys(defaultLayouts);
22225 if (availableLayouts.length <= 1) {
22226 return null;
22227 }
22228 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
22229 return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(Menu5, { children: [
22230 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22231 Menu5.TriggerButton,
22232 {
22233 render: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22234 import_components26.Button,
22235 {
22236 size: "compact",
22237 icon: activeView?.icon,
22238 label: (0, import_i18n31.__)("Layout")
22239 }
22240 )
22241 }
22242 ),
22243 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
22244 const config = VIEW_LAYOUTS.find(
22245 (v2) => v2.type === layout
22246 );
22247 if (!config) {
22248 return null;
22249 }
22250 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22251 Menu5.RadioItem,
22252 {
22253 value: layout,
22254 name: "view-actions-available-view",
22255 checked: layout === view.type,
22256 hideOnClick: true,
22257 onChange: (e2) => {
22258 switch (e2.target.value) {
22259 case "list":
22260 case "grid":
22261 case "table":
22262 case "pickerGrid":
22263 case "pickerTable":
22264 case "activity":
22265 const viewWithoutLayout = { ...view };
22266 if ("layout" in viewWithoutLayout) {
22267 delete viewWithoutLayout.layout;
22268 }
22269 return onChangeView({
22270 ...viewWithoutLayout,
22271 type: e2.target.value,
22272 ...defaultLayouts[e2.target.value]
22273 });
22274 }
22275 (0, import_warning.default)("Invalid dataview");
22276 },
22277 children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Menu5.ItemLabel, { children: config.label })
22278 },
22279 layout
22280 );
22281 }) })
22282 ] });
22283 }
22284 function SortFieldControl() {
22285 const { view, fields, onChangeView } = (0, import_element60.useContext)(dataviews_context_default);
22286 const orderOptions = (0, import_element60.useMemo)(() => {
22287 const sortableFields = fields.filter(
22288 (field) => field.enableSorting !== false
22289 );
22290 return sortableFields.map((field) => {
22291 return {
22292 label: field.label,
22293 value: field.id
22294 };
22295 });
22296 }, [fields]);
22297 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22298 import_components26.SelectControl,
22299 {
22300 __next40pxDefaultSize: true,
22301 label: (0, import_i18n31.__)("Sort by"),
22302 value: view.sort?.field,
22303 options: orderOptions,
22304 onChange: (value) => {
22305 onChangeView({
22306 ...view,
22307 sort: {
22308 direction: view?.sort?.direction || "desc",
22309 field: value
22310 },
22311 showLevels: false
22312 });
22313 }
22314 }
22315 );
22316 }
22317 function SortDirectionControl() {
22318 const { view, fields, onChangeView } = (0, import_element60.useContext)(dataviews_context_default);
22319 const sortableFields = fields.filter(
22320 (field) => field.enableSorting !== false
22321 );
22322 if (sortableFields.length === 0) {
22323 return null;
22324 }
22325 let value = view.sort?.direction;
22326 if (!value && view.sort?.field) {
22327 value = "desc";
22328 }
22329 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22330 import_components26.__experimentalToggleGroupControl,
22331 {
22332 className: "dataviews-view-config__sort-direction",
22333 __next40pxDefaultSize: true,
22334 isBlock: true,
22335 label: (0, import_i18n31.__)("Order"),
22336 value,
22337 onChange: (newDirection) => {
22338 if (newDirection === "asc" || newDirection === "desc") {
22339 onChangeView({
22340 ...view,
22341 sort: {
22342 direction: newDirection,
22343 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
22344 fields.find(
22345 (field) => field.enableSorting !== false
22346 )?.id || ""
22347 },
22348 showLevels: false
22349 });
22350 return;
22351 }
22352 (0, import_warning.default)("Invalid direction");
22353 },
22354 children: SORTING_DIRECTIONS.map((direction) => {
22355 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22356 import_components26.__experimentalToggleGroupControlOptionIcon,
22357 {
22358 value: direction,
22359 icon: sortIcons[direction],
22360 label: sortLabels[direction]
22361 },
22362 direction
22363 );
22364 })
22365 }
22366 );
22367 }
22368 function ItemsPerPageControl() {
22369 const { view, config, onChangeView } = (0, import_element60.useContext)(dataviews_context_default);
22370 const { infiniteScrollEnabled } = view;
22371 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
22372 return null;
22373 }
22374 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22375 import_components26.__experimentalToggleGroupControl,
22376 {
22377 __next40pxDefaultSize: true,
22378 isBlock: true,
22379 label: (0, import_i18n31.__)("Items per page"),
22380 value: view.perPage || 10,
22381 disabled: !view?.sort?.field,
22382 onChange: (newItemsPerPage) => {
22383 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
22384 onChangeView({
22385 ...view,
22386 perPage: newItemsPerPageNumber,
22387 page: 1
22388 });
22389 },
22390 children: config.perPageSizes.map((value) => {
22391 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22392 import_components26.__experimentalToggleGroupControlOption,
22393 {
22394 value,
22395 label: value.toString()
22396 },
22397 value
22398 );
22399 })
22400 }
22401 );
22402 }
22403 function ResetViewButton() {
22404 const { onReset } = (0, import_element60.useContext)(dataviews_context_default);
22405 if (onReset === void 0) {
22406 return null;
22407 }
22408 const isDisabled = onReset === false;
22409 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22410 import_components26.Button,
22411 {
22412 variant: "tertiary",
22413 size: "compact",
22414 disabled: isDisabled,
22415 accessibleWhenDisabled: true,
22416 className: "dataviews-view-config__reset-button",
22417 onClick: () => {
22418 if (typeof onReset === "function") {
22419 onReset();
22420 }
22421 },
22422 children: (0, import_i18n31.__)("Reset view")
22423 }
22424 );
22425 }
22426 function DataviewsViewConfigDropdown() {
22427 const { view, onReset } = (0, import_element60.useContext)(dataviews_context_default);
22428 const popoverId = (0, import_compose10.useInstanceId)(
22429 _DataViewsViewConfig,
22430 "dataviews-view-config-dropdown"
22431 );
22432 const activeLayout = VIEW_LAYOUTS.find(
22433 (layout) => layout.type === view.type
22434 );
22435 const isModified = typeof onReset === "function";
22436 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22437 import_components26.Dropdown,
22438 {
22439 expandOnMobile: true,
22440 popoverProps: {
22441 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
22442 id: popoverId
22443 },
22444 renderToggle: ({ onToggle, isOpen }) => {
22445 return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
22446 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22447 import_components26.Button,
22448 {
22449 size: "compact",
22450 icon: cog_default,
22451 label: (0, import_i18n31._x)(
22452 "View options",
22453 "View is used as a noun"
22454 ),
22455 onClick: onToggle,
22456 "aria-expanded": isOpen ? "true" : "false",
22457 "aria-controls": popoverId
22458 }
22459 ),
22460 isModified && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
22461 ] });
22462 },
22463 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22464 import_components26.__experimentalDropdownContentWrapper,
22465 {
22466 paddingSize: "medium",
22467 className: "dataviews-config__popover-content-wrapper",
22468 children: /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(
22469 Stack,
22470 {
22471 direction: "column",
22472 className: "dataviews-view-config",
22473 gap: "xl",
22474 children: [
22475 /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(
22476 Stack,
22477 {
22478 direction: "row",
22479 justify: "space-between",
22480 align: "center",
22481 className: "dataviews-view-config__header",
22482 children: [
22483 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22484 import_components26.__experimentalHeading,
22485 {
22486 level: 2,
22487 className: "dataviews-settings-section__title",
22488 children: (0, import_i18n31.__)("Appearance")
22489 }
22490 ),
22491 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(ResetViewButton, {})
22492 ]
22493 }
22494 ),
22495 /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22496 /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(
22497 Stack,
22498 {
22499 direction: "row",
22500 gap: "sm",
22501 className: "dataviews-view-config__sort-controls",
22502 children: [
22503 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(SortFieldControl, {}),
22504 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(SortDirectionControl, {})
22505 ]
22506 }
22507 ),
22508 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(activeLayout.viewConfigOptions, {}),
22509 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(ItemsPerPageControl, {}),
22510 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(PropertiesSection, {})
22511 ] })
22512 ]
22513 }
22514 )
22515 }
22516 )
22517 }
22518 );
22519 }
22520 function _DataViewsViewConfig() {
22521 return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(import_jsx_runtime90.Fragment, { children: [
22522 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(ViewTypeMenu, {}),
22523 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(DataviewsViewConfigDropdown, {})
22524 ] });
22525 }
22526 var DataViewsViewConfig = (0, import_element60.memo)(_DataViewsViewConfig);
22527 var dataviews_view_config_default = DataViewsViewConfig;
22528
22529 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22530 var import_components27 = __toESM(require_components(), 1);
22531 var import_element61 = __toESM(require_element(), 1);
22532
22533 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
22534 function getCustomValidity(isValid2, validity) {
22535 let customValidity;
22536 if (isValid2?.required && validity?.required) {
22537 customValidity = validity?.required?.message ? validity.required : void 0;
22538 } else if (isValid2?.pattern && validity?.pattern) {
22539 customValidity = validity.pattern;
22540 } else if (isValid2?.min && validity?.min) {
22541 customValidity = validity.min;
22542 } else if (isValid2?.max && validity?.max) {
22543 customValidity = validity.max;
22544 } else if (isValid2?.minLength && validity?.minLength) {
22545 customValidity = validity.minLength;
22546 } else if (isValid2?.maxLength && validity?.maxLength) {
22547 customValidity = validity.maxLength;
22548 } else if (isValid2?.elements && validity?.elements) {
22549 customValidity = validity.elements;
22550 } else if (validity?.custom) {
22551 customValidity = validity.custom;
22552 }
22553 return customValidity;
22554 }
22555
22556 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22557 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
22558 var { ValidatedCheckboxControl } = unlock2(import_components27.privateApis);
22559 function Checkbox({
22560 field,
22561 onChange,
22562 data,
22563 hideLabelFromVision,
22564 markWhenOptional,
22565 validity
22566 }) {
22567 const { getValue, setValue, label, description, isValid: isValid2 } = field;
22568 const disabled2 = field.isDisabled({ item: data, field });
22569 const onChangeControl = (0, import_element61.useCallback)(() => {
22570 onChange(
22571 setValue({ item: data, value: !getValue({ item: data }) })
22572 );
22573 }, [data, getValue, onChange, setValue]);
22574 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22575 ValidatedCheckboxControl,
22576 {
22577 required: !!field.isValid?.required,
22578 markWhenOptional,
22579 customValidity: getCustomValidity(isValid2, validity),
22580 hidden: hideLabelFromVision,
22581 label,
22582 help: description,
22583 checked: getValue({ item: data }),
22584 onChange: onChangeControl,
22585 disabled: disabled2
22586 }
22587 );
22588 }
22589
22590 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
22591 var import_components28 = __toESM(require_components(), 1);
22592 var import_element62 = __toESM(require_element(), 1);
22593 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
22594 var { ValidatedComboboxControl } = unlock2(import_components28.privateApis);
22595 function Combobox3({
22596 data,
22597 field,
22598 onChange,
22599 hideLabelFromVision,
22600 validity
22601 }) {
22602 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
22603 const value = getValue({ item: data }) ?? "";
22604 const onChangeControl = (0, import_element62.useCallback)(
22605 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
22606 [data, onChange, setValue]
22607 );
22608 const { elements, isLoading } = useElements({
22609 elements: field.elements,
22610 getElements: field.getElements
22611 });
22612 if (isLoading) {
22613 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_components28.Spinner, {});
22614 }
22615 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22616 ValidatedComboboxControl,
22617 {
22618 required: !!field.isValid?.required,
22619 customValidity: getCustomValidity(isValid2, validity),
22620 label,
22621 value,
22622 help: description,
22623 placeholder,
22624 options: elements,
22625 onChange: onChangeControl,
22626 hideLabelFromVision,
22627 allowReset: true,
22628 expandOnFocus: true
22629 }
22630 );
22631 }
22632
22633 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
22634 var import_components30 = __toESM(require_components(), 1);
22635 var import_element65 = __toESM(require_element(), 1);
22636 var import_i18n33 = __toESM(require_i18n(), 1);
22637 var import_date3 = __toESM(require_date(), 1);
22638
22639 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
22640 var import_components29 = __toESM(require_components(), 1);
22641 var import_element63 = __toESM(require_element(), 1);
22642 var import_i18n32 = __toESM(require_i18n(), 1);
22643 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
22644 var TIME_UNITS_OPTIONS = {
22645 [OPERATOR_IN_THE_PAST]: [
22646 { value: "days", label: (0, import_i18n32.__)("Days") },
22647 { value: "weeks", label: (0, import_i18n32.__)("Weeks") },
22648 { value: "months", label: (0, import_i18n32.__)("Months") },
22649 { value: "years", label: (0, import_i18n32.__)("Years") }
22650 ],
22651 [OPERATOR_OVER]: [
22652 { value: "days", label: (0, import_i18n32.__)("Days ago") },
22653 { value: "weeks", label: (0, import_i18n32.__)("Weeks ago") },
22654 { value: "months", label: (0, import_i18n32.__)("Months ago") },
22655 { value: "years", label: (0, import_i18n32.__)("Years ago") }
22656 ]
22657 };
22658 function RelativeDateControl({
22659 className,
22660 data,
22661 field,
22662 onChange,
22663 hideLabelFromVision,
22664 operator
22665 }) {
22666 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
22667 const { id, label, description, getValue, setValue } = field;
22668 const disabled2 = field.isDisabled({ item: data, field });
22669 const fieldValue = getValue({ item: data });
22670 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
22671 const onChangeValue = (0, import_element63.useCallback)(
22672 (newValue) => onChange(
22673 setValue({
22674 item: data,
22675 value: { value: Number(newValue), unit }
22676 })
22677 ),
22678 [onChange, setValue, data, unit]
22679 );
22680 const onChangeUnit = (0, import_element63.useCallback)(
22681 (newUnit) => onChange(
22682 setValue({
22683 item: data,
22684 value: { value: relValue, unit: newUnit }
22685 })
22686 ),
22687 [onChange, setValue, data, relValue]
22688 );
22689 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
22690 import_components29.BaseControl,
22691 {
22692 id,
22693 className: clsx_default(className, "dataviews-controls__relative-date"),
22694 label,
22695 hideLabelFromVision,
22696 help: description,
22697 children: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(Stack, { direction: "row", gap: "sm", children: [
22698 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
22699 import_components29.__experimentalNumberControl,
22700 {
22701 __next40pxDefaultSize: true,
22702 className: "dataviews-controls__relative-date-number",
22703 spinControls: "none",
22704 min: 1,
22705 step: 1,
22706 value: relValue,
22707 onChange: onChangeValue,
22708 disabled: disabled2
22709 }
22710 ),
22711 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
22712 import_components29.SelectControl,
22713 {
22714 className: "dataviews-controls__relative-date-unit",
22715 __next40pxDefaultSize: true,
22716 label: (0, import_i18n32.__)("Unit"),
22717 value: unit,
22718 options,
22719 onChange: onChangeUnit,
22720 hideLabelFromVision: true,
22721 disabled: disabled2
22722 }
22723 )
22724 ] })
22725 }
22726 );
22727 }
22728
22729 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
22730 var import_element64 = __toESM(require_element(), 1);
22731 function useDisabledDateMatchers(isValid2, parseDateFn) {
22732 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
22733 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
22734 const disabledMatchers = (0, import_element64.useMemo)(() => {
22735 const matchers = [];
22736 if (minConstraint) {
22737 const minDate = parseDateFn(minConstraint);
22738 if (minDate) {
22739 matchers.push({ before: minDate });
22740 }
22741 }
22742 if (maxConstraint) {
22743 const maxDate = parseDateFn(maxConstraint);
22744 if (maxDate) {
22745 matchers.push({ after: maxDate });
22746 }
22747 }
22748 return matchers.length > 0 ? matchers : void 0;
22749 }, [minConstraint, maxConstraint, parseDateFn]);
22750 return { minConstraint, maxConstraint, disabledMatchers };
22751 }
22752
22753 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
22754 var import_date2 = __toESM(require_date(), 1);
22755 function parseDateTime(dateTimeString) {
22756 if (!dateTimeString) {
22757 return null;
22758 }
22759 const parsed = (0, import_date2.getDate)(dateTimeString);
22760 return parsed && isValid(parsed) ? parsed : null;
22761 }
22762
22763 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
22764 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
22765 var { DateCalendar, ValidatedInputControl } = unlock2(import_components30.privateApis);
22766 var formatDateTime = (value) => {
22767 if (!value) {
22768 return "";
22769 }
22770 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
22771 };
22772 function CalendarDateTimeControl({
22773 data,
22774 field,
22775 onChange,
22776 hideLabelFromVision,
22777 markWhenOptional,
22778 validity,
22779 config
22780 }) {
22781 const { compact } = config || {};
22782 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
22783 const disabled2 = field.isDisabled({ item: data, field });
22784 const fieldValue = getValue({ item: data });
22785 const value = typeof fieldValue === "string" ? fieldValue : void 0;
22786 const [calendarMonth, setCalendarMonth] = (0, import_element65.useState)(() => {
22787 const parsedDate = parseDateTime(value);
22788 return parsedDate || /* @__PURE__ */ new Date();
22789 });
22790 const inputControlRef = (0, import_element65.useRef)(null);
22791 const validationTimeoutRef = (0, import_element65.useRef)(void 0);
22792 const previousFocusRef = (0, import_element65.useRef)(null);
22793 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
22794 const onChangeCallback = (0, import_element65.useCallback)(
22795 (newValue) => onChange(setValue({ item: data, value: newValue })),
22796 [data, onChange, setValue]
22797 );
22798 (0, import_element65.useEffect)(() => {
22799 return () => {
22800 if (validationTimeoutRef.current) {
22801 clearTimeout(validationTimeoutRef.current);
22802 }
22803 };
22804 }, []);
22805 const onSelectDate = (0, import_element65.useCallback)(
22806 (newDate) => {
22807 let dateTimeValue;
22808 if (newDate) {
22809 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
22810 let wpTime;
22811 if (value) {
22812 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
22813 } else {
22814 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
22815 }
22816 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
22817 dateTimeValue = finalDateTime.toISOString();
22818 onChangeCallback(dateTimeValue);
22819 if (validationTimeoutRef.current) {
22820 clearTimeout(validationTimeoutRef.current);
22821 }
22822 } else {
22823 onChangeCallback(void 0);
22824 }
22825 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
22826 validationTimeoutRef.current = setTimeout(() => {
22827 if (inputControlRef.current) {
22828 inputControlRef.current.focus();
22829 inputControlRef.current.blur();
22830 onChangeCallback(dateTimeValue);
22831 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
22832 previousFocusRef.current.focus();
22833 }
22834 }
22835 }, 0);
22836 },
22837 [onChangeCallback, value]
22838 );
22839 const handleManualDateTimeChange = (0, import_element65.useCallback)(
22840 (newValue) => {
22841 if (newValue) {
22842 const dateTime = (0, import_date3.getDate)(newValue);
22843 onChangeCallback(dateTime.toISOString());
22844 const parsedDate = parseDateTime(dateTime.toISOString());
22845 if (parsedDate) {
22846 setCalendarMonth(parsedDate);
22847 }
22848 } else {
22849 onChangeCallback(void 0);
22850 }
22851 },
22852 [onChangeCallback]
22853 );
22854 const { format: fieldFormat } = field;
22855 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
22856 const {
22857 timezone: { string: timezoneString }
22858 } = (0, import_date3.getSettings)();
22859 let displayLabel = label;
22860 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
22861 displayLabel = `${label} (${(0, import_i18n33.__)("Required")})`;
22862 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
22863 displayLabel = `${label} (${(0, import_i18n33.__)("Optional")})`;
22864 }
22865 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
22866 import_components30.BaseControl,
22867 {
22868 id,
22869 label: displayLabel,
22870 help: description,
22871 hideLabelFromVision,
22872 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22873 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
22874 ValidatedInputControl,
22875 {
22876 ref: inputControlRef,
22877 __next40pxDefaultSize: true,
22878 required: !!isValid2?.required,
22879 customValidity: getCustomValidity(isValid2, validity),
22880 type: "datetime-local",
22881 label: (0, import_i18n33.__)("Date time"),
22882 hideLabelFromVision: true,
22883 value: formatDateTime(value),
22884 onChange: handleManualDateTimeChange,
22885 disabled: disabled2,
22886 min: minConstraint ? formatDateTime(minConstraint) : void 0,
22887 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
22888 }
22889 ),
22890 !compact && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
22891 DateCalendar,
22892 {
22893 style: { width: "100%" },
22894 selected: value ? parseDateTime(value) || void 0 : void 0,
22895 onSelect: onSelectDate,
22896 month: calendarMonth,
22897 onMonthChange: setCalendarMonth,
22898 timeZone: timezoneString || void 0,
22899 weekStartsOn,
22900 disabled: disabled2 || disabledMatchers
22901 }
22902 )
22903 ] })
22904 }
22905 );
22906 }
22907 function DateTime({
22908 data,
22909 field,
22910 onChange,
22911 hideLabelFromVision,
22912 markWhenOptional,
22913 operator,
22914 validity,
22915 config
22916 }) {
22917 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
22918 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
22919 RelativeDateControl,
22920 {
22921 className: "dataviews-controls__datetime",
22922 data,
22923 field,
22924 onChange,
22925 hideLabelFromVision,
22926 operator
22927 }
22928 );
22929 }
22930 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
22931 CalendarDateTimeControl,
22932 {
22933 data,
22934 field,
22935 onChange,
22936 hideLabelFromVision,
22937 markWhenOptional,
22938 validity,
22939 config
22940 }
22941 );
22942 }
22943
22944 // packages/dataviews/build-module/components/dataform-controls/date.mjs
22945 var import_components31 = __toESM(require_components(), 1);
22946 var import_element66 = __toESM(require_element(), 1);
22947 var import_i18n34 = __toESM(require_i18n(), 1);
22948 var import_date4 = __toESM(require_date(), 1);
22949 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
22950 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock2(import_components31.privateApis);
22951 var DATE_PRESETS = [
22952 {
22953 id: "today",
22954 label: (0, import_i18n34.__)("Today"),
22955 getValue: () => (0, import_date4.getDate)(null)
22956 },
22957 {
22958 id: "yesterday",
22959 label: (0, import_i18n34.__)("Yesterday"),
22960 getValue: () => {
22961 const today = (0, import_date4.getDate)(null);
22962 return subDays(today, 1);
22963 }
22964 },
22965 {
22966 id: "past-week",
22967 label: (0, import_i18n34.__)("Past week"),
22968 getValue: () => {
22969 const today = (0, import_date4.getDate)(null);
22970 return subDays(today, 7);
22971 }
22972 },
22973 {
22974 id: "past-month",
22975 label: (0, import_i18n34.__)("Past month"),
22976 getValue: () => {
22977 const today = (0, import_date4.getDate)(null);
22978 return subMonths(today, 1);
22979 }
22980 }
22981 ];
22982 var DATE_RANGE_PRESETS = [
22983 {
22984 id: "last-7-days",
22985 label: (0, import_i18n34.__)("Last 7 days"),
22986 getValue: () => {
22987 const today = (0, import_date4.getDate)(null);
22988 return [subDays(today, 7), today];
22989 }
22990 },
22991 {
22992 id: "last-30-days",
22993 label: (0, import_i18n34.__)("Last 30 days"),
22994 getValue: () => {
22995 const today = (0, import_date4.getDate)(null);
22996 return [subDays(today, 30), today];
22997 }
22998 },
22999 {
23000 id: "month-to-date",
23001 label: (0, import_i18n34.__)("Month to date"),
23002 getValue: () => {
23003 const today = (0, import_date4.getDate)(null);
23004 return [startOfMonth(today), today];
23005 }
23006 },
23007 {
23008 id: "last-year",
23009 label: (0, import_i18n34.__)("Last year"),
23010 getValue: () => {
23011 const today = (0, import_date4.getDate)(null);
23012 return [subYears(today, 1), today];
23013 }
23014 },
23015 {
23016 id: "year-to-date",
23017 label: (0, import_i18n34.__)("Year to date"),
23018 getValue: () => {
23019 const today = (0, import_date4.getDate)(null);
23020 return [startOfYear(today), today];
23021 }
23022 }
23023 ];
23024 var parseDate = (dateString) => {
23025 if (!dateString) {
23026 return null;
23027 }
23028 const parsed = (0, import_date4.getDate)(dateString);
23029 return parsed && isValid(parsed) ? parsed : null;
23030 };
23031 var formatDate = (date) => {
23032 if (!date) {
23033 return "";
23034 }
23035 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
23036 };
23037 function ValidatedDateControl({
23038 field,
23039 validity,
23040 inputRefs,
23041 isTouched,
23042 setIsTouched,
23043 children
23044 }) {
23045 const { isValid: isValid2 } = field;
23046 const [customValidity, setCustomValidity] = (0, import_element66.useState)(void 0);
23047 const validateRefs = (0, import_element66.useCallback)(() => {
23048 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23049 for (const ref of refs) {
23050 const input = ref.current;
23051 if (input && !input.validity.valid) {
23052 setCustomValidity({
23053 type: "invalid",
23054 message: input.validationMessage
23055 });
23056 return;
23057 }
23058 }
23059 setCustomValidity(void 0);
23060 }, [inputRefs]);
23061 (0, import_element66.useEffect)(() => {
23062 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23063 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23064 for (const ref of refs) {
23065 const input = ref.current;
23066 if (input) {
23067 input.setCustomValidity(
23068 result?.type === "invalid" && result.message ? result.message : ""
23069 );
23070 }
23071 }
23072 }, [inputRefs, isValid2, validity]);
23073 (0, import_element66.useEffect)(() => {
23074 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23075 const handleInvalid = (event) => {
23076 event.preventDefault();
23077 setIsTouched(true);
23078 };
23079 for (const ref of refs) {
23080 ref.current?.addEventListener("invalid", handleInvalid);
23081 }
23082 return () => {
23083 for (const ref of refs) {
23084 ref.current?.removeEventListener("invalid", handleInvalid);
23085 }
23086 };
23087 }, [inputRefs, setIsTouched]);
23088 (0, import_element66.useEffect)(() => {
23089 if (!isTouched) {
23090 return;
23091 }
23092 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23093 if (result) {
23094 setCustomValidity(result);
23095 } else {
23096 validateRefs();
23097 }
23098 }, [isTouched, isValid2, validity, validateRefs]);
23099 const onBlur = (event) => {
23100 if (isTouched) {
23101 return;
23102 }
23103 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
23104 setIsTouched(true);
23105 }
23106 };
23107 return /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)("div", { onBlur, children: [
23108 children,
23109 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(
23110 "p",
23111 {
23112 className: clsx_default(
23113 "components-validated-control__indicator",
23114 customValidity.type === "invalid" ? "is-invalid" : void 0
23115 ),
23116 children: [
23117 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23118 import_components31.Icon,
23119 {
23120 className: "components-validated-control__indicator-icon",
23121 icon: error_default,
23122 size: 16,
23123 fill: "currentColor"
23124 }
23125 ),
23126 customValidity.message
23127 ]
23128 }
23129 ) })
23130 ] });
23131 }
23132 function CalendarDateControl({
23133 data,
23134 field,
23135 onChange,
23136 hideLabelFromVision,
23137 markWhenOptional,
23138 validity
23139 }) {
23140 const {
23141 id,
23142 label,
23143 description,
23144 setValue,
23145 getValue,
23146 isValid: isValid2,
23147 format: fieldFormat
23148 } = field;
23149 const disabled2 = field.isDisabled({ item: data, field });
23150 const [selectedPresetId, setSelectedPresetId] = (0, import_element66.useState)(
23151 null
23152 );
23153 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23154 const fieldValue = getValue({ item: data });
23155 const value = typeof fieldValue === "string" ? fieldValue : void 0;
23156 const [calendarMonth, setCalendarMonth] = (0, import_element66.useState)(() => {
23157 const parsedDate = parseDate(value);
23158 return parsedDate || /* @__PURE__ */ new Date();
23159 });
23160 const [isTouched, setIsTouched] = (0, import_element66.useState)(false);
23161 const validityTargetRef = (0, import_element66.useRef)(null);
23162 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23163 const onChangeCallback = (0, import_element66.useCallback)(
23164 (newValue) => onChange(setValue({ item: data, value: newValue })),
23165 [data, onChange, setValue]
23166 );
23167 const onSelectDate = (0, import_element66.useCallback)(
23168 (newDate) => {
23169 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
23170 onChangeCallback(dateValue);
23171 setSelectedPresetId(null);
23172 setIsTouched(true);
23173 },
23174 [onChangeCallback]
23175 );
23176 const handlePresetClick = (0, import_element66.useCallback)(
23177 (preset) => {
23178 const presetDate = preset.getValue();
23179 const dateValue = formatDate(presetDate);
23180 setCalendarMonth(presetDate);
23181 onChangeCallback(dateValue);
23182 setSelectedPresetId(preset.id);
23183 setIsTouched(true);
23184 },
23185 [onChangeCallback]
23186 );
23187 const handleManualDateChange = (0, import_element66.useCallback)(
23188 (newValue) => {
23189 onChangeCallback(newValue);
23190 if (newValue) {
23191 const parsedDate = parseDate(newValue);
23192 if (parsedDate) {
23193 setCalendarMonth(parsedDate);
23194 }
23195 }
23196 setSelectedPresetId(null);
23197 setIsTouched(true);
23198 },
23199 [onChangeCallback]
23200 );
23201 const {
23202 timezone: { string: timezoneString }
23203 } = (0, import_date4.getSettings)();
23204 let displayLabel = label;
23205 if (isValid2?.required && !markWhenOptional) {
23206 displayLabel = `${label} (${(0, import_i18n34.__)("Required")})`;
23207 } else if (!isValid2?.required && markWhenOptional) {
23208 displayLabel = `${label} (${(0, import_i18n34.__)("Optional")})`;
23209 }
23210 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23211 ValidatedDateControl,
23212 {
23213 field,
23214 validity,
23215 inputRefs: validityTargetRef,
23216 isTouched,
23217 setIsTouched,
23218 children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23219 import_components31.BaseControl,
23220 {
23221 id,
23222 className: "dataviews-controls__date",
23223 label: displayLabel,
23224 help: description,
23225 hideLabelFromVision,
23226 children: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23227 /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(
23228 Stack,
23229 {
23230 direction: "row",
23231 gap: "sm",
23232 wrap: "wrap",
23233 justify: "flex-start",
23234 children: [
23235 DATE_PRESETS.map((preset) => {
23236 const isSelected2 = selectedPresetId === preset.id;
23237 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23238 import_components31.Button,
23239 {
23240 className: "dataviews-controls__date-preset",
23241 variant: "tertiary",
23242 isPressed: isSelected2,
23243 size: "small",
23244 disabled: disabled2,
23245 accessibleWhenDisabled: true,
23246 onClick: () => handlePresetClick(preset),
23247 children: preset.label
23248 },
23249 preset.id
23250 );
23251 }),
23252 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23253 import_components31.Button,
23254 {
23255 className: "dataviews-controls__date-preset",
23256 variant: "tertiary",
23257 isPressed: !selectedPresetId,
23258 size: "small",
23259 disabled: !!selectedPresetId || disabled2,
23260 accessibleWhenDisabled: true,
23261 children: (0, import_i18n34.__)("Custom")
23262 }
23263 )
23264 ]
23265 }
23266 ),
23267 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23268 import_components31.__experimentalInputControl,
23269 {
23270 __next40pxDefaultSize: true,
23271 ref: validityTargetRef,
23272 type: "date",
23273 label: (0, import_i18n34.__)("Date"),
23274 hideLabelFromVision: true,
23275 value,
23276 onChange: handleManualDateChange,
23277 required: !!field.isValid?.required,
23278 disabled: disabled2,
23279 min: minConstraint,
23280 max: maxConstraint
23281 }
23282 ),
23283 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23284 DateCalendar2,
23285 {
23286 style: { width: "100%" },
23287 selected: value ? parseDate(value) || void 0 : void 0,
23288 onSelect: onSelectDate,
23289 month: calendarMonth,
23290 onMonthChange: setCalendarMonth,
23291 timeZone: timezoneString || void 0,
23292 weekStartsOn,
23293 disabled: disabled2 || disabledMatchers,
23294 disableNavigation: disabled2
23295 }
23296 )
23297 ] })
23298 }
23299 )
23300 }
23301 );
23302 }
23303 function CalendarDateRangeControl({
23304 data,
23305 field,
23306 onChange,
23307 hideLabelFromVision,
23308 markWhenOptional,
23309 validity
23310 }) {
23311 const {
23312 id,
23313 label,
23314 description,
23315 getValue,
23316 setValue,
23317 isValid: isValid2,
23318 format: fieldFormat
23319 } = field;
23320 const disabled2 = field.isDisabled({ item: data, field });
23321 let value;
23322 const fieldValue = getValue({ item: data });
23323 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
23324 value = fieldValue;
23325 }
23326 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23327 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23328 const onChangeCallback = (0, import_element66.useCallback)(
23329 (newValue) => {
23330 onChange(
23331 setValue({
23332 item: data,
23333 value: newValue
23334 })
23335 );
23336 },
23337 [data, onChange, setValue]
23338 );
23339 const [selectedPresetId, setSelectedPresetId] = (0, import_element66.useState)(
23340 null
23341 );
23342 const selectedRange = (0, import_element66.useMemo)(() => {
23343 if (!value) {
23344 return { from: void 0, to: void 0 };
23345 }
23346 const [from, to] = value;
23347 return {
23348 from: parseDate(from) || void 0,
23349 to: parseDate(to) || void 0
23350 };
23351 }, [value]);
23352 const [calendarMonth, setCalendarMonth] = (0, import_element66.useState)(() => {
23353 return selectedRange.from || /* @__PURE__ */ new Date();
23354 });
23355 const [isTouched, setIsTouched] = (0, import_element66.useState)(false);
23356 const fromInputRef = (0, import_element66.useRef)(null);
23357 const toInputRef = (0, import_element66.useRef)(null);
23358 const updateDateRange = (0, import_element66.useCallback)(
23359 (fromDate, toDate2) => {
23360 if (fromDate && toDate2) {
23361 onChangeCallback([
23362 formatDate(fromDate),
23363 formatDate(toDate2)
23364 ]);
23365 } else if (!fromDate && !toDate2) {
23366 onChangeCallback(void 0);
23367 }
23368 },
23369 [onChangeCallback]
23370 );
23371 const onSelectCalendarRange = (0, import_element66.useCallback)(
23372 (newRange) => {
23373 updateDateRange(newRange?.from, newRange?.to);
23374 setSelectedPresetId(null);
23375 setIsTouched(true);
23376 },
23377 [updateDateRange]
23378 );
23379 const handlePresetClick = (0, import_element66.useCallback)(
23380 (preset) => {
23381 const [startDate, endDate] = preset.getValue();
23382 setCalendarMonth(startDate);
23383 updateDateRange(startDate, endDate);
23384 setSelectedPresetId(preset.id);
23385 setIsTouched(true);
23386 },
23387 [updateDateRange]
23388 );
23389 const handleManualDateChange = (0, import_element66.useCallback)(
23390 (fromOrTo, newValue) => {
23391 const [currentFrom, currentTo] = value || [
23392 void 0,
23393 void 0
23394 ];
23395 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
23396 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
23397 updateDateRange(updatedFrom, updatedTo);
23398 if (newValue) {
23399 const parsedDate = parseDate(newValue);
23400 if (parsedDate) {
23401 setCalendarMonth(parsedDate);
23402 }
23403 }
23404 setSelectedPresetId(null);
23405 setIsTouched(true);
23406 },
23407 [value, updateDateRange]
23408 );
23409 const { timezone } = (0, import_date4.getSettings)();
23410 let displayLabel = label;
23411 if (field.isValid?.required && !markWhenOptional) {
23412 displayLabel = `${label} (${(0, import_i18n34.__)("Required")})`;
23413 } else if (!field.isValid?.required && markWhenOptional) {
23414 displayLabel = `${label} (${(0, import_i18n34.__)("Optional")})`;
23415 }
23416 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23417 ValidatedDateControl,
23418 {
23419 field,
23420 validity,
23421 inputRefs: [fromInputRef, toInputRef],
23422 isTouched,
23423 setIsTouched,
23424 children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23425 import_components31.BaseControl,
23426 {
23427 id,
23428 className: "dataviews-controls__date",
23429 label: displayLabel,
23430 help: description,
23431 hideLabelFromVision,
23432 children: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23433 /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(
23434 Stack,
23435 {
23436 direction: "row",
23437 gap: "sm",
23438 wrap: "wrap",
23439 justify: "flex-start",
23440 children: [
23441 DATE_RANGE_PRESETS.map((preset) => {
23442 const isSelected2 = selectedPresetId === preset.id;
23443 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23444 import_components31.Button,
23445 {
23446 className: "dataviews-controls__date-preset",
23447 variant: "tertiary",
23448 isPressed: isSelected2,
23449 size: "small",
23450 disabled: disabled2,
23451 accessibleWhenDisabled: true,
23452 onClick: () => handlePresetClick(preset),
23453 children: preset.label
23454 },
23455 preset.id
23456 );
23457 }),
23458 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23459 import_components31.Button,
23460 {
23461 className: "dataviews-controls__date-preset",
23462 variant: "tertiary",
23463 isPressed: !selectedPresetId,
23464 size: "small",
23465 accessibleWhenDisabled: true,
23466 disabled: !!selectedPresetId || disabled2,
23467 children: (0, import_i18n34.__)("Custom")
23468 }
23469 )
23470 ]
23471 }
23472 ),
23473 /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(
23474 Stack,
23475 {
23476 direction: "row",
23477 gap: "sm",
23478 justify: "space-between",
23479 className: "dataviews-controls__date-range-inputs",
23480 children: [
23481 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23482 import_components31.__experimentalInputControl,
23483 {
23484 __next40pxDefaultSize: true,
23485 ref: fromInputRef,
23486 type: "date",
23487 label: (0, import_i18n34.__)("From"),
23488 hideLabelFromVision: true,
23489 value: value?.[0],
23490 onChange: (newValue) => handleManualDateChange("from", newValue),
23491 required: !!field.isValid?.required,
23492 disabled: disabled2,
23493 min: minConstraint,
23494 max: maxConstraint
23495 }
23496 ),
23497 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23498 import_components31.__experimentalInputControl,
23499 {
23500 __next40pxDefaultSize: true,
23501 ref: toInputRef,
23502 type: "date",
23503 label: (0, import_i18n34.__)("To"),
23504 hideLabelFromVision: true,
23505 value: value?.[1],
23506 onChange: (newValue) => handleManualDateChange("to", newValue),
23507 required: !!field.isValid?.required,
23508 disabled: disabled2,
23509 min: minConstraint,
23510 max: maxConstraint
23511 }
23512 )
23513 ]
23514 }
23515 ),
23516 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23517 DateRangeCalendar,
23518 {
23519 style: { width: "100%" },
23520 selected: selectedRange,
23521 onSelect: onSelectCalendarRange,
23522 month: calendarMonth,
23523 onMonthChange: setCalendarMonth,
23524 timeZone: timezone.string || void 0,
23525 weekStartsOn,
23526 disabled: disabled2 || disabledMatchers
23527 }
23528 )
23529 ] })
23530 }
23531 )
23532 }
23533 );
23534 }
23535 function DateControl({
23536 data,
23537 field,
23538 onChange,
23539 hideLabelFromVision,
23540 markWhenOptional,
23541 operator,
23542 validity
23543 }) {
23544 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
23545 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23546 RelativeDateControl,
23547 {
23548 className: "dataviews-controls__date",
23549 data,
23550 field,
23551 onChange,
23552 hideLabelFromVision,
23553 operator
23554 }
23555 );
23556 }
23557 if (operator === OPERATOR_BETWEEN) {
23558 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23559 CalendarDateRangeControl,
23560 {
23561 data,
23562 field,
23563 onChange,
23564 hideLabelFromVision,
23565 markWhenOptional,
23566 validity
23567 }
23568 );
23569 }
23570 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23571 CalendarDateControl,
23572 {
23573 data,
23574 field,
23575 onChange,
23576 hideLabelFromVision,
23577 markWhenOptional,
23578 validity
23579 }
23580 );
23581 }
23582
23583 // packages/dataviews/build-module/components/dataform-controls/select.mjs
23584 var import_components32 = __toESM(require_components(), 1);
23585 var import_element67 = __toESM(require_element(), 1);
23586 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
23587 var { ValidatedSelectControl } = unlock2(import_components32.privateApis);
23588 function Select({
23589 data,
23590 field,
23591 onChange,
23592 hideLabelFromVision,
23593 markWhenOptional,
23594 validity
23595 }) {
23596 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
23597 const disabled2 = field.isDisabled({ item: data, field });
23598 const isMultiple = type === "array";
23599 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
23600 const onChangeControl = (0, import_element67.useCallback)(
23601 (newValue) => onChange(setValue({ item: data, value: newValue })),
23602 [data, onChange, setValue]
23603 );
23604 const { elements, isLoading } = useElements({
23605 elements: field.elements,
23606 getElements: field.getElements
23607 });
23608 if (isLoading) {
23609 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(import_components32.Spinner, {});
23610 }
23611 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23612 ValidatedSelectControl,
23613 {
23614 required: !!field.isValid?.required,
23615 markWhenOptional,
23616 customValidity: getCustomValidity(isValid2, validity),
23617 label,
23618 value,
23619 help: description,
23620 options: elements,
23621 onChange: onChangeControl,
23622 __next40pxDefaultSize: true,
23623 hideLabelFromVision,
23624 multiple: isMultiple,
23625 disabled: disabled2
23626 }
23627 );
23628 }
23629
23630 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
23631 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
23632 var ELEMENTS_THRESHOLD = 10;
23633 function AdaptiveSelect(props) {
23634 const { field } = props;
23635 const { elements } = useElements({
23636 elements: field.elements,
23637 getElements: field.getElements
23638 });
23639 if (elements.length >= ELEMENTS_THRESHOLD) {
23640 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(Combobox3, { ...props });
23641 }
23642 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(Select, { ...props });
23643 }
23644
23645 // packages/dataviews/build-module/components/dataform-controls/email.mjs
23646 var import_components34 = __toESM(require_components(), 1);
23647
23648 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
23649 var import_components33 = __toESM(require_components(), 1);
23650 var import_element68 = __toESM(require_element(), 1);
23651 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
23652 var { ValidatedInputControl: ValidatedInputControl2 } = unlock2(import_components33.privateApis);
23653 function ValidatedText({
23654 data,
23655 field,
23656 onChange,
23657 hideLabelFromVision,
23658 markWhenOptional,
23659 type,
23660 prefix,
23661 suffix,
23662 validity
23663 }) {
23664 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
23665 const value = getValue({ item: data });
23666 const disabled2 = field.isDisabled({ item: data, field });
23667 const onChangeControl = (0, import_element68.useCallback)(
23668 (newValue) => onChange(
23669 setValue({
23670 item: data,
23671 value: newValue
23672 })
23673 ),
23674 [data, setValue, onChange]
23675 );
23676 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
23677 ValidatedInputControl2,
23678 {
23679 required: !!isValid2.required,
23680 markWhenOptional,
23681 customValidity: getCustomValidity(isValid2, validity),
23682 label,
23683 placeholder,
23684 value: value ?? "",
23685 help: description,
23686 onChange: onChangeControl,
23687 hideLabelFromVision,
23688 type,
23689 prefix,
23690 suffix,
23691 disabled: disabled2,
23692 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
23693 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
23694 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
23695 __next40pxDefaultSize: true
23696 }
23697 );
23698 }
23699
23700 // packages/dataviews/build-module/components/dataform-controls/email.mjs
23701 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
23702 function Email({
23703 data,
23704 field,
23705 onChange,
23706 hideLabelFromVision,
23707 markWhenOptional,
23708 validity
23709 }) {
23710 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
23711 ValidatedText,
23712 {
23713 ...{
23714 data,
23715 field,
23716 onChange,
23717 hideLabelFromVision,
23718 markWhenOptional,
23719 validity,
23720 type: "email",
23721 prefix: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_components34.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_components34.Icon, { icon: envelope_default }) })
23722 }
23723 }
23724 );
23725 }
23726
23727 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
23728 var import_components35 = __toESM(require_components(), 1);
23729 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
23730 function Telephone({
23731 data,
23732 field,
23733 onChange,
23734 hideLabelFromVision,
23735 markWhenOptional,
23736 validity
23737 }) {
23738 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
23739 ValidatedText,
23740 {
23741 ...{
23742 data,
23743 field,
23744 onChange,
23745 hideLabelFromVision,
23746 markWhenOptional,
23747 validity,
23748 type: "tel",
23749 prefix: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components35.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components35.Icon, { icon: mobile_default }) })
23750 }
23751 }
23752 );
23753 }
23754
23755 // packages/dataviews/build-module/components/dataform-controls/url.mjs
23756 var import_components36 = __toESM(require_components(), 1);
23757 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
23758 function Url({
23759 data,
23760 field,
23761 onChange,
23762 hideLabelFromVision,
23763 markWhenOptional,
23764 validity
23765 }) {
23766 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
23767 ValidatedText,
23768 {
23769 ...{
23770 data,
23771 field,
23772 onChange,
23773 hideLabelFromVision,
23774 markWhenOptional,
23775 validity,
23776 type: "url",
23777 prefix: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components36.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components36.Icon, { icon: link_default }) })
23778 }
23779 }
23780 );
23781 }
23782
23783 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
23784 var import_components37 = __toESM(require_components(), 1);
23785 var import_element69 = __toESM(require_element(), 1);
23786 var import_i18n35 = __toESM(require_i18n(), 1);
23787 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
23788 var { ValidatedNumberControl } = unlock2(import_components37.privateApis);
23789 function toNumberOrEmpty(value) {
23790 if (value === "" || value === void 0) {
23791 return "";
23792 }
23793 const number = Number(value);
23794 return Number.isFinite(number) ? number : "";
23795 }
23796 function BetweenControls({
23797 value,
23798 onChange,
23799 hideLabelFromVision,
23800 step
23801 }) {
23802 const [min2 = "", max2 = ""] = value;
23803 const onChangeMin = (0, import_element69.useCallback)(
23804 (newValue) => onChange([toNumberOrEmpty(newValue), max2]),
23805 [onChange, max2]
23806 );
23807 const onChangeMax = (0, import_element69.useCallback)(
23808 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]),
23809 [onChange, min2]
23810 );
23811 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
23812 import_components37.BaseControl,
23813 {
23814 help: (0, import_i18n35.__)("The max. value must be greater than the min. value."),
23815 children: /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)(import_components37.Flex, { direction: "row", gap: 4, children: [
23816 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
23817 import_components37.__experimentalNumberControl,
23818 {
23819 label: (0, import_i18n35.__)("Min."),
23820 value: min2,
23821 max: max2 ? Number(max2) - step : void 0,
23822 onChange: onChangeMin,
23823 __next40pxDefaultSize: true,
23824 hideLabelFromVision,
23825 step
23826 }
23827 ),
23828 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
23829 import_components37.__experimentalNumberControl,
23830 {
23831 label: (0, import_i18n35.__)("Max."),
23832 value: max2,
23833 min: min2 ? Number(min2) + step : void 0,
23834 onChange: onChangeMax,
23835 __next40pxDefaultSize: true,
23836 hideLabelFromVision,
23837 step
23838 }
23839 )
23840 ] })
23841 }
23842 );
23843 }
23844 function ValidatedNumber({
23845 data,
23846 field,
23847 onChange,
23848 hideLabelFromVision,
23849 markWhenOptional,
23850 operator,
23851 validity
23852 }) {
23853 const decimals = field.format?.decimals ?? 0;
23854 const step = Math.pow(10, Math.abs(decimals) * -1);
23855 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23856 const value = getValue({ item: data }) ?? "";
23857 const disabled2 = field.isDisabled({ item: data, field });
23858 const onChangeControl = (0, import_element69.useCallback)(
23859 (newValue) => {
23860 onChange(
23861 setValue({
23862 item: data,
23863 // Do not convert an empty string or undefined to a number,
23864 // otherwise there's a mismatch between the UI control (empty)
23865 // and the data relied by onChange (0).
23866 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
23867 })
23868 );
23869 },
23870 [data, onChange, setValue]
23871 );
23872 const onChangeBetweenControls = (0, import_element69.useCallback)(
23873 (newValue) => {
23874 onChange(
23875 setValue({
23876 item: data,
23877 value: newValue
23878 })
23879 );
23880 },
23881 [data, onChange, setValue]
23882 );
23883 if (operator === OPERATOR_BETWEEN) {
23884 let valueBetween = ["", ""];
23885 if (Array.isArray(value) && value.length === 2 && value.every(
23886 (element) => typeof element === "number" || element === ""
23887 )) {
23888 valueBetween = value;
23889 }
23890 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
23891 BetweenControls,
23892 {
23893 value: valueBetween,
23894 onChange: onChangeBetweenControls,
23895 hideLabelFromVision,
23896 step
23897 }
23898 );
23899 }
23900 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
23901 ValidatedNumberControl,
23902 {
23903 required: !!isValid2.required,
23904 markWhenOptional,
23905 customValidity: getCustomValidity(isValid2, validity),
23906 label,
23907 help: description,
23908 value,
23909 onChange: onChangeControl,
23910 __next40pxDefaultSize: true,
23911 hideLabelFromVision,
23912 step,
23913 min: isValid2.min ? isValid2.min.constraint : void 0,
23914 max: isValid2.max ? isValid2.max.constraint : void 0,
23915 disabled: disabled2
23916 }
23917 );
23918 }
23919
23920 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
23921 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
23922 function Integer(props) {
23923 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(ValidatedNumber, { ...props });
23924 }
23925
23926 // packages/dataviews/build-module/components/dataform-controls/number.mjs
23927 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
23928 function Number2(props) {
23929 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(ValidatedNumber, { ...props });
23930 }
23931
23932 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
23933 var import_components38 = __toESM(require_components(), 1);
23934 var import_element70 = __toESM(require_element(), 1);
23935 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
23936 var { ValidatedRadioControl } = unlock2(import_components38.privateApis);
23937 function Radio({
23938 data,
23939 field,
23940 onChange,
23941 hideLabelFromVision,
23942 markWhenOptional,
23943 validity
23944 }) {
23945 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23946 const disabled2 = field.isDisabled({ item: data, field });
23947 const { elements, isLoading } = useElements({
23948 elements: field.elements,
23949 getElements: field.getElements
23950 });
23951 const value = getValue({ item: data });
23952 const onChangeControl = (0, import_element70.useCallback)(
23953 (newValue) => onChange(setValue({ item: data, value: newValue })),
23954 [data, onChange, setValue]
23955 );
23956 if (isLoading) {
23957 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components38.Spinner, {});
23958 }
23959 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
23960 ValidatedRadioControl,
23961 {
23962 required: !!field.isValid?.required,
23963 markWhenOptional,
23964 customValidity: getCustomValidity(isValid2, validity),
23965 label,
23966 help: description,
23967 onChange: onChangeControl,
23968 options: elements,
23969 selected: value,
23970 hideLabelFromVision,
23971 disabled: disabled2
23972 }
23973 );
23974 }
23975
23976 // packages/dataviews/build-module/components/dataform-controls/text.mjs
23977 var import_element71 = __toESM(require_element(), 1);
23978 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
23979 function Text3({
23980 data,
23981 field,
23982 onChange,
23983 hideLabelFromVision,
23984 markWhenOptional,
23985 config,
23986 validity
23987 }) {
23988 const { prefix, suffix } = config || {};
23989 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
23990 ValidatedText,
23991 {
23992 ...{
23993 data,
23994 field,
23995 onChange,
23996 hideLabelFromVision,
23997 markWhenOptional,
23998 validity,
23999 prefix: prefix ? (0, import_element71.createElement)(prefix) : void 0,
24000 suffix: suffix ? (0, import_element71.createElement)(suffix) : void 0
24001 }
24002 }
24003 );
24004 }
24005
24006 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
24007 var import_components39 = __toESM(require_components(), 1);
24008 var import_element72 = __toESM(require_element(), 1);
24009 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
24010 var { ValidatedToggleControl } = unlock2(import_components39.privateApis);
24011 function Toggle({
24012 field,
24013 onChange,
24014 data,
24015 hideLabelFromVision,
24016 markWhenOptional,
24017 validity
24018 }) {
24019 const { label, description, getValue, setValue, isValid: isValid2 } = field;
24020 const disabled2 = field.isDisabled({ item: data, field });
24021 const onChangeControl = (0, import_element72.useCallback)(() => {
24022 onChange(
24023 setValue({ item: data, value: !getValue({ item: data }) })
24024 );
24025 }, [onChange, setValue, data, getValue]);
24026 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
24027 ValidatedToggleControl,
24028 {
24029 required: !!isValid2.required,
24030 markWhenOptional,
24031 customValidity: getCustomValidity(isValid2, validity),
24032 hidden: hideLabelFromVision,
24033 label,
24034 help: description,
24035 checked: getValue({ item: data }),
24036 onChange: onChangeControl,
24037 disabled: disabled2
24038 }
24039 );
24040 }
24041
24042 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
24043 var import_components40 = __toESM(require_components(), 1);
24044 var import_element73 = __toESM(require_element(), 1);
24045 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
24046 var { ValidatedTextareaControl } = unlock2(import_components40.privateApis);
24047 function Textarea({
24048 data,
24049 field,
24050 onChange,
24051 hideLabelFromVision,
24052 markWhenOptional,
24053 config,
24054 validity
24055 }) {
24056 const { rows = 4 } = config || {};
24057 const disabled2 = field.isDisabled({ item: data, field });
24058 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
24059 const value = field.getValue({ item: data });
24060 const onChangeControl = (0, import_element73.useCallback)(
24061 (newValue) => onChange(setValue({ item: data, value: newValue })),
24062 [data, onChange, setValue]
24063 );
24064 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
24065 ValidatedTextareaControl,
24066 {
24067 required: !!isValid2.required,
24068 markWhenOptional,
24069 customValidity: getCustomValidity(isValid2, validity),
24070 label,
24071 placeholder,
24072 value: value ?? "",
24073 help: description,
24074 onChange: onChangeControl,
24075 rows,
24076 disabled: disabled2,
24077 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
24078 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
24079 __next40pxDefaultSize: true,
24080 hideLabelFromVision
24081 }
24082 );
24083 }
24084
24085 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
24086 var import_components41 = __toESM(require_components(), 1);
24087 var import_element74 = __toESM(require_element(), 1);
24088 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
24089 var { ValidatedToggleGroupControl } = unlock2(import_components41.privateApis);
24090 function ToggleGroup({
24091 data,
24092 field,
24093 onChange,
24094 hideLabelFromVision,
24095 markWhenOptional,
24096 validity
24097 }) {
24098 const { getValue, setValue, isValid: isValid2 } = field;
24099 const disabled2 = field.isDisabled({ item: data, field });
24100 const value = getValue({ item: data });
24101 const onChangeControl = (0, import_element74.useCallback)(
24102 (newValue) => onChange(setValue({ item: data, value: newValue })),
24103 [data, onChange, setValue]
24104 );
24105 const { elements, isLoading } = useElements({
24106 elements: field.elements,
24107 getElements: field.getElements
24108 });
24109 if (isLoading) {
24110 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_components41.Spinner, {});
24111 }
24112 if (elements.length === 0) {
24113 return null;
24114 }
24115 const selectedOption = elements.find((el) => el.value === value);
24116 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24117 ValidatedToggleGroupControl,
24118 {
24119 required: !!field.isValid?.required,
24120 markWhenOptional,
24121 customValidity: getCustomValidity(isValid2, validity),
24122 __next40pxDefaultSize: true,
24123 isBlock: true,
24124 label: field.label,
24125 help: selectedOption?.description || field.description,
24126 onChange: onChangeControl,
24127 value,
24128 hideLabelFromVision,
24129 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24130 import_components41.__experimentalToggleGroupControlOption,
24131 {
24132 label: el.label,
24133 value: el.value,
24134 disabled: disabled2
24135 },
24136 el.value
24137 ))
24138 }
24139 );
24140 }
24141
24142 // packages/dataviews/build-module/components/dataform-controls/array.mjs
24143 var import_components42 = __toESM(require_components(), 1);
24144 var import_element75 = __toESM(require_element(), 1);
24145 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
24146 var { ValidatedFormTokenField } = unlock2(import_components42.privateApis);
24147 function ArrayControl({
24148 data,
24149 field,
24150 onChange,
24151 hideLabelFromVision,
24152 markWhenOptional,
24153 validity
24154 }) {
24155 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
24156 const value = getValue({ item: data });
24157 const disabled2 = field.isDisabled({ item: data, field });
24158 const { elements, isLoading } = useElements({
24159 elements: field.elements,
24160 getElements: field.getElements
24161 });
24162 const arrayValueAsElements = (0, import_element75.useMemo)(
24163 () => Array.isArray(value) ? value.map((token) => {
24164 const element = elements?.find(
24165 (suggestion) => suggestion.value === token
24166 );
24167 return element || { value: token, label: token };
24168 }) : [],
24169 [value, elements]
24170 );
24171 const onChangeControl = (0, import_element75.useCallback)(
24172 (tokens) => {
24173 const valueTokens = tokens.map((token) => {
24174 if (typeof token === "object" && "value" in token) {
24175 return token.value;
24176 }
24177 return token;
24178 });
24179 onChange(setValue({ item: data, value: valueTokens }));
24180 },
24181 [onChange, setValue, data]
24182 );
24183 if (isLoading) {
24184 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_components42.Spinner, {});
24185 }
24186 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
24187 ValidatedFormTokenField,
24188 {
24189 required: !!isValid2?.required,
24190 markWhenOptional,
24191 customValidity: getCustomValidity(isValid2, validity),
24192 label: hideLabelFromVision ? void 0 : label,
24193 value: arrayValueAsElements,
24194 onChange: onChangeControl,
24195 placeholder,
24196 suggestions: elements?.map((element) => element.value),
24197 disabled: disabled2,
24198 __experimentalValidateInput: (token) => {
24199 if (field.isValid?.elements && elements) {
24200 return elements.some(
24201 (element) => element.value === token || element.label === token
24202 );
24203 }
24204 return true;
24205 },
24206 __experimentalExpandOnFocus: elements && elements.length > 0,
24207 help: description ?? (field.isValid?.elements ? "" : void 0),
24208 displayTransform: (token) => {
24209 if (typeof token === "object" && "label" in token) {
24210 return token.label;
24211 }
24212 if (typeof token === "string" && elements) {
24213 const element = elements.find(
24214 (el) => el.value === token
24215 );
24216 return element?.label || token;
24217 }
24218 return token;
24219 },
24220 __experimentalRenderItem: ({ item }) => {
24221 if (typeof item === "string" && elements) {
24222 const element = elements.find(
24223 (el) => el.value === item
24224 );
24225 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("span", { children: element?.label || item });
24226 }
24227 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("span", { children: item });
24228 }
24229 }
24230 );
24231 }
24232
24233 // node_modules/colord/index.mjs
24234 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
24235 var t = function(r3) {
24236 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
24237 };
24238 var n = function(r3, t2, n2) {
24239 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
24240 };
24241 var e = function(r3, t2, n2) {
24242 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
24243 };
24244 var u = function(r3) {
24245 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
24246 };
24247 var a = function(r3) {
24248 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
24249 };
24250 var o = function(r3) {
24251 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
24252 };
24253 var i = /^#([0-9a-f]{3,8})$/i;
24254 var s = function(r3) {
24255 var t2 = r3.toString(16);
24256 return t2.length < 2 ? "0" + t2 : t2;
24257 };
24258 var h = function(r3) {
24259 var t2 = r3.r, n2 = r3.g, e2 = r3.b, u2 = r3.a, a2 = Math.max(t2, n2, e2), o2 = a2 - Math.min(t2, n2, e2), i2 = o2 ? a2 === t2 ? (n2 - e2) / o2 : a2 === n2 ? 2 + (e2 - t2) / o2 : 4 + (t2 - n2) / o2 : 0;
24260 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
24261 };
24262 var b = function(r3) {
24263 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
24264 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
24265 var a2 = Math.floor(t2), o2 = e2 * (1 - n2), i2 = e2 * (1 - (t2 - a2) * n2), s2 = e2 * (1 - (1 - t2 + a2) * n2), h2 = a2 % 6;
24266 return { r: 255 * [e2, i2, o2, o2, s2, e2][h2], g: 255 * [s2, e2, e2, i2, o2, o2][h2], b: 255 * [o2, o2, s2, e2, e2, i2][h2], a: u2 };
24267 };
24268 var g = function(r3) {
24269 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
24270 };
24271 var d = function(r3) {
24272 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
24273 };
24274 var f = function(r3) {
24275 return b((n2 = (t2 = r3).s, { h: t2.h, s: (n2 *= ((e2 = t2.l) < 50 ? e2 : 100 - e2) / 100) > 0 ? 2 * n2 / (e2 + n2) * 100 : 0, v: e2 + n2, a: t2.a }));
24276 var t2, n2, e2;
24277 };
24278 var c = function(r3) {
24279 return { h: (t2 = h(r3)).h, s: (u2 = (200 - (n2 = t2.s)) * (e2 = t2.v) / 100) > 0 && u2 < 200 ? n2 * e2 / 100 / (u2 <= 100 ? u2 : 200 - u2) * 100 : 0, l: u2 / 2, a: t2.a };
24280 var t2, n2, e2, u2;
24281 };
24282 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24283 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24284 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24285 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24286 var y = { string: [[function(r3) {
24287 var t2 = i.exec(r3);
24288 return t2 ? (r3 = t2[1]).length <= 4 ? { r: parseInt(r3[0] + r3[0], 16), g: parseInt(r3[1] + r3[1], 16), b: parseInt(r3[2] + r3[2], 16), a: 4 === r3.length ? n(parseInt(r3[3] + r3[3], 16) / 255, 2) : 1 } : 6 === r3.length || 8 === r3.length ? { r: parseInt(r3.substr(0, 2), 16), g: parseInt(r3.substr(2, 2), 16), b: parseInt(r3.substr(4, 2), 16), a: 8 === r3.length ? n(parseInt(r3.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
24289 }, "hex"], [function(r3) {
24290 var t2 = v.exec(r3) || m.exec(r3);
24291 return t2 ? t2[2] !== t2[4] || t2[4] !== t2[6] ? null : a({ r: Number(t2[1]) / (t2[2] ? 100 / 255 : 1), g: Number(t2[3]) / (t2[4] ? 100 / 255 : 1), b: Number(t2[5]) / (t2[6] ? 100 / 255 : 1), a: void 0 === t2[7] ? 1 : Number(t2[7]) / (t2[8] ? 100 : 1) }) : null;
24292 }, "rgb"], [function(t2) {
24293 var n2 = l.exec(t2) || p.exec(t2);
24294 if (!n2) return null;
24295 var e2, u2, a2 = g({ h: (e2 = n2[1], u2 = n2[2], void 0 === u2 && (u2 = "deg"), Number(e2) * (r2[u2] || 1)), s: Number(n2[3]), l: Number(n2[4]), a: void 0 === n2[5] ? 1 : Number(n2[5]) / (n2[6] ? 100 : 1) });
24296 return f(a2);
24297 }, "hsl"]], object: [[function(r3) {
24298 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
24299 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
24300 }, "rgb"], [function(r3) {
24301 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
24302 if (!t(n2) || !t(e2) || !t(u2)) return null;
24303 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
24304 return f(i2);
24305 }, "hsl"], [function(r3) {
24306 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
24307 if (!t(n2) || !t(a2) || !t(o2)) return null;
24308 var h2 = (function(r4) {
24309 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
24310 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
24311 return b(h2);
24312 }, "hsv"]] };
24313 var N = function(r3, t2) {
24314 for (var n2 = 0; n2 < t2.length; n2++) {
24315 var e2 = t2[n2][0](r3);
24316 if (e2) return [e2, t2[n2][1]];
24317 }
24318 return [null, void 0];
24319 };
24320 var x = function(r3) {
24321 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
24322 };
24323 var M = function(r3, t2) {
24324 var n2 = c(r3);
24325 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
24326 };
24327 var H = function(r3) {
24328 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
24329 };
24330 var $ = function(r3, t2) {
24331 var n2 = c(r3);
24332 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
24333 };
24334 var j = (function() {
24335 function r3(r4) {
24336 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
24337 }
24338 return r3.prototype.isValid = function() {
24339 return null !== this.parsed;
24340 }, r3.prototype.brightness = function() {
24341 return n(H(this.rgba), 2);
24342 }, r3.prototype.isDark = function() {
24343 return H(this.rgba) < 0.5;
24344 }, r3.prototype.isLight = function() {
24345 return H(this.rgba) >= 0.5;
24346 }, r3.prototype.toHex = function() {
24347 return r4 = o(this.rgba), t2 = r4.r, e2 = r4.g, u2 = r4.b, i2 = (a2 = r4.a) < 1 ? s(n(255 * a2)) : "", "#" + s(t2) + s(e2) + s(u2) + i2;
24348 var r4, t2, e2, u2, a2, i2;
24349 }, r3.prototype.toRgb = function() {
24350 return o(this.rgba);
24351 }, r3.prototype.toRgbString = function() {
24352 return r4 = o(this.rgba), t2 = r4.r, n2 = r4.g, e2 = r4.b, (u2 = r4.a) < 1 ? "rgba(" + t2 + ", " + n2 + ", " + e2 + ", " + u2 + ")" : "rgb(" + t2 + ", " + n2 + ", " + e2 + ")";
24353 var r4, t2, n2, e2, u2;
24354 }, r3.prototype.toHsl = function() {
24355 return d(c(this.rgba));
24356 }, r3.prototype.toHslString = function() {
24357 return r4 = d(c(this.rgba)), t2 = r4.h, n2 = r4.s, e2 = r4.l, (u2 = r4.a) < 1 ? "hsla(" + t2 + ", " + n2 + "%, " + e2 + "%, " + u2 + ")" : "hsl(" + t2 + ", " + n2 + "%, " + e2 + "%)";
24358 var r4, t2, n2, e2, u2;
24359 }, r3.prototype.toHsv = function() {
24360 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
24361 var r4;
24362 }, r3.prototype.invert = function() {
24363 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
24364 var r4;
24365 }, r3.prototype.saturate = function(r4) {
24366 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
24367 }, r3.prototype.desaturate = function(r4) {
24368 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
24369 }, r3.prototype.grayscale = function() {
24370 return w(M(this.rgba, -1));
24371 }, r3.prototype.lighten = function(r4) {
24372 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
24373 }, r3.prototype.darken = function(r4) {
24374 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
24375 }, r3.prototype.rotate = function(r4) {
24376 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
24377 }, r3.prototype.alpha = function(r4) {
24378 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
24379 var t2;
24380 }, r3.prototype.hue = function(r4) {
24381 var t2 = c(this.rgba);
24382 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
24383 }, r3.prototype.isEqual = function(r4) {
24384 return this.toHex() === w(r4).toHex();
24385 }, r3;
24386 })();
24387 var w = function(r3) {
24388 return r3 instanceof j ? r3 : new j(r3);
24389 };
24390
24391 // packages/dataviews/build-module/components/dataform-controls/color.mjs
24392 var import_components43 = __toESM(require_components(), 1);
24393 var import_element76 = __toESM(require_element(), 1);
24394 var import_i18n36 = __toESM(require_i18n(), 1);
24395 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
24396 var { ValidatedInputControl: ValidatedInputControl3 } = unlock2(import_components43.privateApis);
24397 var ColorPickerDropdown = ({
24398 color,
24399 onColorChange,
24400 disabled: disabled2
24401 }) => {
24402 const validColor = color && w(color).isValid() ? color : "#ffffff";
24403 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24404 import_components43.Dropdown,
24405 {
24406 className: "dataviews-controls__color-picker-dropdown",
24407 popoverProps: { resize: false },
24408 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24409 import_components43.Button,
24410 {
24411 onClick: onToggle,
24412 "aria-label": (0, import_i18n36.__)("Open color picker"),
24413 size: "small",
24414 disabled: disabled2,
24415 accessibleWhenDisabled: true,
24416 icon: () => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_components43.ColorIndicator, { colorValue: validColor })
24417 }
24418 ),
24419 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_components43.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24420 import_components43.ColorPicker,
24421 {
24422 color: validColor,
24423 onChange: onColorChange,
24424 enableAlpha: true
24425 }
24426 ) })
24427 }
24428 );
24429 };
24430 function Color({
24431 data,
24432 field,
24433 onChange,
24434 hideLabelFromVision,
24435 markWhenOptional,
24436 validity
24437 }) {
24438 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
24439 const disabled2 = field.isDisabled({ item: data, field });
24440 const value = field.getValue({ item: data }) || "";
24441 const handleColorChange = (0, import_element76.useCallback)(
24442 (newColor) => {
24443 onChange(setValue({ item: data, value: newColor }));
24444 },
24445 [data, onChange, setValue]
24446 );
24447 const handleInputChange = (0, import_element76.useCallback)(
24448 (newValue) => {
24449 onChange(setValue({ item: data, value: newValue || "" }));
24450 },
24451 [data, onChange, setValue]
24452 );
24453 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24454 ValidatedInputControl3,
24455 {
24456 required: !!field.isValid?.required,
24457 markWhenOptional,
24458 customValidity: getCustomValidity(isValid2, validity),
24459 label,
24460 placeholder,
24461 value,
24462 help: description,
24463 onChange: handleInputChange,
24464 hideLabelFromVision,
24465 type: "text",
24466 disabled: disabled2,
24467 prefix: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_components43.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24468 ColorPickerDropdown,
24469 {
24470 color: value,
24471 onColorChange: handleColorChange,
24472 disabled: disabled2
24473 }
24474 ) })
24475 }
24476 );
24477 }
24478
24479 // packages/dataviews/build-module/components/dataform-controls/password.mjs
24480 var import_components44 = __toESM(require_components(), 1);
24481 var import_element77 = __toESM(require_element(), 1);
24482 var import_i18n37 = __toESM(require_i18n(), 1);
24483 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
24484 function Password({
24485 data,
24486 field,
24487 onChange,
24488 hideLabelFromVision,
24489 markWhenOptional,
24490 validity
24491 }) {
24492 const [isVisible2, setIsVisible] = (0, import_element77.useState)(false);
24493 const disabled2 = field.isDisabled({ item: data, field });
24494 const toggleVisibility = (0, import_element77.useCallback)(() => {
24495 setIsVisible((prev) => !prev);
24496 }, []);
24497 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24498 ValidatedText,
24499 {
24500 ...{
24501 data,
24502 field,
24503 onChange,
24504 hideLabelFromVision,
24505 markWhenOptional,
24506 validity,
24507 type: isVisible2 ? "text" : "password",
24508 suffix: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_components44.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24509 import_components44.Button,
24510 {
24511 icon: isVisible2 ? unseen_default : seen_default,
24512 onClick: toggleVisibility,
24513 size: "small",
24514 label: isVisible2 ? (0, import_i18n37.__)("Hide password") : (0, import_i18n37.__)("Show password"),
24515 disabled: disabled2,
24516 accessibleWhenDisabled: true
24517 }
24518 ) })
24519 }
24520 }
24521 );
24522 }
24523
24524 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
24525 function hasElements(field) {
24526 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
24527 }
24528
24529 // packages/dataviews/build-module/components/dataform-controls/index.mjs
24530 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
24531 var FORM_CONTROLS = {
24532 adaptiveSelect: AdaptiveSelect,
24533 array: ArrayControl,
24534 checkbox: Checkbox,
24535 color: Color,
24536 combobox: Combobox3,
24537 datetime: DateTime,
24538 date: DateControl,
24539 email: Email,
24540 telephone: Telephone,
24541 url: Url,
24542 integer: Integer,
24543 number: Number2,
24544 password: Password,
24545 radio: Radio,
24546 select: Select,
24547 text: Text3,
24548 toggle: Toggle,
24549 textarea: Textarea,
24550 toggleGroup: ToggleGroup
24551 };
24552 function isEditConfig(value) {
24553 return value && typeof value === "object" && typeof value.control === "string";
24554 }
24555 function createConfiguredControl(config) {
24556 const { control, ...controlConfig } = config;
24557 const BaseControlType = getControlByType(control);
24558 if (BaseControlType === null) {
24559 return null;
24560 }
24561 return function ConfiguredControl(props) {
24562 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(BaseControlType, { ...props, config: controlConfig });
24563 };
24564 }
24565 function getControl(field, fallback) {
24566 if (typeof field.Edit === "function") {
24567 return field.Edit;
24568 }
24569 if (typeof field.Edit === "string") {
24570 return getControlByType(field.Edit);
24571 }
24572 if (isEditConfig(field.Edit)) {
24573 return createConfiguredControl(field.Edit);
24574 }
24575 if (hasElements(field) && field.type !== "array") {
24576 return getControlByType("adaptiveSelect");
24577 }
24578 if (fallback === null) {
24579 return null;
24580 }
24581 return getControlByType(fallback);
24582 }
24583 function getControlByType(type) {
24584 if (Object.keys(FORM_CONTROLS).includes(type)) {
24585 return FORM_CONTROLS[type];
24586 }
24587 return null;
24588 }
24589
24590 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
24591 function getFilterBy(field, defaultOperators, validOperators) {
24592 if (field.filterBy === false) {
24593 return false;
24594 }
24595 const operators = field.filterBy?.operators?.filter(
24596 (op) => validOperators.includes(op)
24597 ) ?? defaultOperators;
24598 if (operators.length === 0) {
24599 return false;
24600 }
24601 return {
24602 isPrimary: !!field.filterBy?.isPrimary,
24603 operators
24604 };
24605 }
24606 var get_filter_by_default = getFilterBy;
24607
24608 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
24609 var getValueFromId = (id) => ({ item }) => {
24610 const path = id.split(".");
24611 let value = item;
24612 for (const segment of path) {
24613 if (value.hasOwnProperty(segment)) {
24614 value = value[segment];
24615 } else {
24616 value = void 0;
24617 }
24618 }
24619 return value;
24620 };
24621 var get_value_from_id_default = getValueFromId;
24622
24623 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
24624 var setValueFromId = (id) => ({ value }) => {
24625 const path = id.split(".");
24626 const result = {};
24627 let current = result;
24628 for (const segment of path.slice(0, -1)) {
24629 current[segment] = {};
24630 current = current[segment];
24631 }
24632 current[path.at(-1)] = value;
24633 return result;
24634 };
24635 var set_value_from_id_default = setValueFromId;
24636
24637 // packages/dataviews/build-module/field-types/email.mjs
24638 var import_i18n38 = __toESM(require_i18n(), 1);
24639
24640 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
24641 function RenderFromElements({
24642 item,
24643 field
24644 }) {
24645 const { elements, isLoading } = useElements({
24646 elements: field.elements,
24647 getElements: field.getElements
24648 });
24649 const value = field.getValue({ item });
24650 if (isLoading) {
24651 return value;
24652 }
24653 if (elements.length === 0) {
24654 return value;
24655 }
24656 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
24657 }
24658
24659 // packages/dataviews/build-module/field-types/utils/render-default.mjs
24660 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
24661 function render({
24662 item,
24663 field
24664 }) {
24665 if (field.hasElements) {
24666 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(RenderFromElements, { item, field });
24667 }
24668 return field.getValueFormatted({ item, field });
24669 }
24670
24671 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
24672 var sort_text_default = (a2, b2, direction) => {
24673 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
24674 };
24675
24676 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
24677 function isValidRequired(item, field) {
24678 const value = field.getValue({ item });
24679 return ![void 0, "", null].includes(value);
24680 }
24681
24682 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
24683 function isValidMinLength(item, field) {
24684 if (typeof field.isValid.minLength?.constraint !== "number") {
24685 return false;
24686 }
24687 const value = field.getValue({ item });
24688 if ([void 0, "", null].includes(value)) {
24689 return true;
24690 }
24691 return String(value).length >= field.isValid.minLength.constraint;
24692 }
24693
24694 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
24695 function isValidMaxLength(item, field) {
24696 if (typeof field.isValid.maxLength?.constraint !== "number") {
24697 return false;
24698 }
24699 const value = field.getValue({ item });
24700 if ([void 0, "", null].includes(value)) {
24701 return true;
24702 }
24703 return String(value).length <= field.isValid.maxLength.constraint;
24704 }
24705
24706 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
24707 function isValidPattern(item, field) {
24708 if (field.isValid.pattern?.constraint === void 0) {
24709 return true;
24710 }
24711 try {
24712 const regexp = new RegExp(field.isValid.pattern.constraint);
24713 const value = field.getValue({ item });
24714 if ([void 0, "", null].includes(value)) {
24715 return true;
24716 }
24717 return regexp.test(String(value));
24718 } catch {
24719 return false;
24720 }
24721 }
24722
24723 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
24724 function isValidElements(item, field) {
24725 const elements = field.elements ?? [];
24726 const validValues = elements.map((el) => el.value);
24727 if (validValues.length === 0) {
24728 return true;
24729 }
24730 const value = field.getValue({ item });
24731 return [].concat(value).every((v2) => validValues.includes(v2));
24732 }
24733
24734 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
24735 function getValueFormatted({
24736 item,
24737 field
24738 }) {
24739 return field.getValue({ item });
24740 }
24741 var get_value_formatted_default_default = getValueFormatted;
24742
24743 // packages/dataviews/build-module/field-types/email.mjs
24744 var emailRegex = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
24745 function isValidCustom(item, field) {
24746 const value = field.getValue({ item });
24747 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
24748 return (0, import_i18n38.__)("Value must be a valid email address.");
24749 }
24750 return null;
24751 }
24752 var email_default = {
24753 type: "email",
24754 render,
24755 Edit: "email",
24756 sort: sort_text_default,
24757 enableSorting: true,
24758 enableGlobalSearch: false,
24759 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24760 validOperators: [
24761 OPERATOR_IS,
24762 OPERATOR_IS_NOT,
24763 OPERATOR_CONTAINS,
24764 OPERATOR_NOT_CONTAINS,
24765 OPERATOR_STARTS_WITH,
24766 // Multiple selection
24767 OPERATOR_IS_ANY,
24768 OPERATOR_IS_NONE,
24769 OPERATOR_IS_ALL,
24770 OPERATOR_IS_NOT_ALL
24771 ],
24772 format: {},
24773 getValueFormatted: get_value_formatted_default_default,
24774 validate: {
24775 required: isValidRequired,
24776 pattern: isValidPattern,
24777 minLength: isValidMinLength,
24778 maxLength: isValidMaxLength,
24779 elements: isValidElements,
24780 custom: isValidCustom
24781 }
24782 };
24783
24784 // packages/dataviews/build-module/field-types/integer.mjs
24785 var import_i18n39 = __toESM(require_i18n(), 1);
24786
24787 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
24788 var sort_number_default = (a2, b2, direction) => {
24789 return direction === "asc" ? a2 - b2 : b2 - a2;
24790 };
24791
24792 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
24793 function isValidMin(item, field) {
24794 if (typeof field.isValid.min?.constraint !== "number") {
24795 return false;
24796 }
24797 const value = field.getValue({ item });
24798 if ([void 0, "", null].includes(value)) {
24799 return true;
24800 }
24801 return Number(value) >= field.isValid.min.constraint;
24802 }
24803
24804 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
24805 function isValidMax(item, field) {
24806 if (typeof field.isValid.max?.constraint !== "number") {
24807 return false;
24808 }
24809 const value = field.getValue({ item });
24810 if ([void 0, "", null].includes(value)) {
24811 return true;
24812 }
24813 return Number(value) <= field.isValid.max.constraint;
24814 }
24815
24816 // packages/dataviews/build-module/field-types/integer.mjs
24817 var format2 = {
24818 separatorThousand: ","
24819 };
24820 function getValueFormatted2({
24821 item,
24822 field
24823 }) {
24824 let value = field.getValue({ item });
24825 if (value === null || value === void 0) {
24826 return "";
24827 }
24828 value = Number(value);
24829 if (!Number.isFinite(value)) {
24830 return String(value);
24831 }
24832 let formatInteger;
24833 if (field.type !== "integer") {
24834 formatInteger = format2;
24835 } else {
24836 formatInteger = field.format;
24837 }
24838 const { separatorThousand } = formatInteger;
24839 const integerValue = Math.trunc(value);
24840 if (!separatorThousand) {
24841 return String(integerValue);
24842 }
24843 return String(integerValue).replace(
24844 /\B(?=(\d{3})+(?!\d))/g,
24845 separatorThousand
24846 );
24847 }
24848 function isValidCustom2(item, field) {
24849 const value = field.getValue({ item });
24850 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
24851 return (0, import_i18n39.__)("Value must be an integer.");
24852 }
24853 return null;
24854 }
24855 var integer_default = {
24856 type: "integer",
24857 render,
24858 Edit: "integer",
24859 sort: sort_number_default,
24860 enableSorting: true,
24861 enableGlobalSearch: false,
24862 defaultOperators: [
24863 OPERATOR_IS,
24864 OPERATOR_IS_NOT,
24865 OPERATOR_LESS_THAN,
24866 OPERATOR_GREATER_THAN,
24867 OPERATOR_LESS_THAN_OR_EQUAL,
24868 OPERATOR_GREATER_THAN_OR_EQUAL,
24869 OPERATOR_BETWEEN
24870 ],
24871 validOperators: [
24872 // Single-selection
24873 OPERATOR_IS,
24874 OPERATOR_IS_NOT,
24875 OPERATOR_LESS_THAN,
24876 OPERATOR_GREATER_THAN,
24877 OPERATOR_LESS_THAN_OR_EQUAL,
24878 OPERATOR_GREATER_THAN_OR_EQUAL,
24879 OPERATOR_BETWEEN,
24880 // Multiple-selection
24881 OPERATOR_IS_ANY,
24882 OPERATOR_IS_NONE,
24883 OPERATOR_IS_ALL,
24884 OPERATOR_IS_NOT_ALL
24885 ],
24886 format: format2,
24887 getValueFormatted: getValueFormatted2,
24888 validate: {
24889 required: isValidRequired,
24890 min: isValidMin,
24891 max: isValidMax,
24892 elements: isValidElements,
24893 custom: isValidCustom2
24894 }
24895 };
24896
24897 // packages/dataviews/build-module/field-types/number.mjs
24898 var import_i18n40 = __toESM(require_i18n(), 1);
24899 var format3 = {
24900 separatorThousand: ",",
24901 separatorDecimal: ".",
24902 decimals: 2
24903 };
24904 function getValueFormatted3({
24905 item,
24906 field
24907 }) {
24908 let value = field.getValue({ item });
24909 if (value === null || value === void 0) {
24910 return "";
24911 }
24912 value = Number(value);
24913 if (!Number.isFinite(value)) {
24914 return String(value);
24915 }
24916 let formatNumber;
24917 if (field.type !== "number") {
24918 formatNumber = format3;
24919 } else {
24920 formatNumber = field.format;
24921 }
24922 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
24923 const fixedValue = value.toFixed(decimals);
24924 const [integerPart, decimalPart] = fixedValue.split(".");
24925 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
24926 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
24927 }
24928 function isEmpty2(value) {
24929 return value === "" || value === void 0 || value === null;
24930 }
24931 function isValidCustom3(item, field) {
24932 const value = field.getValue({ item });
24933 if (!isEmpty2(value) && !Number.isFinite(value)) {
24934 return (0, import_i18n40.__)("Value must be a number.");
24935 }
24936 return null;
24937 }
24938 var number_default = {
24939 type: "number",
24940 render,
24941 Edit: "number",
24942 sort: sort_number_default,
24943 enableSorting: true,
24944 enableGlobalSearch: false,
24945 defaultOperators: [
24946 OPERATOR_IS,
24947 OPERATOR_IS_NOT,
24948 OPERATOR_LESS_THAN,
24949 OPERATOR_GREATER_THAN,
24950 OPERATOR_LESS_THAN_OR_EQUAL,
24951 OPERATOR_GREATER_THAN_OR_EQUAL,
24952 OPERATOR_BETWEEN
24953 ],
24954 validOperators: [
24955 // Single-selection
24956 OPERATOR_IS,
24957 OPERATOR_IS_NOT,
24958 OPERATOR_LESS_THAN,
24959 OPERATOR_GREATER_THAN,
24960 OPERATOR_LESS_THAN_OR_EQUAL,
24961 OPERATOR_GREATER_THAN_OR_EQUAL,
24962 OPERATOR_BETWEEN,
24963 // Multiple-selection
24964 OPERATOR_IS_ANY,
24965 OPERATOR_IS_NONE,
24966 OPERATOR_IS_ALL,
24967 OPERATOR_IS_NOT_ALL
24968 ],
24969 format: format3,
24970 getValueFormatted: getValueFormatted3,
24971 validate: {
24972 required: isValidRequired,
24973 min: isValidMin,
24974 max: isValidMax,
24975 elements: isValidElements,
24976 custom: isValidCustom3
24977 }
24978 };
24979
24980 // packages/dataviews/build-module/field-types/text.mjs
24981 var text_default = {
24982 type: "text",
24983 render,
24984 Edit: "text",
24985 sort: sort_text_default,
24986 enableSorting: true,
24987 enableGlobalSearch: false,
24988 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24989 validOperators: [
24990 // Single selection
24991 OPERATOR_IS,
24992 OPERATOR_IS_NOT,
24993 OPERATOR_CONTAINS,
24994 OPERATOR_NOT_CONTAINS,
24995 OPERATOR_STARTS_WITH,
24996 // Multiple selection
24997 OPERATOR_IS_ANY,
24998 OPERATOR_IS_NONE,
24999 OPERATOR_IS_ALL,
25000 OPERATOR_IS_NOT_ALL
25001 ],
25002 format: {},
25003 getValueFormatted: get_value_formatted_default_default,
25004 validate: {
25005 required: isValidRequired,
25006 pattern: isValidPattern,
25007 minLength: isValidMinLength,
25008 maxLength: isValidMaxLength,
25009 elements: isValidElements
25010 }
25011 };
25012
25013 // packages/dataviews/build-module/field-types/datetime.mjs
25014 var import_date7 = __toESM(require_date(), 1);
25015
25016 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
25017 var import_date6 = __toESM(require_date(), 1);
25018 function parseDateLike(value) {
25019 if (!value) {
25020 return null;
25021 }
25022 if (!isValid(new Date(value))) {
25023 return null;
25024 }
25025 const parsed = (0, import_date6.getDate)(value);
25026 return parsed && isValid(parsed) ? parsed : null;
25027 }
25028 function validateDateLikeBoundary(item, field, boundary) {
25029 const constraint = field.isValid[boundary]?.constraint;
25030 if (typeof constraint !== "string") {
25031 return false;
25032 }
25033 const value = field.getValue({ item });
25034 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
25035 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
25036 return true;
25037 }
25038 const parsedConstraint = parseDateLike(constraint);
25039 const parsedValue = parseDateLike(String(boundaryValue));
25040 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
25041 }
25042 function isValidMinDate(item, field) {
25043 return validateDateLikeBoundary(item, field, "min");
25044 }
25045 function isValidMaxDate(item, field) {
25046 return validateDateLikeBoundary(item, field, "max");
25047 }
25048
25049 // packages/dataviews/build-module/field-types/datetime.mjs
25050 var format4 = {
25051 datetime: (0, import_date7.getSettings)().formats.datetime,
25052 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
25053 };
25054 function getValueFormatted4({
25055 item,
25056 field
25057 }) {
25058 const value = field.getValue({ item });
25059 if (["", void 0, null].includes(value)) {
25060 return "";
25061 }
25062 let formatDatetime;
25063 if (field.type !== "datetime") {
25064 formatDatetime = format4;
25065 } else {
25066 formatDatetime = field.format;
25067 }
25068 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
25069 }
25070 var sort = (a2, b2, direction) => {
25071 const timeA = new Date(a2).getTime();
25072 const timeB = new Date(b2).getTime();
25073 return direction === "asc" ? timeA - timeB : timeB - timeA;
25074 };
25075 var datetime_default = {
25076 type: "datetime",
25077 render,
25078 Edit: "datetime",
25079 sort,
25080 enableSorting: true,
25081 enableGlobalSearch: false,
25082 defaultOperators: [
25083 OPERATOR_ON,
25084 OPERATOR_NOT_ON,
25085 OPERATOR_BEFORE,
25086 OPERATOR_AFTER,
25087 OPERATOR_BEFORE_INC,
25088 OPERATOR_AFTER_INC,
25089 OPERATOR_IN_THE_PAST,
25090 OPERATOR_OVER
25091 ],
25092 validOperators: [
25093 OPERATOR_ON,
25094 OPERATOR_NOT_ON,
25095 OPERATOR_BEFORE,
25096 OPERATOR_AFTER,
25097 OPERATOR_BEFORE_INC,
25098 OPERATOR_AFTER_INC,
25099 OPERATOR_IN_THE_PAST,
25100 OPERATOR_OVER
25101 ],
25102 format: format4,
25103 getValueFormatted: getValueFormatted4,
25104 validate: {
25105 required: isValidRequired,
25106 elements: isValidElements,
25107 min: isValidMinDate,
25108 max: isValidMaxDate
25109 }
25110 };
25111
25112 // packages/dataviews/build-module/field-types/date.mjs
25113 var import_date8 = __toESM(require_date(), 1);
25114 var format5 = {
25115 date: (0, import_date8.getSettings)().formats.date,
25116 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
25117 };
25118 function getValueFormatted5({
25119 item,
25120 field
25121 }) {
25122 const value = field.getValue({ item });
25123 if (["", void 0, null].includes(value)) {
25124 return "";
25125 }
25126 let formatDate2;
25127 if (field.type !== "date") {
25128 formatDate2 = format5;
25129 } else {
25130 formatDate2 = field.format;
25131 }
25132 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
25133 }
25134 var sort2 = (a2, b2, direction) => {
25135 const timeA = new Date(a2).getTime();
25136 const timeB = new Date(b2).getTime();
25137 return direction === "asc" ? timeA - timeB : timeB - timeA;
25138 };
25139 var date_default = {
25140 type: "date",
25141 render,
25142 Edit: "date",
25143 sort: sort2,
25144 enableSorting: true,
25145 enableGlobalSearch: false,
25146 defaultOperators: [
25147 OPERATOR_ON,
25148 OPERATOR_NOT_ON,
25149 OPERATOR_BEFORE,
25150 OPERATOR_AFTER,
25151 OPERATOR_BEFORE_INC,
25152 OPERATOR_AFTER_INC,
25153 OPERATOR_IN_THE_PAST,
25154 OPERATOR_OVER,
25155 OPERATOR_BETWEEN
25156 ],
25157 validOperators: [
25158 OPERATOR_ON,
25159 OPERATOR_NOT_ON,
25160 OPERATOR_BEFORE,
25161 OPERATOR_AFTER,
25162 OPERATOR_BEFORE_INC,
25163 OPERATOR_AFTER_INC,
25164 OPERATOR_IN_THE_PAST,
25165 OPERATOR_OVER,
25166 OPERATOR_BETWEEN
25167 ],
25168 format: format5,
25169 getValueFormatted: getValueFormatted5,
25170 validate: {
25171 required: isValidRequired,
25172 elements: isValidElements,
25173 min: isValidMinDate,
25174 max: isValidMaxDate
25175 }
25176 };
25177
25178 // packages/dataviews/build-module/field-types/boolean.mjs
25179 var import_i18n41 = __toESM(require_i18n(), 1);
25180
25181 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
25182 function isValidRequiredForBool(item, field) {
25183 const value = field.getValue({ item });
25184 return value === true;
25185 }
25186
25187 // packages/dataviews/build-module/field-types/boolean.mjs
25188 function getValueFormatted6({
25189 item,
25190 field
25191 }) {
25192 const value = field.getValue({ item });
25193 if (value === true) {
25194 return (0, import_i18n41.__)("True");
25195 }
25196 if (value === false) {
25197 return (0, import_i18n41.__)("False");
25198 }
25199 return "";
25200 }
25201 function isValidCustom4(item, field) {
25202 const value = field.getValue({ item });
25203 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
25204 return (0, import_i18n41.__)("Value must be true, false, or undefined");
25205 }
25206 return null;
25207 }
25208 var sort3 = (a2, b2, direction) => {
25209 const boolA = Boolean(a2);
25210 const boolB = Boolean(b2);
25211 if (boolA === boolB) {
25212 return 0;
25213 }
25214 if (direction === "asc") {
25215 return boolA ? 1 : -1;
25216 }
25217 return boolA ? -1 : 1;
25218 };
25219 var boolean_default = {
25220 type: "boolean",
25221 render,
25222 Edit: "checkbox",
25223 sort: sort3,
25224 validate: {
25225 required: isValidRequiredForBool,
25226 elements: isValidElements,
25227 custom: isValidCustom4
25228 },
25229 enableSorting: true,
25230 enableGlobalSearch: false,
25231 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25232 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25233 format: {},
25234 getValueFormatted: getValueFormatted6
25235 };
25236
25237 // packages/dataviews/build-module/field-types/media.mjs
25238 var media_default = {
25239 type: "media",
25240 render: () => null,
25241 Edit: null,
25242 sort: () => 0,
25243 enableSorting: false,
25244 enableGlobalSearch: false,
25245 defaultOperators: [],
25246 validOperators: [],
25247 format: {},
25248 getValueFormatted: get_value_formatted_default_default,
25249 // cannot validate any constraint, so
25250 // the only available validation for the field author
25251 // would be providing a custom validator.
25252 validate: {}
25253 };
25254
25255 // packages/dataviews/build-module/field-types/array.mjs
25256 var import_i18n42 = __toESM(require_i18n(), 1);
25257
25258 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
25259 function isValidRequiredForArray(item, field) {
25260 const value = field.getValue({ item });
25261 return Array.isArray(value) && value.length > 0 && value.every(
25262 (element) => ![void 0, "", null].includes(element)
25263 );
25264 }
25265
25266 // packages/dataviews/build-module/field-types/array.mjs
25267 function getValueFormatted7({
25268 item,
25269 field
25270 }) {
25271 const value = field.getValue({ item });
25272 const arr = Array.isArray(value) ? value : [];
25273 return arr.join(", ");
25274 }
25275 function render2({ item, field }) {
25276 return getValueFormatted7({ item, field });
25277 }
25278 function isValidCustom5(item, field) {
25279 const value = field.getValue({ item });
25280 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
25281 return (0, import_i18n42.__)("Value must be an array.");
25282 }
25283 if (!value.every((v2) => typeof v2 === "string")) {
25284 return (0, import_i18n42.__)("Every value must be a string.");
25285 }
25286 return null;
25287 }
25288 var sort4 = (a2, b2, direction) => {
25289 const arrA = Array.isArray(a2) ? a2 : [];
25290 const arrB = Array.isArray(b2) ? b2 : [];
25291 if (arrA.length !== arrB.length) {
25292 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
25293 }
25294 const joinedA = arrA.join(",");
25295 const joinedB = arrB.join(",");
25296 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
25297 };
25298 var array_default = {
25299 type: "array",
25300 render: render2,
25301 Edit: "array",
25302 sort: sort4,
25303 enableSorting: true,
25304 enableGlobalSearch: false,
25305 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25306 validOperators: [
25307 OPERATOR_IS_ANY,
25308 OPERATOR_IS_NONE,
25309 OPERATOR_IS_ALL,
25310 OPERATOR_IS_NOT_ALL
25311 ],
25312 format: {},
25313 getValueFormatted: getValueFormatted7,
25314 validate: {
25315 required: isValidRequiredForArray,
25316 elements: isValidElements,
25317 custom: isValidCustom5
25318 }
25319 };
25320
25321 // packages/dataviews/build-module/field-types/password.mjs
25322 function getValueFormatted8({
25323 item,
25324 field
25325 }) {
25326 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
25327 }
25328 var password_default = {
25329 type: "password",
25330 render,
25331 Edit: "password",
25332 sort: () => 0,
25333 // Passwords should not be sortable for security reasons
25334 enableSorting: false,
25335 enableGlobalSearch: false,
25336 defaultOperators: [],
25337 validOperators: [],
25338 format: {},
25339 getValueFormatted: getValueFormatted8,
25340 validate: {
25341 required: isValidRequired,
25342 pattern: isValidPattern,
25343 minLength: isValidMinLength,
25344 maxLength: isValidMaxLength,
25345 elements: isValidElements
25346 }
25347 };
25348
25349 // packages/dataviews/build-module/field-types/telephone.mjs
25350 var telephone_default = {
25351 type: "telephone",
25352 render,
25353 Edit: "telephone",
25354 sort: sort_text_default,
25355 enableSorting: true,
25356 enableGlobalSearch: false,
25357 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25358 validOperators: [
25359 OPERATOR_IS,
25360 OPERATOR_IS_NOT,
25361 OPERATOR_CONTAINS,
25362 OPERATOR_NOT_CONTAINS,
25363 OPERATOR_STARTS_WITH,
25364 // Multiple selection
25365 OPERATOR_IS_ANY,
25366 OPERATOR_IS_NONE,
25367 OPERATOR_IS_ALL,
25368 OPERATOR_IS_NOT_ALL
25369 ],
25370 format: {},
25371 getValueFormatted: get_value_formatted_default_default,
25372 validate: {
25373 required: isValidRequired,
25374 pattern: isValidPattern,
25375 minLength: isValidMinLength,
25376 maxLength: isValidMaxLength,
25377 elements: isValidElements
25378 }
25379 };
25380
25381 // packages/dataviews/build-module/field-types/color.mjs
25382 var import_i18n43 = __toESM(require_i18n(), 1);
25383 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
25384 function render3({ item, field }) {
25385 if (field.hasElements) {
25386 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(RenderFromElements, { item, field });
25387 }
25388 const value = get_value_formatted_default_default({ item, field });
25389 if (!value || !w(value).isValid()) {
25390 return value;
25391 }
25392 return /* @__PURE__ */ (0, import_jsx_runtime115.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
25393 /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
25394 "div",
25395 {
25396 style: {
25397 width: "16px",
25398 height: "16px",
25399 borderRadius: "50%",
25400 backgroundColor: value,
25401 border: "1px solid #ddd",
25402 flexShrink: 0
25403 }
25404 }
25405 ),
25406 /* @__PURE__ */ (0, import_jsx_runtime115.jsx)("span", { children: value })
25407 ] });
25408 }
25409 function isValidCustom6(item, field) {
25410 const value = field.getValue({ item });
25411 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
25412 return (0, import_i18n43.__)("Value must be a valid color.");
25413 }
25414 return null;
25415 }
25416 var sort5 = (a2, b2, direction) => {
25417 const colorA = w(a2);
25418 const colorB = w(b2);
25419 if (!colorA.isValid() && !colorB.isValid()) {
25420 return 0;
25421 }
25422 if (!colorA.isValid()) {
25423 return direction === "asc" ? 1 : -1;
25424 }
25425 if (!colorB.isValid()) {
25426 return direction === "asc" ? -1 : 1;
25427 }
25428 const hslA = colorA.toHsl();
25429 const hslB = colorB.toHsl();
25430 if (hslA.h !== hslB.h) {
25431 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
25432 }
25433 if (hslA.s !== hslB.s) {
25434 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
25435 }
25436 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
25437 };
25438 var color_default = {
25439 type: "color",
25440 render: render3,
25441 Edit: "color",
25442 sort: sort5,
25443 enableSorting: true,
25444 enableGlobalSearch: false,
25445 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25446 validOperators: [
25447 OPERATOR_IS,
25448 OPERATOR_IS_NOT,
25449 OPERATOR_IS_ANY,
25450 OPERATOR_IS_NONE
25451 ],
25452 format: {},
25453 getValueFormatted: get_value_formatted_default_default,
25454 validate: {
25455 required: isValidRequired,
25456 elements: isValidElements,
25457 custom: isValidCustom6
25458 }
25459 };
25460
25461 // packages/dataviews/build-module/field-types/url.mjs
25462 var url_default = {
25463 type: "url",
25464 render,
25465 Edit: "url",
25466 sort: sort_text_default,
25467 enableSorting: true,
25468 enableGlobalSearch: false,
25469 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25470 validOperators: [
25471 OPERATOR_IS,
25472 OPERATOR_IS_NOT,
25473 OPERATOR_CONTAINS,
25474 OPERATOR_NOT_CONTAINS,
25475 OPERATOR_STARTS_WITH,
25476 // Multiple selection
25477 OPERATOR_IS_ANY,
25478 OPERATOR_IS_NONE,
25479 OPERATOR_IS_ALL,
25480 OPERATOR_IS_NOT_ALL
25481 ],
25482 format: {},
25483 getValueFormatted: get_value_formatted_default_default,
25484 validate: {
25485 required: isValidRequired,
25486 pattern: isValidPattern,
25487 minLength: isValidMinLength,
25488 maxLength: isValidMaxLength,
25489 elements: isValidElements
25490 }
25491 };
25492
25493 // packages/dataviews/build-module/field-types/no-type.mjs
25494 var sort6 = (a2, b2, direction) => {
25495 if (typeof a2 === "number" && typeof b2 === "number") {
25496 return sort_number_default(a2, b2, direction);
25497 }
25498 return sort_text_default(a2, b2, direction);
25499 };
25500 var no_type_default = {
25501 // type: no type for this one
25502 render,
25503 Edit: null,
25504 sort: sort6,
25505 enableSorting: true,
25506 enableGlobalSearch: false,
25507 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25508 validOperators: getAllOperatorNames(),
25509 format: {},
25510 getValueFormatted: get_value_formatted_default_default,
25511 validate: {
25512 required: isValidRequired,
25513 elements: isValidElements
25514 }
25515 };
25516
25517 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
25518 function supportsNumericRangeConstraint(type) {
25519 return type === "integer" || type === "number";
25520 }
25521 function supportsDateRangeConstraint(type) {
25522 return type === "date" || type === "datetime";
25523 }
25524 function normalizeRangeRule(value, fieldType, key) {
25525 const validator = fieldType.validate[key];
25526 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
25527 return { constraint: value, validate: validator };
25528 }
25529 return void 0;
25530 }
25531 function getIsValid(field, fieldType) {
25532 const rules = field.isValid;
25533 let required;
25534 if (rules?.required === true && fieldType.validate.required !== void 0) {
25535 required = {
25536 constraint: true,
25537 validate: fieldType.validate.required
25538 };
25539 }
25540 let elements;
25541 if ((rules?.elements === true || // elements is enabled unless the field opts-out
25542 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
25543 elements = {
25544 constraint: true,
25545 validate: fieldType.validate.elements
25546 };
25547 }
25548 const min2 = normalizeRangeRule(rules?.min, fieldType, "min");
25549 const max2 = normalizeRangeRule(rules?.max, fieldType, "max");
25550 const minLengthValue = rules?.minLength;
25551 let minLength;
25552 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
25553 minLength = {
25554 constraint: minLengthValue,
25555 validate: fieldType.validate.minLength
25556 };
25557 }
25558 const maxLengthValue = rules?.maxLength;
25559 let maxLength;
25560 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
25561 maxLength = {
25562 constraint: maxLengthValue,
25563 validate: fieldType.validate.maxLength
25564 };
25565 }
25566 const patternValue = rules?.pattern;
25567 let pattern;
25568 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
25569 pattern = {
25570 constraint: patternValue,
25571 validate: fieldType.validate.pattern
25572 };
25573 }
25574 const custom = rules?.custom ?? fieldType.validate.custom;
25575 return {
25576 required,
25577 elements,
25578 min: min2,
25579 max: max2,
25580 minLength,
25581 maxLength,
25582 pattern,
25583 custom
25584 };
25585 }
25586
25587 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
25588 function getFilter(fieldType) {
25589 return fieldType.validOperators.reduce((accumulator, operator) => {
25590 const operatorObj = getOperatorByName(operator);
25591 if (operatorObj?.filter) {
25592 accumulator[operator] = operatorObj.filter;
25593 }
25594 return accumulator;
25595 }, {});
25596 }
25597
25598 // packages/dataviews/build-module/field-types/utils/get-format.mjs
25599 function getFormat(field, fieldType) {
25600 return {
25601 ...fieldType.format,
25602 ...field.format
25603 };
25604 }
25605 var get_format_default = getFormat;
25606
25607 // packages/dataviews/build-module/field-types/index.mjs
25608 function getFieldTypeByName(type) {
25609 const found = [
25610 email_default,
25611 integer_default,
25612 number_default,
25613 text_default,
25614 datetime_default,
25615 date_default,
25616 boolean_default,
25617 media_default,
25618 array_default,
25619 password_default,
25620 telephone_default,
25621 color_default,
25622 url_default
25623 ].find((fieldType) => fieldType?.type === type);
25624 if (!!found) {
25625 return found;
25626 }
25627 return no_type_default;
25628 }
25629 function normalizeFields(fields) {
25630 return fields.map((field) => {
25631 const fieldType = getFieldTypeByName(field.type);
25632 const getValue = field.getValue || get_value_from_id_default(field.id);
25633 const sort7 = function(a2, b2, direction) {
25634 const aValue = getValue({ item: a2 });
25635 const bValue = getValue({ item: b2 });
25636 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
25637 };
25638 return {
25639 id: field.id,
25640 label: field.label || field.id,
25641 header: field.header || field.label || field.id,
25642 description: field.description,
25643 placeholder: field.placeholder,
25644 getValue,
25645 setValue: field.setValue || set_value_from_id_default(field.id),
25646 elements: field.elements,
25647 getElements: field.getElements,
25648 hasElements: hasElements(field),
25649 isVisible: field.isVisible,
25650 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
25651 enableHiding: field.enableHiding ?? true,
25652 readOnly: field.readOnly ?? false,
25653 // The type provides defaults for the following props
25654 type: fieldType.type,
25655 render: field.render ?? fieldType.render,
25656 Edit: getControl(field, fieldType.Edit),
25657 sort: sort7,
25658 enableSorting: field.enableSorting ?? fieldType.enableSorting,
25659 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
25660 isValid: getIsValid(field, fieldType),
25661 filterBy: get_filter_by_default(
25662 field,
25663 fieldType.defaultOperators,
25664 fieldType.validOperators
25665 ),
25666 filter: getFilter(fieldType),
25667 format: get_format_default(field, fieldType),
25668 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
25669 };
25670 });
25671 }
25672
25673 // packages/dataviews/build-module/hooks/use-data.mjs
25674 var import_element78 = __toESM(require_element(), 1);
25675 function useData({
25676 view,
25677 data: shownData,
25678 getItemId,
25679 isLoading,
25680 paginationInfo,
25681 selection
25682 }) {
25683 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
25684 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element78.useState)(
25685 !isLoading
25686 );
25687 (0, import_element78.useEffect)(() => {
25688 if (!isLoading) {
25689 setHasInitiallyLoaded(true);
25690 }
25691 }, [isLoading]);
25692 const previousDataRef = (0, import_element78.useRef)(shownData);
25693 const previousPaginationInfoRef = (0, import_element78.useRef)(paginationInfo);
25694 (0, import_element78.useEffect)(() => {
25695 if (!isLoading) {
25696 previousDataRef.current = shownData;
25697 previousPaginationInfoRef.current = paginationInfo;
25698 }
25699 }, [shownData, isLoading, paginationInfo]);
25700 const [visibleEntries, setVisibleEntries] = (0, import_element78.useState)([]);
25701 const positionMapRef = (0, import_element78.useRef)(/* @__PURE__ */ new Map());
25702 const allLoadedRecordsRef = (0, import_element78.useRef)([]);
25703 const prevViewParamsRef = (0, import_element78.useRef)({
25704 search: void 0,
25705 filters: void 0,
25706 perPage: void 0
25707 });
25708 const scrollDirectionRef = (0, import_element78.useRef)(void 0);
25709 const prevStartPositionRef = (0, import_element78.useRef)(void 0);
25710 const hasInitializedRef = (0, import_element78.useRef)(false);
25711 const allLoadedRecords = (0, import_element78.useMemo)(() => {
25712 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
25713 if (view.startPosition < prevStartPositionRef.current) {
25714 scrollDirectionRef.current = "up";
25715 } else if (view.startPosition > prevStartPositionRef.current) {
25716 scrollDirectionRef.current = "down";
25717 }
25718 }
25719 prevStartPositionRef.current = view.startPosition;
25720 const currentFiltersKey = JSON.stringify(view.filters ?? []);
25721 const prevFiltersKey = prevViewParamsRef.current.filters;
25722 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
25723 hasInitializedRef.current = true;
25724 prevViewParamsRef.current = {
25725 search: view.search,
25726 filters: currentFiltersKey,
25727 perPage: view.perPage
25728 };
25729 if (shouldReset) {
25730 positionMapRef.current.clear();
25731 scrollDirectionRef.current = void 0;
25732 const startPosition = view.search ? 1 : view.startPosition ?? 1;
25733 const records = shownData.map((record, index2) => {
25734 const position = startPosition + index2;
25735 positionMapRef.current.set(getItemId(record), position);
25736 return {
25737 ...record,
25738 position
25739 };
25740 });
25741 allLoadedRecordsRef.current = records;
25742 return records;
25743 }
25744 const prev = allLoadedRecordsRef.current;
25745 const shownDataIds = new Set(shownData.map(getItemId));
25746 const scrollDirection = scrollDirectionRef.current;
25747 const basePosition = view.search ? 1 : view.startPosition ?? 1;
25748 const newRecords = shownData.map((record, index2) => {
25749 const itemId = getItemId(record);
25750 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0;
25751 if (position !== void 0) {
25752 positionMapRef.current.set(itemId, position);
25753 }
25754 return {
25755 ...record,
25756 position
25757 };
25758 });
25759 if (newRecords.length === 0) {
25760 return prev;
25761 }
25762 const prevWithoutDuplicates = prev.filter(
25763 (record) => !shownDataIds.has(getItemId(record))
25764 );
25765 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
25766 allRecords.sort((a2, b2) => {
25767 const posA = a2.position;
25768 const posB = b2.position;
25769 return posA - posB;
25770 });
25771 let result = allRecords;
25772 if (visibleEntries.length > 0) {
25773 const visibleMin = Math.min(...visibleEntries);
25774 const visibleMax = Math.max(...visibleEntries);
25775 const buffer = 20;
25776 const recordPositions = allRecords.map(
25777 (r3) => r3.position
25778 );
25779 const minRecordPos = Math.min(...recordPositions);
25780 const maxRecordPos = Math.max(...recordPositions);
25781 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
25782 if (hasOverlap) {
25783 result = allRecords.filter((record) => {
25784 const itemId = getItemId(record);
25785 const isSelected2 = selection?.includes(itemId);
25786 if (isSelected2) {
25787 return true;
25788 }
25789 const itemPosition = record.position;
25790 if (scrollDirection === "up") {
25791 return itemPosition <= visibleMax + buffer;
25792 } else if (scrollDirection === "down") {
25793 return itemPosition >= visibleMin - buffer;
25794 }
25795 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
25796 });
25797 }
25798 }
25799 allLoadedRecordsRef.current = result;
25800 return result;
25801 }, [
25802 shownData,
25803 view.search,
25804 view.filters,
25805 view.perPage,
25806 view.startPosition,
25807 view.infiniteScrollEnabled,
25808 visibleEntries,
25809 selection,
25810 getItemId
25811 ]);
25812 if (!isInfiniteScrollEnabled) {
25813 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
25814 return {
25815 data: dataToReturn.map((item) => ({
25816 ...item,
25817 position: void 0
25818 })),
25819 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
25820 hasInitiallyLoaded,
25821 setVisibleEntries: void 0
25822 };
25823 }
25824 return {
25825 data: allLoadedRecords,
25826 paginationInfo,
25827 hasInitiallyLoaded,
25828 setVisibleEntries
25829 };
25830 }
25831
25832 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
25833 var import_element79 = __toESM(require_element(), 1);
25834 var import_compose11 = __toESM(require_compose(), 1);
25835 function captureAnchorElement(container, anchorElementRef, direction) {
25836 const containerRect = container.getBoundingClientRect();
25837 const centerY = containerRect.top + containerRect.height / 2;
25838 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
25839 if (items.length === 0) {
25840 return false;
25841 }
25842 const bestAnchor = items.reduce((best, item) => {
25843 const itemRect = item.getBoundingClientRect();
25844 const itemCenterY = itemRect.top + itemRect.height / 2;
25845 const distance = Math.abs(itemCenterY - centerY);
25846 const bestRect = best.getBoundingClientRect();
25847 const bestCenterY = bestRect.top + bestRect.height / 2;
25848 const bestDistance = Math.abs(bestCenterY - centerY);
25849 return distance < bestDistance ? item : best;
25850 });
25851 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
25852 const anchorRect = bestAnchor.getBoundingClientRect();
25853 anchorElementRef.current = {
25854 posinset,
25855 viewportOffset: anchorRect.top - containerRect.top,
25856 direction
25857 };
25858 return true;
25859 }
25860 function useInfiniteScroll({
25861 view,
25862 onChangeView,
25863 isLoading,
25864 paginationInfo,
25865 containerRef,
25866 setVisibleEntries
25867 }) {
25868 const anchorElementRef = (0, import_element79.useRef)(null);
25869 const viewRef = (0, import_element79.useRef)(view);
25870 const isLoadingRef = (0, import_element79.useRef)(isLoading);
25871 const onChangeViewRef = (0, import_element79.useRef)(onChangeView);
25872 const totalItemsRef = (0, import_element79.useRef)(paginationInfo.totalItems);
25873 (0, import_element79.useLayoutEffect)(() => {
25874 viewRef.current = view;
25875 isLoadingRef.current = isLoading;
25876 onChangeViewRef.current = onChangeView;
25877 totalItemsRef.current = paginationInfo.totalItems;
25878 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
25879 const intersectionObserverCallback = (0, import_element79.useCallback)(
25880 (entries) => {
25881 if (!setVisibleEntries) {
25882 return;
25883 }
25884 setVisibleEntries((prev) => {
25885 const newVisibleEntries = new Set(prev);
25886 let hasChanged = false;
25887 entries.forEach((entry) => {
25888 const posInSet = Number(
25889 entry.target?.attributes?.getNamedItem(
25890 "aria-posinset"
25891 )?.value
25892 );
25893 if (isNaN(posInSet)) {
25894 return;
25895 }
25896 if (entry.isIntersecting) {
25897 if (!newVisibleEntries.has(posInSet)) {
25898 newVisibleEntries.add(posInSet);
25899 hasChanged = true;
25900 }
25901 } else if (newVisibleEntries.has(posInSet)) {
25902 newVisibleEntries.delete(posInSet);
25903 hasChanged = true;
25904 }
25905 });
25906 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
25907 });
25908 },
25909 [setVisibleEntries]
25910 );
25911 (0, import_element79.useLayoutEffect)(() => {
25912 const container = containerRef.current;
25913 const anchor = anchorElementRef.current;
25914 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
25915 return;
25916 }
25917 const anchorElement = container.querySelector(
25918 `[aria-posinset="${anchor.posinset}"]`
25919 );
25920 if (anchorElement) {
25921 const containerRect = container.getBoundingClientRect();
25922 const anchorRect = anchorElement.getBoundingClientRect();
25923 const currentOffset = anchorRect.top - containerRect.top;
25924 const scrollAdjustment = currentOffset - anchor.viewportOffset;
25925 if (Math.abs(scrollAdjustment) > 1) {
25926 container.scrollTop += scrollAdjustment;
25927 }
25928 }
25929 anchorElementRef.current = null;
25930 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
25931 const intersectionObserverRef = (0, import_element79.useRef)(
25932 null
25933 );
25934 (0, import_element79.useEffect)(() => {
25935 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
25936 if (intersectionObserverRef.current) {
25937 intersectionObserverRef.current.disconnect();
25938 intersectionObserverRef.current = null;
25939 }
25940 return;
25941 }
25942 intersectionObserverRef.current = new IntersectionObserver(
25943 intersectionObserverCallback,
25944 { root: null, rootMargin: "0px", threshold: 0.1 }
25945 );
25946 return () => {
25947 if (intersectionObserverRef.current) {
25948 intersectionObserverRef.current.disconnect();
25949 intersectionObserverRef.current = null;
25950 }
25951 };
25952 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
25953 (0, import_element79.useEffect)(() => {
25954 if (!view.infiniteScrollEnabled || !containerRef.current) {
25955 return;
25956 }
25957 let lastScrollTop = 0;
25958 const BOTTOM_THRESHOLD = 600;
25959 const TOP_THRESHOLD = 800;
25960 const handleScroll = (0, import_compose11.throttle)((event) => {
25961 const currentView = viewRef.current;
25962 const totalItems = totalItemsRef.current;
25963 const target = event.target;
25964 const scrollTop = target.scrollTop;
25965 const scrollHeight = target.scrollHeight;
25966 const clientHeight = target.clientHeight;
25967 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
25968 lastScrollTop = scrollTop;
25969 if (isLoadingRef.current) {
25970 return;
25971 }
25972 const currentStartPosition = currentView.startPosition || 1;
25973 const batchSize = currentView.perPage || 10;
25974 const currentEndPosition = Math.min(
25975 currentStartPosition + batchSize,
25976 totalItems
25977 );
25978 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
25979 if (currentEndPosition < totalItems) {
25980 const newStartPosition = currentEndPosition;
25981 captureAnchorElement(target, anchorElementRef, "down");
25982 onChangeViewRef.current({
25983 ...currentView,
25984 startPosition: newStartPosition
25985 });
25986 }
25987 }
25988 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
25989 if (currentStartPosition > 1) {
25990 const calculatedStartPosition = currentStartPosition - batchSize;
25991 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
25992 captureAnchorElement(target, anchorElementRef, "up");
25993 onChangeViewRef.current({
25994 ...currentView,
25995 startPosition: newStartPosition
25996 });
25997 }
25998 }
25999 }, 50);
26000 const container = containerRef.current;
26001 container.addEventListener("scroll", handleScroll);
26002 return () => {
26003 container.removeEventListener("scroll", handleScroll);
26004 handleScroll.cancel();
26005 };
26006 }, [containerRef, view.infiniteScrollEnabled]);
26007 return {
26008 intersectionObserver: intersectionObserverRef.current
26009 };
26010 }
26011
26012 // packages/dataviews/build-module/dataviews/index.mjs
26013 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
26014 var defaultGetItemId = (item) => item.id;
26015 var defaultIsItemClickable = () => true;
26016 var EMPTY_ARRAY6 = [];
26017 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} };
26018 var dataViewsLayouts = VIEW_LAYOUTS.filter(
26019 (viewLayout) => !viewLayout.isPicker
26020 );
26021 function DefaultUI({
26022 header,
26023 search = true,
26024 searchLabel = void 0
26025 }) {
26026 const { view } = (0, import_element80.useContext)(dataviews_context_default);
26027 const isInfiniteScroll = view.infiniteScrollEnabled;
26028 return /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)(import_jsx_runtime116.Fragment, { children: [
26029 /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)(
26030 Stack,
26031 {
26032 direction: "row",
26033 align: "top",
26034 justify: "space-between",
26035 className: clsx_default("dataviews__view-actions", {
26036 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
26037 }),
26038 gap: "xs",
26039 children: [
26040 /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)(
26041 Stack,
26042 {
26043 direction: "row",
26044 justify: "start",
26045 gap: "sm",
26046 className: "dataviews__search",
26047 children: [
26048 search && /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(dataviews_search_default, { label: searchLabel }),
26049 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(toggle_default, {})
26050 ]
26051 }
26052 ),
26053 /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
26054 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(dataviews_view_config_default, {}),
26055 header
26056 ] })
26057 ]
26058 }
26059 ),
26060 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
26061 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(DataViewsLayout, {}),
26062 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(DataViewsFooter, {})
26063 ] });
26064 }
26065 function DataViews({
26066 view,
26067 onChangeView,
26068 fields,
26069 search = true,
26070 searchLabel = void 0,
26071 actions = EMPTY_ARRAY6,
26072 data,
26073 getItemId = defaultGetItemId,
26074 getItemLevel,
26075 isLoading = false,
26076 paginationInfo,
26077 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS,
26078 selection: selectionProperty,
26079 onChangeSelection,
26080 onClickItem,
26081 renderItemLink,
26082 isItemClickable = defaultIsItemClickable,
26083 header,
26084 children,
26085 config = { perPageSizes: [10, 20, 50, 100] },
26086 empty,
26087 onReset
26088 }) {
26089 const [selectionState, setSelectionState] = (0, import_element80.useState)([]);
26090 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0;
26091 const selection = isUncontrolled ? selectionState : selectionProperty;
26092 const {
26093 data: displayData,
26094 paginationInfo: displayPaginationInfo,
26095 hasInitiallyLoaded,
26096 setVisibleEntries
26097 } = useData({
26098 view,
26099 data,
26100 getItemId,
26101 isLoading,
26102 selection,
26103 paginationInfo
26104 });
26105 const containerRef = (0, import_element80.useRef)(null);
26106 const [containerWidth, setContainerWidth] = (0, import_element80.useState)(0);
26107 const resizeObserverRef = (0, import_compose12.useResizeObserver)(
26108 (resizeObserverEntries) => {
26109 setContainerWidth(
26110 resizeObserverEntries[0].borderBoxSize[0].inlineSize
26111 );
26112 },
26113 { box: "border-box" }
26114 );
26115 const [openedFilter, setOpenedFilter] = (0, import_element80.useState)(null);
26116 function setSelectionWithChange(value) {
26117 const newValue = typeof value === "function" ? value(selection) : value;
26118 if (isUncontrolled) {
26119 setSelectionState(newValue);
26120 }
26121 if (onChangeSelection) {
26122 onChangeSelection(newValue);
26123 }
26124 }
26125 const _fields = (0, import_element80.useMemo)(() => normalizeFields(fields), [fields]);
26126 const _selection = (0, import_element80.useMemo)(() => {
26127 if (view.infiniteScrollEnabled) {
26128 return selection;
26129 }
26130 return selection.filter(
26131 (id) => data.some((item) => getItemId(item) === id)
26132 );
26133 }, [selection, data, getItemId, view.infiniteScrollEnabled]);
26134 const filters = use_filters_default(_fields, view);
26135 const hasPrimaryOrLockedFilters = (0, import_element80.useMemo)(
26136 () => (filters || []).some(
26137 (filter) => filter.isPrimary || filter.isLocked
26138 ),
26139 [filters]
26140 );
26141 const [isShowingFilter, setIsShowingFilter] = (0, import_element80.useState)(
26142 hasPrimaryOrLockedFilters
26143 );
26144 const { intersectionObserver } = useInfiniteScroll({
26145 view,
26146 onChangeView,
26147 isLoading,
26148 paginationInfo,
26149 containerRef,
26150 setVisibleEntries
26151 });
26152 (0, import_element80.useEffect)(() => {
26153 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
26154 setIsShowingFilter(true);
26155 }
26156 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
26157 const defaultLayouts = (0, import_element80.useMemo)(
26158 () => Object.fromEntries(
26159 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
26160 return dataViewsLayouts.some(
26161 (viewLayout) => viewLayout.type === layoutType
26162 );
26163 }).map(([key, value]) => [
26164 key,
26165 value === true ? {} : value
26166 ])
26167 ),
26168 [defaultLayoutsProperty]
26169 );
26170 if (!defaultLayouts[view.type]) {
26171 return null;
26172 }
26173 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
26174 dataviews_context_default.Provider,
26175 {
26176 value: {
26177 view,
26178 onChangeView,
26179 fields: _fields,
26180 actions,
26181 data: displayData,
26182 isLoading,
26183 paginationInfo: displayPaginationInfo,
26184 selection: _selection,
26185 onChangeSelection: setSelectionWithChange,
26186 openedFilter,
26187 setOpenedFilter,
26188 getItemId,
26189 getItemLevel,
26190 isItemClickable,
26191 onClickItem,
26192 renderItemLink,
26193 containerWidth,
26194 containerRef,
26195 resizeObserverRef,
26196 defaultLayouts,
26197 filters,
26198 isShowingFilter,
26199 setIsShowingFilter,
26200 config,
26201 empty,
26202 hasInitiallyLoaded,
26203 onReset,
26204 intersectionObserver
26205 },
26206 children: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
26207 DefaultUI,
26208 {
26209 header,
26210 search,
26211 searchLabel
26212 }
26213 ) })
26214 }
26215 );
26216 }
26217 var DataViewsSubComponents = DataViews;
26218 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
26219 DataViewsSubComponents.Filters = filters_default;
26220 DataViewsSubComponents.FiltersToggled = filters_toggled_default;
26221 DataViewsSubComponents.FiltersToggle = toggle_default;
26222 DataViewsSubComponents.Layout = DataViewsLayout;
26223 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
26224 DataViewsSubComponents.Pagination = DataViewsPagination;
26225 DataViewsSubComponents.Search = dataviews_search_default;
26226 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
26227 DataViewsSubComponents.Footer = DataViewsFooter;
26228 var dataviews_default = DataViewsSubComponents;
26229
26230 // packages/dataviews/build-module/utils/filter-sort-and-paginate.mjs
26231 var import_remove_accents2 = __toESM(require_remove_accents(), 1);
26232 var import_deprecated = __toESM(require_deprecated(), 1);
26233 function normalizeSearchInput2(input = "") {
26234 return (0, import_remove_accents2.default)(input.trim().toLowerCase());
26235 }
26236 var EMPTY_ARRAY7 = [];
26237 function filterSortAndPaginate(data, view, fields) {
26238 if (!data) {
26239 return {
26240 data: EMPTY_ARRAY7,
26241 paginationInfo: { totalItems: 0, totalPages: 0 }
26242 };
26243 }
26244 const _fields = normalizeFields(fields);
26245 let filteredData = [...data];
26246 if (view.search) {
26247 const normalizedSearch = normalizeSearchInput2(view.search);
26248 filteredData = filteredData.filter((item) => {
26249 return _fields.filter((field) => field.enableGlobalSearch).some((field) => {
26250 const fieldValue = field.getValue({ item });
26251 const values = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
26252 return values.some(
26253 (value) => normalizeSearchInput2(String(value)).includes(
26254 normalizedSearch
26255 )
26256 );
26257 });
26258 });
26259 }
26260 if (view.filters && view.filters?.length > 0) {
26261 view.filters.forEach((filter) => {
26262 const field = _fields.find(
26263 (_field) => _field.id === filter.field
26264 );
26265 if (field) {
26266 if (filter.operator === OPERATOR_IS_NOT_ALL) {
26267 (0, import_deprecated.default)("The 'isNotAll' filter operator", {
26268 since: "7.0",
26269 alternative: "'isNone'"
26270 });
26271 }
26272 const handler = field.filter[filter.operator];
26273 if (handler) {
26274 filteredData = filteredData.filter(
26275 (item) => handler(item, field, filter.value)
26276 );
26277 }
26278 }
26279 });
26280 }
26281 const sortByField = view.sort?.field ? _fields.find((field) => {
26282 return field.enableSorting !== false && field.id === view.sort?.field;
26283 }) : null;
26284 const groupByField = view.groupBy?.field ? _fields.find((field) => {
26285 return field.enableSorting !== false && field.id === view.groupBy?.field;
26286 }) : null;
26287 if (sortByField || groupByField) {
26288 filteredData.sort((a2, b2) => {
26289 if (groupByField) {
26290 const groupCompare = groupByField.sort(
26291 a2,
26292 b2,
26293 view.groupBy?.direction ?? "asc"
26294 );
26295 if (groupCompare !== 0) {
26296 return groupCompare;
26297 }
26298 }
26299 if (sortByField) {
26300 return sortByField.sort(a2, b2, view.sort?.direction ?? "desc");
26301 }
26302 return 0;
26303 });
26304 }
26305 let totalItems = filteredData.length;
26306 let totalPages = 1;
26307 if (view.infiniteScrollEnabled && view.startPosition !== void 0 && view.perPage !== void 0) {
26308 const start = view.startPosition - 1;
26309 const end = Math.min(start + view.perPage, totalItems);
26310 filteredData = filteredData?.slice(start, end);
26311 } else if (view.page !== void 0 && view.perPage !== void 0) {
26312 const start = (view.page - 1) * view.perPage;
26313 totalItems = filteredData?.length || 0;
26314 totalPages = Math.ceil(totalItems / view.perPage);
26315 filteredData = filteredData?.slice(start, start + view.perPage);
26316 }
26317 return {
26318 data: filteredData,
26319 paginationInfo: {
26320 totalItems,
26321 totalPages
26322 }
26323 };
26324 }
26325
26326 // packages/style-runtime/src/index.ts
26327 var STYLE_HASH_ATTRIBUTE14 = "data-wp-hash";
26328 function getRuntime14() {
26329 const globalScope = globalThis;
26330 if (globalScope.__wpStyleRuntime) {
26331 return globalScope.__wpStyleRuntime;
26332 }
26333 globalScope.__wpStyleRuntime = {
26334 documents: /* @__PURE__ */ new Map(),
26335 styles: /* @__PURE__ */ new Map(),
26336 injectedStyles: /* @__PURE__ */ new WeakMap()
26337 };
26338 if (typeof document !== "undefined") {
26339 registerDocument14(document);
26340 }
26341 return globalScope.__wpStyleRuntime;
26342 }
26343 function documentContainsStyleHash14(targetDocument, hash) {
26344 if (!targetDocument.head) {
26345 return false;
26346 }
26347 for (const style of targetDocument.head.querySelectorAll(
26348 `style[${STYLE_HASH_ATTRIBUTE14}]`
26349 )) {
26350 if (style.getAttribute(STYLE_HASH_ATTRIBUTE14) === hash) {
26351 return true;
26352 }
26353 }
26354 return false;
26355 }
26356 function injectStyle14(targetDocument, hash, css) {
26357 if (!targetDocument.head) {
26358 return;
26359 }
26360 const runtime = getRuntime14();
26361 let injectedStyles = runtime.injectedStyles.get(targetDocument);
26362 if (!injectedStyles) {
26363 injectedStyles = /* @__PURE__ */ new Set();
26364 runtime.injectedStyles.set(targetDocument, injectedStyles);
26365 }
26366 if (injectedStyles.has(hash)) {
26367 return;
26368 }
26369 if (documentContainsStyleHash14(targetDocument, hash)) {
26370 injectedStyles.add(hash);
26371 return;
26372 }
26373 const style = targetDocument.createElement("style");
26374 style.setAttribute(STYLE_HASH_ATTRIBUTE14, hash);
26375 style.appendChild(targetDocument.createTextNode(css));
26376 targetDocument.head.appendChild(style);
26377 injectedStyles.add(hash);
26378 }
26379 function registerDocument14(targetDocument) {
26380 const runtime = getRuntime14();
26381 runtime.documents.set(
26382 targetDocument,
26383 (runtime.documents.get(targetDocument) ?? 0) + 1
26384 );
26385 for (const [hash, css] of runtime.styles) {
26386 injectStyle14(targetDocument, hash, css);
26387 }
26388 return () => {
26389 const count = runtime.documents.get(targetDocument);
26390 if (count === void 0) {
26391 return;
26392 }
26393 if (count <= 1) {
26394 runtime.documents.delete(targetDocument);
26395 return;
26396 }
26397 runtime.documents.set(targetDocument, count - 1);
26398 };
26399 }
26400 function registerStyle14(hash, css) {
26401 const runtime = getRuntime14();
26402 runtime.styles.set(hash, css);
26403 for (const targetDocument of runtime.documents.keys()) {
26404 injectStyle14(targetDocument, hash, css);
26405 }
26406 }
26407
26408 // widgets/activity/style.module.css
26409 if (typeof process === "undefined" || true) {
26410 registerStyle14("4aa3daa799", "._784d2967c5e53514__loading{height:100%}._21768f83511c9ec9__list{max-height:420px}");
26411 }
26412 var style_default13 = { "loading": "_784d2967c5e53514__loading", "list": "_21768f83511c9ec9__list" };
26413
26414 // widgets/activity/render.tsx
26415 var import_jsx_runtime117 = __toESM(require_jsx_runtime());
26416 function formatGroupDate(dateStr) {
26417 const now = (0, import_date10.getDate)();
26418 const today = (0, import_date10.dateI18n)("Y-m-d", now);
26419 if (dateStr === today) {
26420 return (0, import_i18n44.__)("Today");
26421 }
26422 const yesterday = (0, import_date10.getDate)();
26423 yesterday.setDate(yesterday.getDate() - 1);
26424 const yesterdayStr = (0, import_date10.dateI18n)("Y-m-d", yesterday);
26425 if (dateStr === yesterdayStr) {
26426 return (0, import_i18n44.__)("Yesterday");
26427 }
26428 const currentYear = (0, import_date10.dateI18n)("Y", now);
26429 if (dateStr.slice(0, 4) === currentYear) {
26430 return (0, import_date10.dateI18n)((0, import_i18n44.__)("M jS"), dateStr);
26431 }
26432 return (0, import_date10.dateI18n)((0, import_i18n44.__)("M jS Y"), dateStr);
26433 }
26434 function htmlToPlainText(html) {
26435 const { body } = new window.DOMParser().parseFromString(
26436 html,
26437 "text/html"
26438 );
26439 return (body.textContent ?? "").trim();
26440 }
26441 var FIELDS = [
26442 {
26443 id: "icon",
26444 label: (0, import_i18n44.__)("Icon"),
26445 type: "media",
26446 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(icon_default, { icon: item.kind === "comment" ? comment_default : post_list_default }),
26447 enableSorting: false,
26448 enableHiding: false
26449 },
26450 {
26451 id: "title",
26452 label: (0, import_i18n44.__)("Title"),
26453 type: "text",
26454 getValue: ({ item }) => item.title,
26455 enableSorting: false,
26456 enableGlobalSearch: true
26457 },
26458 {
26459 id: "description",
26460 label: (0, import_i18n44.__)("Description"),
26461 type: "text",
26462 getValue: ({ item }) => item.description,
26463 enableSorting: false,
26464 enableGlobalSearch: true
26465 },
26466 {
26467 id: "datetime",
26468 label: (0, import_i18n44.__)("Time"),
26469 getValue: ({ item }) => item.datetime,
26470 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime117.jsx)("span", { children: (0, import_date10.dateI18n)((0, import_i18n44.__)("g:i a"), item.datetime) }),
26471 enableSorting: true
26472 },
26473 {
26474 id: "date",
26475 label: (0, import_i18n44.__)("Date"),
26476 getValue: ({ item }) => item.datetime.split("T")[0],
26477 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime117.jsx)("span", { children: formatGroupDate(item.datetime.split("T")[0]) }),
26478 enableSorting: true,
26479 enableHiding: false
26480 }
26481 ];
26482 var DEFAULT_PER_PAGE = 5;
26483 var SOURCE_COUNT = 3;
26484 var DEFAULT_VIEW = {
26485 type: "activity",
26486 search: "",
26487 page: 1,
26488 perPage: DEFAULT_PER_PAGE,
26489 filters: [],
26490 fields: ["datetime"],
26491 titleField: "title",
26492 descriptionField: "description",
26493 mediaField: "icon",
26494 showMedia: true,
26495 sort: {
26496 field: "datetime",
26497 direction: "desc"
26498 },
26499 groupBy: {
26500 field: "date",
26501 direction: "desc",
26502 showLabel: false
26503 }
26504 };
26505 function Activity({
26506 attributes
26507 }) {
26508 const perPage = Math.max(1, attributes?.perPage ?? DEFAULT_PER_PAGE);
26509 const [view, setView] = (0, import_element81.useState)(DEFAULT_VIEW);
26510 const queries = (0, import_element81.useMemo)(
26511 () => ({
26512 future: {
26513 status: "future",
26514 orderby: "date",
26515 order: "asc",
26516 per_page: perPage
26517 },
26518 recent: {
26519 status: "publish",
26520 orderby: "date",
26521 order: "desc",
26522 per_page: perPage
26523 },
26524 comments: { per_page: perPage }
26525 }),
26526 [perPage]
26527 );
26528 const { futurePosts, recentPosts, comments, isResolved } = (0, import_data6.useSelect)(
26529 (select) => {
26530 const coreData = select(import_core_data.store);
26531 return {
26532 futurePosts: coreData.getEntityRecords(
26533 "postType",
26534 "post",
26535 queries.future
26536 ),
26537 recentPosts: coreData.getEntityRecords(
26538 "postType",
26539 "post",
26540 queries.recent
26541 ),
26542 comments: coreData.getEntityRecords(
26543 "root",
26544 "comment",
26545 queries.comments
26546 ),
26547 isResolved: coreData.hasFinishedResolution("getEntityRecords", [
26548 "postType",
26549 "post",
26550 queries.future
26551 ]) && coreData.hasFinishedResolution("getEntityRecords", [
26552 "postType",
26553 "post",
26554 queries.recent
26555 ]) && coreData.hasFinishedResolution("getEntityRecords", [
26556 "root",
26557 "comment",
26558 queries.comments
26559 ])
26560 };
26561 },
26562 [queries]
26563 );
26564 const allEvents = (0, import_element81.useMemo)(() => {
26565 const events = [];
26566 for (const post of futurePosts ?? []) {
26567 events.push({
26568 id: `post-future-${post.id}`,
26569 datetime: post.date ?? "",
26570 title: (0, import_html_entities.decodeEntities)(
26571 post.title?.rendered ?? ""
26572 ),
26573 description: "",
26574 link: post.link ?? "",
26575 kind: "post-future"
26576 });
26577 }
26578 for (const post of recentPosts ?? []) {
26579 events.push({
26580 id: `post-published-${post.id}`,
26581 datetime: post.date ?? "",
26582 title: (0, import_html_entities.decodeEntities)(
26583 post.title?.rendered ?? ""
26584 ),
26585 description: "",
26586 link: post.link ?? "",
26587 kind: "post-published"
26588 });
26589 }
26590 for (const c2 of comments ?? []) {
26591 events.push({
26592 id: `comment-${c2.id}`,
26593 datetime: c2.date ?? "",
26594 title: (0, import_html_entities.decodeEntities)(c2.author_name ?? ""),
26595 description: htmlToPlainText(
26596 c2.content?.rendered ?? ""
26597 ),
26598 link: c2.link ?? "",
26599 kind: "comment"
26600 });
26601 }
26602 return events;
26603 }, [futurePosts, recentPosts, comments]);
26604 const resolvedView = (0, import_element81.useMemo)(
26605 () => ({ ...view, perPage: perPage * SOURCE_COUNT }),
26606 [view, perPage]
26607 );
26608 const { data: shownData, paginationInfo } = (0, import_element81.useMemo)(
26609 () => filterSortAndPaginate(allEvents, resolvedView, FIELDS),
26610 [allEvents, resolvedView]
26611 );
26612 if (!isResolved) {
26613 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
26614 Stack,
26615 {
26616 direction: "column",
26617 align: "center",
26618 justify: "center",
26619 className: style_default13.loading,
26620 children: /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(import_components45.Spinner, {})
26621 }
26622 );
26623 }
26624 if (allEvents.length === 0) {
26625 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
26626 Stack,
26627 {
26628 direction: "column",
26629 align: "center",
26630 justify: "center",
26631 className: style_default13.loading,
26632 children: /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(empty_state_exports.Root, { children: [
26633 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(empty_state_exports.Icon, { icon: post_list_default }),
26634 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(empty_state_exports.Title, { children: (0, import_i18n44.__)("No activity yet.") }),
26635 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(empty_state_exports.Description, { children: (0, import_i18n44.__)(
26636 "When you publish posts or receive comments, they will appear here."
26637 ) })
26638 ] })
26639 }
26640 );
26641 }
26642 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(Stack, { direction: "column", className: style_default13.list, children: /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
26643 dataviews_default,
26644 {
26645 data: shownData,
26646 fields: FIELDS,
26647 view: resolvedView,
26648 onChangeView: setView,
26649 paginationInfo,
26650 getItemId: (item) => item.id,
26651 search: false,
26652 isLoading: false,
26653 defaultLayouts: {
26654 activity: {
26655 sort: {
26656 field: "datetime",
26657 direction: "desc"
26658 }
26659 }
26660 },
26661 renderItemLink: ({ item, children, ...aProps }) => /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(Link, { href: item.link, ...aProps, children }),
26662 isItemClickable: (item) => !!item.link,
26663 children: /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(dataviews_default.Layout, {})
26664 }
26665 ) });
26666 }
26667 export {
26668 Activity as default
26669 };
26670 /*! Bundled license information:
26671
26672 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
26673 (**
26674 * @license React
26675 * use-sync-external-store-shim.development.js
26676 *
26677 * Copyright (c) Meta Platforms, Inc. and affiliates.
26678 *
26679 * This source code is licensed under the MIT license found in the
26680 * LICENSE file in the root directory of this source tree.
26681 *)
26682
26683 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
26684 (**
26685 * @license React
26686 * use-sync-external-store-shim/with-selector.development.js
26687 *
26688 * Copyright (c) Meta Platforms, Inc. and affiliates.
26689 *
26690 * This source code is licensed under the MIT license found in the
26691 * LICENSE file in the root directory of this source tree.
26692 *)
26693 */
26694