PluginProbe
Gutenberg / 23.3.2
Gutenberg v23.3.2
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.2, at build/widgets/activity/render.js

26,688 lines 918.6 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)(icon, {
857 width: size4,
858 height: size4,
859 ...props,
860 ref
861 });
862 }
863 );
864
865 // packages/icons/build-module/library/arrow-down.mjs
866 var import_primitives = __toESM(require_primitives(), 1);
867 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
868 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" }) });
869
870 // packages/icons/build-module/library/arrow-left.mjs
871 var import_primitives2 = __toESM(require_primitives(), 1);
872 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
873 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" }) });
874
875 // packages/icons/build-module/library/arrow-right.mjs
876 var import_primitives3 = __toESM(require_primitives(), 1);
877 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
878 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" }) });
879
880 // packages/icons/build-module/library/arrow-up.mjs
881 var import_primitives4 = __toESM(require_primitives(), 1);
882 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
883 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" }) });
884
885 // packages/icons/build-module/library/block-table.mjs
886 var import_primitives5 = __toESM(require_primitives(), 1);
887 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
888 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" }) });
889
890 // packages/icons/build-module/library/category.mjs
891 var import_primitives6 = __toESM(require_primitives(), 1);
892 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
893 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" }) });
894
895 // packages/icons/build-module/library/check.mjs
896 var import_primitives7 = __toESM(require_primitives(), 1);
897 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
898 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" }) });
899
900 // packages/icons/build-module/library/close-small.mjs
901 var import_primitives8 = __toESM(require_primitives(), 1);
902 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
903 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" }) });
904
905 // packages/icons/build-module/library/cog.mjs
906 var import_primitives9 = __toESM(require_primitives(), 1);
907 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
908 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" }) });
909
910 // packages/icons/build-module/library/comment.mjs
911 var import_primitives10 = __toESM(require_primitives(), 1);
912 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
913 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" }) });
914
915 // packages/icons/build-module/library/envelope.mjs
916 var import_primitives11 = __toESM(require_primitives(), 1);
917 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
918 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" }) });
919
920 // packages/icons/build-module/library/error.mjs
921 var import_primitives12 = __toESM(require_primitives(), 1);
922 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
923 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" }) });
924
925 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
926 var import_primitives13 = __toESM(require_primitives(), 1);
927 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
928 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" }) });
929
930 // packages/icons/build-module/library/format-list-bullets.mjs
931 var import_primitives14 = __toESM(require_primitives(), 1);
932 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
933 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" }) });
934
935 // packages/icons/build-module/library/funnel.mjs
936 var import_primitives15 = __toESM(require_primitives(), 1);
937 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
938 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" }) });
939
940 // packages/icons/build-module/library/link.mjs
941 var import_primitives16 = __toESM(require_primitives(), 1);
942 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
943 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" }) });
944
945 // packages/icons/build-module/library/mobile.mjs
946 var import_primitives17 = __toESM(require_primitives(), 1);
947 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
948 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" }) });
949
950 // packages/icons/build-module/library/more-vertical.mjs
951 var import_primitives18 = __toESM(require_primitives(), 1);
952 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
953 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" }) });
954
955 // packages/icons/build-module/library/next.mjs
956 var import_primitives19 = __toESM(require_primitives(), 1);
957 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
958 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" }) });
959
960 // packages/icons/build-module/library/post-list.mjs
961 var import_primitives20 = __toESM(require_primitives(), 1);
962 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
963 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" }) });
964
965 // packages/icons/build-module/library/previous.mjs
966 var import_primitives21 = __toESM(require_primitives(), 1);
967 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
968 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" }) });
969
970 // packages/icons/build-module/library/scheduled.mjs
971 var import_primitives22 = __toESM(require_primitives(), 1);
972 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
973 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" }) });
974
975 // packages/icons/build-module/library/search.mjs
976 var import_primitives23 = __toESM(require_primitives(), 1);
977 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
978 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" }) });
979
980 // packages/icons/build-module/library/seen.mjs
981 var import_primitives24 = __toESM(require_primitives(), 1);
982 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
983 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" }) });
984
985 // packages/icons/build-module/library/unseen.mjs
986 var import_primitives25 = __toESM(require_primitives(), 1);
987 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
988 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" }) });
989
990 // node_modules/clsx/dist/clsx.mjs
991 function r(e2) {
992 var t2, f2, n2 = "";
993 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
994 else if ("object" == typeof e2) if (Array.isArray(e2)) {
995 var o2 = e2.length;
996 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
997 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
998 return n2;
999 }
1000 function clsx() {
1001 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
1002 return n2;
1003 }
1004 var clsx_default = clsx;
1005
1006 // packages/dataviews/build-module/dataviews/index.mjs
1007 var import_element80 = __toESM(require_element(), 1);
1008 var import_compose12 = __toESM(require_compose(), 1);
1009
1010 // node_modules/@base-ui/utils/esm/useStableCallback.js
1011 var React2 = __toESM(require_react(), 1);
1012
1013 // node_modules/@base-ui/utils/esm/useRefWithInit.js
1014 var React = __toESM(require_react(), 1);
1015 var UNINITIALIZED = {};
1016 function useRefWithInit(init2, initArg) {
1017 const ref = React.useRef(UNINITIALIZED);
1018 if (ref.current === UNINITIALIZED) {
1019 ref.current = init2(initArg);
1020 }
1021 return ref;
1022 }
1023
1024 // node_modules/@base-ui/utils/esm/useStableCallback.js
1025 var useInsertionEffect = React2[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0, -3)];
1026 var useSafeInsertionEffect = (
1027 // React 17 doesn't have useInsertionEffect.
1028 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
1029 useInsertionEffect !== React2.useLayoutEffect ? useInsertionEffect : (fn) => fn()
1030 );
1031 function useStableCallback(callback) {
1032 const stable = useRefWithInit(createStableCallback).current;
1033 stable.next = callback;
1034 useSafeInsertionEffect(stable.effect);
1035 return stable.trampoline;
1036 }
1037 function createStableCallback() {
1038 const stable = {
1039 next: void 0,
1040 callback: assertNotCalled,
1041 trampoline: (...args) => stable.callback?.(...args),
1042 effect: () => {
1043 stable.callback = stable.next;
1044 }
1045 };
1046 return stable;
1047 }
1048 function assertNotCalled() {
1049 if (true) {
1050 throw (
1051 /* minify-error-disabled */
1052 new Error("Base UI: Cannot call an event handler while rendering.")
1053 );
1054 }
1055 }
1056
1057 // node_modules/@base-ui/utils/esm/useIsoLayoutEffect.js
1058 var React3 = __toESM(require_react(), 1);
1059 var noop = () => {
1060 };
1061 var useIsoLayoutEffect = typeof document !== "undefined" ? React3.useLayoutEffect : noop;
1062
1063 // node_modules/@base-ui/utils/esm/warn.js
1064 var set;
1065 if (true) {
1066 set = /* @__PURE__ */ new Set();
1067 }
1068 function warn(...messages) {
1069 if (true) {
1070 const messageKey = messages.join(" ");
1071 if (!set.has(messageKey)) {
1072 set.add(messageKey);
1073 console.warn(`Base UI: ${messageKey}`);
1074 }
1075 }
1076 }
1077
1078 // node_modules/@base-ui/react/esm/internals/direction-context/DirectionContext.js
1079 var React4 = __toESM(require_react(), 1);
1080 var DirectionContext = /* @__PURE__ */ React4.createContext(void 0);
1081 if (true) DirectionContext.displayName = "DirectionContext";
1082 function useDirection() {
1083 const context = React4.useContext(DirectionContext);
1084 return context?.direction ?? "ltr";
1085 }
1086
1087 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1088 var React7 = __toESM(require_react(), 1);
1089
1090 // node_modules/@base-ui/utils/esm/useMergedRefs.js
1091 function useMergedRefs(a2, b2, c2, d2) {
1092 const forkRef = useRefWithInit(createForkRef).current;
1093 if (didChange(forkRef, a2, b2, c2, d2)) {
1094 update(forkRef, [a2, b2, c2, d2]);
1095 }
1096 return forkRef.callback;
1097 }
1098 function useMergedRefsN(refs) {
1099 const forkRef = useRefWithInit(createForkRef).current;
1100 if (didChangeN(forkRef, refs)) {
1101 update(forkRef, refs);
1102 }
1103 return forkRef.callback;
1104 }
1105 function createForkRef() {
1106 return {
1107 callback: null,
1108 cleanup: null,
1109 refs: []
1110 };
1111 }
1112 function didChange(forkRef, a2, b2, c2, d2) {
1113 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
1114 }
1115 function didChangeN(forkRef, newRefs) {
1116 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
1117 }
1118 function update(forkRef, refs) {
1119 forkRef.refs = refs;
1120 if (refs.every((ref) => ref == null)) {
1121 forkRef.callback = null;
1122 return;
1123 }
1124 forkRef.callback = (instance) => {
1125 if (forkRef.cleanup) {
1126 forkRef.cleanup();
1127 forkRef.cleanup = null;
1128 }
1129 if (instance != null) {
1130 const cleanupCallbacks = Array(refs.length).fill(null);
1131 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1132 const ref = refs[i2];
1133 if (ref == null) {
1134 continue;
1135 }
1136 switch (typeof ref) {
1137 case "function": {
1138 const refCleanup = ref(instance);
1139 if (typeof refCleanup === "function") {
1140 cleanupCallbacks[i2] = refCleanup;
1141 }
1142 break;
1143 }
1144 case "object": {
1145 ref.current = instance;
1146 break;
1147 }
1148 default:
1149 }
1150 }
1151 forkRef.cleanup = () => {
1152 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1153 const ref = refs[i2];
1154 if (ref == null) {
1155 continue;
1156 }
1157 switch (typeof ref) {
1158 case "function": {
1159 const cleanupCallback = cleanupCallbacks[i2];
1160 if (typeof cleanupCallback === "function") {
1161 cleanupCallback();
1162 } else {
1163 ref(null);
1164 }
1165 break;
1166 }
1167 case "object": {
1168 ref.current = null;
1169 break;
1170 }
1171 default:
1172 }
1173 }
1174 };
1175 }
1176 };
1177 }
1178
1179 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1180 var React6 = __toESM(require_react(), 1);
1181
1182 // node_modules/@base-ui/utils/esm/reactVersion.js
1183 var React5 = __toESM(require_react(), 1);
1184 var majorVersion = parseInt(React5.version, 10);
1185 function isReactVersionAtLeast(reactVersionToCheck) {
1186 return majorVersion >= reactVersionToCheck;
1187 }
1188
1189 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1190 function getReactElementRef(element) {
1191 if (!/* @__PURE__ */ React6.isValidElement(element)) {
1192 return null;
1193 }
1194 const reactElement = element;
1195 const propsWithRef = reactElement.props;
1196 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1197 }
1198
1199 // node_modules/@base-ui/utils/esm/mergeObjects.js
1200 function mergeObjects(a2, b2) {
1201 if (a2 && !b2) {
1202 return a2;
1203 }
1204 if (!a2 && b2) {
1205 return b2;
1206 }
1207 if (a2 || b2) {
1208 return {
1209 ...a2,
1210 ...b2
1211 };
1212 }
1213 return void 0;
1214 }
1215
1216 // node_modules/@base-ui/utils/esm/empty.js
1217 function NOOP() {
1218 }
1219 var EMPTY_ARRAY = Object.freeze([]);
1220 var EMPTY_OBJECT = Object.freeze({});
1221
1222 // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js
1223 function getStateAttributesProps(state, customMapping) {
1224 const props = {};
1225 for (const key in state) {
1226 const value = state[key];
1227 if (customMapping?.hasOwnProperty(key)) {
1228 const customProps = customMapping[key](value);
1229 if (customProps != null) {
1230 Object.assign(props, customProps);
1231 }
1232 continue;
1233 }
1234 if (value === true) {
1235 props[`data-${key.toLowerCase()}`] = "";
1236 } else if (value) {
1237 props[`data-${key.toLowerCase()}`] = value.toString();
1238 }
1239 }
1240 return props;
1241 }
1242
1243 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
1244 function resolveClassName(className, state) {
1245 return typeof className === "function" ? className(state) : className;
1246 }
1247
1248 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
1249 function resolveStyle(style, state) {
1250 return typeof style === "function" ? style(state) : style;
1251 }
1252
1253 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
1254 var EMPTY_PROPS = {};
1255 function mergeProps(a2, b2, c2, d2, e2) {
1256 if (!c2 && !d2 && !e2 && !a2) {
1257 return createInitialMergedProps(b2);
1258 }
1259 let merged = createInitialMergedProps(a2);
1260 if (b2) {
1261 merged = mergeInto(merged, b2);
1262 }
1263 if (c2) {
1264 merged = mergeInto(merged, c2);
1265 }
1266 if (d2) {
1267 merged = mergeInto(merged, d2);
1268 }
1269 if (e2) {
1270 merged = mergeInto(merged, e2);
1271 }
1272 return merged;
1273 }
1274 function mergePropsN(props) {
1275 if (props.length === 0) {
1276 return EMPTY_PROPS;
1277 }
1278 if (props.length === 1) {
1279 return createInitialMergedProps(props[0]);
1280 }
1281 let merged = createInitialMergedProps(props[0]);
1282 for (let i2 = 1; i2 < props.length; i2 += 1) {
1283 merged = mergeInto(merged, props[i2]);
1284 }
1285 return merged;
1286 }
1287 function createInitialMergedProps(inputProps) {
1288 if (isPropsGetter(inputProps)) {
1289 return {
1290 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1291 };
1292 }
1293 return copyInitialProps(inputProps);
1294 }
1295 function mergeInto(merged, inputProps) {
1296 if (isPropsGetter(inputProps)) {
1297 return resolvePropsGetter(inputProps, merged);
1298 }
1299 return mutablyMergeInto(merged, inputProps);
1300 }
1301 function copyInitialProps(inputProps) {
1302 const copiedProps = {
1303 ...inputProps
1304 };
1305 for (const propName in copiedProps) {
1306 const propValue = copiedProps[propName];
1307 if (isEventHandler(propName, propValue)) {
1308 copiedProps[propName] = wrapEventHandler(propValue);
1309 }
1310 }
1311 return copiedProps;
1312 }
1313 function mutablyMergeInto(mergedProps, externalProps) {
1314 if (!externalProps) {
1315 return mergedProps;
1316 }
1317 for (const propName in externalProps) {
1318 const externalPropValue = externalProps[propName];
1319 switch (propName) {
1320 case "style": {
1321 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1322 break;
1323 }
1324 case "className": {
1325 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1326 break;
1327 }
1328 default: {
1329 if (isEventHandler(propName, externalPropValue)) {
1330 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1331 } else {
1332 mergedProps[propName] = externalPropValue;
1333 }
1334 }
1335 }
1336 }
1337 return mergedProps;
1338 }
1339 function isEventHandler(key, value) {
1340 const code0 = key.charCodeAt(0);
1341 const code1 = key.charCodeAt(1);
1342 const code2 = key.charCodeAt(2);
1343 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1344 }
1345 function isPropsGetter(inputProps) {
1346 return typeof inputProps === "function";
1347 }
1348 function resolvePropsGetter(inputProps, previousProps) {
1349 if (isPropsGetter(inputProps)) {
1350 return inputProps(previousProps);
1351 }
1352 return inputProps ?? EMPTY_PROPS;
1353 }
1354 function mergeEventHandlers(ourHandler, theirHandler) {
1355 if (!theirHandler) {
1356 return ourHandler;
1357 }
1358 if (!ourHandler) {
1359 return wrapEventHandler(theirHandler);
1360 }
1361 return (...args) => {
1362 const event = args[0];
1363 if (isSyntheticEvent(event)) {
1364 const baseUIEvent = event;
1365 makeEventPreventable(baseUIEvent);
1366 const result2 = theirHandler(...args);
1367 if (!baseUIEvent.baseUIHandlerPrevented) {
1368 ourHandler?.(...args);
1369 }
1370 return result2;
1371 }
1372 const result = theirHandler(...args);
1373 ourHandler?.(...args);
1374 return result;
1375 };
1376 }
1377 function wrapEventHandler(handler) {
1378 if (!handler) {
1379 return handler;
1380 }
1381 return (...args) => {
1382 const event = args[0];
1383 if (isSyntheticEvent(event)) {
1384 makeEventPreventable(event);
1385 }
1386 return handler(...args);
1387 };
1388 }
1389 function makeEventPreventable(event) {
1390 event.preventBaseUIHandler = () => {
1391 event.baseUIHandlerPrevented = true;
1392 };
1393 return event;
1394 }
1395 function mergeClassNames(ourClassName, theirClassName) {
1396 if (theirClassName) {
1397 if (ourClassName) {
1398 return theirClassName + " " + ourClassName;
1399 }
1400 return theirClassName;
1401 }
1402 return ourClassName;
1403 }
1404 function isSyntheticEvent(event) {
1405 return event != null && typeof event === "object" && "nativeEvent" in event;
1406 }
1407
1408 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1409 var import_react = __toESM(require_react(), 1);
1410 function useRenderElement(element, componentProps, params = {}) {
1411 const renderProp = componentProps.render;
1412 const outProps = useRenderElementProps(componentProps, params);
1413 if (params.enabled === false) {
1414 return null;
1415 }
1416 const state = params.state ?? EMPTY_OBJECT;
1417 return evaluateRenderProp(element, renderProp, outProps, state);
1418 }
1419 function useRenderElementProps(componentProps, params = {}) {
1420 const {
1421 className: classNameProp,
1422 style: styleProp,
1423 render: renderProp
1424 } = componentProps;
1425 const {
1426 state = EMPTY_OBJECT,
1427 ref,
1428 props,
1429 stateAttributesMapping: stateAttributesMapping3,
1430 enabled = true
1431 } = params;
1432 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1433 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1434 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping3) : EMPTY_OBJECT;
1435 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1436 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1437 if (typeof document !== "undefined") {
1438 if (!enabled) {
1439 useMergedRefs(null, null);
1440 } else if (Array.isArray(ref)) {
1441 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1442 } else {
1443 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1444 }
1445 }
1446 if (!enabled) {
1447 return EMPTY_OBJECT;
1448 }
1449 if (className !== void 0) {
1450 outProps.className = mergeClassNames(outProps.className, className);
1451 }
1452 if (style !== void 0) {
1453 outProps.style = mergeObjects(outProps.style, style);
1454 }
1455 return outProps;
1456 }
1457 function resolveRenderFunctionProps(props) {
1458 if (Array.isArray(props)) {
1459 return mergePropsN(props);
1460 }
1461 return mergeProps(void 0, props);
1462 }
1463 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1464 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1465 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1466 function evaluateRenderProp(element, render4, props, state) {
1467 if (render4) {
1468 if (typeof render4 === "function") {
1469 if (true) {
1470 warnIfRenderPropLooksLikeComponent(render4);
1471 }
1472 return render4(props, state);
1473 }
1474 const mergedProps = mergeProps(props, render4.props);
1475 mergedProps.ref = props.ref;
1476 let newElement = render4;
1477 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1478 const children = React7.Children.toArray(render4);
1479 newElement = children[0];
1480 }
1481 if (true) {
1482 if (!/* @__PURE__ */ React7.isValidElement(newElement)) {
1483 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"));
1484 }
1485 }
1486 return /* @__PURE__ */ React7.cloneElement(newElement, mergedProps);
1487 }
1488 if (element) {
1489 if (typeof element === "string") {
1490 return renderTag(element, props);
1491 }
1492 }
1493 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1494 }
1495 function warnIfRenderPropLooksLikeComponent(renderFn) {
1496 const functionName = renderFn.name;
1497 if (functionName.length === 0) {
1498 return;
1499 }
1500 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1501 return;
1502 }
1503 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1504 return;
1505 }
1506 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");
1507 }
1508 function renderTag(Tag, props) {
1509 if (Tag === "button") {
1510 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1511 type: "button",
1512 ...props,
1513 key: props.key
1514 });
1515 }
1516 if (Tag === "img") {
1517 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1518 alt: "",
1519 ...props,
1520 key: props.key
1521 });
1522 }
1523 return /* @__PURE__ */ React7.createElement(Tag, props);
1524 }
1525
1526 // node_modules/@base-ui/react/esm/internals/reason-parts.js
1527 var reason_parts_exports = {};
1528 __export(reason_parts_exports, {
1529 cancelOpen: () => cancelOpen,
1530 chipRemovePress: () => chipRemovePress,
1531 clearPress: () => clearPress,
1532 closePress: () => closePress,
1533 closeWatcher: () => closeWatcher,
1534 decrementPress: () => decrementPress,
1535 disabled: () => disabled,
1536 drag: () => drag,
1537 escapeKey: () => escapeKey,
1538 focusOut: () => focusOut,
1539 imperativeAction: () => imperativeAction,
1540 incrementPress: () => incrementPress,
1541 inputBlur: () => inputBlur,
1542 inputChange: () => inputChange,
1543 inputClear: () => inputClear,
1544 inputPaste: () => inputPaste,
1545 inputPress: () => inputPress,
1546 itemPress: () => itemPress,
1547 keyboard: () => keyboard,
1548 linkPress: () => linkPress,
1549 listNavigation: () => listNavigation,
1550 none: () => none,
1551 outsidePress: () => outsidePress,
1552 pointer: () => pointer,
1553 scrub: () => scrub,
1554 siblingOpen: () => siblingOpen,
1555 swipe: () => swipe,
1556 trackPress: () => trackPress,
1557 triggerFocus: () => triggerFocus,
1558 triggerHover: () => triggerHover,
1559 triggerPress: () => triggerPress,
1560 wheel: () => wheel,
1561 windowResize: () => windowResize
1562 });
1563 var none = "none";
1564 var triggerPress = "trigger-press";
1565 var triggerHover = "trigger-hover";
1566 var triggerFocus = "trigger-focus";
1567 var outsidePress = "outside-press";
1568 var itemPress = "item-press";
1569 var closePress = "close-press";
1570 var linkPress = "link-press";
1571 var clearPress = "clear-press";
1572 var chipRemovePress = "chip-remove-press";
1573 var trackPress = "track-press";
1574 var incrementPress = "increment-press";
1575 var decrementPress = "decrement-press";
1576 var inputChange = "input-change";
1577 var inputClear = "input-clear";
1578 var inputBlur = "input-blur";
1579 var inputPaste = "input-paste";
1580 var inputPress = "input-press";
1581 var focusOut = "focus-out";
1582 var escapeKey = "escape-key";
1583 var closeWatcher = "close-watcher";
1584 var listNavigation = "list-navigation";
1585 var keyboard = "keyboard";
1586 var pointer = "pointer";
1587 var drag = "drag";
1588 var wheel = "wheel";
1589 var scrub = "scrub";
1590 var cancelOpen = "cancel-open";
1591 var siblingOpen = "sibling-open";
1592 var disabled = "disabled";
1593 var imperativeAction = "imperative-action";
1594 var swipe = "swipe";
1595 var windowResize = "window-resize";
1596
1597 // node_modules/@base-ui/react/esm/internals/createBaseUIEventDetails.js
1598 function createChangeEventDetails(reason, event, trigger, customProperties) {
1599 let canceled = false;
1600 let allowPropagation = false;
1601 const custom = customProperties ?? EMPTY_OBJECT;
1602 const details = {
1603 reason,
1604 event: event ?? new Event("base-ui"),
1605 cancel() {
1606 canceled = true;
1607 },
1608 allowPropagation() {
1609 allowPropagation = true;
1610 },
1611 get isCanceled() {
1612 return canceled;
1613 },
1614 get isPropagationAllowed() {
1615 return allowPropagation;
1616 },
1617 trigger,
1618 ...custom
1619 };
1620 return details;
1621 }
1622
1623 // node_modules/@base-ui/utils/esm/useId.js
1624 var React9 = __toESM(require_react(), 1);
1625
1626 // node_modules/@base-ui/utils/esm/safeReact.js
1627 var React8 = __toESM(require_react(), 1);
1628 var SafeReact = {
1629 ...React8
1630 };
1631
1632 // node_modules/@base-ui/utils/esm/useId.js
1633 var globalId = 0;
1634 function useGlobalId(idOverride, prefix = "mui") {
1635 const [defaultId, setDefaultId] = React9.useState(idOverride);
1636 const id = idOverride || defaultId;
1637 React9.useEffect(() => {
1638 if (defaultId == null) {
1639 globalId += 1;
1640 setDefaultId(`${prefix}-${globalId}`);
1641 }
1642 }, [defaultId, prefix]);
1643 return id;
1644 }
1645 var maybeReactUseId = SafeReact.useId;
1646 function useId(idOverride, prefix) {
1647 if (maybeReactUseId !== void 0) {
1648 const reactId = maybeReactUseId();
1649 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
1650 }
1651 return useGlobalId(idOverride, prefix);
1652 }
1653
1654 // node_modules/@base-ui/react/esm/internals/useBaseUiId.js
1655 function useBaseUiId(idOverride) {
1656 return useId(idOverride, "base-ui");
1657 }
1658
1659 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
1660 var ReactDOM = __toESM(require_react_dom(), 1);
1661
1662 // node_modules/@base-ui/utils/esm/useOnMount.js
1663 var React10 = __toESM(require_react(), 1);
1664 var EMPTY = [];
1665 function useOnMount(fn) {
1666 React10.useEffect(fn, EMPTY);
1667 }
1668
1669 // node_modules/@base-ui/utils/esm/useAnimationFrame.js
1670 var EMPTY2 = null;
1671 var LAST_RAF = globalThis.requestAnimationFrame;
1672 var Scheduler = class {
1673 /* This implementation uses an array as a backing data-structure for frame callbacks.
1674 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
1675 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
1676 * be much more efficient if there is a call pattern that alterns as
1677 * "request-cancel-request-cancel-…".
1678 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
1679 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
1680 callbacks = [];
1681 callbacksCount = 0;
1682 nextId = 1;
1683 startId = 1;
1684 isScheduled = false;
1685 tick = (timestamp) => {
1686 this.isScheduled = false;
1687 const currentCallbacks = this.callbacks;
1688 const currentCallbacksCount = this.callbacksCount;
1689 this.callbacks = [];
1690 this.callbacksCount = 0;
1691 this.startId = this.nextId;
1692 if (currentCallbacksCount > 0) {
1693 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
1694 currentCallbacks[i2]?.(timestamp);
1695 }
1696 }
1697 };
1698 request(fn) {
1699 const id = this.nextId;
1700 this.nextId += 1;
1701 this.callbacks.push(fn);
1702 this.callbacksCount += 1;
1703 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
1704 if (!this.isScheduled || didRAFChange) {
1705 requestAnimationFrame(this.tick);
1706 this.isScheduled = true;
1707 }
1708 return id;
1709 }
1710 cancel(id) {
1711 const index2 = id - this.startId;
1712 if (index2 < 0 || index2 >= this.callbacks.length) {
1713 return;
1714 }
1715 this.callbacks[index2] = null;
1716 this.callbacksCount -= 1;
1717 }
1718 };
1719 var scheduler = new Scheduler();
1720 var AnimationFrame = class _AnimationFrame {
1721 static create() {
1722 return new _AnimationFrame();
1723 }
1724 static request(fn) {
1725 return scheduler.request(fn);
1726 }
1727 static cancel(id) {
1728 return scheduler.cancel(id);
1729 }
1730 currentId = EMPTY2;
1731 /**
1732 * Executes `fn` after `delay`, clearing any previously scheduled call.
1733 */
1734 request(fn) {
1735 this.cancel();
1736 this.currentId = scheduler.request(() => {
1737 this.currentId = EMPTY2;
1738 fn();
1739 });
1740 }
1741 cancel = () => {
1742 if (this.currentId !== EMPTY2) {
1743 scheduler.cancel(this.currentId);
1744 this.currentId = EMPTY2;
1745 }
1746 };
1747 disposeEffect = () => {
1748 return this.cancel;
1749 };
1750 };
1751 function useAnimationFrame() {
1752 const timeout = useRefWithInit(AnimationFrame.create).current;
1753 useOnMount(timeout.disposeEffect);
1754 return timeout;
1755 }
1756
1757 // node_modules/@base-ui/react/esm/utils/resolveRef.js
1758 function resolveRef(maybeRef) {
1759 if (maybeRef == null) {
1760 return maybeRef;
1761 }
1762 return "current" in maybeRef ? maybeRef.current : maybeRef;
1763 }
1764
1765 // node_modules/@base-ui/react/esm/internals/stateAttributesMapping.js
1766 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
1767 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
1768 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
1769 return TransitionStatusDataAttributes2;
1770 })({});
1771 var STARTING_HOOK = {
1772 [TransitionStatusDataAttributes.startingStyle]: ""
1773 };
1774 var ENDING_HOOK = {
1775 [TransitionStatusDataAttributes.endingStyle]: ""
1776 };
1777 var transitionStatusMapping = {
1778 transitionStatus(value) {
1779 if (value === "starting") {
1780 return STARTING_HOOK;
1781 }
1782 if (value === "ending") {
1783 return ENDING_HOOK;
1784 }
1785 return null;
1786 }
1787 };
1788
1789 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
1790 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
1791 const frame = useAnimationFrame();
1792 return useStableCallback((fnToExecute, signal = null) => {
1793 frame.cancel();
1794 const element = resolveRef(elementOrRef);
1795 if (element == null) {
1796 return;
1797 }
1798 const resolvedElement = element;
1799 const done = () => {
1800 ReactDOM.flushSync(fnToExecute);
1801 };
1802 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
1803 fnToExecute();
1804 return;
1805 }
1806 function exec() {
1807 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
1808 if (!signal?.aborted) {
1809 done();
1810 }
1811 }).catch(() => {
1812 if (treatAbortedAsFinished) {
1813 if (!signal?.aborted) {
1814 done();
1815 }
1816 return;
1817 }
1818 const currentAnimations = resolvedElement.getAnimations();
1819 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
1820 exec();
1821 }
1822 });
1823 }
1824 if (waitForStartingStyleRemoved) {
1825 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
1826 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
1827 frame.request(exec);
1828 return;
1829 }
1830 const attributeObserver = new MutationObserver(() => {
1831 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
1832 attributeObserver.disconnect();
1833 exec();
1834 }
1835 });
1836 attributeObserver.observe(resolvedElement, {
1837 attributes: true,
1838 attributeFilter: [startingStyleAttribute]
1839 });
1840 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
1841 once: true
1842 });
1843 return;
1844 }
1845 frame.request(exec);
1846 });
1847 }
1848
1849 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1850 var React11 = __toESM(require_react(), 1);
1851 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
1852 const [transitionStatus, setTransitionStatus] = React11.useState(open && enableIdleState ? "idle" : void 0);
1853 const [mounted, setMounted] = React11.useState(open);
1854 if (open && !mounted) {
1855 setMounted(true);
1856 setTransitionStatus("starting");
1857 }
1858 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
1859 setTransitionStatus("ending");
1860 }
1861 if (!open && !mounted && transitionStatus === "ending") {
1862 setTransitionStatus(void 0);
1863 }
1864 useIsoLayoutEffect(() => {
1865 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
1866 const frame = AnimationFrame.request(() => {
1867 setTransitionStatus("ending");
1868 });
1869 return () => {
1870 AnimationFrame.cancel(frame);
1871 };
1872 }
1873 return void 0;
1874 }, [open, mounted, transitionStatus, deferEndingState]);
1875 useIsoLayoutEffect(() => {
1876 if (!open || enableIdleState) {
1877 return void 0;
1878 }
1879 const frame = AnimationFrame.request(() => {
1880 setTransitionStatus(void 0);
1881 });
1882 return () => {
1883 AnimationFrame.cancel(frame);
1884 };
1885 }, [enableIdleState, open]);
1886 useIsoLayoutEffect(() => {
1887 if (!open || !enableIdleState) {
1888 return void 0;
1889 }
1890 if (open && mounted && transitionStatus !== "idle") {
1891 setTransitionStatus("starting");
1892 }
1893 const frame = AnimationFrame.request(() => {
1894 setTransitionStatus("idle");
1895 });
1896 return () => {
1897 AnimationFrame.cancel(frame);
1898 };
1899 }, [enableIdleState, open, mounted, transitionStatus]);
1900 return {
1901 mounted,
1902 setMounted,
1903 transitionStatus
1904 };
1905 }
1906
1907 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
1908 function hasWindow() {
1909 return typeof window !== "undefined";
1910 }
1911 function getNodeName(node) {
1912 if (isNode(node)) {
1913 return (node.nodeName || "").toLowerCase();
1914 }
1915 return "#document";
1916 }
1917 function getWindow(node) {
1918 var _node$ownerDocument;
1919 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1920 }
1921 function getDocumentElement(node) {
1922 var _ref;
1923 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1924 }
1925 function isNode(value) {
1926 if (!hasWindow()) {
1927 return false;
1928 }
1929 return value instanceof Node || value instanceof getWindow(value).Node;
1930 }
1931 function isElement(value) {
1932 if (!hasWindow()) {
1933 return false;
1934 }
1935 return value instanceof Element || value instanceof getWindow(value).Element;
1936 }
1937 function isHTMLElement(value) {
1938 if (!hasWindow()) {
1939 return false;
1940 }
1941 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1942 }
1943 function isShadowRoot(value) {
1944 if (!hasWindow() || typeof ShadowRoot === "undefined") {
1945 return false;
1946 }
1947 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1948 }
1949 function isOverflowElement(element) {
1950 const {
1951 overflow,
1952 overflowX,
1953 overflowY,
1954 display
1955 } = getComputedStyle2(element);
1956 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
1957 }
1958 function isTableElement(element) {
1959 return /^(table|td|th)$/.test(getNodeName(element));
1960 }
1961 function isTopLayer(element) {
1962 try {
1963 if (element.matches(":popover-open")) {
1964 return true;
1965 }
1966 } catch (_e) {
1967 }
1968 try {
1969 return element.matches(":modal");
1970 } catch (_e) {
1971 return false;
1972 }
1973 }
1974 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
1975 var containRe = /paint|layout|strict|content/;
1976 var isNotNone = (value) => !!value && value !== "none";
1977 var isWebKitValue;
1978 function isContainingBlock(elementOrCss) {
1979 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
1980 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 || "");
1981 }
1982 function getContainingBlock(element) {
1983 let currentNode = getParentNode(element);
1984 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1985 if (isContainingBlock(currentNode)) {
1986 return currentNode;
1987 } else if (isTopLayer(currentNode)) {
1988 return null;
1989 }
1990 currentNode = getParentNode(currentNode);
1991 }
1992 return null;
1993 }
1994 function isWebKit() {
1995 if (isWebKitValue == null) {
1996 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
1997 }
1998 return isWebKitValue;
1999 }
2000 function isLastTraversableNode(node) {
2001 return /^(html|body|#document)$/.test(getNodeName(node));
2002 }
2003 function getComputedStyle2(element) {
2004 return getWindow(element).getComputedStyle(element);
2005 }
2006 function getNodeScroll(element) {
2007 if (isElement(element)) {
2008 return {
2009 scrollLeft: element.scrollLeft,
2010 scrollTop: element.scrollTop
2011 };
2012 }
2013 return {
2014 scrollLeft: element.scrollX,
2015 scrollTop: element.scrollY
2016 };
2017 }
2018 function getParentNode(node) {
2019 if (getNodeName(node) === "html") {
2020 return node;
2021 }
2022 const result = (
2023 // Step into the shadow DOM of the parent of a slotted node.
2024 node.assignedSlot || // DOM Element detected.
2025 node.parentNode || // ShadowRoot detected.
2026 isShadowRoot(node) && node.host || // Fallback.
2027 getDocumentElement(node)
2028 );
2029 return isShadowRoot(result) ? result.host : result;
2030 }
2031 function getNearestOverflowAncestor(node) {
2032 const parentNode = getParentNode(node);
2033 if (isLastTraversableNode(parentNode)) {
2034 return node.ownerDocument ? node.ownerDocument.body : node.body;
2035 }
2036 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
2037 return parentNode;
2038 }
2039 return getNearestOverflowAncestor(parentNode);
2040 }
2041 function getOverflowAncestors(node, list, traverseIframes) {
2042 var _node$ownerDocument2;
2043 if (list === void 0) {
2044 list = [];
2045 }
2046 if (traverseIframes === void 0) {
2047 traverseIframes = true;
2048 }
2049 const scrollableAncestor = getNearestOverflowAncestor(node);
2050 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
2051 const win = getWindow(scrollableAncestor);
2052 if (isBody) {
2053 const frameElement = getFrameElement(win);
2054 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
2055 } else {
2056 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
2057 }
2058 }
2059 function getFrameElement(win) {
2060 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
2061 }
2062
2063 // node_modules/@base-ui/utils/esm/detectBrowser.js
2064 var hasNavigator = typeof navigator !== "undefined";
2065 var nav = getNavigatorData();
2066 var platform = getPlatform();
2067 var userAgent = getUserAgent();
2068 var isWebKit2 = typeof CSS === "undefined" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter:none");
2069 var isIOS = (
2070 // iPads can claim to be MacIntel
2071 nav.platform === "MacIntel" && nav.maxTouchPoints > 1 ? true : /iP(hone|ad|od)|iOS/.test(nav.platform)
2072 );
2073 var isFirefox = hasNavigator && /firefox/i.test(userAgent);
2074 var isSafari = hasNavigator && /apple/i.test(navigator.vendor);
2075 var isEdge = hasNavigator && /Edg/i.test(userAgent);
2076 var isAndroid = hasNavigator && /android/i.test(platform) || /android/i.test(userAgent);
2077 var isMac = hasNavigator && platform.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
2078 var isJSDOM = userAgent.includes("jsdom/");
2079 function getNavigatorData() {
2080 if (!hasNavigator) {
2081 return {
2082 platform: "",
2083 maxTouchPoints: -1
2084 };
2085 }
2086 const uaData = navigator.userAgentData;
2087 if (uaData?.platform) {
2088 return {
2089 platform: uaData.platform,
2090 maxTouchPoints: navigator.maxTouchPoints
2091 };
2092 }
2093 return {
2094 platform: navigator.platform ?? "",
2095 maxTouchPoints: navigator.maxTouchPoints ?? -1
2096 };
2097 }
2098 function getUserAgent() {
2099 if (!hasNavigator) {
2100 return "";
2101 }
2102 const uaData = navigator.userAgentData;
2103 if (uaData && Array.isArray(uaData.brands)) {
2104 return uaData.brands.map(({
2105 brand,
2106 version: version2
2107 }) => `${brand}/${version2}`).join(" ");
2108 }
2109 return navigator.userAgent;
2110 }
2111 function getPlatform() {
2112 if (!hasNavigator) {
2113 return "";
2114 }
2115 const uaData = navigator.userAgentData;
2116 if (uaData?.platform) {
2117 return uaData.platform;
2118 }
2119 return navigator.platform ?? "";
2120 }
2121
2122 // node_modules/@base-ui/react/esm/floating-ui-react/utils/constants.js
2123 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
2124 var ACTIVE_KEY = "active";
2125 var SELECTED_KEY = "selected";
2126 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
2127
2128 // node_modules/@base-ui/react/esm/internals/shadowDom.js
2129 function activeElement(doc) {
2130 let element = doc.activeElement;
2131 while (element?.shadowRoot?.activeElement != null) {
2132 element = element.shadowRoot.activeElement;
2133 }
2134 return element;
2135 }
2136 function contains(parent, child) {
2137 if (!parent || !child) {
2138 return false;
2139 }
2140 const rootNode = child.getRootNode?.();
2141 if (parent.contains(child)) {
2142 return true;
2143 }
2144 if (rootNode && isShadowRoot(rootNode)) {
2145 let next = child;
2146 while (next) {
2147 if (parent === next) {
2148 return true;
2149 }
2150 next = next.parentNode || next.host;
2151 }
2152 }
2153 return false;
2154 }
2155 function getTarget(event) {
2156 if ("composedPath" in event) {
2157 return event.composedPath()[0];
2158 }
2159 return event.target;
2160 }
2161
2162 // node_modules/@base-ui/react/esm/floating-ui-react/utils/element.js
2163 function isTargetInsideEnabledTrigger(target, triggerElements) {
2164 if (!isElement(target)) {
2165 return false;
2166 }
2167 const targetElement = target;
2168 if (triggerElements.hasElement(targetElement)) {
2169 return !targetElement.hasAttribute("data-trigger-disabled");
2170 }
2171 for (const [, trigger] of triggerElements.entries()) {
2172 if (contains(trigger, targetElement)) {
2173 return !trigger.hasAttribute("data-trigger-disabled");
2174 }
2175 }
2176 return false;
2177 }
2178 function isEventTargetWithin(event, node) {
2179 if (node == null) {
2180 return false;
2181 }
2182 if ("composedPath" in event) {
2183 return event.composedPath().includes(node);
2184 }
2185 const eventAgain = event;
2186 return eventAgain.target != null && node.contains(eventAgain.target);
2187 }
2188 function isRootElement(element) {
2189 return element.matches("html,body");
2190 }
2191 function isTypeableElement(element) {
2192 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
2193 }
2194 function isInteractiveElement(element) {
2195 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
2196 }
2197 function matchesFocusVisible(element) {
2198 if (!element || isJSDOM) {
2199 return true;
2200 }
2201 try {
2202 return element.matches(":focus-visible");
2203 } catch (_e) {
2204 return true;
2205 }
2206 }
2207
2208 // node_modules/@base-ui/react/esm/floating-ui-react/utils/nodes.js
2209 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
2210 const directChildren = nodes.filter((node) => node.parentId === id);
2211 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
2212 }
2213
2214 // node_modules/@base-ui/react/esm/floating-ui-react/utils/event.js
2215 function isReactEvent(event) {
2216 return "nativeEvent" in event;
2217 }
2218 function isMouseLikePointerType(pointerType, strict) {
2219 const values = ["mouse", "pen"];
2220 if (!strict) {
2221 values.push("", void 0);
2222 }
2223 return values.includes(pointerType);
2224 }
2225 function isClickLikeEvent(event) {
2226 const type = event.type;
2227 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
2228 }
2229
2230 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
2231 var sides = ["top", "right", "bottom", "left"];
2232 var min = Math.min;
2233 var max = Math.max;
2234 var round = Math.round;
2235 var floor = Math.floor;
2236 var createCoords = (v2) => ({
2237 x: v2,
2238 y: v2
2239 });
2240 var oppositeSideMap = {
2241 left: "right",
2242 right: "left",
2243 bottom: "top",
2244 top: "bottom"
2245 };
2246 function clamp(start, value, end) {
2247 return max(start, min(value, end));
2248 }
2249 function evaluate(value, param) {
2250 return typeof value === "function" ? value(param) : value;
2251 }
2252 function getSide(placement) {
2253 return placement.split("-")[0];
2254 }
2255 function getAlignment(placement) {
2256 return placement.split("-")[1];
2257 }
2258 function getOppositeAxis(axis) {
2259 return axis === "x" ? "y" : "x";
2260 }
2261 function getAxisLength(axis) {
2262 return axis === "y" ? "height" : "width";
2263 }
2264 function getSideAxis(placement) {
2265 const firstChar = placement[0];
2266 return firstChar === "t" || firstChar === "b" ? "y" : "x";
2267 }
2268 function getAlignmentAxis(placement) {
2269 return getOppositeAxis(getSideAxis(placement));
2270 }
2271 function getAlignmentSides(placement, rects, rtl) {
2272 if (rtl === void 0) {
2273 rtl = false;
2274 }
2275 const alignment = getAlignment(placement);
2276 const alignmentAxis = getAlignmentAxis(placement);
2277 const length = getAxisLength(alignmentAxis);
2278 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
2279 if (rects.reference[length] > rects.floating[length]) {
2280 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
2281 }
2282 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
2283 }
2284 function getExpandedPlacements(placement) {
2285 const oppositePlacement = getOppositePlacement(placement);
2286 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
2287 }
2288 function getOppositeAlignmentPlacement(placement) {
2289 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
2290 }
2291 var lrPlacement = ["left", "right"];
2292 var rlPlacement = ["right", "left"];
2293 var tbPlacement = ["top", "bottom"];
2294 var btPlacement = ["bottom", "top"];
2295 function getSideList(side, isStart, rtl) {
2296 switch (side) {
2297 case "top":
2298 case "bottom":
2299 if (rtl) return isStart ? rlPlacement : lrPlacement;
2300 return isStart ? lrPlacement : rlPlacement;
2301 case "left":
2302 case "right":
2303 return isStart ? tbPlacement : btPlacement;
2304 default:
2305 return [];
2306 }
2307 }
2308 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
2309 const alignment = getAlignment(placement);
2310 let list = getSideList(getSide(placement), direction === "start", rtl);
2311 if (alignment) {
2312 list = list.map((side) => side + "-" + alignment);
2313 if (flipAlignment) {
2314 list = list.concat(list.map(getOppositeAlignmentPlacement));
2315 }
2316 }
2317 return list;
2318 }
2319 function getOppositePlacement(placement) {
2320 const side = getSide(placement);
2321 return oppositeSideMap[side] + placement.slice(side.length);
2322 }
2323 function expandPaddingObject(padding) {
2324 return {
2325 top: 0,
2326 right: 0,
2327 bottom: 0,
2328 left: 0,
2329 ...padding
2330 };
2331 }
2332 function getPaddingObject(padding) {
2333 return typeof padding !== "number" ? expandPaddingObject(padding) : {
2334 top: padding,
2335 right: padding,
2336 bottom: padding,
2337 left: padding
2338 };
2339 }
2340 function rectToClientRect(rect) {
2341 const {
2342 x: x2,
2343 y: y2,
2344 width,
2345 height
2346 } = rect;
2347 return {
2348 width,
2349 height,
2350 top: y2,
2351 left: x2,
2352 right: x2 + width,
2353 bottom: y2 + height,
2354 x: x2,
2355 y: y2
2356 };
2357 }
2358
2359 // node_modules/@base-ui/react/esm/floating-ui-react/utils/composite.js
2360 function isHiddenByStyles(styles) {
2361 return styles.visibility === "hidden" || styles.visibility === "collapse";
2362 }
2363 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
2364 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
2365 return false;
2366 }
2367 if (typeof element.checkVisibility === "function") {
2368 return element.checkVisibility();
2369 }
2370 return styles.display !== "none" && styles.display !== "contents";
2371 }
2372
2373 // node_modules/@base-ui/utils/esm/owner.js
2374 function ownerDocument(node) {
2375 return node?.ownerDocument || document;
2376 }
2377
2378 // node_modules/@base-ui/react/esm/floating-ui-react/utils/tabbable.js
2379 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
2380 function getParentElement(element) {
2381 const assignedSlot = element.assignedSlot;
2382 if (assignedSlot) {
2383 return assignedSlot;
2384 }
2385 if (element.parentElement) {
2386 return element.parentElement;
2387 }
2388 const rootNode = element.getRootNode();
2389 return isShadowRoot(rootNode) ? rootNode.host : null;
2390 }
2391 function getDetailsSummary(details) {
2392 for (const child of Array.from(details.children)) {
2393 if (getNodeName(child) === "summary") {
2394 return child;
2395 }
2396 }
2397 return null;
2398 }
2399 function isWithinOpenDetailsSummary(element, details) {
2400 const summary = getDetailsSummary(details);
2401 return !!summary && (element === summary || contains(summary, element));
2402 }
2403 function isFocusableCandidate(element) {
2404 const nodeName = element ? getNodeName(element) : "";
2405 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");
2406 }
2407 function isFocusableElement(element) {
2408 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
2409 return false;
2410 }
2411 for (let current = element; current; current = getParentElement(current)) {
2412 const isAncestor = current !== element;
2413 const isSlot = getNodeName(current) === "slot";
2414 if (current.hasAttribute("inert")) {
2415 return false;
2416 }
2417 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
2418 return false;
2419 }
2420 }
2421 return true;
2422 }
2423 function isVisibleInTabbableTree(element, isAncestor) {
2424 const styles = getComputedStyle2(element);
2425 if (!isAncestor) {
2426 return isElementVisible(element, styles);
2427 }
2428 return styles.display !== "none";
2429 }
2430 function getTabIndex(element) {
2431 const tabIndex = element.tabIndex;
2432 if (tabIndex < 0) {
2433 const nodeName = getNodeName(element);
2434 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
2435 return 0;
2436 }
2437 }
2438 return tabIndex;
2439 }
2440 function getNamedRadioInput(element) {
2441 if (getNodeName(element) !== "input") {
2442 return null;
2443 }
2444 const input = element;
2445 return input.type === "radio" && input.name !== "" ? input : null;
2446 }
2447 function isTabbableRadio(element, candidates) {
2448 const input = getNamedRadioInput(element);
2449 if (!input) {
2450 return true;
2451 }
2452 const checkedRadio = candidates.find((candidate) => {
2453 const radio = getNamedRadioInput(candidate);
2454 return radio?.name === input.name && radio.form === input.form && radio.checked;
2455 });
2456 if (checkedRadio) {
2457 return checkedRadio === input;
2458 }
2459 return candidates.find((candidate) => {
2460 const radio = getNamedRadioInput(candidate);
2461 return radio?.name === input.name && radio.form === input.form;
2462 }) === input;
2463 }
2464 function getComposedChildren(container) {
2465 if (isHTMLElement(container) && getNodeName(container) === "slot") {
2466 const assignedElements = container.assignedElements({
2467 flatten: true
2468 });
2469 if (assignedElements.length > 0) {
2470 return assignedElements;
2471 }
2472 }
2473 if (isHTMLElement(container) && container.shadowRoot) {
2474 return Array.from(container.shadowRoot.children);
2475 }
2476 return Array.from(container.children);
2477 }
2478 function appendCandidates(container, list) {
2479 getComposedChildren(container).forEach((child) => {
2480 if (isFocusableCandidate(child)) {
2481 list.push(child);
2482 }
2483 appendCandidates(child, list);
2484 });
2485 }
2486 function appendMatchingElements(container, selector2, list) {
2487 getComposedChildren(container).forEach((child) => {
2488 if (isHTMLElement(child) && child.matches(selector2)) {
2489 list.push(child);
2490 }
2491 appendMatchingElements(child, selector2, list);
2492 });
2493 }
2494 function focusable(container) {
2495 const candidates = [];
2496 appendCandidates(container, candidates);
2497 return candidates.filter(isFocusableElement);
2498 }
2499 function tabbable(container) {
2500 const candidates = focusable(container);
2501 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
2502 }
2503 function getTabbableIn(container, dir) {
2504 const list = tabbable(container);
2505 const len = list.length;
2506 if (len === 0) {
2507 return void 0;
2508 }
2509 const active = activeElement(ownerDocument(container));
2510 const index2 = list.indexOf(active);
2511 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
2512 return list[nextIndex];
2513 }
2514 function getNextTabbable(referenceElement) {
2515 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
2516 }
2517 function getPreviousTabbable(referenceElement) {
2518 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
2519 }
2520 function isOutsideEvent(event, container) {
2521 const containerElement = container || event.currentTarget;
2522 const relatedTarget = event.relatedTarget;
2523 return !relatedTarget || !contains(containerElement, relatedTarget);
2524 }
2525 function disableFocusInside(container) {
2526 const tabbableElements = tabbable(container);
2527 tabbableElements.forEach((element) => {
2528 element.dataset.tabindex = element.getAttribute("tabindex") || "";
2529 element.setAttribute("tabindex", "-1");
2530 });
2531 }
2532 function enableFocusInside(container) {
2533 const elements = [];
2534 appendMatchingElements(container, "[data-tabindex]", elements);
2535 elements.forEach((element) => {
2536 const tabindex = element.dataset.tabindex;
2537 delete element.dataset.tabindex;
2538 if (tabindex) {
2539 element.setAttribute("tabindex", tabindex);
2540 } else {
2541 element.removeAttribute("tabindex");
2542 }
2543 });
2544 }
2545
2546 // node_modules/@base-ui/utils/esm/addEventListener.js
2547 function addEventListener(target, type, listener, options) {
2548 target.addEventListener(type, listener, options);
2549 return () => {
2550 target.removeEventListener(type, listener, options);
2551 };
2552 }
2553
2554 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
2555 var React12 = __toESM(require_react(), 1);
2556 function useOpenChangeComplete(parameters) {
2557 const {
2558 enabled = true,
2559 open,
2560 ref,
2561 onComplete: onCompleteParam
2562 } = parameters;
2563 const onComplete = useStableCallback(onCompleteParam);
2564 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
2565 React12.useEffect(() => {
2566 if (!enabled) {
2567 return void 0;
2568 }
2569 const abortController = new AbortController();
2570 runOnceAnimationsFinish(onComplete, abortController.signal);
2571 return () => {
2572 abortController.abort();
2573 };
2574 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
2575 }
2576
2577 // node_modules/@base-ui/utils/esm/useOnFirstRender.js
2578 var React13 = __toESM(require_react(), 1);
2579 function useOnFirstRender(fn) {
2580 const ref = React13.useRef(true);
2581 if (ref.current) {
2582 ref.current = false;
2583 fn();
2584 }
2585 }
2586
2587 // node_modules/@base-ui/utils/esm/useTimeout.js
2588 var EMPTY3 = 0;
2589 var Timeout = class _Timeout {
2590 static create() {
2591 return new _Timeout();
2592 }
2593 currentId = EMPTY3;
2594 /**
2595 * Executes `fn` after `delay`, clearing any previously scheduled call.
2596 */
2597 start(delay, fn) {
2598 this.clear();
2599 this.currentId = setTimeout(() => {
2600 this.currentId = EMPTY3;
2601 fn();
2602 }, delay);
2603 }
2604 isStarted() {
2605 return this.currentId !== EMPTY3;
2606 }
2607 clear = () => {
2608 if (this.currentId !== EMPTY3) {
2609 clearTimeout(this.currentId);
2610 this.currentId = EMPTY3;
2611 }
2612 };
2613 disposeEffect = () => {
2614 return this.clear;
2615 };
2616 };
2617 function useTimeout() {
2618 const timeout = useRefWithInit(Timeout.create).current;
2619 useOnMount(timeout.disposeEffect);
2620 return timeout;
2621 }
2622
2623 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2624 var React14 = __toESM(require_react(), 1);
2625
2626 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverShared.js
2627 function resolveValue(value, pointerType) {
2628 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
2629 return 0;
2630 }
2631 if (typeof value === "function") {
2632 return value();
2633 }
2634 return value;
2635 }
2636 function getDelay(value, prop, pointerType) {
2637 const result = resolveValue(value, pointerType);
2638 if (typeof result === "number") {
2639 return result;
2640 }
2641 return result?.[prop];
2642 }
2643 function getRestMs(value) {
2644 if (typeof value === "function") {
2645 return value();
2646 }
2647 return value;
2648 }
2649 function isClickLikeOpenEvent(openEventType, interactedInside) {
2650 return interactedInside || openEventType === "click" || openEventType === "mousedown";
2651 }
2652
2653 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2654 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
2655 var FloatingDelayGroupContext = /* @__PURE__ */ React14.createContext({
2656 hasProvider: false,
2657 timeoutMs: 0,
2658 delayRef: {
2659 current: 0
2660 },
2661 initialDelayRef: {
2662 current: 0
2663 },
2664 timeout: new Timeout(),
2665 currentIdRef: {
2666 current: null
2667 },
2668 currentContextRef: {
2669 current: null
2670 }
2671 });
2672 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
2673 function FloatingDelayGroup(props) {
2674 const {
2675 children,
2676 delay,
2677 timeoutMs = 0
2678 } = props;
2679 const delayRef = React14.useRef(delay);
2680 const initialDelayRef = React14.useRef(delay);
2681 const currentIdRef = React14.useRef(null);
2682 const currentContextRef = React14.useRef(null);
2683 const timeout = useTimeout();
2684 return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(FloatingDelayGroupContext.Provider, {
2685 value: React14.useMemo(() => ({
2686 hasProvider: true,
2687 delayRef,
2688 initialDelayRef,
2689 currentIdRef,
2690 timeoutMs,
2691 currentContextRef,
2692 timeout
2693 }), [timeoutMs, timeout]),
2694 children
2695 });
2696 }
2697 function useDelayGroup(context, options = {
2698 open: false
2699 }) {
2700 const store = "rootStore" in context ? context.rootStore : context;
2701 const floatingId = store.useState("floatingId");
2702 const {
2703 open
2704 } = options;
2705 const groupContext = React14.useContext(FloatingDelayGroupContext);
2706 const {
2707 currentIdRef,
2708 delayRef,
2709 timeoutMs,
2710 initialDelayRef,
2711 currentContextRef,
2712 hasProvider,
2713 timeout
2714 } = groupContext;
2715 const [isInstantPhase, setIsInstantPhase] = React14.useState(false);
2716 useIsoLayoutEffect(() => {
2717 function unset() {
2718 setIsInstantPhase(false);
2719 currentContextRef.current?.setIsInstantPhase(false);
2720 currentIdRef.current = null;
2721 currentContextRef.current = null;
2722 delayRef.current = initialDelayRef.current;
2723 }
2724 if (!currentIdRef.current) {
2725 return void 0;
2726 }
2727 if (!open && currentIdRef.current === floatingId) {
2728 setIsInstantPhase(false);
2729 if (timeoutMs) {
2730 const closingId = floatingId;
2731 timeout.start(timeoutMs, () => {
2732 if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
2733 return;
2734 }
2735 unset();
2736 });
2737 return () => {
2738 timeout.clear();
2739 };
2740 }
2741 unset();
2742 }
2743 return void 0;
2744 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]);
2745 useIsoLayoutEffect(() => {
2746 if (!open) {
2747 return;
2748 }
2749 const prevContext = currentContextRef.current;
2750 const prevId = currentIdRef.current;
2751 timeout.clear();
2752 currentContextRef.current = {
2753 onOpenChange: store.setOpen,
2754 setIsInstantPhase
2755 };
2756 currentIdRef.current = floatingId;
2757 delayRef.current = {
2758 open: 0,
2759 close: getDelay(initialDelayRef.current, "close")
2760 };
2761 if (prevId !== null && prevId !== floatingId) {
2762 setIsInstantPhase(true);
2763 prevContext?.setIsInstantPhase(true);
2764 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
2765 } else {
2766 setIsInstantPhase(false);
2767 prevContext?.setIsInstantPhase(false);
2768 }
2769 }, [open, floatingId, store, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout]);
2770 useIsoLayoutEffect(() => {
2771 return () => {
2772 currentContextRef.current = null;
2773 };
2774 }, [currentContextRef]);
2775 return React14.useMemo(() => ({
2776 hasProvider,
2777 delayRef,
2778 isInstantPhase
2779 }), [hasProvider, delayRef, isInstantPhase]);
2780 }
2781
2782 // node_modules/@base-ui/utils/esm/mergeCleanups.js
2783 function mergeCleanups(...cleanups) {
2784 return () => {
2785 for (let i2 = 0; i2 < cleanups.length; i2 += 1) {
2786 const cleanup = cleanups[i2];
2787 if (cleanup) {
2788 cleanup();
2789 }
2790 }
2791 };
2792 }
2793
2794 // node_modules/@base-ui/utils/esm/useValueAsRef.js
2795 function useValueAsRef(value) {
2796 const latest = useRefWithInit(createLatestRef, value).current;
2797 latest.next = value;
2798 useIsoLayoutEffect(latest.effect);
2799 return latest;
2800 }
2801 function createLatestRef(value) {
2802 const latest = {
2803 current: value,
2804 next: value,
2805 effect: () => {
2806 latest.current = latest.next;
2807 }
2808 };
2809 return latest;
2810 }
2811
2812 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
2813 var React15 = __toESM(require_react(), 1);
2814
2815 // node_modules/@base-ui/utils/esm/visuallyHidden.js
2816 var visuallyHiddenBase = {
2817 clipPath: "inset(50%)",
2818 overflow: "hidden",
2819 whiteSpace: "nowrap",
2820 border: 0,
2821 padding: 0,
2822 width: 1,
2823 height: 1,
2824 margin: -1
2825 };
2826 var visuallyHidden = {
2827 ...visuallyHiddenBase,
2828 position: "fixed",
2829 top: 0,
2830 left: 0
2831 };
2832 var visuallyHiddenInput = {
2833 ...visuallyHiddenBase,
2834 position: "absolute"
2835 };
2836
2837 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
2838 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
2839 var FocusGuard = /* @__PURE__ */ React15.forwardRef(function FocusGuard2(props, ref) {
2840 const [role, setRole] = React15.useState();
2841 useIsoLayoutEffect(() => {
2842 if (isSafari) {
2843 setRole("button");
2844 }
2845 }, []);
2846 const restProps = {
2847 tabIndex: 0,
2848 // Role is only for VoiceOver
2849 role
2850 };
2851 return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", {
2852 ...props,
2853 ref,
2854 style: visuallyHidden,
2855 "aria-hidden": role ? void 0 : true,
2856 ...restProps,
2857 "data-base-ui-focus-guard": ""
2858 });
2859 });
2860 if (true) FocusGuard.displayName = "FocusGuard";
2861
2862 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createAttribute.js
2863 function createAttribute(name) {
2864 return `data-base-ui-${name}`;
2865 }
2866
2867 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
2868 var React16 = __toESM(require_react(), 1);
2869 var ReactDOM2 = __toESM(require_react_dom(), 1);
2870
2871 // node_modules/@base-ui/react/esm/internals/constants.js
2872 var DISABLED_TRANSITIONS_STYLE = {
2873 style: {
2874 transition: "none"
2875 }
2876 };
2877 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
2878 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
2879 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
2880 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
2881 var POPUP_COLLISION_AVOIDANCE = {
2882 fallbackAxisSide: "end"
2883 };
2884 var ownerVisuallyHidden = {
2885 clipPath: "inset(50%)",
2886 position: "fixed",
2887 top: 0,
2888 left: 0
2889 };
2890
2891 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
2892 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
2893 var PortalContext = /* @__PURE__ */ React16.createContext(null);
2894 if (true) PortalContext.displayName = "PortalContext";
2895 var usePortalContext = () => React16.useContext(PortalContext);
2896 var attr = createAttribute("portal");
2897 function useFloatingPortalNode(props = {}) {
2898 const {
2899 ref,
2900 container: containerProp,
2901 componentProps = EMPTY_OBJECT,
2902 elementProps
2903 } = props;
2904 const uniqueId = useId();
2905 const portalContext = usePortalContext();
2906 const parentPortalNode = portalContext?.portalNode;
2907 const [containerElement, setContainerElement] = React16.useState(null);
2908 const [portalNode, setPortalNode] = React16.useState(null);
2909 const setPortalNodeRef = useStableCallback((node) => {
2910 if (node !== null) {
2911 setPortalNode(node);
2912 }
2913 });
2914 const containerRef = React16.useRef(null);
2915 useIsoLayoutEffect(() => {
2916 if (containerProp === null) {
2917 if (containerRef.current) {
2918 containerRef.current = null;
2919 setPortalNode(null);
2920 setContainerElement(null);
2921 }
2922 return;
2923 }
2924 if (uniqueId == null) {
2925 return;
2926 }
2927 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
2928 if (resolvedContainer == null) {
2929 if (containerRef.current) {
2930 containerRef.current = null;
2931 setPortalNode(null);
2932 setContainerElement(null);
2933 }
2934 return;
2935 }
2936 if (containerRef.current !== resolvedContainer) {
2937 containerRef.current = resolvedContainer;
2938 setPortalNode(null);
2939 setContainerElement(resolvedContainer);
2940 }
2941 }, [containerProp, parentPortalNode, uniqueId]);
2942 const portalElement = useRenderElement("div", componentProps, {
2943 ref: [ref, setPortalNodeRef],
2944 props: [{
2945 id: uniqueId,
2946 [attr]: ""
2947 }, elementProps]
2948 });
2949 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
2950 return {
2951 portalNode,
2952 portalSubtree
2953 };
2954 }
2955 var FloatingPortal = /* @__PURE__ */ React16.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
2956 const {
2957 children,
2958 container,
2959 className,
2960 render: render4,
2961 renderGuards,
2962 style,
2963 ...elementProps
2964 } = componentProps;
2965 const {
2966 portalNode,
2967 portalSubtree
2968 } = useFloatingPortalNode({
2969 container,
2970 ref: forwardedRef,
2971 componentProps,
2972 elementProps
2973 });
2974 const beforeOutsideRef = React16.useRef(null);
2975 const afterOutsideRef = React16.useRef(null);
2976 const beforeInsideRef = React16.useRef(null);
2977 const afterInsideRef = React16.useRef(null);
2978 const [focusManagerState, setFocusManagerState] = React16.useState(null);
2979 const focusInsideDisabledRef = React16.useRef(false);
2980 const modal = focusManagerState?.modal;
2981 const open = focusManagerState?.open;
2982 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
2983 React16.useEffect(() => {
2984 if (!portalNode || modal) {
2985 return void 0;
2986 }
2987 function onFocus(event) {
2988 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
2989 if (event.type === "focusin") {
2990 if (focusInsideDisabledRef.current) {
2991 enableFocusInside(portalNode);
2992 focusInsideDisabledRef.current = false;
2993 }
2994 } else {
2995 disableFocusInside(portalNode);
2996 focusInsideDisabledRef.current = true;
2997 }
2998 }
2999 }
3000 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
3001 }, [portalNode, modal]);
3002 React16.useEffect(() => {
3003 if (!portalNode || open !== false) {
3004 return;
3005 }
3006 enableFocusInside(portalNode);
3007 focusInsideDisabledRef.current = false;
3008 }, [open, portalNode]);
3009 const portalContextValue = React16.useMemo(() => ({
3010 beforeOutsideRef,
3011 afterOutsideRef,
3012 beforeInsideRef,
3013 afterInsideRef,
3014 portalNode,
3015 setFocusManagerState
3016 }), [portalNode]);
3017 return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(React16.Fragment, {
3018 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(PortalContext.Provider, {
3019 value: portalContextValue,
3020 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(FocusGuard, {
3021 "data-type": "outside",
3022 ref: beforeOutsideRef,
3023 onFocus: (event) => {
3024 if (isOutsideEvent(event, portalNode)) {
3025 beforeInsideRef.current?.focus();
3026 } else {
3027 const domReference = focusManagerState ? focusManagerState.domReference : null;
3028 const prevTabbable = getPreviousTabbable(domReference);
3029 prevTabbable?.focus();
3030 }
3031 }
3032 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", {
3033 "aria-owns": portalNode.id,
3034 style: ownerVisuallyHidden
3035 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(FocusGuard, {
3036 "data-type": "outside",
3037 ref: afterOutsideRef,
3038 onFocus: (event) => {
3039 if (isOutsideEvent(event, portalNode)) {
3040 afterInsideRef.current?.focus();
3041 } else {
3042 const domReference = focusManagerState ? focusManagerState.domReference : null;
3043 const nextTabbable = getNextTabbable(domReference);
3044 nextTabbable?.focus();
3045 if (focusManagerState?.closeOnFocusOut) {
3046 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
3047 }
3048 }
3049 }
3050 })]
3051 })]
3052 });
3053 });
3054 if (true) FloatingPortal.displayName = "FloatingPortal";
3055
3056 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
3057 var React17 = __toESM(require_react(), 1);
3058
3059 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createEventEmitter.js
3060 function createEventEmitter() {
3061 const map = /* @__PURE__ */ new Map();
3062 return {
3063 emit(event, data) {
3064 map.get(event)?.forEach((listener) => listener(data));
3065 },
3066 on(event, listener) {
3067 if (!map.has(event)) {
3068 map.set(event, /* @__PURE__ */ new Set());
3069 }
3070 map.get(event).add(listener);
3071 },
3072 off(event, listener) {
3073 map.get(event)?.delete(listener);
3074 }
3075 };
3076 }
3077
3078 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
3079 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
3080 var FloatingNodeContext = /* @__PURE__ */ React17.createContext(null);
3081 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
3082 var FloatingTreeContext = /* @__PURE__ */ React17.createContext(null);
3083 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
3084 var useFloatingParentNodeId = () => React17.useContext(FloatingNodeContext)?.id || null;
3085 var useFloatingTree = (externalTree) => {
3086 const contextTree = React17.useContext(FloatingTreeContext);
3087 return externalTree ?? contextTree;
3088 };
3089
3090 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useClientPoint.js
3091 var React18 = __toESM(require_react(), 1);
3092 function createVirtualElement(domElement, data) {
3093 let offsetX = null;
3094 let offsetY = null;
3095 let isAutoUpdateEvent = false;
3096 return {
3097 contextElement: domElement || void 0,
3098 getBoundingClientRect() {
3099 const domRect = domElement?.getBoundingClientRect() || {
3100 width: 0,
3101 height: 0,
3102 x: 0,
3103 y: 0
3104 };
3105 const isXAxis = data.axis === "x" || data.axis === "both";
3106 const isYAxis = data.axis === "y" || data.axis === "both";
3107 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
3108 let width = domRect.width;
3109 let height = domRect.height;
3110 let x2 = domRect.x;
3111 let y2 = domRect.y;
3112 if (offsetX == null && data.x && isXAxis) {
3113 offsetX = domRect.x - data.x;
3114 }
3115 if (offsetY == null && data.y && isYAxis) {
3116 offsetY = domRect.y - data.y;
3117 }
3118 x2 -= offsetX || 0;
3119 y2 -= offsetY || 0;
3120 width = 0;
3121 height = 0;
3122 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
3123 width = data.axis === "y" ? domRect.width : 0;
3124 height = data.axis === "x" ? domRect.height : 0;
3125 x2 = isXAxis && data.x != null ? data.x : x2;
3126 y2 = isYAxis && data.y != null ? data.y : y2;
3127 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
3128 height = data.axis === "x" ? domRect.height : height;
3129 width = data.axis === "y" ? domRect.width : width;
3130 }
3131 isAutoUpdateEvent = true;
3132 return {
3133 width,
3134 height,
3135 x: x2,
3136 y: y2,
3137 top: y2,
3138 right: x2 + width,
3139 bottom: y2 + height,
3140 left: x2
3141 };
3142 }
3143 };
3144 }
3145 function isMouseBasedEvent(event) {
3146 return event != null && event.clientX != null;
3147 }
3148 function useClientPoint(context, props = {}) {
3149 const store = "rootStore" in context ? context.rootStore : context;
3150 const open = store.useState("open");
3151 const floating = store.useState("floatingElement");
3152 const domReference = store.useState("domReferenceElement");
3153 const dataRef = store.context.dataRef;
3154 const {
3155 enabled = true,
3156 axis = "both"
3157 } = props;
3158 const initialRef = React18.useRef(false);
3159 const cleanupListenerRef = React18.useRef(null);
3160 const [pointerType, setPointerType] = React18.useState();
3161 const [reactive, setReactive] = React18.useState([]);
3162 const setReference = useStableCallback((newX, newY, referenceElement) => {
3163 if (initialRef.current) {
3164 return;
3165 }
3166 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
3167 return;
3168 }
3169 store.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
3170 x: newX,
3171 y: newY,
3172 axis,
3173 dataRef,
3174 pointerType
3175 }));
3176 });
3177 const handleReferenceEnterOrMove = useStableCallback((event) => {
3178 if (!open) {
3179 setReference(event.clientX, event.clientY, event.currentTarget);
3180 } else if (!cleanupListenerRef.current) {
3181 setReactive([]);
3182 }
3183 });
3184 const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
3185 const addListener = React18.useCallback(() => {
3186 if (!openCheck || !enabled) {
3187 return void 0;
3188 }
3189 const win = getWindow(floating);
3190 function handleMouseMove(event) {
3191 const target = getTarget(event);
3192 if (!contains(floating, target)) {
3193 setReference(event.clientX, event.clientY);
3194 } else {
3195 cleanupListenerRef.current?.();
3196 cleanupListenerRef.current = null;
3197 }
3198 }
3199 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
3200 const cleanup = () => {
3201 cleanupListenerRef.current?.();
3202 cleanupListenerRef.current = null;
3203 };
3204 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
3205 return cleanup;
3206 }
3207 store.set("positionReference", domReference);
3208 return void 0;
3209 }, [openCheck, enabled, floating, dataRef, domReference, store, setReference]);
3210 React18.useEffect(() => {
3211 return addListener();
3212 }, [addListener, reactive]);
3213 React18.useEffect(() => {
3214 if (enabled && !floating) {
3215 initialRef.current = false;
3216 }
3217 }, [enabled, floating]);
3218 React18.useEffect(() => {
3219 if (!enabled && open) {
3220 initialRef.current = true;
3221 }
3222 }, [enabled, open]);
3223 const reference = React18.useMemo(() => {
3224 function setPointerTypeRef(event) {
3225 setPointerType(event.pointerType);
3226 }
3227 return {
3228 onPointerDown: setPointerTypeRef,
3229 onPointerEnter: setPointerTypeRef,
3230 onMouseMove: handleReferenceEnterOrMove,
3231 onMouseEnter: handleReferenceEnterOrMove
3232 };
3233 }, [handleReferenceEnterOrMove]);
3234 return React18.useMemo(() => enabled ? {
3235 reference,
3236 trigger: reference
3237 } : {}, [enabled, reference]);
3238 }
3239
3240 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useDismiss.js
3241 var React19 = __toESM(require_react(), 1);
3242 var bubbleHandlerKeys = {
3243 intentional: "onClick",
3244 sloppy: "onPointerDown"
3245 };
3246 function alwaysFalse() {
3247 return false;
3248 }
3249 function normalizeProp(normalizable) {
3250 return {
3251 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
3252 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
3253 };
3254 }
3255 function useDismiss(context, props = {}) {
3256 const store = "rootStore" in context ? context.rootStore : context;
3257 const open = store.useState("open");
3258 const floatingElement = store.useState("floatingElement");
3259 const {
3260 dataRef
3261 } = store.context;
3262 const {
3263 enabled = true,
3264 escapeKey: escapeKey2 = true,
3265 outsidePress: outsidePressProp = true,
3266 outsidePressEvent = "sloppy",
3267 referencePress = alwaysFalse,
3268 referencePressEvent = "sloppy",
3269 bubbles,
3270 externalTree
3271 } = props;
3272 const tree = useFloatingTree(externalTree);
3273 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
3274 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
3275 const outsidePressEnabled = outsidePress2 !== false;
3276 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
3277 const pressStartedInsideRef = React19.useRef(false);
3278 const pressStartPreventedRef = React19.useRef(false);
3279 const suppressNextOutsideClickRef = React19.useRef(false);
3280 const {
3281 escapeKey: escapeKeyBubbles,
3282 outsidePress: outsidePressBubbles
3283 } = normalizeProp(bubbles);
3284 const touchStateRef = React19.useRef(null);
3285 const cancelDismissOnEndTimeout = useTimeout();
3286 const clearInsideReactTreeTimeout = useTimeout();
3287 const clearInsideReactTree = useStableCallback(() => {
3288 clearInsideReactTreeTimeout.clear();
3289 dataRef.current.insideReactTree = false;
3290 });
3291 const isComposingRef = React19.useRef(false);
3292 const currentPointerTypeRef = React19.useRef("");
3293 const isReferencePressEnabled = useStableCallback(referencePress);
3294 const closeOnEscapeKeyDown = useStableCallback((event) => {
3295 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
3296 return;
3297 }
3298 if (isComposingRef.current) {
3299 return;
3300 }
3301 const nodeId = dataRef.current.floatingContext?.nodeId;
3302 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
3303 if (!escapeKeyBubbles) {
3304 if (children.length > 0) {
3305 let shouldDismiss = true;
3306 children.forEach((child) => {
3307 if (child.context?.open && !child.context.dataRef.current.__escapeKeyBubbles) {
3308 shouldDismiss = false;
3309 }
3310 });
3311 if (!shouldDismiss) {
3312 return;
3313 }
3314 }
3315 }
3316 const native = isReactEvent(event) ? event.nativeEvent : event;
3317 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
3318 store.setOpen(false, eventDetails);
3319 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
3320 event.stopPropagation();
3321 }
3322 });
3323 const markInsideReactTree = useStableCallback(() => {
3324 dataRef.current.insideReactTree = true;
3325 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
3326 });
3327 React19.useEffect(() => {
3328 if (!open || !enabled) {
3329 return void 0;
3330 }
3331 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
3332 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
3333 const compositionTimeout = new Timeout();
3334 const preventedPressSuppressionTimeout = new Timeout();
3335 function handleCompositionStart() {
3336 compositionTimeout.clear();
3337 isComposingRef.current = true;
3338 }
3339 function handleCompositionEnd() {
3340 compositionTimeout.start(
3341 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
3342 // Only apply to WebKit for the test to remain 0ms.
3343 isWebKit() ? 5 : 0,
3344 () => {
3345 isComposingRef.current = false;
3346 }
3347 );
3348 }
3349 function suppressImmediateOutsideClickAfterPreventedStart() {
3350 suppressNextOutsideClickRef.current = true;
3351 preventedPressSuppressionTimeout.start(0, () => {
3352 suppressNextOutsideClickRef.current = false;
3353 });
3354 }
3355 function resetPressStartState() {
3356 pressStartedInsideRef.current = false;
3357 pressStartPreventedRef.current = false;
3358 }
3359 function getOutsidePressEvent() {
3360 const type = currentPointerTypeRef.current;
3361 const computedType = type === "pen" || !type ? "mouse" : type;
3362 const outsidePressEventValue = getOutsidePressEventProp();
3363 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
3364 if (typeof resolved === "string") {
3365 return resolved;
3366 }
3367 return resolved[computedType];
3368 }
3369 function shouldIgnoreEvent(event) {
3370 const computedOutsidePressEvent = getOutsidePressEvent();
3371 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
3372 }
3373 function isEventWithinFloatingTree(event) {
3374 const nodeId = dataRef.current.floatingContext?.nodeId;
3375 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
3376 return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement")) || targetIsInsideChildren;
3377 }
3378 function closeOnPressOutside(event) {
3379 if (shouldIgnoreEvent(event)) {
3380 clearInsideReactTree();
3381 return;
3382 }
3383 if (dataRef.current.insideReactTree) {
3384 clearInsideReactTree();
3385 return;
3386 }
3387 const target = getTarget(event);
3388 const inertSelector = `[${createAttribute("inert")}]`;
3389 const targetRoot = isElement(target) ? target.getRootNode() : null;
3390 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
3391 const triggers = store.context.triggerElements;
3392 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
3393 return;
3394 }
3395 let targetRootAncestor = isElement(target) ? target : null;
3396 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
3397 const nextParent = getParentNode(targetRootAncestor);
3398 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
3399 break;
3400 }
3401 targetRootAncestor = nextParent;
3402 }
3403 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
3404 !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
3405 // element was injected after the floating element rendered.
3406 markers.every((marker) => !contains(targetRootAncestor, marker))) {
3407 return;
3408 }
3409 if (isHTMLElement(target) && !("touches" in event)) {
3410 const lastTraversableNode = isLastTraversableNode(target);
3411 const style = getComputedStyle2(target);
3412 const scrollRe = /auto|scroll/;
3413 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
3414 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
3415 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
3416 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
3417 const isRTL7 = style.direction === "rtl";
3418 const pressedVerticalScrollbar = canScrollY && (isRTL7 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
3419 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
3420 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
3421 return;
3422 }
3423 }
3424 if (isEventWithinFloatingTree(event)) {
3425 return;
3426 }
3427 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
3428 preventedPressSuppressionTimeout.clear();
3429 suppressNextOutsideClickRef.current = false;
3430 return;
3431 }
3432 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3433 return;
3434 }
3435 const nodeId = dataRef.current.floatingContext?.nodeId;
3436 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
3437 if (children.length > 0) {
3438 let shouldDismiss = true;
3439 children.forEach((child) => {
3440 if (child.context?.open && !child.context.dataRef.current.__outsidePressBubbles) {
3441 shouldDismiss = false;
3442 }
3443 });
3444 if (!shouldDismiss) {
3445 return;
3446 }
3447 }
3448 store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
3449 clearInsideReactTree();
3450 }
3451 function handlePointerDown(event) {
3452 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
3453 return;
3454 }
3455 closeOnPressOutside(event);
3456 }
3457 function handleTouchStart(event) {
3458 if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
3459 return;
3460 }
3461 const touch = event.touches[0];
3462 if (touch) {
3463 touchStateRef.current = {
3464 startTime: Date.now(),
3465 startX: touch.clientX,
3466 startY: touch.clientY,
3467 dismissOnTouchEnd: false,
3468 dismissOnMouseDown: true
3469 };
3470 cancelDismissOnEndTimeout.start(1e3, () => {
3471 if (touchStateRef.current) {
3472 touchStateRef.current.dismissOnTouchEnd = false;
3473 touchStateRef.current.dismissOnMouseDown = false;
3474 }
3475 });
3476 }
3477 }
3478 function addTargetEventListenerOnce(event, listener) {
3479 const target = getTarget(event);
3480 if (!target) {
3481 return;
3482 }
3483 const unsubscribe2 = addEventListener(target, event.type, () => {
3484 listener(event);
3485 unsubscribe2();
3486 });
3487 }
3488 function handleTouchStartCapture(event) {
3489 currentPointerTypeRef.current = "touch";
3490 addTargetEventListenerOnce(event, handleTouchStart);
3491 }
3492 function closeOnPressOutsideCapture(event) {
3493 cancelDismissOnEndTimeout.clear();
3494 if (event.type === "pointerdown") {
3495 currentPointerTypeRef.current = event.pointerType;
3496 }
3497 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
3498 return;
3499 }
3500 addTargetEventListenerOnce(event, (targetEvent) => {
3501 if (targetEvent.type === "pointerdown") {
3502 handlePointerDown(targetEvent);
3503 } else {
3504 closeOnPressOutside(targetEvent);
3505 }
3506 });
3507 }
3508 function handlePressEndCapture(event) {
3509 if (!pressStartedInsideRef.current) {
3510 return;
3511 }
3512 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
3513 resetPressStartState();
3514 if (getOutsidePressEvent() !== "intentional") {
3515 return;
3516 }
3517 if (event.type === "pointercancel") {
3518 if (pressStartedInsideDefaultPrevented) {
3519 suppressImmediateOutsideClickAfterPreventedStart();
3520 }
3521 return;
3522 }
3523 if (isEventWithinFloatingTree(event)) {
3524 return;
3525 }
3526 if (pressStartedInsideDefaultPrevented) {
3527 suppressImmediateOutsideClickAfterPreventedStart();
3528 return;
3529 }
3530 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3531 return;
3532 }
3533 preventedPressSuppressionTimeout.clear();
3534 suppressNextOutsideClickRef.current = true;
3535 clearInsideReactTree();
3536 }
3537 function handleTouchMove(event) {
3538 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
3539 return;
3540 }
3541 const touch = event.touches[0];
3542 if (!touch) {
3543 return;
3544 }
3545 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
3546 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
3547 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
3548 if (distance > 5) {
3549 touchStateRef.current.dismissOnTouchEnd = true;
3550 }
3551 if (distance > 10) {
3552 closeOnPressOutside(event);
3553 cancelDismissOnEndTimeout.clear();
3554 touchStateRef.current = null;
3555 }
3556 }
3557 function handleTouchMoveCapture(event) {
3558 addTargetEventListenerOnce(event, handleTouchMove);
3559 }
3560 function handleTouchEnd(event) {
3561 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
3562 return;
3563 }
3564 if (touchStateRef.current.dismissOnTouchEnd) {
3565 closeOnPressOutside(event);
3566 }
3567 cancelDismissOnEndTimeout.clear();
3568 touchStateRef.current = null;
3569 }
3570 function handleTouchEndCapture(event) {
3571 addTargetEventListenerOnce(event, handleTouchEnd);
3572 }
3573 const doc = ownerDocument(floatingElement);
3574 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)));
3575 return () => {
3576 unsubscribe();
3577 compositionTimeout.clear();
3578 preventedPressSuppressionTimeout.clear();
3579 resetPressStartState();
3580 suppressNextOutsideClickRef.current = false;
3581 };
3582 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, tree, store, cancelDismissOnEndTimeout]);
3583 React19.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
3584 const reference = React19.useMemo(() => ({
3585 onKeyDown: closeOnEscapeKeyDown,
3586 [bubbleHandlerKeys[referencePressEvent]]: (event) => {
3587 if (!isReferencePressEnabled()) {
3588 return;
3589 }
3590 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
3591 },
3592 ...referencePressEvent !== "intentional" && {
3593 onClick(event) {
3594 if (!isReferencePressEnabled()) {
3595 return;
3596 }
3597 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
3598 }
3599 }
3600 }), [closeOnEscapeKeyDown, store, referencePressEvent, isReferencePressEnabled]);
3601 const markPressStartedInsideReactTree = useStableCallback((event) => {
3602 if (!open || !enabled || event.button !== 0) {
3603 return;
3604 }
3605 const target = getTarget(event.nativeEvent);
3606 if (!contains(store.select("floatingElement"), target)) {
3607 return;
3608 }
3609 if (!pressStartedInsideRef.current) {
3610 pressStartedInsideRef.current = true;
3611 pressStartPreventedRef.current = false;
3612 }
3613 });
3614 const markInsidePressStartPrevented = useStableCallback((event) => {
3615 if (!open || !enabled) {
3616 return;
3617 }
3618 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
3619 return;
3620 }
3621 if (pressStartedInsideRef.current) {
3622 pressStartPreventedRef.current = true;
3623 }
3624 });
3625 const floating = React19.useMemo(() => ({
3626 onKeyDown: closeOnEscapeKeyDown,
3627 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
3628 // `onPointerDown`, such as with <NumberField.ScrubArea>.
3629 // See https://github.com/mui/base-ui/pull/3379
3630 onPointerDown: markInsidePressStartPrevented,
3631 onMouseDown: markInsidePressStartPrevented,
3632 onClickCapture: markInsideReactTree,
3633 onMouseDownCapture(event) {
3634 markInsideReactTree();
3635 markPressStartedInsideReactTree(event);
3636 },
3637 onPointerDownCapture(event) {
3638 markInsideReactTree();
3639 markPressStartedInsideReactTree(event);
3640 },
3641 onMouseUpCapture: markInsideReactTree,
3642 onTouchEndCapture: markInsideReactTree,
3643 onTouchMoveCapture: markInsideReactTree
3644 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
3645 return React19.useMemo(() => enabled ? {
3646 reference,
3647 floating,
3648 trigger: reference
3649 } : {}, [enabled, reference, floating]);
3650 }
3651
3652 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
3653 var React25 = __toESM(require_react(), 1);
3654
3655 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
3656 function computeCoordsFromPlacement(_ref, placement, rtl) {
3657 let {
3658 reference,
3659 floating
3660 } = _ref;
3661 const sideAxis = getSideAxis(placement);
3662 const alignmentAxis = getAlignmentAxis(placement);
3663 const alignLength = getAxisLength(alignmentAxis);
3664 const side = getSide(placement);
3665 const isVertical = sideAxis === "y";
3666 const commonX = reference.x + reference.width / 2 - floating.width / 2;
3667 const commonY = reference.y + reference.height / 2 - floating.height / 2;
3668 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
3669 let coords;
3670 switch (side) {
3671 case "top":
3672 coords = {
3673 x: commonX,
3674 y: reference.y - floating.height
3675 };
3676 break;
3677 case "bottom":
3678 coords = {
3679 x: commonX,
3680 y: reference.y + reference.height
3681 };
3682 break;
3683 case "right":
3684 coords = {
3685 x: reference.x + reference.width,
3686 y: commonY
3687 };
3688 break;
3689 case "left":
3690 coords = {
3691 x: reference.x - floating.width,
3692 y: commonY
3693 };
3694 break;
3695 default:
3696 coords = {
3697 x: reference.x,
3698 y: reference.y
3699 };
3700 }
3701 switch (getAlignment(placement)) {
3702 case "start":
3703 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
3704 break;
3705 case "end":
3706 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
3707 break;
3708 }
3709 return coords;
3710 }
3711 async function detectOverflow(state, options) {
3712 var _await$platform$isEle;
3713 if (options === void 0) {
3714 options = {};
3715 }
3716 const {
3717 x: x2,
3718 y: y2,
3719 platform: platform3,
3720 rects,
3721 elements,
3722 strategy
3723 } = state;
3724 const {
3725 boundary = "clippingAncestors",
3726 rootBoundary = "viewport",
3727 elementContext = "floating",
3728 altBoundary = false,
3729 padding = 0
3730 } = evaluate(options, state);
3731 const paddingObject = getPaddingObject(padding);
3732 const altContext = elementContext === "floating" ? "reference" : "floating";
3733 const element = elements[altBoundary ? altContext : elementContext];
3734 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
3735 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)),
3736 boundary,
3737 rootBoundary,
3738 strategy
3739 }));
3740 const rect = elementContext === "floating" ? {
3741 x: x2,
3742 y: y2,
3743 width: rects.floating.width,
3744 height: rects.floating.height
3745 } : rects.reference;
3746 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
3747 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
3748 x: 1,
3749 y: 1
3750 } : {
3751 x: 1,
3752 y: 1
3753 };
3754 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
3755 elements,
3756 rect,
3757 offsetParent,
3758 strategy
3759 }) : rect);
3760 return {
3761 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
3762 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
3763 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
3764 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
3765 };
3766 }
3767 var MAX_RESET_COUNT = 50;
3768 var computePosition = async (reference, floating, config) => {
3769 const {
3770 placement = "bottom",
3771 strategy = "absolute",
3772 middleware = [],
3773 platform: platform3
3774 } = config;
3775 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
3776 ...platform3,
3777 detectOverflow
3778 };
3779 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
3780 let rects = await platform3.getElementRects({
3781 reference,
3782 floating,
3783 strategy
3784 });
3785 let {
3786 x: x2,
3787 y: y2
3788 } = computeCoordsFromPlacement(rects, placement, rtl);
3789 let statefulPlacement = placement;
3790 let resetCount = 0;
3791 const middlewareData = {};
3792 for (let i2 = 0; i2 < middleware.length; i2++) {
3793 const currentMiddleware = middleware[i2];
3794 if (!currentMiddleware) {
3795 continue;
3796 }
3797 const {
3798 name,
3799 fn
3800 } = currentMiddleware;
3801 const {
3802 x: nextX,
3803 y: nextY,
3804 data,
3805 reset
3806 } = await fn({
3807 x: x2,
3808 y: y2,
3809 initialPlacement: placement,
3810 placement: statefulPlacement,
3811 strategy,
3812 middlewareData,
3813 rects,
3814 platform: platformWithDetectOverflow,
3815 elements: {
3816 reference,
3817 floating
3818 }
3819 });
3820 x2 = nextX != null ? nextX : x2;
3821 y2 = nextY != null ? nextY : y2;
3822 middlewareData[name] = {
3823 ...middlewareData[name],
3824 ...data
3825 };
3826 if (reset && resetCount < MAX_RESET_COUNT) {
3827 resetCount++;
3828 if (typeof reset === "object") {
3829 if (reset.placement) {
3830 statefulPlacement = reset.placement;
3831 }
3832 if (reset.rects) {
3833 rects = reset.rects === true ? await platform3.getElementRects({
3834 reference,
3835 floating,
3836 strategy
3837 }) : reset.rects;
3838 }
3839 ({
3840 x: x2,
3841 y: y2
3842 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
3843 }
3844 i2 = -1;
3845 }
3846 }
3847 return {
3848 x: x2,
3849 y: y2,
3850 placement: statefulPlacement,
3851 strategy,
3852 middlewareData
3853 };
3854 };
3855 var flip = function(options) {
3856 if (options === void 0) {
3857 options = {};
3858 }
3859 return {
3860 name: "flip",
3861 options,
3862 async fn(state) {
3863 var _middlewareData$arrow, _middlewareData$flip;
3864 const {
3865 placement,
3866 middlewareData,
3867 rects,
3868 initialPlacement,
3869 platform: platform3,
3870 elements
3871 } = state;
3872 const {
3873 mainAxis: checkMainAxis = true,
3874 crossAxis: checkCrossAxis = true,
3875 fallbackPlacements: specifiedFallbackPlacements,
3876 fallbackStrategy = "bestFit",
3877 fallbackAxisSideDirection = "none",
3878 flipAlignment = true,
3879 ...detectOverflowOptions
3880 } = evaluate(options, state);
3881 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
3882 return {};
3883 }
3884 const side = getSide(placement);
3885 const initialSideAxis = getSideAxis(initialPlacement);
3886 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
3887 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
3888 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
3889 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
3890 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
3891 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
3892 }
3893 const placements2 = [initialPlacement, ...fallbackPlacements];
3894 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
3895 const overflows = [];
3896 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
3897 if (checkMainAxis) {
3898 overflows.push(overflow[side]);
3899 }
3900 if (checkCrossAxis) {
3901 const sides2 = getAlignmentSides(placement, rects, rtl);
3902 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
3903 }
3904 overflowsData = [...overflowsData, {
3905 placement,
3906 overflows
3907 }];
3908 if (!overflows.every((side2) => side2 <= 0)) {
3909 var _middlewareData$flip2, _overflowsData$filter;
3910 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
3911 const nextPlacement = placements2[nextIndex];
3912 if (nextPlacement) {
3913 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
3914 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
3915 // overflows the main axis.
3916 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) {
3917 return {
3918 data: {
3919 index: nextIndex,
3920 overflows: overflowsData
3921 },
3922 reset: {
3923 placement: nextPlacement
3924 }
3925 };
3926 }
3927 }
3928 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;
3929 if (!resetPlacement) {
3930 switch (fallbackStrategy) {
3931 case "bestFit": {
3932 var _overflowsData$filter2;
3933 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
3934 if (hasFallbackAxisSideDirection) {
3935 const currentSideAxis = getSideAxis(d2.placement);
3936 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
3937 // reading directions favoring greater width.
3938 currentSideAxis === "y";
3939 }
3940 return true;
3941 }).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];
3942 if (placement2) {
3943 resetPlacement = placement2;
3944 }
3945 break;
3946 }
3947 case "initialPlacement":
3948 resetPlacement = initialPlacement;
3949 break;
3950 }
3951 }
3952 if (placement !== resetPlacement) {
3953 return {
3954 reset: {
3955 placement: resetPlacement
3956 }
3957 };
3958 }
3959 }
3960 return {};
3961 }
3962 };
3963 };
3964 function getSideOffsets(overflow, rect) {
3965 return {
3966 top: overflow.top - rect.height,
3967 right: overflow.right - rect.width,
3968 bottom: overflow.bottom - rect.height,
3969 left: overflow.left - rect.width
3970 };
3971 }
3972 function isAnySideFullyClipped(overflow) {
3973 return sides.some((side) => overflow[side] >= 0);
3974 }
3975 var hide = function(options) {
3976 if (options === void 0) {
3977 options = {};
3978 }
3979 return {
3980 name: "hide",
3981 options,
3982 async fn(state) {
3983 const {
3984 rects,
3985 platform: platform3
3986 } = state;
3987 const {
3988 strategy = "referenceHidden",
3989 ...detectOverflowOptions
3990 } = evaluate(options, state);
3991 switch (strategy) {
3992 case "referenceHidden": {
3993 const overflow = await platform3.detectOverflow(state, {
3994 ...detectOverflowOptions,
3995 elementContext: "reference"
3996 });
3997 const offsets = getSideOffsets(overflow, rects.reference);
3998 return {
3999 data: {
4000 referenceHiddenOffsets: offsets,
4001 referenceHidden: isAnySideFullyClipped(offsets)
4002 }
4003 };
4004 }
4005 case "escaped": {
4006 const overflow = await platform3.detectOverflow(state, {
4007 ...detectOverflowOptions,
4008 altBoundary: true
4009 });
4010 const offsets = getSideOffsets(overflow, rects.floating);
4011 return {
4012 data: {
4013 escapedOffsets: offsets,
4014 escaped: isAnySideFullyClipped(offsets)
4015 }
4016 };
4017 }
4018 default: {
4019 return {};
4020 }
4021 }
4022 }
4023 };
4024 };
4025 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
4026 async function convertValueToCoords(state, options) {
4027 const {
4028 placement,
4029 platform: platform3,
4030 elements
4031 } = state;
4032 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4033 const side = getSide(placement);
4034 const alignment = getAlignment(placement);
4035 const isVertical = getSideAxis(placement) === "y";
4036 const mainAxisMulti = originSides.has(side) ? -1 : 1;
4037 const crossAxisMulti = rtl && isVertical ? -1 : 1;
4038 const rawValue = evaluate(options, state);
4039 let {
4040 mainAxis,
4041 crossAxis,
4042 alignmentAxis
4043 } = typeof rawValue === "number" ? {
4044 mainAxis: rawValue,
4045 crossAxis: 0,
4046 alignmentAxis: null
4047 } : {
4048 mainAxis: rawValue.mainAxis || 0,
4049 crossAxis: rawValue.crossAxis || 0,
4050 alignmentAxis: rawValue.alignmentAxis
4051 };
4052 if (alignment && typeof alignmentAxis === "number") {
4053 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
4054 }
4055 return isVertical ? {
4056 x: crossAxis * crossAxisMulti,
4057 y: mainAxis * mainAxisMulti
4058 } : {
4059 x: mainAxis * mainAxisMulti,
4060 y: crossAxis * crossAxisMulti
4061 };
4062 }
4063 var offset = function(options) {
4064 if (options === void 0) {
4065 options = 0;
4066 }
4067 return {
4068 name: "offset",
4069 options,
4070 async fn(state) {
4071 var _middlewareData$offse, _middlewareData$arrow;
4072 const {
4073 x: x2,
4074 y: y2,
4075 placement,
4076 middlewareData
4077 } = state;
4078 const diffCoords = await convertValueToCoords(state, options);
4079 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4080 return {};
4081 }
4082 return {
4083 x: x2 + diffCoords.x,
4084 y: y2 + diffCoords.y,
4085 data: {
4086 ...diffCoords,
4087 placement
4088 }
4089 };
4090 }
4091 };
4092 };
4093 var shift = function(options) {
4094 if (options === void 0) {
4095 options = {};
4096 }
4097 return {
4098 name: "shift",
4099 options,
4100 async fn(state) {
4101 const {
4102 x: x2,
4103 y: y2,
4104 placement,
4105 platform: platform3
4106 } = state;
4107 const {
4108 mainAxis: checkMainAxis = true,
4109 crossAxis: checkCrossAxis = false,
4110 limiter = {
4111 fn: (_ref) => {
4112 let {
4113 x: x3,
4114 y: y3
4115 } = _ref;
4116 return {
4117 x: x3,
4118 y: y3
4119 };
4120 }
4121 },
4122 ...detectOverflowOptions
4123 } = evaluate(options, state);
4124 const coords = {
4125 x: x2,
4126 y: y2
4127 };
4128 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4129 const crossAxis = getSideAxis(getSide(placement));
4130 const mainAxis = getOppositeAxis(crossAxis);
4131 let mainAxisCoord = coords[mainAxis];
4132 let crossAxisCoord = coords[crossAxis];
4133 if (checkMainAxis) {
4134 const minSide = mainAxis === "y" ? "top" : "left";
4135 const maxSide = mainAxis === "y" ? "bottom" : "right";
4136 const min2 = mainAxisCoord + overflow[minSide];
4137 const max2 = mainAxisCoord - overflow[maxSide];
4138 mainAxisCoord = clamp(min2, mainAxisCoord, max2);
4139 }
4140 if (checkCrossAxis) {
4141 const minSide = crossAxis === "y" ? "top" : "left";
4142 const maxSide = crossAxis === "y" ? "bottom" : "right";
4143 const min2 = crossAxisCoord + overflow[minSide];
4144 const max2 = crossAxisCoord - overflow[maxSide];
4145 crossAxisCoord = clamp(min2, crossAxisCoord, max2);
4146 }
4147 const limitedCoords = limiter.fn({
4148 ...state,
4149 [mainAxis]: mainAxisCoord,
4150 [crossAxis]: crossAxisCoord
4151 });
4152 return {
4153 ...limitedCoords,
4154 data: {
4155 x: limitedCoords.x - x2,
4156 y: limitedCoords.y - y2,
4157 enabled: {
4158 [mainAxis]: checkMainAxis,
4159 [crossAxis]: checkCrossAxis
4160 }
4161 }
4162 };
4163 }
4164 };
4165 };
4166 var limitShift = function(options) {
4167 if (options === void 0) {
4168 options = {};
4169 }
4170 return {
4171 options,
4172 fn(state) {
4173 const {
4174 x: x2,
4175 y: y2,
4176 placement,
4177 rects,
4178 middlewareData
4179 } = state;
4180 const {
4181 offset: offset4 = 0,
4182 mainAxis: checkMainAxis = true,
4183 crossAxis: checkCrossAxis = true
4184 } = evaluate(options, state);
4185 const coords = {
4186 x: x2,
4187 y: y2
4188 };
4189 const crossAxis = getSideAxis(placement);
4190 const mainAxis = getOppositeAxis(crossAxis);
4191 let mainAxisCoord = coords[mainAxis];
4192 let crossAxisCoord = coords[crossAxis];
4193 const rawOffset = evaluate(offset4, state);
4194 const computedOffset = typeof rawOffset === "number" ? {
4195 mainAxis: rawOffset,
4196 crossAxis: 0
4197 } : {
4198 mainAxis: 0,
4199 crossAxis: 0,
4200 ...rawOffset
4201 };
4202 if (checkMainAxis) {
4203 const len = mainAxis === "y" ? "height" : "width";
4204 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
4205 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
4206 if (mainAxisCoord < limitMin) {
4207 mainAxisCoord = limitMin;
4208 } else if (mainAxisCoord > limitMax) {
4209 mainAxisCoord = limitMax;
4210 }
4211 }
4212 if (checkCrossAxis) {
4213 var _middlewareData$offse, _middlewareData$offse2;
4214 const len = mainAxis === "y" ? "width" : "height";
4215 const isOriginSide = originSides.has(getSide(placement));
4216 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);
4217 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);
4218 if (crossAxisCoord < limitMin) {
4219 crossAxisCoord = limitMin;
4220 } else if (crossAxisCoord > limitMax) {
4221 crossAxisCoord = limitMax;
4222 }
4223 }
4224 return {
4225 [mainAxis]: mainAxisCoord,
4226 [crossAxis]: crossAxisCoord
4227 };
4228 }
4229 };
4230 };
4231 var size = function(options) {
4232 if (options === void 0) {
4233 options = {};
4234 }
4235 return {
4236 name: "size",
4237 options,
4238 async fn(state) {
4239 var _state$middlewareData, _state$middlewareData2;
4240 const {
4241 placement,
4242 rects,
4243 platform: platform3,
4244 elements
4245 } = state;
4246 const {
4247 apply = () => {
4248 },
4249 ...detectOverflowOptions
4250 } = evaluate(options, state);
4251 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4252 const side = getSide(placement);
4253 const alignment = getAlignment(placement);
4254 const isYAxis = getSideAxis(placement) === "y";
4255 const {
4256 width,
4257 height
4258 } = rects.floating;
4259 let heightSide;
4260 let widthSide;
4261 if (side === "top" || side === "bottom") {
4262 heightSide = side;
4263 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
4264 } else {
4265 widthSide = side;
4266 heightSide = alignment === "end" ? "top" : "bottom";
4267 }
4268 const maximumClippingHeight = height - overflow.top - overflow.bottom;
4269 const maximumClippingWidth = width - overflow.left - overflow.right;
4270 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
4271 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
4272 const noShift = !state.middlewareData.shift;
4273 let availableHeight = overflowAvailableHeight;
4274 let availableWidth = overflowAvailableWidth;
4275 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
4276 availableWidth = maximumClippingWidth;
4277 }
4278 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
4279 availableHeight = maximumClippingHeight;
4280 }
4281 if (noShift && !alignment) {
4282 const xMin = max(overflow.left, 0);
4283 const xMax = max(overflow.right, 0);
4284 const yMin = max(overflow.top, 0);
4285 const yMax = max(overflow.bottom, 0);
4286 if (isYAxis) {
4287 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
4288 } else {
4289 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
4290 }
4291 }
4292 await apply({
4293 ...state,
4294 availableWidth,
4295 availableHeight
4296 });
4297 const nextDimensions = await platform3.getDimensions(elements.floating);
4298 if (width !== nextDimensions.width || height !== nextDimensions.height) {
4299 return {
4300 reset: {
4301 rects: true
4302 }
4303 };
4304 }
4305 return {};
4306 }
4307 };
4308 };
4309
4310 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
4311 function getCssDimensions(element) {
4312 const css = getComputedStyle2(element);
4313 let width = parseFloat(css.width) || 0;
4314 let height = parseFloat(css.height) || 0;
4315 const hasOffset = isHTMLElement(element);
4316 const offsetWidth = hasOffset ? element.offsetWidth : width;
4317 const offsetHeight = hasOffset ? element.offsetHeight : height;
4318 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
4319 if (shouldFallback) {
4320 width = offsetWidth;
4321 height = offsetHeight;
4322 }
4323 return {
4324 width,
4325 height,
4326 $: shouldFallback
4327 };
4328 }
4329 function unwrapElement(element) {
4330 return !isElement(element) ? element.contextElement : element;
4331 }
4332 function getScale(element) {
4333 const domElement = unwrapElement(element);
4334 if (!isHTMLElement(domElement)) {
4335 return createCoords(1);
4336 }
4337 const rect = domElement.getBoundingClientRect();
4338 const {
4339 width,
4340 height,
4341 $: $2
4342 } = getCssDimensions(domElement);
4343 let x2 = ($2 ? round(rect.width) : rect.width) / width;
4344 let y2 = ($2 ? round(rect.height) : rect.height) / height;
4345 if (!x2 || !Number.isFinite(x2)) {
4346 x2 = 1;
4347 }
4348 if (!y2 || !Number.isFinite(y2)) {
4349 y2 = 1;
4350 }
4351 return {
4352 x: x2,
4353 y: y2
4354 };
4355 }
4356 var noOffsets = /* @__PURE__ */ createCoords(0);
4357 function getVisualOffsets(element) {
4358 const win = getWindow(element);
4359 if (!isWebKit() || !win.visualViewport) {
4360 return noOffsets;
4361 }
4362 return {
4363 x: win.visualViewport.offsetLeft,
4364 y: win.visualViewport.offsetTop
4365 };
4366 }
4367 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
4368 if (isFixed === void 0) {
4369 isFixed = false;
4370 }
4371 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
4372 return false;
4373 }
4374 return isFixed;
4375 }
4376 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
4377 if (includeScale === void 0) {
4378 includeScale = false;
4379 }
4380 if (isFixedStrategy === void 0) {
4381 isFixedStrategy = false;
4382 }
4383 const clientRect = element.getBoundingClientRect();
4384 const domElement = unwrapElement(element);
4385 let scale = createCoords(1);
4386 if (includeScale) {
4387 if (offsetParent) {
4388 if (isElement(offsetParent)) {
4389 scale = getScale(offsetParent);
4390 }
4391 } else {
4392 scale = getScale(element);
4393 }
4394 }
4395 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
4396 let x2 = (clientRect.left + visualOffsets.x) / scale.x;
4397 let y2 = (clientRect.top + visualOffsets.y) / scale.y;
4398 let width = clientRect.width / scale.x;
4399 let height = clientRect.height / scale.y;
4400 if (domElement) {
4401 const win = getWindow(domElement);
4402 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
4403 let currentWin = win;
4404 let currentIFrame = getFrameElement(currentWin);
4405 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
4406 const iframeScale = getScale(currentIFrame);
4407 const iframeRect = currentIFrame.getBoundingClientRect();
4408 const css = getComputedStyle2(currentIFrame);
4409 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
4410 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
4411 x2 *= iframeScale.x;
4412 y2 *= iframeScale.y;
4413 width *= iframeScale.x;
4414 height *= iframeScale.y;
4415 x2 += left;
4416 y2 += top;
4417 currentWin = getWindow(currentIFrame);
4418 currentIFrame = getFrameElement(currentWin);
4419 }
4420 }
4421 return rectToClientRect({
4422 width,
4423 height,
4424 x: x2,
4425 y: y2
4426 });
4427 }
4428 function getWindowScrollBarX(element, rect) {
4429 const leftScroll = getNodeScroll(element).scrollLeft;
4430 if (!rect) {
4431 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
4432 }
4433 return rect.left + leftScroll;
4434 }
4435 function getHTMLOffset(documentElement, scroll) {
4436 const htmlRect = documentElement.getBoundingClientRect();
4437 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
4438 const y2 = htmlRect.top + scroll.scrollTop;
4439 return {
4440 x: x2,
4441 y: y2
4442 };
4443 }
4444 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
4445 let {
4446 elements,
4447 rect,
4448 offsetParent,
4449 strategy
4450 } = _ref;
4451 const isFixed = strategy === "fixed";
4452 const documentElement = getDocumentElement(offsetParent);
4453 const topLayer = elements ? isTopLayer(elements.floating) : false;
4454 if (offsetParent === documentElement || topLayer && isFixed) {
4455 return rect;
4456 }
4457 let scroll = {
4458 scrollLeft: 0,
4459 scrollTop: 0
4460 };
4461 let scale = createCoords(1);
4462 const offsets = createCoords(0);
4463 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4464 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4465 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4466 scroll = getNodeScroll(offsetParent);
4467 }
4468 if (isOffsetParentAnElement) {
4469 const offsetRect = getBoundingClientRect(offsetParent);
4470 scale = getScale(offsetParent);
4471 offsets.x = offsetRect.x + offsetParent.clientLeft;
4472 offsets.y = offsetRect.y + offsetParent.clientTop;
4473 }
4474 }
4475 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4476 return {
4477 width: rect.width * scale.x,
4478 height: rect.height * scale.y,
4479 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
4480 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
4481 };
4482 }
4483 function getClientRects(element) {
4484 return Array.from(element.getClientRects());
4485 }
4486 function getDocumentRect(element) {
4487 const html = getDocumentElement(element);
4488 const scroll = getNodeScroll(element);
4489 const body = element.ownerDocument.body;
4490 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
4491 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
4492 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
4493 const y2 = -scroll.scrollTop;
4494 if (getComputedStyle2(body).direction === "rtl") {
4495 x2 += max(html.clientWidth, body.clientWidth) - width;
4496 }
4497 return {
4498 width,
4499 height,
4500 x: x2,
4501 y: y2
4502 };
4503 }
4504 var SCROLLBAR_MAX = 25;
4505 function getViewportRect(element, strategy) {
4506 const win = getWindow(element);
4507 const html = getDocumentElement(element);
4508 const visualViewport = win.visualViewport;
4509 let width = html.clientWidth;
4510 let height = html.clientHeight;
4511 let x2 = 0;
4512 let y2 = 0;
4513 if (visualViewport) {
4514 width = visualViewport.width;
4515 height = visualViewport.height;
4516 const visualViewportBased = isWebKit();
4517 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
4518 x2 = visualViewport.offsetLeft;
4519 y2 = visualViewport.offsetTop;
4520 }
4521 }
4522 const windowScrollbarX = getWindowScrollBarX(html);
4523 if (windowScrollbarX <= 0) {
4524 const doc = html.ownerDocument;
4525 const body = doc.body;
4526 const bodyStyles = getComputedStyle(body);
4527 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
4528 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
4529 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
4530 width -= clippingStableScrollbarWidth;
4531 }
4532 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
4533 width += windowScrollbarX;
4534 }
4535 return {
4536 width,
4537 height,
4538 x: x2,
4539 y: y2
4540 };
4541 }
4542 function getInnerBoundingClientRect(element, strategy) {
4543 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
4544 const top = clientRect.top + element.clientTop;
4545 const left = clientRect.left + element.clientLeft;
4546 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
4547 const width = element.clientWidth * scale.x;
4548 const height = element.clientHeight * scale.y;
4549 const x2 = left * scale.x;
4550 const y2 = top * scale.y;
4551 return {
4552 width,
4553 height,
4554 x: x2,
4555 y: y2
4556 };
4557 }
4558 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
4559 let rect;
4560 if (clippingAncestor === "viewport") {
4561 rect = getViewportRect(element, strategy);
4562 } else if (clippingAncestor === "document") {
4563 rect = getDocumentRect(getDocumentElement(element));
4564 } else if (isElement(clippingAncestor)) {
4565 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
4566 } else {
4567 const visualOffsets = getVisualOffsets(element);
4568 rect = {
4569 x: clippingAncestor.x - visualOffsets.x,
4570 y: clippingAncestor.y - visualOffsets.y,
4571 width: clippingAncestor.width,
4572 height: clippingAncestor.height
4573 };
4574 }
4575 return rectToClientRect(rect);
4576 }
4577 function hasFixedPositionAncestor(element, stopNode) {
4578 const parentNode = getParentNode(element);
4579 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
4580 return false;
4581 }
4582 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
4583 }
4584 function getClippingElementAncestors(element, cache) {
4585 const cachedResult = cache.get(element);
4586 if (cachedResult) {
4587 return cachedResult;
4588 }
4589 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
4590 let currentContainingBlockComputedStyle = null;
4591 const elementIsFixed = getComputedStyle2(element).position === "fixed";
4592 let currentNode = elementIsFixed ? getParentNode(element) : element;
4593 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
4594 const computedStyle = getComputedStyle2(currentNode);
4595 const currentNodeIsContaining = isContainingBlock(currentNode);
4596 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
4597 currentContainingBlockComputedStyle = null;
4598 }
4599 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
4600 if (shouldDropCurrentNode) {
4601 result = result.filter((ancestor) => ancestor !== currentNode);
4602 } else {
4603 currentContainingBlockComputedStyle = computedStyle;
4604 }
4605 currentNode = getParentNode(currentNode);
4606 }
4607 cache.set(element, result);
4608 return result;
4609 }
4610 function getClippingRect(_ref) {
4611 let {
4612 element,
4613 boundary,
4614 rootBoundary,
4615 strategy
4616 } = _ref;
4617 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
4618 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
4619 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
4620 let top = firstRect.top;
4621 let right = firstRect.right;
4622 let bottom = firstRect.bottom;
4623 let left = firstRect.left;
4624 for (let i2 = 1; i2 < clippingAncestors.length; i2++) {
4625 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy);
4626 top = max(rect.top, top);
4627 right = min(rect.right, right);
4628 bottom = min(rect.bottom, bottom);
4629 left = max(rect.left, left);
4630 }
4631 return {
4632 width: right - left,
4633 height: bottom - top,
4634 x: left,
4635 y: top
4636 };
4637 }
4638 function getDimensions(element) {
4639 const {
4640 width,
4641 height
4642 } = getCssDimensions(element);
4643 return {
4644 width,
4645 height
4646 };
4647 }
4648 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
4649 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4650 const documentElement = getDocumentElement(offsetParent);
4651 const isFixed = strategy === "fixed";
4652 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
4653 let scroll = {
4654 scrollLeft: 0,
4655 scrollTop: 0
4656 };
4657 const offsets = createCoords(0);
4658 function setLeftRTLScrollbarOffset() {
4659 offsets.x = getWindowScrollBarX(documentElement);
4660 }
4661 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4662 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4663 scroll = getNodeScroll(offsetParent);
4664 }
4665 if (isOffsetParentAnElement) {
4666 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
4667 offsets.x = offsetRect.x + offsetParent.clientLeft;
4668 offsets.y = offsetRect.y + offsetParent.clientTop;
4669 } else if (documentElement) {
4670 setLeftRTLScrollbarOffset();
4671 }
4672 }
4673 if (isFixed && !isOffsetParentAnElement && documentElement) {
4674 setLeftRTLScrollbarOffset();
4675 }
4676 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4677 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
4678 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
4679 return {
4680 x: x2,
4681 y: y2,
4682 width: rect.width,
4683 height: rect.height
4684 };
4685 }
4686 function isStaticPositioned(element) {
4687 return getComputedStyle2(element).position === "static";
4688 }
4689 function getTrueOffsetParent(element, polyfill) {
4690 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
4691 return null;
4692 }
4693 if (polyfill) {
4694 return polyfill(element);
4695 }
4696 let rawOffsetParent = element.offsetParent;
4697 if (getDocumentElement(element) === rawOffsetParent) {
4698 rawOffsetParent = rawOffsetParent.ownerDocument.body;
4699 }
4700 return rawOffsetParent;
4701 }
4702 function getOffsetParent(element, polyfill) {
4703 const win = getWindow(element);
4704 if (isTopLayer(element)) {
4705 return win;
4706 }
4707 if (!isHTMLElement(element)) {
4708 let svgOffsetParent = getParentNode(element);
4709 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
4710 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
4711 return svgOffsetParent;
4712 }
4713 svgOffsetParent = getParentNode(svgOffsetParent);
4714 }
4715 return win;
4716 }
4717 let offsetParent = getTrueOffsetParent(element, polyfill);
4718 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
4719 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
4720 }
4721 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
4722 return win;
4723 }
4724 return offsetParent || getContainingBlock(element) || win;
4725 }
4726 var getElementRects = async function(data) {
4727 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
4728 const getDimensionsFn = this.getDimensions;
4729 const floatingDimensions = await getDimensionsFn(data.floating);
4730 return {
4731 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
4732 floating: {
4733 x: 0,
4734 y: 0,
4735 width: floatingDimensions.width,
4736 height: floatingDimensions.height
4737 }
4738 };
4739 };
4740 function isRTL(element) {
4741 return getComputedStyle2(element).direction === "rtl";
4742 }
4743 var platform2 = {
4744 convertOffsetParentRelativeRectToViewportRelativeRect,
4745 getDocumentElement,
4746 getClippingRect,
4747 getOffsetParent,
4748 getElementRects,
4749 getClientRects,
4750 getDimensions,
4751 getScale,
4752 isElement,
4753 isRTL
4754 };
4755 function rectsAreEqual(a2, b2) {
4756 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
4757 }
4758 function observeMove(element, onMove) {
4759 let io = null;
4760 let timeoutId;
4761 const root = getDocumentElement(element);
4762 function cleanup() {
4763 var _io;
4764 clearTimeout(timeoutId);
4765 (_io = io) == null || _io.disconnect();
4766 io = null;
4767 }
4768 function refresh(skip, threshold) {
4769 if (skip === void 0) {
4770 skip = false;
4771 }
4772 if (threshold === void 0) {
4773 threshold = 1;
4774 }
4775 cleanup();
4776 const elementRectForRootMargin = element.getBoundingClientRect();
4777 const {
4778 left,
4779 top,
4780 width,
4781 height
4782 } = elementRectForRootMargin;
4783 if (!skip) {
4784 onMove();
4785 }
4786 if (!width || !height) {
4787 return;
4788 }
4789 const insetTop = floor(top);
4790 const insetRight = floor(root.clientWidth - (left + width));
4791 const insetBottom = floor(root.clientHeight - (top + height));
4792 const insetLeft = floor(left);
4793 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
4794 const options = {
4795 rootMargin,
4796 threshold: max(0, min(1, threshold)) || 1
4797 };
4798 let isFirstUpdate = true;
4799 function handleObserve(entries) {
4800 const ratio = entries[0].intersectionRatio;
4801 if (ratio !== threshold) {
4802 if (!isFirstUpdate) {
4803 return refresh();
4804 }
4805 if (!ratio) {
4806 timeoutId = setTimeout(() => {
4807 refresh(false, 1e-7);
4808 }, 1e3);
4809 } else {
4810 refresh(false, ratio);
4811 }
4812 }
4813 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
4814 refresh();
4815 }
4816 isFirstUpdate = false;
4817 }
4818 try {
4819 io = new IntersectionObserver(handleObserve, {
4820 ...options,
4821 // Handle <iframe>s
4822 root: root.ownerDocument
4823 });
4824 } catch (_e) {
4825 io = new IntersectionObserver(handleObserve, options);
4826 }
4827 io.observe(element);
4828 }
4829 refresh(true);
4830 return cleanup;
4831 }
4832 function autoUpdate(reference, floating, update2, options) {
4833 if (options === void 0) {
4834 options = {};
4835 }
4836 const {
4837 ancestorScroll = true,
4838 ancestorResize = true,
4839 elementResize = typeof ResizeObserver === "function",
4840 layoutShift = typeof IntersectionObserver === "function",
4841 animationFrame = false
4842 } = options;
4843 const referenceEl = unwrapElement(reference);
4844 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
4845 ancestors.forEach((ancestor) => {
4846 ancestorScroll && ancestor.addEventListener("scroll", update2, {
4847 passive: true
4848 });
4849 ancestorResize && ancestor.addEventListener("resize", update2);
4850 });
4851 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
4852 let reobserveFrame = -1;
4853 let resizeObserver = null;
4854 if (elementResize) {
4855 resizeObserver = new ResizeObserver((_ref) => {
4856 let [firstEntry] = _ref;
4857 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
4858 resizeObserver.unobserve(floating);
4859 cancelAnimationFrame(reobserveFrame);
4860 reobserveFrame = requestAnimationFrame(() => {
4861 var _resizeObserver;
4862 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
4863 });
4864 }
4865 update2();
4866 });
4867 if (referenceEl && !animationFrame) {
4868 resizeObserver.observe(referenceEl);
4869 }
4870 if (floating) {
4871 resizeObserver.observe(floating);
4872 }
4873 }
4874 let frameId;
4875 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
4876 if (animationFrame) {
4877 frameLoop();
4878 }
4879 function frameLoop() {
4880 const nextRefRect = getBoundingClientRect(reference);
4881 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
4882 update2();
4883 }
4884 prevRefRect = nextRefRect;
4885 frameId = requestAnimationFrame(frameLoop);
4886 }
4887 update2();
4888 return () => {
4889 var _resizeObserver2;
4890 ancestors.forEach((ancestor) => {
4891 ancestorScroll && ancestor.removeEventListener("scroll", update2);
4892 ancestorResize && ancestor.removeEventListener("resize", update2);
4893 });
4894 cleanupIo == null || cleanupIo();
4895 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
4896 resizeObserver = null;
4897 if (animationFrame) {
4898 cancelAnimationFrame(frameId);
4899 }
4900 };
4901 }
4902 var offset2 = offset;
4903 var shift2 = shift;
4904 var flip2 = flip;
4905 var size2 = size;
4906 var hide2 = hide;
4907 var limitShift2 = limitShift;
4908 var computePosition2 = (reference, floating, options) => {
4909 const cache = /* @__PURE__ */ new Map();
4910 const mergedOptions = {
4911 platform: platform2,
4912 ...options
4913 };
4914 const platformWithCache = {
4915 ...mergedOptions.platform,
4916 _c: cache
4917 };
4918 return computePosition(reference, floating, {
4919 ...mergedOptions,
4920 platform: platformWithCache
4921 });
4922 };
4923
4924 // node_modules/@base-ui/react/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
4925 var React20 = __toESM(require_react(), 1);
4926 var import_react2 = __toESM(require_react(), 1);
4927 var ReactDOM3 = __toESM(require_react_dom(), 1);
4928 var isClient = typeof document !== "undefined";
4929 var noop2 = function noop3() {
4930 };
4931 var index = isClient ? import_react2.useLayoutEffect : noop2;
4932 function deepEqual(a2, b2) {
4933 if (a2 === b2) {
4934 return true;
4935 }
4936 if (typeof a2 !== typeof b2) {
4937 return false;
4938 }
4939 if (typeof a2 === "function" && a2.toString() === b2.toString()) {
4940 return true;
4941 }
4942 let length;
4943 let i2;
4944 let keys;
4945 if (a2 && b2 && typeof a2 === "object") {
4946 if (Array.isArray(a2)) {
4947 length = a2.length;
4948 if (length !== b2.length) return false;
4949 for (i2 = length; i2-- !== 0; ) {
4950 if (!deepEqual(a2[i2], b2[i2])) {
4951 return false;
4952 }
4953 }
4954 return true;
4955 }
4956 keys = Object.keys(a2);
4957 length = keys.length;
4958 if (length !== Object.keys(b2).length) {
4959 return false;
4960 }
4961 for (i2 = length; i2-- !== 0; ) {
4962 if (!{}.hasOwnProperty.call(b2, keys[i2])) {
4963 return false;
4964 }
4965 }
4966 for (i2 = length; i2-- !== 0; ) {
4967 const key = keys[i2];
4968 if (key === "_owner" && a2.$$typeof) {
4969 continue;
4970 }
4971 if (!deepEqual(a2[key], b2[key])) {
4972 return false;
4973 }
4974 }
4975 return true;
4976 }
4977 return a2 !== a2 && b2 !== b2;
4978 }
4979 function getDPR(element) {
4980 if (typeof window === "undefined") {
4981 return 1;
4982 }
4983 const win = element.ownerDocument.defaultView || window;
4984 return win.devicePixelRatio || 1;
4985 }
4986 function roundByDPR(element, value) {
4987 const dpr = getDPR(element);
4988 return Math.round(value * dpr) / dpr;
4989 }
4990 function useLatestRef(value) {
4991 const ref = React20.useRef(value);
4992 index(() => {
4993 ref.current = value;
4994 });
4995 return ref;
4996 }
4997 function useFloating(options) {
4998 if (options === void 0) {
4999 options = {};
5000 }
5001 const {
5002 placement = "bottom",
5003 strategy = "absolute",
5004 middleware = [],
5005 platform: platform3,
5006 elements: {
5007 reference: externalReference,
5008 floating: externalFloating
5009 } = {},
5010 transform = true,
5011 whileElementsMounted,
5012 open
5013 } = options;
5014 const [data, setData] = React20.useState({
5015 x: 0,
5016 y: 0,
5017 strategy,
5018 placement,
5019 middlewareData: {},
5020 isPositioned: false
5021 });
5022 const [latestMiddleware, setLatestMiddleware] = React20.useState(middleware);
5023 if (!deepEqual(latestMiddleware, middleware)) {
5024 setLatestMiddleware(middleware);
5025 }
5026 const [_reference, _setReference] = React20.useState(null);
5027 const [_floating, _setFloating] = React20.useState(null);
5028 const setReference = React20.useCallback((node) => {
5029 if (node !== referenceRef.current) {
5030 referenceRef.current = node;
5031 _setReference(node);
5032 }
5033 }, []);
5034 const setFloating = React20.useCallback((node) => {
5035 if (node !== floatingRef.current) {
5036 floatingRef.current = node;
5037 _setFloating(node);
5038 }
5039 }, []);
5040 const referenceEl = externalReference || _reference;
5041 const floatingEl = externalFloating || _floating;
5042 const referenceRef = React20.useRef(null);
5043 const floatingRef = React20.useRef(null);
5044 const dataRef = React20.useRef(data);
5045 const hasWhileElementsMounted = whileElementsMounted != null;
5046 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
5047 const platformRef = useLatestRef(platform3);
5048 const openRef = useLatestRef(open);
5049 const update2 = React20.useCallback(() => {
5050 if (!referenceRef.current || !floatingRef.current) {
5051 return;
5052 }
5053 const config = {
5054 placement,
5055 strategy,
5056 middleware: latestMiddleware
5057 };
5058 if (platformRef.current) {
5059 config.platform = platformRef.current;
5060 }
5061 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
5062 const fullData = {
5063 ...data2,
5064 // The floating element's position may be recomputed while it's closed
5065 // but still mounted (such as when transitioning out). To ensure
5066 // `isPositioned` will be `false` initially on the next open, avoid
5067 // setting it to `true` when `open === false` (must be specified).
5068 isPositioned: openRef.current !== false
5069 };
5070 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
5071 dataRef.current = fullData;
5072 ReactDOM3.flushSync(() => {
5073 setData(fullData);
5074 });
5075 }
5076 });
5077 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
5078 index(() => {
5079 if (open === false && dataRef.current.isPositioned) {
5080 dataRef.current.isPositioned = false;
5081 setData((data2) => ({
5082 ...data2,
5083 isPositioned: false
5084 }));
5085 }
5086 }, [open]);
5087 const isMountedRef = React20.useRef(false);
5088 index(() => {
5089 isMountedRef.current = true;
5090 return () => {
5091 isMountedRef.current = false;
5092 };
5093 }, []);
5094 index(() => {
5095 if (referenceEl) referenceRef.current = referenceEl;
5096 if (floatingEl) floatingRef.current = floatingEl;
5097 if (referenceEl && floatingEl) {
5098 if (whileElementsMountedRef.current) {
5099 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
5100 }
5101 update2();
5102 }
5103 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
5104 const refs = React20.useMemo(() => ({
5105 reference: referenceRef,
5106 floating: floatingRef,
5107 setReference,
5108 setFloating
5109 }), [setReference, setFloating]);
5110 const elements = React20.useMemo(() => ({
5111 reference: referenceEl,
5112 floating: floatingEl
5113 }), [referenceEl, floatingEl]);
5114 const floatingStyles = React20.useMemo(() => {
5115 const initialStyles = {
5116 position: strategy,
5117 left: 0,
5118 top: 0
5119 };
5120 if (!elements.floating) {
5121 return initialStyles;
5122 }
5123 const x2 = roundByDPR(elements.floating, data.x);
5124 const y2 = roundByDPR(elements.floating, data.y);
5125 if (transform) {
5126 return {
5127 ...initialStyles,
5128 transform: "translate(" + x2 + "px, " + y2 + "px)",
5129 ...getDPR(elements.floating) >= 1.5 && {
5130 willChange: "transform"
5131 }
5132 };
5133 }
5134 return {
5135 position: strategy,
5136 left: x2,
5137 top: y2
5138 };
5139 }, [strategy, transform, elements.floating, data.x, data.y]);
5140 return React20.useMemo(() => ({
5141 ...data,
5142 update: update2,
5143 refs,
5144 elements,
5145 floatingStyles
5146 }), [data, update2, refs, elements, floatingStyles]);
5147 }
5148 var offset3 = (options, deps) => {
5149 const result = offset2(options);
5150 return {
5151 name: result.name,
5152 fn: result.fn,
5153 options: [options, deps]
5154 };
5155 };
5156 var shift3 = (options, deps) => {
5157 const result = shift2(options);
5158 return {
5159 name: result.name,
5160 fn: result.fn,
5161 options: [options, deps]
5162 };
5163 };
5164 var limitShift3 = (options, deps) => {
5165 const result = limitShift2(options);
5166 return {
5167 fn: result.fn,
5168 options: [options, deps]
5169 };
5170 };
5171 var flip3 = (options, deps) => {
5172 const result = flip2(options);
5173 return {
5174 name: result.name,
5175 fn: result.fn,
5176 options: [options, deps]
5177 };
5178 };
5179 var size3 = (options, deps) => {
5180 const result = size2(options);
5181 return {
5182 name: result.name,
5183 fn: result.fn,
5184 options: [options, deps]
5185 };
5186 };
5187 var hide3 = (options, deps) => {
5188 const result = hide2(options);
5189 return {
5190 name: result.name,
5191 fn: result.fn,
5192 options: [options, deps]
5193 };
5194 };
5195
5196 // node_modules/@base-ui/utils/esm/store/createSelector.js
5197 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => {
5198 if (other.length > 0) {
5199 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
5200 }
5201 let selector2;
5202 if (a2 && b2 && c2 && d2 && e2 && f2) {
5203 selector2 = (state, a1, a22, a3) => {
5204 const va = a2(state, a1, a22, a3);
5205 const vb = b2(state, a1, a22, a3);
5206 const vc = c2(state, a1, a22, a3);
5207 const vd = d2(state, a1, a22, a3);
5208 const ve = e2(state, a1, a22, a3);
5209 return f2(va, vb, vc, vd, ve, a1, a22, a3);
5210 };
5211 } else if (a2 && b2 && c2 && d2 && e2) {
5212 selector2 = (state, a1, a22, a3) => {
5213 const va = a2(state, a1, a22, a3);
5214 const vb = b2(state, a1, a22, a3);
5215 const vc = c2(state, a1, a22, a3);
5216 const vd = d2(state, a1, a22, a3);
5217 return e2(va, vb, vc, vd, a1, a22, a3);
5218 };
5219 } else if (a2 && b2 && c2 && d2) {
5220 selector2 = (state, a1, a22, a3) => {
5221 const va = a2(state, a1, a22, a3);
5222 const vb = b2(state, a1, a22, a3);
5223 const vc = c2(state, a1, a22, a3);
5224 return d2(va, vb, vc, a1, a22, a3);
5225 };
5226 } else if (a2 && b2 && c2) {
5227 selector2 = (state, a1, a22, a3) => {
5228 const va = a2(state, a1, a22, a3);
5229 const vb = b2(state, a1, a22, a3);
5230 return c2(va, vb, a1, a22, a3);
5231 };
5232 } else if (a2 && b2) {
5233 selector2 = (state, a1, a22, a3) => {
5234 const va = a2(state, a1, a22, a3);
5235 return b2(va, a1, a22, a3);
5236 };
5237 } else if (a2) {
5238 selector2 = a2;
5239 } else {
5240 throw (
5241 /* minify-error-disabled */
5242 new Error("Missing arguments")
5243 );
5244 }
5245 return selector2;
5246 };
5247
5248 // node_modules/@base-ui/utils/esm/store/useStore.js
5249 var React22 = __toESM(require_react(), 1);
5250 var import_shim = __toESM(require_shim(), 1);
5251 var import_with_selector = __toESM(require_with_selector(), 1);
5252
5253 // node_modules/@base-ui/utils/esm/fastHooks.js
5254 var React21 = __toESM(require_react(), 1);
5255 var hooks = [];
5256 var currentInstance = void 0;
5257 function getInstance() {
5258 return currentInstance;
5259 }
5260 function register(hook) {
5261 hooks.push(hook);
5262 }
5263 function fastComponent(fn) {
5264 const FastComponent = (props, forwardedRef) => {
5265 const instance = useRefWithInit(createInstance).current;
5266 let result;
5267 try {
5268 currentInstance = instance;
5269 for (const hook of hooks) {
5270 hook.before(instance);
5271 }
5272 result = fn(props, forwardedRef);
5273 for (const hook of hooks) {
5274 hook.after(instance);
5275 }
5276 instance.didInitialize = true;
5277 } finally {
5278 currentInstance = void 0;
5279 }
5280 return result;
5281 };
5282 FastComponent.displayName = fn.displayName || fn.name;
5283 return FastComponent;
5284 }
5285 function fastComponentRef(fn) {
5286 return /* @__PURE__ */ React21.forwardRef(fastComponent(fn));
5287 }
5288 function createInstance() {
5289 return {
5290 didInitialize: false
5291 };
5292 }
5293
5294 // node_modules/@base-ui/utils/esm/store/useStore.js
5295 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
5296 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
5297 function useStore(store, selector2, a1, a2, a3) {
5298 return useStoreImplementation(store, selector2, a1, a2, a3);
5299 }
5300 function useStoreR19(store, selector2, a1, a2, a3) {
5301 const getSelection = React22.useCallback(() => selector2(store.getSnapshot(), a1, a2, a3), [store, selector2, a1, a2, a3]);
5302 return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection);
5303 }
5304 register({
5305 before(instance) {
5306 instance.syncIndex = 0;
5307 if (!instance.didInitialize) {
5308 instance.syncTick = 1;
5309 instance.syncHooks = [];
5310 instance.didChangeStore = true;
5311 instance.getSnapshot = () => {
5312 let didChange2 = false;
5313 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) {
5314 const hook = instance.syncHooks[i2];
5315 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
5316 if (hook.didChange || !Object.is(hook.value, value)) {
5317 didChange2 = true;
5318 hook.value = value;
5319 hook.didChange = false;
5320 }
5321 }
5322 if (didChange2) {
5323 instance.syncTick += 1;
5324 }
5325 return instance.syncTick;
5326 };
5327 }
5328 },
5329 after(instance) {
5330 if (instance.syncHooks.length > 0) {
5331 if (instance.didChangeStore) {
5332 instance.didChangeStore = false;
5333 instance.subscribe = (onStoreChange) => {
5334 const stores = /* @__PURE__ */ new Set();
5335 for (const hook of instance.syncHooks) {
5336 stores.add(hook.store);
5337 }
5338 const unsubscribes = [];
5339 for (const store of stores) {
5340 unsubscribes.push(store.subscribe(onStoreChange));
5341 }
5342 return () => {
5343 for (const unsubscribe of unsubscribes) {
5344 unsubscribe();
5345 }
5346 };
5347 };
5348 }
5349 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
5350 }
5351 }
5352 });
5353 function useStoreFast(store, selector2, a1, a2, a3) {
5354 const instance = getInstance();
5355 if (!instance) {
5356 return useStoreR19(store, selector2, a1, a2, a3);
5357 }
5358 const index2 = instance.syncIndex;
5359 instance.syncIndex += 1;
5360 let hook;
5361 if (!instance.didInitialize) {
5362 hook = {
5363 store,
5364 selector: selector2,
5365 a1,
5366 a2,
5367 a3,
5368 value: selector2(store.getSnapshot(), a1, a2, a3),
5369 didChange: false
5370 };
5371 instance.syncHooks.push(hook);
5372 } else {
5373 hook = instance.syncHooks[index2];
5374 if (hook.store !== store || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
5375 if (hook.store !== store) {
5376 instance.didChangeStore = true;
5377 }
5378 hook.store = store;
5379 hook.selector = selector2;
5380 hook.a1 = a1;
5381 hook.a2 = a2;
5382 hook.a3 = a3;
5383 hook.didChange = true;
5384 }
5385 }
5386 return hook.value;
5387 }
5388 function useStoreLegacy(store, selector2, a1, a2, a3) {
5389 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector2(state, a1, a2, a3));
5390 }
5391
5392 // node_modules/@base-ui/utils/esm/store/Store.js
5393 var Store = class {
5394 /**
5395 * The current state of the store.
5396 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
5397 * 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).
5398 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
5399 *
5400 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
5401 */
5402 // Internal state to handle recursive `setState()` calls
5403 constructor(state) {
5404 this.state = state;
5405 this.listeners = /* @__PURE__ */ new Set();
5406 this.updateTick = 0;
5407 }
5408 /**
5409 * Registers a listener that will be called whenever the store's state changes.
5410 *
5411 * @param fn The listener function to be called on state changes.
5412 * @returns A function to unsubscribe the listener.
5413 */
5414 subscribe = (fn) => {
5415 this.listeners.add(fn);
5416 return () => {
5417 this.listeners.delete(fn);
5418 };
5419 };
5420 /**
5421 * Returns the current state of the store.
5422 */
5423 getSnapshot = () => {
5424 return this.state;
5425 };
5426 /**
5427 * Updates the entire store's state and notifies all registered listeners.
5428 *
5429 * @param newState The new state to set for the store.
5430 */
5431 setState(newState) {
5432 if (this.state === newState) {
5433 return;
5434 }
5435 this.state = newState;
5436 this.updateTick += 1;
5437 const currentTick = this.updateTick;
5438 for (const listener of this.listeners) {
5439 if (currentTick !== this.updateTick) {
5440 return;
5441 }
5442 listener(newState);
5443 }
5444 }
5445 /**
5446 * Merges the provided changes into the current state and notifies listeners if there are changes.
5447 *
5448 * @param changes An object containing the changes to apply to the current state.
5449 */
5450 update(changes) {
5451 for (const key in changes) {
5452 if (!Object.is(this.state[key], changes[key])) {
5453 this.setState({
5454 ...this.state,
5455 ...changes
5456 });
5457 return;
5458 }
5459 }
5460 }
5461 /**
5462 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
5463 *
5464 * @param key The key in the store's state to update.
5465 * @param value The new value to set for the specified key.
5466 */
5467 set(key, value) {
5468 if (!Object.is(this.state[key], value)) {
5469 this.setState({
5470 ...this.state,
5471 [key]: value
5472 });
5473 }
5474 }
5475 /**
5476 * Gives the state a new reference and updates all registered listeners.
5477 */
5478 notifyAll() {
5479 const newState = {
5480 ...this.state
5481 };
5482 this.setState(newState);
5483 }
5484 use(selector2, a1, a2, a3) {
5485 return useStore(this, selector2, a1, a2, a3);
5486 }
5487 };
5488
5489 // node_modules/@base-ui/utils/esm/store/ReactStore.js
5490 var React23 = __toESM(require_react(), 1);
5491 var ReactStore = class extends Store {
5492 /**
5493 * Creates a new ReactStore instance.
5494 *
5495 * @param state Initial state of the store.
5496 * @param context Non-reactive context values.
5497 * @param selectors Optional selectors for use with `useState`.
5498 */
5499 constructor(state, context = {}, selectors3) {
5500 super(state);
5501 this.context = context;
5502 this.selectors = selectors3;
5503 }
5504 /**
5505 * Non-reactive values such as refs, callbacks, etc.
5506 */
5507 /**
5508 * Synchronizes a single external value into the store.
5509 *
5510 * Note that the while the value in `state` is updated immediately, the value returned
5511 * by `useState` is updated before the next render (similarly to React's `useState`).
5512 */
5513 useSyncedValue(key, value) {
5514 React23.useDebugValue(key);
5515 useIsoLayoutEffect(() => {
5516 if (this.state[key] !== value) {
5517 this.set(key, value);
5518 }
5519 }, [key, value]);
5520 }
5521 /**
5522 * Synchronizes a single external value into the store and
5523 * cleans it up (sets to `undefined`) on unmount.
5524 *
5525 * Note that the while the value in `state` is updated immediately, the value returned
5526 * by `useState` is updated before the next render (similarly to React's `useState`).
5527 */
5528 useSyncedValueWithCleanup(key, value) {
5529 const store = this;
5530 useIsoLayoutEffect(() => {
5531 if (store.state[key] !== value) {
5532 store.set(key, value);
5533 }
5534 return () => {
5535 store.set(key, void 0);
5536 };
5537 }, [store, key, value]);
5538 }
5539 /**
5540 * Synchronizes multiple external values into the store.
5541 *
5542 * Note that the while the values in `state` are updated immediately, the values returned
5543 * by `useState` are updated before the next render (similarly to React's `useState`).
5544 */
5545 useSyncedValues(statePart) {
5546 const store = this;
5547 if (true) {
5548 React23.useDebugValue(statePart, (p2) => Object.keys(p2));
5549 const keys = React23.useRef(Object.keys(statePart)).current;
5550 const nextKeys = Object.keys(statePart);
5551 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
5552 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
5553 }
5554 }
5555 const dependencies = Object.values(statePart);
5556 useIsoLayoutEffect(() => {
5557 store.update(statePart);
5558 }, [store, ...dependencies]);
5559 }
5560 /**
5561 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
5562 * is non-undefined, the store's state at `key` is updated to match `controlled`.
5563 */
5564 useControlledProp(key, controlled) {
5565 React23.useDebugValue(key);
5566 const isControlled = controlled !== void 0;
5567 useIsoLayoutEffect(() => {
5568 if (isControlled && !Object.is(this.state[key], controlled)) {
5569 super.setState({
5570 ...this.state,
5571 [key]: controlled
5572 });
5573 }
5574 }, [key, controlled, isControlled]);
5575 if (true) {
5576 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
5577 if (!cache.has(key)) {
5578 cache.set(key, isControlled);
5579 }
5580 const previouslyControlled = cache.get(key);
5581 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
5582 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).`);
5583 }
5584 }
5585 }
5586 /** Gets the current value from the store using a selector with the provided key.
5587 *
5588 * @param key Key of the selector to use.
5589 */
5590 select(key, a1, a2, a3) {
5591 const selector2 = this.selectors[key];
5592 return selector2(this.state, a1, a2, a3);
5593 }
5594 /**
5595 * Returns a value from the store's state using a selector function.
5596 * Used to subscribe to specific parts of the state.
5597 * This methods causes a rerender whenever the selected state changes.
5598 *
5599 * @param key Key of the selector to use.
5600 */
5601 useState(key, a1, a2, a3) {
5602 React23.useDebugValue(key);
5603 return useStore(this, this.selectors[key], a1, a2, a3);
5604 }
5605 /**
5606 * Wraps a function with `useStableCallback` to ensure it has a stable reference
5607 * and assigns it to the context.
5608 *
5609 * @param key Key of the event callback. Must be a function in the context.
5610 * @param fn Function to assign.
5611 */
5612 useContextCallback(key, fn) {
5613 React23.useDebugValue(key);
5614 const stableFunction = useStableCallback(fn ?? NOOP);
5615 this.context[key] = stableFunction;
5616 }
5617 /**
5618 * Returns a stable setter function for a specific key in the store's state.
5619 * It's commonly used to pass as a ref callback to React elements.
5620 *
5621 * @param key Key of the state to set.
5622 */
5623 useStateSetter(key) {
5624 const ref = React23.useRef(void 0);
5625 if (ref.current === void 0) {
5626 ref.current = (value) => {
5627 this.set(key, value);
5628 };
5629 }
5630 return ref.current;
5631 }
5632 /**
5633 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
5634 *
5635 * @param key Key of the selector to observe.
5636 * @param listener Listener function called when the selector result changes.
5637 */
5638 observe(selector2, listener) {
5639 let selectFn;
5640 if (typeof selector2 === "function") {
5641 selectFn = selector2;
5642 } else {
5643 selectFn = this.selectors[selector2];
5644 }
5645 let prevValue = selectFn(this.state);
5646 listener(prevValue, prevValue, this);
5647 return this.subscribe((nextState) => {
5648 const nextValue = selectFn(nextState);
5649 if (!Object.is(prevValue, nextValue)) {
5650 const oldValue = prevValue;
5651 prevValue = nextValue;
5652 listener(nextValue, oldValue, this);
5653 }
5654 });
5655 }
5656 };
5657
5658 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingRootStore.js
5659 var selectors = {
5660 open: createSelector((state) => state.open),
5661 transitionStatus: createSelector((state) => state.transitionStatus),
5662 domReferenceElement: createSelector((state) => state.domReferenceElement),
5663 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
5664 floatingElement: createSelector((state) => state.floatingElement),
5665 floatingId: createSelector((state) => state.floatingId)
5666 };
5667 var FloatingRootStore = class extends ReactStore {
5668 constructor(options) {
5669 const {
5670 syncOnly,
5671 nested,
5672 onOpenChange,
5673 triggerElements,
5674 ...initialState
5675 } = options;
5676 super({
5677 ...initialState,
5678 positionReference: initialState.referenceElement,
5679 domReferenceElement: initialState.referenceElement
5680 }, {
5681 onOpenChange,
5682 dataRef: {
5683 current: {}
5684 },
5685 events: createEventEmitter(),
5686 nested,
5687 triggerElements
5688 }, selectors);
5689 this.syncOnly = syncOnly;
5690 }
5691 /**
5692 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
5693 */
5694 syncOpenEvent = (newOpen, event) => {
5695 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
5696 // click events to upgrade a hover-open.
5697 event != null && isClickLikeEvent(event)) {
5698 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
5699 }
5700 };
5701 /**
5702 * Runs the root-owned side effects for an open state change.
5703 */
5704 dispatchOpenChange = (newOpen, eventDetails) => {
5705 this.syncOpenEvent(newOpen, eventDetails.event);
5706 const details = {
5707 open: newOpen,
5708 reason: eventDetails.reason,
5709 nativeEvent: eventDetails.event,
5710 nested: this.context.nested,
5711 triggerElement: eventDetails.trigger
5712 };
5713 this.context.events.emit("openchange", details);
5714 };
5715 /**
5716 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
5717 *
5718 * @param newOpen The new open state.
5719 * @param eventDetails Details about the event that triggered the open state change.
5720 */
5721 setOpen = (newOpen, eventDetails) => {
5722 if (this.syncOnly) {
5723 this.context.onOpenChange?.(newOpen, eventDetails);
5724 return;
5725 }
5726 this.dispatchOpenChange(newOpen, eventDetails);
5727 this.context.onOpenChange?.(newOpen, eventDetails);
5728 };
5729 };
5730
5731 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
5732 var React24 = __toESM(require_react(), 1);
5733 function useTriggerRegistration(id, store) {
5734 const registeredElementIdRef = React24.useRef(null);
5735 const registeredElementRef = React24.useRef(null);
5736 return React24.useCallback((element) => {
5737 if (id === void 0) {
5738 return;
5739 }
5740 if (registeredElementIdRef.current !== null) {
5741 const registeredId = registeredElementIdRef.current;
5742 const registeredElement = registeredElementRef.current;
5743 const currentElement = store.context.triggerElements.getById(registeredId);
5744 if (registeredElement && currentElement === registeredElement) {
5745 store.context.triggerElements.delete(registeredId);
5746 }
5747 registeredElementIdRef.current = null;
5748 registeredElementRef.current = null;
5749 }
5750 if (element !== null) {
5751 registeredElementIdRef.current = id;
5752 registeredElementRef.current = element;
5753 store.context.triggerElements.add(id, element);
5754 }
5755 }, [store, id]);
5756 }
5757 function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
5758 const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
5759 const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
5760 const registerTrigger = useStableCallback((element) => {
5761 baseRegisterTrigger(element);
5762 if (!element || !store.select("open")) {
5763 return;
5764 }
5765 const activeTriggerId = store.select("activeTriggerId");
5766 if (activeTriggerId === triggerId) {
5767 store.update({
5768 activeTriggerElement: element,
5769 ...stateUpdates
5770 });
5771 return;
5772 }
5773 if (activeTriggerId == null) {
5774 store.update({
5775 activeTriggerId: triggerId,
5776 activeTriggerElement: element,
5777 ...stateUpdates
5778 });
5779 }
5780 });
5781 useIsoLayoutEffect(() => {
5782 if (isMountedByThisTrigger) {
5783 store.update({
5784 activeTriggerElement: triggerElementRef.current,
5785 ...stateUpdates
5786 });
5787 }
5788 }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]);
5789 return {
5790 registerTrigger,
5791 isMountedByThisTrigger
5792 };
5793 }
5794 function useImplicitActiveTrigger(store) {
5795 const open = store.useState("open");
5796 useIsoLayoutEffect(() => {
5797 if (open && !store.select("activeTriggerId") && store.context.triggerElements.size === 1) {
5798 const iteratorResult = store.context.triggerElements.entries().next();
5799 if (!iteratorResult.done) {
5800 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
5801 store.update({
5802 activeTriggerId: implicitTriggerId,
5803 activeTriggerElement: implicitTriggerElement
5804 });
5805 }
5806 }
5807 }, [open, store]);
5808 }
5809 function useOpenStateTransitions(open, store, onUnmount) {
5810 const {
5811 mounted,
5812 setMounted,
5813 transitionStatus
5814 } = useTransitionStatus(open);
5815 store.useSyncedValues({
5816 mounted,
5817 transitionStatus
5818 });
5819 const forceUnmount = useStableCallback(() => {
5820 setMounted(false);
5821 store.update({
5822 activeTriggerId: null,
5823 activeTriggerElement: null,
5824 mounted: false
5825 });
5826 onUnmount?.();
5827 store.context.onOpenChangeComplete?.(false);
5828 });
5829 const preventUnmountingOnClose = store.useState("preventUnmountingOnClose");
5830 useOpenChangeComplete({
5831 enabled: !preventUnmountingOnClose,
5832 open,
5833 ref: store.context.popupRef,
5834 onComplete() {
5835 if (!open) {
5836 forceUnmount();
5837 }
5838 }
5839 });
5840 return {
5841 forceUnmount,
5842 transitionStatus
5843 };
5844 }
5845
5846 // node_modules/@base-ui/react/esm/utils/popups/popupTriggerMap.js
5847 var PopupTriggerMap = class {
5848 constructor() {
5849 this.elementsSet = /* @__PURE__ */ new Set();
5850 this.idMap = /* @__PURE__ */ new Map();
5851 }
5852 /**
5853 * Adds a trigger element with the given ID.
5854 *
5855 * Note: The provided element is assumed to not be registered under multiple IDs.
5856 */
5857 add(id, element) {
5858 const existingElement = this.idMap.get(id);
5859 if (existingElement === element) {
5860 return;
5861 }
5862 if (existingElement !== void 0) {
5863 this.elementsSet.delete(existingElement);
5864 }
5865 this.elementsSet.add(element);
5866 this.idMap.set(id, element);
5867 if (true) {
5868 if (this.elementsSet.size !== this.idMap.size) {
5869 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
5870 }
5871 }
5872 }
5873 /**
5874 * Removes the trigger element with the given ID.
5875 */
5876 delete(id) {
5877 const element = this.idMap.get(id);
5878 if (element) {
5879 this.elementsSet.delete(element);
5880 this.idMap.delete(id);
5881 }
5882 }
5883 /**
5884 * Whether the given element is registered as a trigger.
5885 */
5886 hasElement(element) {
5887 return this.elementsSet.has(element);
5888 }
5889 /**
5890 * Whether there is a registered trigger element matching the given predicate.
5891 */
5892 hasMatchingElement(predicate) {
5893 for (const element of this.elementsSet) {
5894 if (predicate(element)) {
5895 return true;
5896 }
5897 }
5898 return false;
5899 }
5900 /**
5901 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
5902 */
5903 getById(id) {
5904 return this.idMap.get(id);
5905 }
5906 /**
5907 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
5908 */
5909 entries() {
5910 return this.idMap.entries();
5911 }
5912 /**
5913 * Returns an iterable of all registered trigger elements.
5914 */
5915 elements() {
5916 return this.elementsSet.values();
5917 }
5918 /**
5919 * Returns the number of registered trigger elements.
5920 */
5921 get size() {
5922 return this.idMap.size;
5923 }
5924 };
5925
5926 // node_modules/@base-ui/react/esm/floating-ui-react/utils/getEmptyRootContext.js
5927 function getEmptyRootContext() {
5928 return new FloatingRootStore({
5929 open: false,
5930 transitionStatus: void 0,
5931 floatingElement: null,
5932 referenceElement: null,
5933 triggerElements: new PopupTriggerMap(),
5934 floatingId: "",
5935 syncOnly: false,
5936 nested: false,
5937 onOpenChange: void 0
5938 });
5939 }
5940
5941 // node_modules/@base-ui/react/esm/utils/popups/store.js
5942 function createInitialPopupStoreState() {
5943 return {
5944 open: false,
5945 openProp: void 0,
5946 mounted: false,
5947 transitionStatus: void 0,
5948 floatingRootContext: getEmptyRootContext(),
5949 preventUnmountingOnClose: false,
5950 payload: void 0,
5951 activeTriggerId: null,
5952 activeTriggerElement: null,
5953 triggerIdProp: void 0,
5954 popupElement: null,
5955 positionerElement: null,
5956 activeTriggerProps: EMPTY_OBJECT,
5957 inactiveTriggerProps: EMPTY_OBJECT,
5958 popupProps: EMPTY_OBJECT
5959 };
5960 }
5961 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
5962 var popupStoreSelectors = {
5963 open: createSelector((state) => state.openProp ?? state.open),
5964 mounted: createSelector((state) => state.mounted),
5965 transitionStatus: createSelector((state) => state.transitionStatus),
5966 floatingRootContext: createSelector((state) => state.floatingRootContext),
5967 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
5968 payload: createSelector((state) => state.payload),
5969 activeTriggerId: activeTriggerIdSelector,
5970 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
5971 /**
5972 * Whether the trigger with the given ID was used to open the popup.
5973 */
5974 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
5975 /**
5976 * Whether the popup is open and was activated by a trigger with the given ID.
5977 */
5978 isOpenedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.open),
5979 /**
5980 * Whether the popup is mounted and was activated by a trigger with the given ID.
5981 */
5982 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
5983 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
5984 popupProps: createSelector((state) => state.popupProps),
5985 popupElement: createSelector((state) => state.popupElement),
5986 positionerElement: createSelector((state) => state.positionerElement)
5987 };
5988
5989 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloatingRootContext.js
5990 function useFloatingRootContext(options) {
5991 const {
5992 open = false,
5993 onOpenChange,
5994 elements = {}
5995 } = options;
5996 const floatingId = useId();
5997 const nested = useFloatingParentNodeId() != null;
5998 if (true) {
5999 const optionDomReference = elements.reference;
6000 if (optionDomReference && !isElement(optionDomReference)) {
6001 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
6002 }
6003 }
6004 const store = useRefWithInit(() => new FloatingRootStore({
6005 open,
6006 transitionStatus: void 0,
6007 onOpenChange,
6008 referenceElement: elements.reference ?? null,
6009 floatingElement: elements.floating ?? null,
6010 triggerElements: new PopupTriggerMap(),
6011 floatingId,
6012 syncOnly: false,
6013 nested
6014 })).current;
6015 useIsoLayoutEffect(() => {
6016 const valuesToSync = {
6017 open,
6018 floatingId
6019 };
6020 if (elements.reference !== void 0) {
6021 valuesToSync.referenceElement = elements.reference;
6022 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
6023 }
6024 if (elements.floating !== void 0) {
6025 valuesToSync.floatingElement = elements.floating;
6026 }
6027 store.update(valuesToSync);
6028 }, [open, floatingId, elements.reference, elements.floating, store]);
6029 store.context.onOpenChange = onOpenChange;
6030 store.context.nested = nested;
6031 return store;
6032 }
6033
6034 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
6035 function useFloating2(options = {}) {
6036 const {
6037 nodeId,
6038 externalTree
6039 } = options;
6040 const internalRootStore = useFloatingRootContext(options);
6041 const rootContext = options.rootContext || internalRootStore;
6042 const rootContextElements = {
6043 reference: rootContext.useState("referenceElement"),
6044 floating: rootContext.useState("floatingElement"),
6045 domReference: rootContext.useState("domReferenceElement")
6046 };
6047 const [positionReference, setPositionReferenceRaw] = React25.useState(null);
6048 const domReferenceRef = React25.useRef(null);
6049 const tree = useFloatingTree(externalTree);
6050 useIsoLayoutEffect(() => {
6051 if (rootContextElements.domReference) {
6052 domReferenceRef.current = rootContextElements.domReference;
6053 }
6054 }, [rootContextElements.domReference]);
6055 const position = useFloating({
6056 ...options,
6057 elements: {
6058 ...rootContextElements,
6059 ...positionReference && {
6060 reference: positionReference
6061 }
6062 }
6063 });
6064 const setPositionReference = React25.useCallback((node) => {
6065 const computedPositionReference = isElement(node) ? {
6066 getBoundingClientRect: () => node.getBoundingClientRect(),
6067 getClientRects: () => node.getClientRects(),
6068 contextElement: node
6069 } : node;
6070 setPositionReferenceRaw(computedPositionReference);
6071 position.refs.setReference(computedPositionReference);
6072 }, [position.refs]);
6073 const [localDomReference, setLocalDomReference] = React25.useState(void 0);
6074 const [localFloatingElement, setLocalFloatingElement] = React25.useState(null);
6075 rootContext.useSyncedValue("referenceElement", localDomReference ?? null);
6076 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
6077 rootContext.useSyncedValue("domReferenceElement", localDomReference === void 0 ? rootContextElements.domReference : localDomReferenceElement);
6078 rootContext.useSyncedValue("floatingElement", localFloatingElement);
6079 const setReference = React25.useCallback((node) => {
6080 if (isElement(node) || node === null) {
6081 domReferenceRef.current = node;
6082 setLocalDomReference(node);
6083 }
6084 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
6085 // `null` to support `positionReference` + an unstable `reference`
6086 // callback ref.
6087 node !== null && !isElement(node)) {
6088 position.refs.setReference(node);
6089 }
6090 }, [position.refs, setLocalDomReference]);
6091 const setFloating = React25.useCallback((node) => {
6092 setLocalFloatingElement(node);
6093 position.refs.setFloating(node);
6094 }, [position.refs]);
6095 const refs = React25.useMemo(() => ({
6096 ...position.refs,
6097 setReference,
6098 setFloating,
6099 setPositionReference,
6100 domReference: domReferenceRef
6101 }), [position.refs, setReference, setFloating, setPositionReference]);
6102 const elements = React25.useMemo(() => ({
6103 ...position.elements,
6104 domReference: rootContextElements.domReference
6105 }), [position.elements, rootContextElements.domReference]);
6106 const open = rootContext.useState("open");
6107 const floatingId = rootContext.useState("floatingId");
6108 const context = React25.useMemo(() => ({
6109 ...position,
6110 dataRef: rootContext.context.dataRef,
6111 open,
6112 onOpenChange: rootContext.setOpen,
6113 events: rootContext.context.events,
6114 floatingId,
6115 refs,
6116 elements,
6117 nodeId,
6118 rootStore: rootContext
6119 }), [position, refs, elements, nodeId, rootContext, open, floatingId]);
6120 useIsoLayoutEffect(() => {
6121 rootContext.context.dataRef.current.floatingContext = context;
6122 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId);
6123 if (node) {
6124 node.context = context;
6125 }
6126 });
6127 return React25.useMemo(() => ({
6128 ...position,
6129 context,
6130 refs,
6131 elements,
6132 rootStore: rootContext
6133 }), [position, refs, elements, context, rootContext]);
6134 }
6135
6136 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
6137 function useSyncedFloatingRootContext(options) {
6138 const {
6139 popupStore,
6140 treatPopupAsFloatingElement = false,
6141 onOpenChange
6142 } = options;
6143 const floatingId = useId();
6144 const nested = useFloatingParentNodeId() != null;
6145 const open = popupStore.useState("open");
6146 const referenceElement = popupStore.useState("activeTriggerElement");
6147 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
6148 const triggerElements = popupStore.context.triggerElements;
6149 const store = useRefWithInit(() => new FloatingRootStore({
6150 open,
6151 transitionStatus: void 0,
6152 referenceElement,
6153 floatingElement,
6154 triggerElements,
6155 onOpenChange,
6156 floatingId,
6157 syncOnly: true,
6158 nested
6159 })).current;
6160 useIsoLayoutEffect(() => {
6161 const valuesToSync = {
6162 open,
6163 floatingId,
6164 referenceElement,
6165 floatingElement
6166 };
6167 if (isElement(referenceElement)) {
6168 valuesToSync.domReferenceElement = referenceElement;
6169 }
6170 if (store.state.positionReference === store.state.referenceElement) {
6171 valuesToSync.positionReference = referenceElement;
6172 }
6173 store.update(valuesToSync);
6174 }, [open, floatingId, referenceElement, floatingElement, store]);
6175 store.context.onOpenChange = onOpenChange;
6176 store.context.nested = nested;
6177 return store;
6178 }
6179
6180 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFocus.js
6181 var React26 = __toESM(require_react(), 1);
6182 var isMacSafari = isMac && isSafari;
6183 function useFocus(context, props = {}) {
6184 const store = "rootStore" in context ? context.rootStore : context;
6185 const {
6186 events,
6187 dataRef
6188 } = store.context;
6189 const {
6190 enabled = true,
6191 delay
6192 } = props;
6193 const blockFocusRef = React26.useRef(false);
6194 const blockedReferenceRef = React26.useRef(null);
6195 const timeout = useTimeout();
6196 const keyboardModalityRef = React26.useRef(true);
6197 React26.useEffect(() => {
6198 const domReference = store.select("domReferenceElement");
6199 if (!enabled) {
6200 return void 0;
6201 }
6202 const win = getWindow(domReference);
6203 function onBlur() {
6204 const currentDomReference = store.select("domReferenceElement");
6205 if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
6206 blockFocusRef.current = true;
6207 }
6208 }
6209 function onKeyDown() {
6210 keyboardModalityRef.current = true;
6211 }
6212 function onPointerDown() {
6213 keyboardModalityRef.current = false;
6214 }
6215 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
6216 }, [store, enabled]);
6217 React26.useEffect(() => {
6218 if (!enabled) {
6219 return void 0;
6220 }
6221 function onOpenChangeLocal(details) {
6222 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
6223 const referenceElement = store.select("domReferenceElement");
6224 if (isElement(referenceElement)) {
6225 blockedReferenceRef.current = referenceElement;
6226 blockFocusRef.current = true;
6227 }
6228 }
6229 }
6230 events.on("openchange", onOpenChangeLocal);
6231 return () => {
6232 events.off("openchange", onOpenChangeLocal);
6233 };
6234 }, [events, enabled, store]);
6235 const reference = React26.useMemo(() => ({
6236 onMouseLeave() {
6237 blockFocusRef.current = false;
6238 blockedReferenceRef.current = null;
6239 },
6240 onFocus(event) {
6241 const focusTarget = event.currentTarget;
6242 if (blockFocusRef.current) {
6243 if (blockedReferenceRef.current === focusTarget) {
6244 return;
6245 }
6246 blockFocusRef.current = false;
6247 blockedReferenceRef.current = null;
6248 }
6249 const target = getTarget(event.nativeEvent);
6250 if (isElement(target)) {
6251 if (isMacSafari && !event.relatedTarget) {
6252 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
6253 return;
6254 }
6255 } else if (!matchesFocusVisible(target)) {
6256 return;
6257 }
6258 }
6259 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);
6260 const {
6261 nativeEvent,
6262 currentTarget
6263 } = event;
6264 const delayValue = typeof delay === "function" ? delay() : delay;
6265 if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
6266 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6267 return;
6268 }
6269 timeout.start(delayValue, () => {
6270 if (blockFocusRef.current) {
6271 return;
6272 }
6273 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6274 });
6275 },
6276 onBlur(event) {
6277 blockFocusRef.current = false;
6278 blockedReferenceRef.current = null;
6279 const relatedTarget = event.relatedTarget;
6280 const nativeEvent = event.nativeEvent;
6281 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
6282 timeout.start(0, () => {
6283 const domReference = store.select("domReferenceElement");
6284 const activeEl = activeElement(ownerDocument(domReference));
6285 if (!relatedTarget && activeEl === domReference) {
6286 return;
6287 }
6288 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
6289 return;
6290 }
6291 const nextFocusedElement = relatedTarget ?? activeEl;
6292 if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {
6293 return;
6294 }
6295 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
6296 });
6297 }
6298 }), [dataRef, store, timeout, delay]);
6299 return React26.useMemo(() => enabled ? {
6300 reference,
6301 trigger: reference
6302 } : {}, [enabled, reference]);
6303 }
6304
6305 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
6306 var React27 = __toESM(require_react(), 1);
6307
6308 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverInteractionSharedState.js
6309 var HoverInteraction = class _HoverInteraction {
6310 constructor() {
6311 this.pointerType = void 0;
6312 this.interactedInside = false;
6313 this.handler = void 0;
6314 this.blockMouseMove = true;
6315 this.performedPointerEventsMutation = false;
6316 this.pointerEventsScopeElement = null;
6317 this.pointerEventsReferenceElement = null;
6318 this.pointerEventsFloatingElement = null;
6319 this.restTimeoutPending = false;
6320 this.openChangeTimeout = new Timeout();
6321 this.restTimeout = new Timeout();
6322 this.handleCloseOptions = void 0;
6323 }
6324 static create() {
6325 return new _HoverInteraction();
6326 }
6327 dispose = () => {
6328 this.openChangeTimeout.clear();
6329 this.restTimeout.clear();
6330 };
6331 disposeEffect = () => {
6332 return this.dispose;
6333 };
6334 };
6335 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
6336 function clearSafePolygonPointerEventsMutation(instance) {
6337 if (!instance.performedPointerEventsMutation) {
6338 return;
6339 }
6340 const scopeElement = instance.pointerEventsScopeElement;
6341 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
6342 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
6343 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
6344 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
6345 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
6346 }
6347 instance.performedPointerEventsMutation = false;
6348 instance.pointerEventsScopeElement = null;
6349 instance.pointerEventsReferenceElement = null;
6350 instance.pointerEventsFloatingElement = null;
6351 }
6352 function applySafePolygonPointerEventsMutation(instance, options) {
6353 const {
6354 scopeElement,
6355 referenceElement,
6356 floatingElement
6357 } = options;
6358 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
6359 if (existingOwner && existingOwner !== instance) {
6360 clearSafePolygonPointerEventsMutation(existingOwner);
6361 }
6362 clearSafePolygonPointerEventsMutation(instance);
6363 instance.performedPointerEventsMutation = true;
6364 instance.pointerEventsScopeElement = scopeElement;
6365 instance.pointerEventsReferenceElement = referenceElement;
6366 instance.pointerEventsFloatingElement = floatingElement;
6367 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
6368 scopeElement.style.pointerEvents = "none";
6369 referenceElement.style.pointerEvents = "auto";
6370 floatingElement.style.pointerEvents = "auto";
6371 }
6372 function useHoverInteractionSharedState(store) {
6373 const instance = useRefWithInit(HoverInteraction.create).current;
6374 const data = store.context.dataRef.current;
6375 if (!data.hoverInteractionState) {
6376 data.hoverInteractionState = instance;
6377 }
6378 useOnMount(data.hoverInteractionState.disposeEffect);
6379 return data.hoverInteractionState;
6380 }
6381
6382 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
6383 function useHoverFloatingInteraction(context, parameters = {}) {
6384 const store = "rootStore" in context ? context.rootStore : context;
6385 const open = store.useState("open");
6386 const floatingElement = store.useState("floatingElement");
6387 const domReferenceElement = store.useState("domReferenceElement");
6388 const {
6389 dataRef
6390 } = store.context;
6391 const {
6392 enabled = true,
6393 closeDelay: closeDelayProp = 0,
6394 nodeId: nodeIdProp
6395 } = parameters;
6396 const instance = useHoverInteractionSharedState(store);
6397 const tree = useFloatingTree();
6398 const parentId = useFloatingParentNodeId();
6399 const isClickLikeOpenEvent2 = useStableCallback(() => {
6400 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6401 });
6402 const isHoverOpen = useStableCallback(() => {
6403 const type = dataRef.current.openEvent?.type;
6404 return type?.includes("mouse") && type !== "mousedown";
6405 });
6406 const isRelatedTargetInsideEnabledTrigger = useStableCallback((target) => {
6407 return isTargetInsideEnabledTrigger(target, store.context.triggerElements);
6408 });
6409 const closeWithDelay = React27.useCallback((event) => {
6410 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
6411 const close = () => {
6412 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6413 tree?.events.emit("floating.closed", event);
6414 };
6415 if (closeDelay) {
6416 instance.openChangeTimeout.start(closeDelay, close);
6417 } else {
6418 instance.openChangeTimeout.clear();
6419 close();
6420 }
6421 }, [closeDelayProp, store, instance, tree]);
6422 const clearPointerEvents = useStableCallback(() => {
6423 clearSafePolygonPointerEventsMutation(instance);
6424 });
6425 const handleInteractInside = useStableCallback((event) => {
6426 const target = getTarget(event);
6427 if (!isInteractiveElement(target)) {
6428 instance.interactedInside = false;
6429 return;
6430 }
6431 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
6432 });
6433 useIsoLayoutEffect(() => {
6434 if (!open) {
6435 instance.pointerType = void 0;
6436 instance.restTimeoutPending = false;
6437 instance.interactedInside = false;
6438 clearPointerEvents();
6439 }
6440 }, [open, instance, clearPointerEvents]);
6441 React27.useEffect(() => {
6442 return clearPointerEvents;
6443 }, [clearPointerEvents]);
6444 useIsoLayoutEffect(() => {
6445 if (!enabled) {
6446 return void 0;
6447 }
6448 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
6449 const ref = domReferenceElement;
6450 const floatingEl = floatingElement;
6451 const doc = ownerDocument(floatingElement);
6452 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
6453 if (parentFloating) {
6454 parentFloating.style.pointerEvents = "";
6455 }
6456 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? instance.pointerEventsScopeElement ?? parentFloating ?? ref.closest("[data-rootownerid]") ?? doc.body;
6457 applySafePolygonPointerEventsMutation(instance, {
6458 scopeElement,
6459 referenceElement: ref,
6460 floatingElement: floatingEl
6461 });
6462 return () => {
6463 clearPointerEvents();
6464 };
6465 }
6466 return void 0;
6467 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
6468 const childClosedTimeout = useTimeout();
6469 React27.useEffect(() => {
6470 if (!enabled) {
6471 return void 0;
6472 }
6473 function onFloatingMouseEnter() {
6474 instance.openChangeTimeout.clear();
6475 childClosedTimeout.clear();
6476 tree?.events.off("floating.closed", onNodeClosed);
6477 clearPointerEvents();
6478 }
6479 function onFloatingMouseLeave(event) {
6480 if (tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0) {
6481 tree.events.on("floating.closed", onNodeClosed);
6482 return;
6483 }
6484 if (isRelatedTargetInsideEnabledTrigger(event.relatedTarget)) {
6485 return;
6486 }
6487 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
6488 const relatedTarget = event.relatedTarget;
6489 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
6490 if (isMovingIntoDescendantFloating) {
6491 return;
6492 }
6493 if (instance.handler) {
6494 instance.handler(event);
6495 return;
6496 }
6497 clearPointerEvents();
6498 if (!isClickLikeOpenEvent2()) {
6499 closeWithDelay(event);
6500 }
6501 }
6502 function onNodeClosed(event) {
6503 if (!tree || !parentId || getNodeChildren(tree.nodesRef.current, parentId).length > 0) {
6504 return;
6505 }
6506 childClosedTimeout.start(0, () => {
6507 tree.events.off("floating.closed", onNodeClosed);
6508 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6509 tree.events.emit("floating.closed", event);
6510 });
6511 }
6512 const floating = floatingElement;
6513 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
6514 tree?.events.off("floating.closed", onNodeClosed);
6515 });
6516 }, [enabled, floatingElement, store, dataRef, nodeIdProp, isClickLikeOpenEvent2, isRelatedTargetInsideEnabledTrigger, closeWithDelay, clearPointerEvents, handleInteractInside, instance, tree, parentId, childClosedTimeout]);
6517 }
6518
6519 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverReferenceInteraction.js
6520 var React28 = __toESM(require_react(), 1);
6521 var ReactDOM4 = __toESM(require_react_dom(), 1);
6522 var EMPTY_REF = {
6523 current: null
6524 };
6525 function useHoverReferenceInteraction(context, props = {}) {
6526 const store = "rootStore" in context ? context.rootStore : context;
6527 const {
6528 dataRef,
6529 events
6530 } = store.context;
6531 const {
6532 enabled = true,
6533 delay = 0,
6534 handleClose = null,
6535 mouseOnly = false,
6536 restMs = 0,
6537 move = true,
6538 triggerElementRef = EMPTY_REF,
6539 externalTree,
6540 isActiveTrigger = true,
6541 getHandleCloseContext,
6542 isClosing
6543 } = props;
6544 const tree = useFloatingTree(externalTree);
6545 const instance = useHoverInteractionSharedState(store);
6546 const isHoverCloseActiveRef = React28.useRef(false);
6547 const handleCloseRef = useValueAsRef(handleClose);
6548 const delayRef = useValueAsRef(delay);
6549 const restMsRef = useValueAsRef(restMs);
6550 const enabledRef = useValueAsRef(enabled);
6551 const isClosingRef = useValueAsRef(isClosing);
6552 if (isActiveTrigger) {
6553 instance.handleCloseOptions = handleCloseRef.current?.__options;
6554 }
6555 const isClickLikeOpenEvent2 = useStableCallback(() => {
6556 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6557 });
6558 const isRelatedTargetInsideEnabledTrigger = useStableCallback((target) => {
6559 return isTargetInsideEnabledTrigger(target, store.context.triggerElements);
6560 });
6561 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
6562 const allTriggers = store.context.triggerElements;
6563 if (allTriggers.hasElement(currentTarget)) {
6564 return !currentDomReference || !contains(currentDomReference, currentTarget);
6565 }
6566 if (!isElement(target)) {
6567 return false;
6568 }
6569 const targetElement = target;
6570 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
6571 });
6572 const closeWithDelay = useStableCallback((event, runElseBranch = true) => {
6573 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
6574 if (closeDelay) {
6575 instance.openChangeTimeout.start(closeDelay, () => {
6576 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6577 tree?.events.emit("floating.closed", event);
6578 });
6579 } else if (runElseBranch) {
6580 instance.openChangeTimeout.clear();
6581 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6582 tree?.events.emit("floating.closed", event);
6583 }
6584 });
6585 const cleanupMouseMoveHandler = useStableCallback(() => {
6586 if (!instance.handler) {
6587 return;
6588 }
6589 const doc = ownerDocument(store.select("domReferenceElement"));
6590 doc.removeEventListener("mousemove", instance.handler);
6591 instance.handler = void 0;
6592 });
6593 const clearPointerEvents = useStableCallback(() => {
6594 clearSafePolygonPointerEventsMutation(instance);
6595 });
6596 React28.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
6597 React28.useEffect(() => {
6598 if (!enabled) {
6599 return void 0;
6600 }
6601 function onOpenChangeLocal(details) {
6602 if (!details.open) {
6603 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
6604 cleanupMouseMoveHandler();
6605 instance.openChangeTimeout.clear();
6606 instance.restTimeout.clear();
6607 instance.blockMouseMove = true;
6608 instance.restTimeoutPending = false;
6609 } else {
6610 isHoverCloseActiveRef.current = false;
6611 }
6612 }
6613 events.on("openchange", onOpenChangeLocal);
6614 return () => {
6615 events.off("openchange", onOpenChangeLocal);
6616 };
6617 }, [enabled, events, instance, cleanupMouseMoveHandler]);
6618 React28.useEffect(() => {
6619 if (!enabled) {
6620 return void 0;
6621 }
6622 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null);
6623 if (!isElement(trigger)) {
6624 return void 0;
6625 }
6626 function onMouseEnter(event) {
6627 instance.openChangeTimeout.clear();
6628 instance.blockMouseMove = false;
6629 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6630 return;
6631 }
6632 const restMsValue = getRestMs(restMsRef.current);
6633 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
6634 const eventTarget = getTarget(event);
6635 const currentTarget = event.currentTarget ?? null;
6636 const currentDomReference = store.select("domReferenceElement");
6637 let triggerNode = currentTarget;
6638 if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) {
6639 for (const triggerElement of store.context.triggerElements.elements()) {
6640 if (contains(triggerElement, eventTarget)) {
6641 triggerNode = triggerElement;
6642 break;
6643 }
6644 }
6645 }
6646 if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
6647 triggerNode = currentDomReference;
6648 }
6649 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
6650 const isOpen = store.select("open");
6651 const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending";
6652 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
6653 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
6654 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
6655 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
6656 const shouldOpen = !isOpen || isOverInactive;
6657 if (shouldOpenImmediately) {
6658 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6659 return;
6660 }
6661 if (isRestOnlyDelay) {
6662 return;
6663 }
6664 if (openDelay) {
6665 instance.openChangeTimeout.start(openDelay, () => {
6666 if (shouldOpen) {
6667 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6668 }
6669 });
6670 } else if (shouldOpen) {
6671 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6672 }
6673 }
6674 function onMouseLeave(event) {
6675 if (isClickLikeOpenEvent2()) {
6676 clearPointerEvents();
6677 return;
6678 }
6679 cleanupMouseMoveHandler();
6680 const domReferenceElement = store.select("domReferenceElement");
6681 const doc = ownerDocument(domReferenceElement);
6682 instance.restTimeout.clear();
6683 instance.restTimeoutPending = false;
6684 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
6685 const ignoreRelatedTargetTrigger = isRelatedTargetInsideEnabledTrigger(event.relatedTarget);
6686 if (ignoreRelatedTargetTrigger) {
6687 return;
6688 }
6689 if (handleCloseRef.current && handleCloseContextBase) {
6690 if (!store.select("open")) {
6691 instance.openChangeTimeout.clear();
6692 }
6693 const currentTrigger = triggerElementRef.current;
6694 instance.handler = handleCloseRef.current({
6695 ...handleCloseContextBase,
6696 tree,
6697 x: event.clientX,
6698 y: event.clientY,
6699 onClose() {
6700 clearPointerEvents();
6701 cleanupMouseMoveHandler();
6702 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) {
6703 closeWithDelay(event, true);
6704 }
6705 }
6706 });
6707 doc.addEventListener("mousemove", instance.handler);
6708 instance.handler(event);
6709 return;
6710 }
6711 const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true;
6712 if (shouldClose) {
6713 closeWithDelay(event);
6714 }
6715 }
6716 if (move) {
6717 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
6718 once: true
6719 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
6720 }
6721 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
6722 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, closeWithDelay, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, isRelatedTargetInsideEnabledTrigger, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef]);
6723 return React28.useMemo(() => {
6724 if (!enabled) {
6725 return void 0;
6726 }
6727 function setPointerRef(event) {
6728 instance.pointerType = event.pointerType;
6729 }
6730 return {
6731 onPointerDown: setPointerRef,
6732 onPointerEnter: setPointerRef,
6733 onMouseMove(event) {
6734 const {
6735 nativeEvent
6736 } = event;
6737 const trigger = event.currentTarget;
6738 const currentDomReference = store.select("domReferenceElement");
6739 const currentOpen = store.select("open");
6740 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
6741 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6742 return;
6743 }
6744 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
6745 const floatingElement = store.select("floatingElement");
6746 if (floatingElement) {
6747 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
6748 applySafePolygonPointerEventsMutation(instance, {
6749 scopeElement,
6750 referenceElement: trigger,
6751 floatingElement
6752 });
6753 }
6754 }
6755 const restMsValue = getRestMs(restMsRef.current);
6756 if (currentOpen && !isOverInactive || restMsValue === 0) {
6757 return;
6758 }
6759 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
6760 return;
6761 }
6762 instance.restTimeout.clear();
6763 function handleMouseMove() {
6764 instance.restTimeoutPending = false;
6765 if (isClickLikeOpenEvent2()) {
6766 return;
6767 }
6768 const latestOpen = store.select("open");
6769 if (!instance.blockMouseMove && (!latestOpen || isOverInactive)) {
6770 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
6771 }
6772 }
6773 if (instance.pointerType === "touch") {
6774 ReactDOM4.flushSync(() => {
6775 handleMouseMove();
6776 });
6777 } else if (isOverInactive && currentOpen) {
6778 handleMouseMove();
6779 } else {
6780 instance.restTimeoutPending = true;
6781 instance.restTimeout.start(restMsValue, handleMouseMove);
6782 }
6783 }
6784 };
6785 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef]);
6786 }
6787
6788 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useInteractions.js
6789 var React29 = __toESM(require_react(), 1);
6790 function useInteractions(propsList = []) {
6791 const referenceDeps = propsList.map((key) => key?.reference);
6792 const floatingDeps = propsList.map((key) => key?.floating);
6793 const itemDeps = propsList.map((key) => key?.item);
6794 const triggerDeps = propsList.map((key) => key?.trigger);
6795 const getReferenceProps = React29.useCallback(
6796 (userProps) => mergeProps2(userProps, propsList, "reference"),
6797 // eslint-disable-next-line react-hooks/exhaustive-deps
6798 referenceDeps
6799 );
6800 const getFloatingProps = React29.useCallback(
6801 (userProps) => mergeProps2(userProps, propsList, "floating"),
6802 // eslint-disable-next-line react-hooks/exhaustive-deps
6803 floatingDeps
6804 );
6805 const getItemProps = React29.useCallback(
6806 (userProps) => mergeProps2(userProps, propsList, "item"),
6807 // eslint-disable-next-line react-hooks/exhaustive-deps
6808 itemDeps
6809 );
6810 const getTriggerProps = React29.useCallback(
6811 (userProps) => mergeProps2(userProps, propsList, "trigger"),
6812 // eslint-disable-next-line react-hooks/exhaustive-deps
6813 triggerDeps
6814 );
6815 return React29.useMemo(() => ({
6816 getReferenceProps,
6817 getFloatingProps,
6818 getItemProps,
6819 getTriggerProps
6820 }), [getReferenceProps, getFloatingProps, getItemProps, getTriggerProps]);
6821 }
6822 function mergeProps2(userProps, propsList, elementKey) {
6823 const eventHandlers = /* @__PURE__ */ new Map();
6824 const isItem2 = elementKey === "item";
6825 const outputProps = {};
6826 if (elementKey === "floating") {
6827 outputProps.tabIndex = -1;
6828 outputProps[FOCUSABLE_ATTRIBUTE] = "";
6829 }
6830 for (const key in userProps) {
6831 if (isItem2 && userProps) {
6832 if (key === ACTIVE_KEY || key === SELECTED_KEY) {
6833 continue;
6834 }
6835 }
6836 outputProps[key] = userProps[key];
6837 }
6838 for (let i2 = 0; i2 < propsList.length; i2 += 1) {
6839 let props;
6840 const propsOrGetProps = propsList[i2]?.[elementKey];
6841 if (typeof propsOrGetProps === "function") {
6842 props = userProps ? propsOrGetProps(userProps) : null;
6843 } else {
6844 props = propsOrGetProps;
6845 }
6846 if (!props) {
6847 continue;
6848 }
6849 mutablyMergeProps(outputProps, props, isItem2, eventHandlers);
6850 }
6851 mutablyMergeProps(outputProps, userProps, isItem2, eventHandlers);
6852 return outputProps;
6853 }
6854 function mutablyMergeProps(outputProps, props, isItem2, eventHandlers) {
6855 for (const key in props) {
6856 const value = props[key];
6857 if (isItem2 && (key === ACTIVE_KEY || key === SELECTED_KEY)) {
6858 continue;
6859 }
6860 if (!key.startsWith("on")) {
6861 outputProps[key] = value;
6862 } else {
6863 if (!eventHandlers.has(key)) {
6864 eventHandlers.set(key, []);
6865 }
6866 if (typeof value === "function") {
6867 eventHandlers.get(key)?.push(value);
6868 outputProps[key] = (...args) => {
6869 return eventHandlers.get(key)?.map((fn) => fn(...args)).find((val) => val !== void 0);
6870 };
6871 }
6872 }
6873 }
6874 }
6875
6876 // node_modules/@base-ui/react/esm/floating-ui-react/safePolygon.js
6877 var CURSOR_SPEED_THRESHOLD = 0.1;
6878 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
6879 var POLYGON_BUFFER = 0.5;
6880 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
6881 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
6882 }
6883 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
6884 let isInsideValue = false;
6885 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
6886 isInsideValue = !isInsideValue;
6887 }
6888 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
6889 isInsideValue = !isInsideValue;
6890 }
6891 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
6892 isInsideValue = !isInsideValue;
6893 }
6894 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
6895 isInsideValue = !isInsideValue;
6896 }
6897 return isInsideValue;
6898 }
6899 function isInsideRect(pointX, pointY, rect) {
6900 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
6901 }
6902 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
6903 const minX = Math.min(x1, x2);
6904 const maxX = Math.max(x1, x2);
6905 const minY = Math.min(y1, y2);
6906 const maxY = Math.max(y1, y2);
6907 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
6908 }
6909 function safePolygon(options = {}) {
6910 const {
6911 blockPointerEvents = false
6912 } = options;
6913 const timeout = new Timeout();
6914 const fn = ({
6915 x: x2,
6916 y: y2,
6917 placement,
6918 elements,
6919 onClose,
6920 nodeId,
6921 tree
6922 }) => {
6923 const side = placement?.split("-")[0];
6924 let hasLanded = false;
6925 let lastX = null;
6926 let lastY = null;
6927 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
6928 function isCursorMovingSlowly(nextX, nextY) {
6929 const currentTime = performance.now();
6930 const elapsedTime = currentTime - lastCursorTime;
6931 if (lastX === null || lastY === null || elapsedTime === 0) {
6932 lastX = nextX;
6933 lastY = nextY;
6934 lastCursorTime = currentTime;
6935 return false;
6936 }
6937 const deltaX = nextX - lastX;
6938 const deltaY = nextY - lastY;
6939 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
6940 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
6941 lastX = nextX;
6942 lastY = nextY;
6943 lastCursorTime = currentTime;
6944 return distanceSquared < thresholdSquared;
6945 }
6946 function close() {
6947 timeout.clear();
6948 onClose();
6949 }
6950 return function onMouseMove(event) {
6951 timeout.clear();
6952 const domReference = elements.domReference;
6953 const floating = elements.floating;
6954 if (!domReference || !floating || side == null || x2 == null || y2 == null) {
6955 return void 0;
6956 }
6957 const {
6958 clientX,
6959 clientY
6960 } = event;
6961 const target = getTarget(event);
6962 const isLeave = event.type === "mouseleave";
6963 const isOverFloatingEl = contains(floating, target);
6964 const isOverReferenceEl = contains(domReference, target);
6965 if (isOverFloatingEl) {
6966 hasLanded = true;
6967 if (!isLeave) {
6968 return void 0;
6969 }
6970 }
6971 if (isOverReferenceEl) {
6972 hasLanded = false;
6973 if (!isLeave) {
6974 hasLanded = true;
6975 return void 0;
6976 }
6977 }
6978 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
6979 return void 0;
6980 }
6981 function hasOpenChildNode() {
6982 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
6983 }
6984 function closeIfNoOpenChild() {
6985 if (!hasOpenChildNode()) {
6986 close();
6987 }
6988 }
6989 if (hasOpenChildNode()) {
6990 return void 0;
6991 }
6992 const refRect = domReference.getBoundingClientRect();
6993 const rect = floating.getBoundingClientRect();
6994 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2;
6995 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2;
6996 const isFloatingWider = rect.width > refRect.width;
6997 const isFloatingTaller = rect.height > refRect.height;
6998 const left = (isFloatingWider ? refRect : rect).left;
6999 const right = (isFloatingWider ? refRect : rect).right;
7000 const top = (isFloatingTaller ? refRect : rect).top;
7001 const bottom = (isFloatingTaller ? refRect : rect).bottom;
7002 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) {
7003 closeIfNoOpenChild();
7004 return void 0;
7005 }
7006 let isInsideTroughRect = false;
7007 switch (side) {
7008 case "top":
7009 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
7010 break;
7011 case "bottom":
7012 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
7013 break;
7014 case "left":
7015 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
7016 break;
7017 case "right":
7018 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
7019 break;
7020 default:
7021 }
7022 if (isInsideTroughRect) {
7023 return void 0;
7024 }
7025 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
7026 closeIfNoOpenChild();
7027 return void 0;
7028 }
7029 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
7030 closeIfNoOpenChild();
7031 return void 0;
7032 }
7033 let isInsidePolygon = false;
7034 switch (side) {
7035 case "top": {
7036 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7037 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7038 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7039 const cursorPointY = y2 + POLYGON_BUFFER + 1;
7040 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
7041 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
7042 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7043 break;
7044 }
7045 case "bottom": {
7046 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7047 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7048 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7049 const cursorPointY = y2 - POLYGON_BUFFER;
7050 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
7051 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
7052 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7053 break;
7054 }
7055 case "left": {
7056 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7057 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7058 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7059 const cursorPointX = x2 + POLYGON_BUFFER + 1;
7060 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
7061 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
7062 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
7063 break;
7064 }
7065 case "right": {
7066 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7067 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7068 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7069 const cursorPointX = x2 - POLYGON_BUFFER;
7070 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
7071 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
7072 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
7073 break;
7074 }
7075 default:
7076 }
7077 if (!isInsidePolygon) {
7078 closeIfNoOpenChild();
7079 } else if (!hasLanded) {
7080 timeout.start(40, closeIfNoOpenChild);
7081 }
7082 return void 0;
7083 };
7084 };
7085 fn.__options = {
7086 ...options,
7087 blockPointerEvents
7088 };
7089 return fn;
7090 }
7091
7092 // node_modules/@base-ui/react/esm/utils/popupStateMapping.js
7093 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
7094 CommonPopupDataAttributes2["open"] = "data-open";
7095 CommonPopupDataAttributes2["closed"] = "data-closed";
7096 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
7097 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
7098 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
7099 CommonPopupDataAttributes2["side"] = "data-side";
7100 CommonPopupDataAttributes2["align"] = "data-align";
7101 return CommonPopupDataAttributes2;
7102 })({});
7103 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
7104 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
7105 CommonTriggerDataAttributes2["pressed"] = "data-pressed";
7106 return CommonTriggerDataAttributes2;
7107 })({});
7108 var TRIGGER_HOOK = {
7109 [CommonTriggerDataAttributes.popupOpen]: ""
7110 };
7111 var PRESSABLE_TRIGGER_HOOK = {
7112 [CommonTriggerDataAttributes.popupOpen]: "",
7113 [CommonTriggerDataAttributes.pressed]: ""
7114 };
7115 var POPUP_OPEN_HOOK = {
7116 [CommonPopupDataAttributes.open]: ""
7117 };
7118 var POPUP_CLOSED_HOOK = {
7119 [CommonPopupDataAttributes.closed]: ""
7120 };
7121 var ANCHOR_HIDDEN_HOOK = {
7122 [CommonPopupDataAttributes.anchorHidden]: ""
7123 };
7124 var triggerOpenStateMapping = {
7125 open(value) {
7126 if (value) {
7127 return TRIGGER_HOOK;
7128 }
7129 return null;
7130 }
7131 };
7132 var popupStateMapping = {
7133 open(value) {
7134 if (value) {
7135 return POPUP_OPEN_HOOK;
7136 }
7137 return POPUP_CLOSED_HOOK;
7138 },
7139 anchorHidden(value) {
7140 if (value) {
7141 return ANCHOR_HIDDEN_HOOK;
7142 }
7143 return null;
7144 }
7145 };
7146
7147 // node_modules/@base-ui/utils/esm/inertValue.js
7148 function inertValue(value) {
7149 if (isReactVersionAtLeast(19)) {
7150 return value;
7151 }
7152 return value ? "true" : void 0;
7153 }
7154
7155 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
7156 var React30 = __toESM(require_react(), 1);
7157
7158 // node_modules/@base-ui/react/esm/floating-ui-react/middleware/arrow.js
7159 var baseArrow = (options) => ({
7160 name: "arrow",
7161 options,
7162 async fn(state) {
7163 const {
7164 x: x2,
7165 y: y2,
7166 placement,
7167 rects,
7168 platform: platform3,
7169 elements,
7170 middlewareData
7171 } = state;
7172 const {
7173 element,
7174 padding = 0,
7175 offsetParent = "real"
7176 } = evaluate(options, state) || {};
7177 if (element == null) {
7178 return {};
7179 }
7180 const paddingObject = getPaddingObject(padding);
7181 const coords = {
7182 x: x2,
7183 y: y2
7184 };
7185 const axis = getAlignmentAxis(placement);
7186 const length = getAxisLength(axis);
7187 const arrowDimensions = await platform3.getDimensions(element);
7188 const isYAxis = axis === "y";
7189 const minProp = isYAxis ? "top" : "left";
7190 const maxProp = isYAxis ? "bottom" : "right";
7191 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
7192 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
7193 const startDiff = coords[axis] - rects.reference[axis];
7194 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
7195 let clientSize = elements.floating[clientProp] || rects.floating[length];
7196 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
7197 clientSize = elements.floating[clientProp] || rects.floating[length];
7198 }
7199 const centerToReference = endDiff / 2 - startDiff / 2;
7200 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
7201 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
7202 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
7203 const min2 = minPadding;
7204 const max2 = clientSize - arrowDimensions[length] - maxPadding;
7205 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
7206 const offset4 = clamp(min2, center, max2);
7207 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
7208 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
7209 return {
7210 [axis]: coords[axis] + alignmentOffset,
7211 data: {
7212 [axis]: offset4,
7213 centerOffset: center - offset4 - alignmentOffset,
7214 ...shouldAddOffset && {
7215 alignmentOffset
7216 }
7217 },
7218 reset: shouldAddOffset
7219 };
7220 }
7221 });
7222 var arrow4 = (options, deps) => ({
7223 ...baseArrow(options),
7224 options: [options, deps]
7225 });
7226
7227 // node_modules/@base-ui/react/esm/utils/hideMiddleware.js
7228 var hide4 = {
7229 name: "hide",
7230 async fn(state) {
7231 const {
7232 width,
7233 height,
7234 x: x2,
7235 y: y2
7236 } = state.rects.reference;
7237 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0;
7238 const nativeHideResult = await hide3().fn(state);
7239 return {
7240 data: {
7241 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
7242 }
7243 };
7244 }
7245 };
7246
7247 // node_modules/@base-ui/react/esm/utils/adaptiveOriginMiddleware.js
7248 var DEFAULT_SIDES = {
7249 sideX: "left",
7250 sideY: "top"
7251 };
7252 var adaptiveOrigin = {
7253 name: "adaptiveOrigin",
7254 async fn(state) {
7255 const {
7256 x: rawX,
7257 y: rawY,
7258 rects: {
7259 floating: floatRect
7260 },
7261 elements: {
7262 floating
7263 },
7264 platform: platform3,
7265 strategy,
7266 placement
7267 } = state;
7268 const win = getWindow(floating);
7269 const styles = win.getComputedStyle(floating);
7270 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
7271 if (!hasTransition) {
7272 return {
7273 x: rawX,
7274 y: rawY,
7275 data: DEFAULT_SIDES
7276 };
7277 }
7278 const offsetParent = await platform3.getOffsetParent?.(floating);
7279 let offsetDimensions = {
7280 width: 0,
7281 height: 0
7282 };
7283 if (strategy === "fixed" && win?.visualViewport) {
7284 offsetDimensions = {
7285 width: win.visualViewport.width,
7286 height: win.visualViewport.height
7287 };
7288 } else if (offsetParent === win) {
7289 const doc = ownerDocument(floating);
7290 offsetDimensions = {
7291 width: doc.documentElement.clientWidth,
7292 height: doc.documentElement.clientHeight
7293 };
7294 } else if (await platform3.isElement?.(offsetParent)) {
7295 offsetDimensions = await platform3.getDimensions(offsetParent);
7296 }
7297 const currentSide = getSide(placement);
7298 let x2 = rawX;
7299 let y2 = rawY;
7300 if (currentSide === "left") {
7301 x2 = offsetDimensions.width - (rawX + floatRect.width);
7302 }
7303 if (currentSide === "top") {
7304 y2 = offsetDimensions.height - (rawY + floatRect.height);
7305 }
7306 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
7307 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
7308 return {
7309 x: x2,
7310 y: y2,
7311 data: {
7312 sideX,
7313 sideY
7314 }
7315 };
7316 }
7317 };
7318
7319 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
7320 function getLogicalSide(sideParam, renderedSide, isRtl) {
7321 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
7322 const logicalRight = isRtl ? "inline-start" : "inline-end";
7323 const logicalLeft = isRtl ? "inline-end" : "inline-start";
7324 return {
7325 top: "top",
7326 right: isLogicalSideParam ? logicalRight : "right",
7327 bottom: "bottom",
7328 left: isLogicalSideParam ? logicalLeft : "left"
7329 }[renderedSide];
7330 }
7331 function getOffsetData(state, sideParam, isRtl) {
7332 const {
7333 rects,
7334 placement
7335 } = state;
7336 const data = {
7337 side: getLogicalSide(sideParam, getSide(placement), isRtl),
7338 align: getAlignment(placement) || "center",
7339 anchor: {
7340 width: rects.reference.width,
7341 height: rects.reference.height
7342 },
7343 positioner: {
7344 width: rects.floating.width,
7345 height: rects.floating.height
7346 }
7347 };
7348 return data;
7349 }
7350 function useAnchorPositioning(params) {
7351 const {
7352 // Public parameters
7353 anchor,
7354 positionMethod = "absolute",
7355 side: sideParam = "bottom",
7356 sideOffset = 0,
7357 align = "center",
7358 alignOffset = 0,
7359 collisionBoundary,
7360 collisionPadding: collisionPaddingParam = 5,
7361 sticky = false,
7362 arrowPadding = 5,
7363 disableAnchorTracking = false,
7364 // Private parameters
7365 keepMounted = false,
7366 floatingRootContext,
7367 mounted,
7368 collisionAvoidance,
7369 shiftCrossAxis = false,
7370 nodeId,
7371 adaptiveOrigin: adaptiveOrigin2,
7372 lazyFlip = false,
7373 externalTree
7374 } = params;
7375 const [mountSide, setMountSide] = React30.useState(null);
7376 if (!mounted && mountSide !== null) {
7377 setMountSide(null);
7378 }
7379 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
7380 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
7381 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
7382 const anchorFn = typeof anchor === "function" ? anchor : void 0;
7383 const anchorFnCallback = useStableCallback(anchorFn);
7384 const anchorDep = anchorFn ? anchorFnCallback : anchor;
7385 const anchorValueRef = useValueAsRef(anchor);
7386 const mountedRef = useValueAsRef(mounted);
7387 const direction = useDirection();
7388 const isRtl = direction === "rtl";
7389 const side = mountSide || {
7390 top: "top",
7391 right: "right",
7392 bottom: "bottom",
7393 left: "left",
7394 "inline-end": isRtl ? "left" : "right",
7395 "inline-start": isRtl ? "right" : "left"
7396 }[sideParam];
7397 const placement = align === "center" ? side : `${side}-${align}`;
7398 let collisionPadding = collisionPaddingParam;
7399 const bias = 1;
7400 const biasTop = sideParam === "bottom" ? bias : 0;
7401 const biasBottom = sideParam === "top" ? bias : 0;
7402 const biasLeft = sideParam === "right" ? bias : 0;
7403 const biasRight = sideParam === "left" ? bias : 0;
7404 if (typeof collisionPadding === "number") {
7405 collisionPadding = {
7406 top: collisionPadding + biasTop,
7407 right: collisionPadding + biasRight,
7408 bottom: collisionPadding + biasBottom,
7409 left: collisionPadding + biasLeft
7410 };
7411 } else if (collisionPadding) {
7412 collisionPadding = {
7413 top: (collisionPadding.top || 0) + biasTop,
7414 right: (collisionPadding.right || 0) + biasRight,
7415 bottom: (collisionPadding.bottom || 0) + biasBottom,
7416 left: (collisionPadding.left || 0) + biasLeft
7417 };
7418 }
7419 const commonCollisionProps = {
7420 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
7421 padding: collisionPadding
7422 };
7423 const arrowRef = React30.useRef(null);
7424 const sideOffsetRef = useValueAsRef(sideOffset);
7425 const alignOffsetRef = useValueAsRef(alignOffset);
7426 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
7427 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
7428 const middleware = [offset3((state) => {
7429 const data = getOffsetData(state, sideParam, isRtl);
7430 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
7431 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
7432 return {
7433 mainAxis: sideAxis,
7434 crossAxis: alignAxis,
7435 alignmentAxis: alignAxis
7436 };
7437 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam])];
7438 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
7439 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
7440 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
7441 ...commonCollisionProps,
7442 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
7443 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
7444 padding: {
7445 top: collisionPadding.top + bias,
7446 right: collisionPadding.right + bias,
7447 bottom: collisionPadding.bottom + bias,
7448 left: collisionPadding.left + bias
7449 },
7450 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
7451 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
7452 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
7453 });
7454 const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
7455 const html = ownerDocument(data.elements.floating).documentElement;
7456 return {
7457 ...commonCollisionProps,
7458 // Use the Layout Viewport to avoid shifting around when pinch-zooming
7459 // for context menus.
7460 rootBoundary: shiftCrossAxis ? {
7461 x: 0,
7462 y: 0,
7463 width: html.clientWidth,
7464 height: html.clientHeight
7465 } : void 0,
7466 mainAxis: collisionAvoidanceAlign !== "none",
7467 crossAxis: crossAxisShiftEnabled,
7468 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
7469 if (!arrowRef.current) {
7470 return {};
7471 }
7472 const {
7473 width,
7474 height
7475 } = arrowRef.current.getBoundingClientRect();
7476 const sideAxis = getSideAxis(getSide(limitData.placement));
7477 const arrowSize = sideAxis === "y" ? width : height;
7478 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
7479 return {
7480 offset: arrowSize / 2 + offsetAmount / 2
7481 };
7482 })
7483 };
7484 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
7485 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
7486 middleware.push(shiftMiddleware, flipMiddleware);
7487 } else {
7488 middleware.push(flipMiddleware, shiftMiddleware);
7489 }
7490 middleware.push(size3({
7491 ...commonCollisionProps,
7492 apply({
7493 elements: {
7494 floating
7495 },
7496 availableWidth,
7497 availableHeight,
7498 rects
7499 }) {
7500 if (!mountedRef.current) {
7501 return;
7502 }
7503 const floatingStyle = floating.style;
7504 floatingStyle.setProperty("--available-width", `${availableWidth}px`);
7505 floatingStyle.setProperty("--available-height", `${availableHeight}px`);
7506 const dpr = getWindow(floating).devicePixelRatio || 1;
7507 const {
7508 x: x3,
7509 y: y3,
7510 width,
7511 height
7512 } = rects.reference;
7513 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr;
7514 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr;
7515 floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
7516 floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
7517 }
7518 }), arrow4(() => ({
7519 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
7520 // we'll create a fake element.
7521 element: arrowRef.current || ownerDocument(arrowRef.current).createElement("div"),
7522 padding: arrowPadding,
7523 offsetParent: "floating"
7524 }), [arrowPadding]), {
7525 name: "transformOrigin",
7526 fn(state) {
7527 const {
7528 elements: elements2,
7529 middlewareData: middlewareData2,
7530 placement: renderedPlacement2,
7531 rects,
7532 y: y3
7533 } = state;
7534 const currentRenderedSide = getSide(renderedPlacement2);
7535 const currentRenderedAxis = getSideAxis(currentRenderedSide);
7536 const arrowEl = arrowRef.current;
7537 const arrowX = middlewareData2.arrow?.x || 0;
7538 const arrowY = middlewareData2.arrow?.y || 0;
7539 const arrowWidth = arrowEl?.clientWidth || 0;
7540 const arrowHeight = arrowEl?.clientHeight || 0;
7541 const transformX = arrowX + arrowWidth / 2;
7542 const transformY = arrowY + arrowHeight / 2;
7543 const shiftY = Math.abs(middlewareData2.shift?.y || 0);
7544 const halfAnchorHeight = rects.reference.height / 2;
7545 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
7546 const isOverlappingAnchor = shiftY > sideOffsetValue;
7547 const adjacentTransformOrigin = {
7548 top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
7549 bottom: `${transformX}px ${-sideOffsetValue}px`,
7550 left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
7551 right: `${-sideOffsetValue}px ${transformY}px`
7552 }[currentRenderedSide];
7553 const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y3}px`;
7554 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
7555 return {};
7556 }
7557 }, hide4, adaptiveOrigin2);
7558 useIsoLayoutEffect(() => {
7559 if (!mounted && floatingRootContext) {
7560 floatingRootContext.update({
7561 referenceElement: null,
7562 floatingElement: null,
7563 domReferenceElement: null,
7564 positionReference: null
7565 });
7566 }
7567 }, [mounted, floatingRootContext]);
7568 const autoUpdateOptions = React30.useMemo(() => ({
7569 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
7570 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
7571 }), [disableAnchorTracking]);
7572 const {
7573 refs,
7574 elements,
7575 x: x2,
7576 y: y2,
7577 middlewareData,
7578 update: update2,
7579 placement: renderedPlacement,
7580 context,
7581 isPositioned,
7582 floatingStyles: originalFloatingStyles
7583 } = useFloating2({
7584 rootContext: floatingRootContext,
7585 open: keepMounted ? mounted : void 0,
7586 placement,
7587 middleware,
7588 strategy: positionMethod,
7589 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
7590 nodeId,
7591 externalTree
7592 });
7593 const {
7594 sideX,
7595 sideY
7596 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
7597 const resolvedPosition = isPositioned ? positionMethod : "fixed";
7598 const floatingStyles = React30.useMemo(() => {
7599 const base = adaptiveOrigin2 ? {
7600 position: resolvedPosition,
7601 [sideX]: x2,
7602 [sideY]: y2
7603 } : {
7604 position: resolvedPosition,
7605 ...originalFloatingStyles
7606 };
7607 if (!isPositioned) {
7608 base.opacity = 0;
7609 }
7610 return base;
7611 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]);
7612 const registeredPositionReferenceRef = React30.useRef(null);
7613 useIsoLayoutEffect(() => {
7614 if (!mounted) {
7615 return;
7616 }
7617 const anchorValue = anchorValueRef.current;
7618 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
7619 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
7620 const finalAnchor = unwrappedElement || null;
7621 if (finalAnchor !== registeredPositionReferenceRef.current) {
7622 refs.setPositionReference(finalAnchor);
7623 registeredPositionReferenceRef.current = finalAnchor;
7624 }
7625 }, [mounted, refs, anchorDep, anchorValueRef]);
7626 React30.useEffect(() => {
7627 if (!mounted) {
7628 return;
7629 }
7630 const anchorValue = anchorValueRef.current;
7631 if (typeof anchorValue === "function") {
7632 return;
7633 }
7634 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
7635 refs.setPositionReference(anchorValue.current);
7636 registeredPositionReferenceRef.current = anchorValue.current;
7637 }
7638 }, [mounted, refs, anchorDep, anchorValueRef]);
7639 React30.useEffect(() => {
7640 if (keepMounted && mounted && elements.domReference && elements.floating) {
7641 return autoUpdate(elements.domReference, elements.floating, update2, autoUpdateOptions);
7642 }
7643 return void 0;
7644 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
7645 const renderedSide = getSide(renderedPlacement);
7646 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
7647 const renderedAlign = getAlignment(renderedPlacement) || "center";
7648 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
7649 useIsoLayoutEffect(() => {
7650 if (lazyFlip && mounted && isPositioned) {
7651 setMountSide(renderedSide);
7652 }
7653 }, [lazyFlip, mounted, isPositioned, renderedSide]);
7654 const arrowStyles = React30.useMemo(() => ({
7655 position: "absolute",
7656 top: middlewareData.arrow?.y,
7657 left: middlewareData.arrow?.x
7658 }), [middlewareData.arrow]);
7659 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
7660 return React30.useMemo(() => ({
7661 positionerStyles: floatingStyles,
7662 arrowStyles,
7663 arrowRef,
7664 arrowUncentered,
7665 side: logicalRenderedSide,
7666 align: renderedAlign,
7667 physicalSide: renderedSide,
7668 anchorHidden,
7669 refs,
7670 context,
7671 isPositioned,
7672 update: update2
7673 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
7674 }
7675 function isRef(param) {
7676 return param != null && "current" in param;
7677 }
7678
7679 // node_modules/@base-ui/react/esm/utils/getDisabledMountTransitionStyles.js
7680 function getDisabledMountTransitionStyles(transitionStatus) {
7681 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
7682 }
7683
7684 // node_modules/@base-ui/react/esm/utils/usePositioner.js
7685 function usePositioner(componentProps, state, {
7686 styles,
7687 transitionStatus,
7688 props,
7689 refs,
7690 hidden,
7691 inert = false
7692 }) {
7693 const style = {
7694 ...styles
7695 };
7696 if (inert) {
7697 style.pointerEvents = "none";
7698 }
7699 return useRenderElement("div", componentProps, {
7700 state,
7701 ref: refs,
7702 props: [{
7703 role: "presentation",
7704 hidden,
7705 style
7706 }, getDisabledMountTransitionStyles(transitionStatus), props],
7707 stateAttributesMapping: popupStateMapping
7708 });
7709 }
7710
7711 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
7712 var React33 = __toESM(require_react(), 1);
7713 var ReactDOM5 = __toESM(require_react_dom(), 1);
7714
7715 // node_modules/@base-ui/utils/esm/usePreviousValue.js
7716 var React31 = __toESM(require_react(), 1);
7717 function usePreviousValue(value) {
7718 const [state, setState] = React31.useState({
7719 current: value,
7720 previous: null
7721 });
7722 if (value !== state.current) {
7723 setState({
7724 current: value,
7725 previous: state.current
7726 });
7727 }
7728 return state.previous;
7729 }
7730
7731 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7732 var React32 = __toESM(require_react(), 1);
7733
7734 // node_modules/@base-ui/react/esm/utils/getCssDimensions.js
7735 function getCssDimensions2(element) {
7736 const css = getComputedStyle2(element);
7737 let width = parseFloat(css.width) || 0;
7738 let height = parseFloat(css.height) || 0;
7739 const hasOffset = isHTMLElement(element);
7740 const offsetWidth = hasOffset ? element.offsetWidth : width;
7741 const offsetHeight = hasOffset ? element.offsetHeight : height;
7742 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
7743 if (shouldFallback) {
7744 width = offsetWidth;
7745 height = offsetHeight;
7746 }
7747 return {
7748 width,
7749 height
7750 };
7751 }
7752
7753 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7754 var DEFAULT_ENABLED = () => true;
7755 function usePopupAutoResize(parameters) {
7756 const {
7757 popupElement,
7758 positionerElement,
7759 content,
7760 mounted,
7761 enabled = DEFAULT_ENABLED,
7762 onMeasureLayout: onMeasureLayoutParam,
7763 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
7764 side,
7765 direction
7766 } = parameters;
7767 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
7768 const animationFrame = useAnimationFrame();
7769 const committedDimensionsRef = React32.useRef(null);
7770 const liveDimensionsRef = React32.useRef(null);
7771 const isInitialRenderRef = React32.useRef(true);
7772 const restoreAnchoringStylesRef = React32.useRef(NOOP);
7773 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
7774 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
7775 const anchoringStyles = React32.useMemo(() => {
7776 let isOriginSide = side === "top";
7777 let isPhysicalLeft = side === "left";
7778 if (direction === "rtl") {
7779 isOriginSide = isOriginSide || side === "inline-end";
7780 isPhysicalLeft = isPhysicalLeft || side === "inline-end";
7781 } else {
7782 isOriginSide = isOriginSide || side === "inline-start";
7783 isPhysicalLeft = isPhysicalLeft || side === "inline-start";
7784 }
7785 return isOriginSide ? {
7786 position: "absolute",
7787 [side === "top" ? "bottom" : "top"]: "0",
7788 [isPhysicalLeft ? "right" : "left"]: "0"
7789 } : EMPTY_OBJECT;
7790 }, [side, direction]);
7791 useIsoLayoutEffect(() => {
7792 if (!mounted || !enabled() || typeof ResizeObserver !== "function") {
7793 restoreAnchoringStylesRef.current = NOOP;
7794 isInitialRenderRef.current = true;
7795 committedDimensionsRef.current = null;
7796 liveDimensionsRef.current = null;
7797 return void 0;
7798 }
7799 if (!popupElement || !positionerElement) {
7800 return void 0;
7801 }
7802 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
7803 const observer = new ResizeObserver((entries) => {
7804 const entry = entries[0];
7805 if (entry) {
7806 liveDimensionsRef.current = {
7807 width: Math.ceil(entry.borderBoxSize[0].inlineSize),
7808 height: Math.ceil(entry.borderBoxSize[0].blockSize)
7809 };
7810 }
7811 });
7812 observer.observe(popupElement);
7813 setPopupCssSize(popupElement, "auto");
7814 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
7815 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
7816 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
7817 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
7818 "--available-width": "max-content",
7819 "--available-height": "max-content"
7820 });
7821 function restoreMeasurementOverrides() {
7822 restorePopupPosition();
7823 restorePopupTransform();
7824 restorePositionerAvailableSize();
7825 }
7826 function restoreMeasurementOverridesIncludingScale() {
7827 restoreMeasurementOverrides();
7828 restorePopupScale();
7829 }
7830 onMeasureLayout?.();
7831 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
7832 setPositionerCssSize(positionerElement, "max-content");
7833 const dimensions = getCssDimensions2(popupElement);
7834 committedDimensionsRef.current = dimensions;
7835 setPositionerCssSize(positionerElement, dimensions);
7836 restoreMeasurementOverridesIncludingScale();
7837 onMeasureLayoutComplete?.(null, dimensions);
7838 isInitialRenderRef.current = false;
7839 return () => {
7840 observer.disconnect();
7841 restoreAnchoringStylesRef.current();
7842 restoreAnchoringStylesRef.current = NOOP;
7843 };
7844 }
7845 setPopupCssSize(popupElement, "auto");
7846 setPositionerCssSize(positionerElement, "max-content");
7847 const previousDimensions = committedDimensionsRef.current ?? liveDimensionsRef.current;
7848 const newDimensions = getCssDimensions2(popupElement);
7849 committedDimensionsRef.current = newDimensions;
7850 if (!previousDimensions) {
7851 setPositionerCssSize(positionerElement, newDimensions);
7852 restoreMeasurementOverridesIncludingScale();
7853 onMeasureLayoutComplete?.(null, newDimensions);
7854 return () => {
7855 observer.disconnect();
7856 animationFrame.cancel();
7857 restoreAnchoringStylesRef.current();
7858 restoreAnchoringStylesRef.current = NOOP;
7859 };
7860 }
7861 setPopupCssSize(popupElement, previousDimensions);
7862 restoreMeasurementOverridesIncludingScale();
7863 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
7864 setPositionerCssSize(positionerElement, newDimensions);
7865 const abortController = new AbortController();
7866 animationFrame.request(() => {
7867 setPopupCssSize(popupElement, newDimensions);
7868 runOnceAnimationsFinish(() => {
7869 popupElement.style.setProperty("--popup-width", "auto");
7870 popupElement.style.setProperty("--popup-height", "auto");
7871 }, abortController.signal);
7872 });
7873 return () => {
7874 observer.disconnect();
7875 abortController.abort();
7876 animationFrame.cancel();
7877 restoreAnchoringStylesRef.current();
7878 restoreAnchoringStylesRef.current = NOOP;
7879 };
7880 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, enabled, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
7881 }
7882 function overrideElementStyle(element, property, value) {
7883 const originalValue = element.style.getPropertyValue(property);
7884 element.style.setProperty(property, value);
7885 return () => {
7886 element.style.setProperty(property, originalValue);
7887 };
7888 }
7889 function applyElementStyles(element, styles) {
7890 const restorers = [];
7891 for (const [key, value] of Object.entries(styles)) {
7892 restorers.push(overrideElementStyle(element, key, value));
7893 }
7894 return restorers.length ? () => {
7895 restorers.forEach((restore) => restore());
7896 } : NOOP;
7897 }
7898 function setPopupCssSize(popupElement, size4) {
7899 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
7900 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
7901 popupElement.style.setProperty("--popup-width", width);
7902 popupElement.style.setProperty("--popup-height", height);
7903 }
7904 function setPositionerCssSize(positionerElement, size4) {
7905 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
7906 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
7907 positionerElement.style.setProperty("--positioner-width", width);
7908 positionerElement.style.setProperty("--positioner-height", height);
7909 }
7910
7911 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
7912 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
7913 function usePopupViewport(parameters) {
7914 const {
7915 store,
7916 side,
7917 cssVars,
7918 children
7919 } = parameters;
7920 const direction = useDirection();
7921 const activeTrigger = store.useState("activeTriggerElement");
7922 const activeTriggerId = store.useState("activeTriggerId");
7923 const open = store.useState("open");
7924 const payload = store.useState("payload");
7925 const mounted = store.useState("mounted");
7926 const popupElement = store.useState("popupElement");
7927 const positionerElement = store.useState("positionerElement");
7928 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
7929 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
7930 const capturedNodeRef = React33.useRef(null);
7931 const [previousContentNode, setPreviousContentNode] = React33.useState(null);
7932 const [newTriggerOffset, setNewTriggerOffset] = React33.useState(null);
7933 const currentContainerRef = React33.useRef(null);
7934 const previousContainerRef = React33.useRef(null);
7935 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
7936 const cleanupFrame = useAnimationFrame();
7937 const [previousContentDimensions, setPreviousContentDimensions] = React33.useState(null);
7938 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React33.useState(false);
7939 useIsoLayoutEffect(() => {
7940 store.set("hasViewport", true);
7941 return () => {
7942 store.set("hasViewport", false);
7943 };
7944 }, [store]);
7945 const handleMeasureLayout = useStableCallback(() => {
7946 currentContainerRef.current?.style.setProperty("animation", "none");
7947 currentContainerRef.current?.style.setProperty("transition", "none");
7948 previousContainerRef.current?.style.setProperty("display", "none");
7949 });
7950 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
7951 currentContainerRef.current?.style.removeProperty("animation");
7952 currentContainerRef.current?.style.removeProperty("transition");
7953 previousContainerRef.current?.style.removeProperty("display");
7954 if (previousDimensions) {
7955 setPreviousContentDimensions(previousDimensions);
7956 }
7957 });
7958 const lastHandledTriggerRef = React33.useRef(null);
7959 useIsoLayoutEffect(() => {
7960 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
7961 setPreviousContentNode(capturedNodeRef.current);
7962 setShowStartingStyleAttribute(true);
7963 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
7964 setNewTriggerOffset(offset4);
7965 cleanupFrame.request(() => {
7966 ReactDOM5.flushSync(() => {
7967 setShowStartingStyleAttribute(false);
7968 });
7969 onAnimationsFinished(() => {
7970 setPreviousContentNode(null);
7971 setPreviousContentDimensions(null);
7972 capturedNodeRef.current = null;
7973 });
7974 });
7975 lastHandledTriggerRef.current = activeTrigger;
7976 }
7977 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
7978 useIsoLayoutEffect(() => {
7979 const source = currentContainerRef.current;
7980 if (!source) {
7981 return;
7982 }
7983 const wrapper = ownerDocument(source).createElement("div");
7984 for (const child of Array.from(source.childNodes)) {
7985 wrapper.appendChild(child.cloneNode(true));
7986 }
7987 capturedNodeRef.current = wrapper;
7988 });
7989 const isTransitioning = previousContentNode != null;
7990 let childrenToRender;
7991 if (!isTransitioning) {
7992 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", {
7993 "data-current": true,
7994 ref: currentContainerRef,
7995 children
7996 }, currentContentKey);
7997 } else {
7998 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(React33.Fragment, {
7999 children: [/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", {
8000 "data-previous": true,
8001 inert: inertValue(true),
8002 ref: previousContainerRef,
8003 style: {
8004 ...previousContentDimensions ? {
8005 [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
8006 [cssVars.popupHeight]: `${previousContentDimensions.height}px`
8007 } : null,
8008 position: "absolute"
8009 },
8010 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
8011 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", {
8012 "data-current": true,
8013 ref: currentContainerRef,
8014 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
8015 children
8016 }, currentContentKey)]
8017 });
8018 }
8019 useIsoLayoutEffect(() => {
8020 const container = previousContainerRef.current;
8021 if (!container || !previousContentNode) {
8022 return;
8023 }
8024 container.replaceChildren(...Array.from(previousContentNode.childNodes));
8025 }, [previousContentNode]);
8026 usePopupAutoResize({
8027 popupElement,
8028 positionerElement,
8029 mounted,
8030 content: payload,
8031 onMeasureLayout: handleMeasureLayout,
8032 onMeasureLayoutComplete: handleMeasureLayoutComplete,
8033 side,
8034 direction
8035 });
8036 const state = {
8037 activationDirection: getActivationDirection(newTriggerOffset),
8038 transitioning: isTransitioning
8039 };
8040 return {
8041 children: childrenToRender,
8042 state
8043 };
8044 }
8045 function getActivationDirection(offset4) {
8046 if (!offset4) {
8047 return void 0;
8048 }
8049 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
8050 }
8051 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
8052 if (value > tolerance) {
8053 return positiveLabel;
8054 }
8055 if (value < -tolerance) {
8056 return negativeLabel;
8057 }
8058 return "";
8059 }
8060 function calculateRelativePosition(from, to) {
8061 const fromRect = from.getBoundingClientRect();
8062 const toRect = to.getBoundingClientRect();
8063 const fromCenter = {
8064 x: fromRect.left + fromRect.width / 2,
8065 y: fromRect.top + fromRect.height / 2
8066 };
8067 const toCenter = {
8068 x: toRect.left + toRect.width / 2,
8069 y: toRect.top + toRect.height / 2
8070 };
8071 return {
8072 horizontal: toCenter.x - fromCenter.x,
8073 vertical: toCenter.y - fromCenter.y
8074 };
8075 }
8076 function usePopupContentKey(activeTriggerId, payload) {
8077 const [contentKey, setContentKey] = React33.useState(0);
8078 const previousActiveTriggerIdRef = React33.useRef(activeTriggerId);
8079 const previousPayloadRef = React33.useRef(payload);
8080 const pendingPayloadUpdateRef = React33.useRef(false);
8081 useIsoLayoutEffect(() => {
8082 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
8083 const previousPayload = previousPayloadRef.current;
8084 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
8085 const payloadChanged = payload !== previousPayload;
8086 if (triggerIdChanged) {
8087 setContentKey((value) => value + 1);
8088 pendingPayloadUpdateRef.current = !payloadChanged;
8089 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
8090 setContentKey((value) => value + 1);
8091 pendingPayloadUpdateRef.current = false;
8092 }
8093 previousActiveTriggerIdRef.current = activeTriggerId;
8094 previousPayloadRef.current = payload;
8095 }, [activeTriggerId, payload]);
8096 return `${activeTriggerId ?? "current"}-${contentKey}`;
8097 }
8098
8099 // node_modules/@base-ui/react/esm/utils/FloatingPortalLite.js
8100 var React34 = __toESM(require_react(), 1);
8101 var ReactDOM6 = __toESM(require_react_dom(), 1);
8102 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
8103 var FloatingPortalLite = /* @__PURE__ */ React34.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
8104 const {
8105 children,
8106 container,
8107 className,
8108 render: render4,
8109 style,
8110 ...elementProps
8111 } = componentProps;
8112 const {
8113 portalNode,
8114 portalSubtree
8115 } = useFloatingPortalNode({
8116 container,
8117 ref: forwardedRef,
8118 componentProps,
8119 elementProps
8120 });
8121 if (!portalSubtree && !portalNode) {
8122 return null;
8123 }
8124 return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(React34.Fragment, {
8125 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM6.createPortal(children, portalNode)]
8126 });
8127 });
8128 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
8129
8130 // node_modules/@base-ui/react/esm/tooltip/index.parts.js
8131 var index_parts_exports = {};
8132 __export(index_parts_exports, {
8133 Arrow: () => TooltipArrow,
8134 Handle: () => TooltipHandle,
8135 Popup: () => TooltipPopup,
8136 Portal: () => TooltipPortal,
8137 Positioner: () => TooltipPositioner,
8138 Provider: () => TooltipProvider,
8139 Root: () => TooltipRoot,
8140 Trigger: () => TooltipTrigger,
8141 Viewport: () => TooltipViewport,
8142 createHandle: () => createTooltipHandle
8143 });
8144
8145 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
8146 var React37 = __toESM(require_react(), 1);
8147
8148 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRootContext.js
8149 var React35 = __toESM(require_react(), 1);
8150 var TooltipRootContext = /* @__PURE__ */ React35.createContext(void 0);
8151 if (true) TooltipRootContext.displayName = "TooltipRootContext";
8152 function useTooltipRootContext(optional) {
8153 const context = React35.useContext(TooltipRootContext);
8154 if (context === void 0 && !optional) {
8155 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
8156 }
8157 return context;
8158 }
8159
8160 // node_modules/@base-ui/react/esm/tooltip/store/TooltipStore.js
8161 var React36 = __toESM(require_react(), 1);
8162 var ReactDOM7 = __toESM(require_react_dom(), 1);
8163 var selectors2 = {
8164 ...popupStoreSelectors,
8165 disabled: createSelector((state) => state.disabled),
8166 instantType: createSelector((state) => state.instantType),
8167 isInstantPhase: createSelector((state) => state.isInstantPhase),
8168 trackCursorAxis: createSelector((state) => state.trackCursorAxis),
8169 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
8170 lastOpenChangeReason: createSelector((state) => state.openChangeReason),
8171 closeOnClick: createSelector((state) => state.closeOnClick),
8172 closeDelay: createSelector((state) => state.closeDelay),
8173 hasViewport: createSelector((state) => state.hasViewport)
8174 };
8175 var TooltipStore = class _TooltipStore extends ReactStore {
8176 constructor(initialState) {
8177 super({
8178 ...createInitialState(),
8179 ...initialState
8180 }, {
8181 popupRef: /* @__PURE__ */ React36.createRef(),
8182 onOpenChange: void 0,
8183 onOpenChangeComplete: void 0,
8184 triggerElements: new PopupTriggerMap()
8185 }, selectors2);
8186 }
8187 setOpen = (nextOpen, eventDetails) => {
8188 const reason = eventDetails.reason;
8189 const isHover = reason === reason_parts_exports.triggerHover;
8190 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
8191 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
8192 eventDetails.preventUnmountOnClose = () => {
8193 this.set("preventUnmountingOnClose", true);
8194 };
8195 this.context.onOpenChange?.(nextOpen, eventDetails);
8196 if (eventDetails.isCanceled) {
8197 return;
8198 }
8199 this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
8200 const changeState = () => {
8201 const updatedState = {
8202 open: nextOpen,
8203 openChangeReason: reason
8204 };
8205 if (isFocusOpen) {
8206 updatedState.instantType = "focus";
8207 } else if (isDismissClose) {
8208 updatedState.instantType = "dismiss";
8209 } else if (reason === reason_parts_exports.triggerHover) {
8210 updatedState.instantType = void 0;
8211 }
8212 const newTriggerId = eventDetails.trigger?.id ?? null;
8213 if (newTriggerId || nextOpen) {
8214 updatedState.activeTriggerId = newTriggerId;
8215 updatedState.activeTriggerElement = eventDetails.trigger ?? null;
8216 }
8217 this.update(updatedState);
8218 };
8219 if (isHover) {
8220 ReactDOM7.flushSync(changeState);
8221 } else {
8222 changeState();
8223 }
8224 };
8225 static useStore(externalStore, initialState) {
8226 const internalStore = useRefWithInit(() => {
8227 return new _TooltipStore(initialState);
8228 }).current;
8229 const store = externalStore ?? internalStore;
8230 const floatingRootContext = useSyncedFloatingRootContext({
8231 popupStore: store,
8232 onOpenChange: store.setOpen
8233 });
8234 store.state.floatingRootContext = floatingRootContext;
8235 return store;
8236 }
8237 };
8238 function createInitialState() {
8239 return {
8240 ...createInitialPopupStoreState(),
8241 disabled: false,
8242 instantType: void 0,
8243 isInstantPhase: false,
8244 trackCursorAxis: "none",
8245 disableHoverablePopup: false,
8246 openChangeReason: null,
8247 closeOnClick: true,
8248 closeDelay: 0,
8249 hasViewport: false
8250 };
8251 }
8252
8253 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
8254 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
8255 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
8256 const {
8257 disabled: disabled2 = false,
8258 defaultOpen = false,
8259 open: openProp,
8260 disableHoverablePopup = false,
8261 trackCursorAxis = "none",
8262 actionsRef,
8263 onOpenChange,
8264 onOpenChangeComplete,
8265 handle,
8266 triggerId: triggerIdProp,
8267 defaultTriggerId: defaultTriggerIdProp = null,
8268 children
8269 } = props;
8270 const store = TooltipStore.useStore(handle?.store, {
8271 open: defaultOpen,
8272 openProp,
8273 activeTriggerId: defaultTriggerIdProp,
8274 triggerIdProp
8275 });
8276 useOnFirstRender(() => {
8277 if (openProp === void 0 && store.state.open === false && defaultOpen === true) {
8278 store.update({
8279 open: true,
8280 activeTriggerId: defaultTriggerIdProp
8281 });
8282 }
8283 });
8284 store.useControlledProp("openProp", openProp);
8285 store.useControlledProp("triggerIdProp", triggerIdProp);
8286 store.useContextCallback("onOpenChange", onOpenChange);
8287 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
8288 const openState = store.useState("open");
8289 const open = !disabled2 && openState;
8290 const activeTriggerId = store.useState("activeTriggerId");
8291 const payload = store.useState("payload");
8292 store.useSyncedValues({
8293 trackCursorAxis,
8294 disableHoverablePopup
8295 });
8296 useIsoLayoutEffect(() => {
8297 if (openState && disabled2) {
8298 store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
8299 }
8300 }, [openState, disabled2, store]);
8301 store.useSyncedValue("disabled", disabled2);
8302 useImplicitActiveTrigger(store);
8303 const {
8304 forceUnmount,
8305 transitionStatus
8306 } = useOpenStateTransitions(open, store);
8307 const floatingRootContext = store.select("floatingRootContext");
8308 const isInstantPhase = store.useState("isInstantPhase");
8309 const instantType = store.useState("instantType");
8310 const lastOpenChangeReason = store.useState("lastOpenChangeReason");
8311 const previousInstantTypeRef = React37.useRef(null);
8312 useIsoLayoutEffect(() => {
8313 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
8314 if (instantType !== "delay") {
8315 previousInstantTypeRef.current = instantType;
8316 }
8317 store.set("instantType", "delay");
8318 } else if (previousInstantTypeRef.current !== null) {
8319 store.set("instantType", previousInstantTypeRef.current);
8320 previousInstantTypeRef.current = null;
8321 }
8322 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]);
8323 useIsoLayoutEffect(() => {
8324 if (open) {
8325 if (activeTriggerId == null) {
8326 store.set("payload", void 0);
8327 }
8328 }
8329 }, [store, activeTriggerId, open]);
8330 const handleImperativeClose = React37.useCallback(() => {
8331 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
8332 }, [store]);
8333 React37.useImperativeHandle(actionsRef, () => ({
8334 unmount: forceUnmount,
8335 close: handleImperativeClose
8336 }), [forceUnmount, handleImperativeClose]);
8337 const dismiss = useDismiss(floatingRootContext, {
8338 enabled: !disabled2,
8339 referencePress: () => store.select("closeOnClick")
8340 });
8341 const clientPoint = useClientPoint(floatingRootContext, {
8342 enabled: !disabled2 && trackCursorAxis !== "none",
8343 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
8344 });
8345 const {
8346 getReferenceProps,
8347 getFloatingProps,
8348 getTriggerProps
8349 } = useInteractions([dismiss, clientPoint]);
8350 const activeTriggerProps = React37.useMemo(() => getReferenceProps(), [getReferenceProps]);
8351 const inactiveTriggerProps = React37.useMemo(() => getTriggerProps(), [getTriggerProps]);
8352 const popupProps = React37.useMemo(() => getFloatingProps(), [getFloatingProps]);
8353 store.useSyncedValues({
8354 activeTriggerProps,
8355 inactiveTriggerProps,
8356 popupProps
8357 });
8358 return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(TooltipRootContext.Provider, {
8359 value: store,
8360 children: typeof children === "function" ? children({
8361 payload
8362 }) : children
8363 });
8364 });
8365 if (true) TooltipRoot.displayName = "TooltipRoot";
8366
8367 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
8368 var React39 = __toESM(require_react(), 1);
8369
8370 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProviderContext.js
8371 var React38 = __toESM(require_react(), 1);
8372 var TooltipProviderContext = /* @__PURE__ */ React38.createContext(void 0);
8373 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
8374 function useTooltipProviderContext() {
8375 return React38.useContext(TooltipProviderContext);
8376 }
8377
8378 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTriggerDataAttributes.js
8379 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
8380 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
8381 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
8382 return TooltipTriggerDataAttributes2;
8383 })({});
8384
8385 // node_modules/@base-ui/react/esm/tooltip/utils/constants.js
8386 var OPEN_DELAY = 600;
8387
8388 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
8389 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
8390 const {
8391 className,
8392 render: render4,
8393 handle,
8394 payload,
8395 disabled: disabledProp,
8396 delay,
8397 closeOnClick = true,
8398 closeDelay,
8399 id: idProp,
8400 style,
8401 ...elementProps
8402 } = componentProps;
8403 const rootContext = useTooltipRootContext(true);
8404 const store = handle?.store ?? rootContext;
8405 if (!store) {
8406 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));
8407 }
8408 const thisTriggerId = useBaseUiId(idProp);
8409 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
8410 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
8411 const floatingRootContext = store.useState("floatingRootContext");
8412 const triggerElementRef = React39.useRef(null);
8413 const delayWithDefault = delay ?? OPEN_DELAY;
8414 const closeDelayWithDefault = closeDelay ?? 0;
8415 const {
8416 registerTrigger,
8417 isMountedByThisTrigger
8418 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
8419 payload,
8420 closeOnClick,
8421 closeDelay: closeDelayWithDefault
8422 });
8423 const providerContext = useTooltipProviderContext();
8424 const {
8425 delayRef,
8426 isInstantPhase,
8427 hasProvider
8428 } = useDelayGroup(floatingRootContext, {
8429 open: isOpenedByThisTrigger
8430 });
8431 store.useSyncedValue("isInstantPhase", isInstantPhase);
8432 const rootDisabled = store.useState("disabled");
8433 const disabled2 = disabledProp ?? rootDisabled;
8434 const trackCursorAxis = store.useState("trackCursorAxis");
8435 const disableHoverablePopup = store.useState("disableHoverablePopup");
8436 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
8437 enabled: !disabled2,
8438 mouseOnly: true,
8439 move: false,
8440 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
8441 restMs() {
8442 const providerDelay = providerContext?.delay;
8443 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
8444 let computedRestMs = delayWithDefault;
8445 if (hasProvider) {
8446 if (groupOpenValue !== 0) {
8447 computedRestMs = delay ?? providerDelay ?? delayWithDefault;
8448 } else {
8449 computedRestMs = 0;
8450 }
8451 }
8452 return computedRestMs;
8453 },
8454 delay() {
8455 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
8456 let computedCloseDelay = closeDelayWithDefault;
8457 if (closeDelay == null && hasProvider) {
8458 computedCloseDelay = closeValue;
8459 }
8460 return {
8461 close: computedCloseDelay
8462 };
8463 },
8464 triggerElementRef,
8465 isActiveTrigger: isTriggerActive,
8466 isClosing: () => store.select("transitionStatus") === "ending"
8467 });
8468 const focusProps = useFocus(floatingRootContext, {
8469 enabled: !disabled2
8470 }).reference;
8471 const state = {
8472 open: isOpenedByThisTrigger
8473 };
8474 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
8475 const element = useRenderElement("button", componentProps, {
8476 state,
8477 ref: [forwardedRef, registerTrigger, triggerElementRef],
8478 props: [hoverProps, focusProps, rootTriggerProps, {
8479 onPointerDown() {
8480 store.set("closeOnClick", closeOnClick);
8481 },
8482 id: thisTriggerId,
8483 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0
8484 }, elementProps],
8485 stateAttributesMapping: triggerOpenStateMapping
8486 });
8487 return element;
8488 });
8489 if (true) TooltipTrigger.displayName = "TooltipTrigger";
8490
8491 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
8492 var React41 = __toESM(require_react(), 1);
8493
8494 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortalContext.js
8495 var React40 = __toESM(require_react(), 1);
8496 var TooltipPortalContext = /* @__PURE__ */ React40.createContext(void 0);
8497 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
8498 function useTooltipPortalContext() {
8499 const value = React40.useContext(TooltipPortalContext);
8500 if (value === void 0) {
8501 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
8502 }
8503 return value;
8504 }
8505
8506 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
8507 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
8508 var TooltipPortal = /* @__PURE__ */ React41.forwardRef(function TooltipPortal2(props, forwardedRef) {
8509 const {
8510 keepMounted = false,
8511 ...portalProps
8512 } = props;
8513 const store = useTooltipRootContext();
8514 const mounted = store.useState("mounted");
8515 const shouldRender = mounted || keepMounted;
8516 if (!shouldRender) {
8517 return null;
8518 }
8519 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(TooltipPortalContext.Provider, {
8520 value: keepMounted,
8521 children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(FloatingPortalLite, {
8522 ref: forwardedRef,
8523 ...portalProps
8524 })
8525 });
8526 });
8527 if (true) TooltipPortal.displayName = "TooltipPortal";
8528
8529 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
8530 var React43 = __toESM(require_react(), 1);
8531
8532 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositionerContext.js
8533 var React42 = __toESM(require_react(), 1);
8534 var TooltipPositionerContext = /* @__PURE__ */ React42.createContext(void 0);
8535 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
8536 function useTooltipPositionerContext() {
8537 const context = React42.useContext(TooltipPositionerContext);
8538 if (context === void 0) {
8539 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
8540 }
8541 return context;
8542 }
8543
8544 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
8545 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
8546 var TooltipPositioner = /* @__PURE__ */ React43.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
8547 const {
8548 render: render4,
8549 className,
8550 anchor,
8551 positionMethod = "absolute",
8552 side = "top",
8553 align = "center",
8554 sideOffset = 0,
8555 alignOffset = 0,
8556 collisionBoundary = "clipping-ancestors",
8557 collisionPadding = 5,
8558 arrowPadding = 5,
8559 sticky = false,
8560 disableAnchorTracking = false,
8561 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
8562 style,
8563 ...elementProps
8564 } = componentProps;
8565 const store = useTooltipRootContext();
8566 const keepMounted = useTooltipPortalContext();
8567 const open = store.useState("open");
8568 const mounted = store.useState("mounted");
8569 const trackCursorAxis = store.useState("trackCursorAxis");
8570 const disableHoverablePopup = store.useState("disableHoverablePopup");
8571 const floatingRootContext = store.useState("floatingRootContext");
8572 const instantType = store.useState("instantType");
8573 const transitionStatus = store.useState("transitionStatus");
8574 const hasViewport = store.useState("hasViewport");
8575 const positioning = useAnchorPositioning({
8576 anchor,
8577 positionMethod,
8578 floatingRootContext,
8579 mounted,
8580 side,
8581 sideOffset,
8582 align,
8583 alignOffset,
8584 collisionBoundary,
8585 collisionPadding,
8586 sticky,
8587 arrowPadding,
8588 disableAnchorTracking,
8589 keepMounted,
8590 collisionAvoidance,
8591 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
8592 });
8593 const state = React43.useMemo(() => ({
8594 open,
8595 side: positioning.side,
8596 align: positioning.align,
8597 anchorHidden: positioning.anchorHidden,
8598 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
8599 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
8600 const element = usePositioner(componentProps, state, {
8601 styles: positioning.positionerStyles,
8602 transitionStatus,
8603 props: elementProps,
8604 refs: [forwardedRef, store.useStateSetter("positionerElement")],
8605 hidden: !mounted,
8606 inert: !open || trackCursorAxis === "both" || disableHoverablePopup
8607 });
8608 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(TooltipPositionerContext.Provider, {
8609 value: positioning,
8610 children: element
8611 });
8612 });
8613 if (true) TooltipPositioner.displayName = "TooltipPositioner";
8614
8615 // node_modules/@base-ui/react/esm/tooltip/popup/TooltipPopup.js
8616 var React44 = __toESM(require_react(), 1);
8617 var stateAttributesMapping = {
8618 ...popupStateMapping,
8619 ...transitionStatusMapping
8620 };
8621 var TooltipPopup = /* @__PURE__ */ React44.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
8622 const {
8623 className,
8624 render: render4,
8625 style,
8626 ...elementProps
8627 } = componentProps;
8628 const store = useTooltipRootContext();
8629 const {
8630 side,
8631 align
8632 } = useTooltipPositionerContext();
8633 const open = store.useState("open");
8634 const instantType = store.useState("instantType");
8635 const transitionStatus = store.useState("transitionStatus");
8636 const popupProps = store.useState("popupProps");
8637 const floatingContext = store.useState("floatingRootContext");
8638 useOpenChangeComplete({
8639 open,
8640 ref: store.context.popupRef,
8641 onComplete() {
8642 if (open) {
8643 store.context.onOpenChangeComplete?.(true);
8644 }
8645 }
8646 });
8647 const disabled2 = store.useState("disabled");
8648 const closeDelay = store.useState("closeDelay");
8649 useHoverFloatingInteraction(floatingContext, {
8650 enabled: !disabled2,
8651 closeDelay
8652 });
8653 const state = {
8654 open,
8655 side,
8656 align,
8657 instant: instantType,
8658 transitionStatus
8659 };
8660 const element = useRenderElement("div", componentProps, {
8661 state,
8662 ref: [forwardedRef, store.context.popupRef, store.useStateSetter("popupElement")],
8663 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
8664 stateAttributesMapping
8665 });
8666 return element;
8667 });
8668 if (true) TooltipPopup.displayName = "TooltipPopup";
8669
8670 // node_modules/@base-ui/react/esm/tooltip/arrow/TooltipArrow.js
8671 var React45 = __toESM(require_react(), 1);
8672 var TooltipArrow = /* @__PURE__ */ React45.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
8673 const {
8674 className,
8675 render: render4,
8676 style,
8677 ...elementProps
8678 } = componentProps;
8679 const store = useTooltipRootContext();
8680 const open = store.useState("open");
8681 const instantType = store.useState("instantType");
8682 const {
8683 arrowRef,
8684 side,
8685 align,
8686 arrowUncentered,
8687 arrowStyles
8688 } = useTooltipPositionerContext();
8689 const state = {
8690 open,
8691 side,
8692 align,
8693 uncentered: arrowUncentered,
8694 instant: instantType
8695 };
8696 const element = useRenderElement("div", componentProps, {
8697 state,
8698 ref: [forwardedRef, arrowRef],
8699 props: [{
8700 style: arrowStyles,
8701 "aria-hidden": true
8702 }, elementProps],
8703 stateAttributesMapping: popupStateMapping
8704 });
8705 return element;
8706 });
8707 if (true) TooltipArrow.displayName = "TooltipArrow";
8708
8709 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProvider.js
8710 var React46 = __toESM(require_react(), 1);
8711 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
8712 var TooltipProvider = function TooltipProvider2(props) {
8713 const {
8714 delay,
8715 closeDelay,
8716 timeout = 400
8717 } = props;
8718 const contextValue = React46.useMemo(() => ({
8719 delay,
8720 closeDelay
8721 }), [delay, closeDelay]);
8722 const delayValue = React46.useMemo(() => ({
8723 open: delay,
8724 close: closeDelay
8725 }), [delay, closeDelay]);
8726 return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(TooltipProviderContext.Provider, {
8727 value: contextValue,
8728 children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(FloatingDelayGroup, {
8729 delay: delayValue,
8730 timeoutMs: timeout,
8731 children: props.children
8732 })
8733 });
8734 };
8735 if (true) TooltipProvider.displayName = "TooltipProvider";
8736
8737 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
8738 var React47 = __toESM(require_react(), 1);
8739
8740 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewportCssVars.js
8741 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
8742 TooltipViewportCssVars2["popupWidth"] = "--popup-width";
8743 TooltipViewportCssVars2["popupHeight"] = "--popup-height";
8744 return TooltipViewportCssVars2;
8745 })({});
8746
8747 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
8748 var stateAttributesMapping2 = {
8749 activationDirection: (value) => value ? {
8750 "data-activation-direction": value
8751 } : null
8752 };
8753 var TooltipViewport = /* @__PURE__ */ React47.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
8754 const {
8755 render: render4,
8756 className,
8757 style,
8758 children,
8759 ...elementProps
8760 } = componentProps;
8761 const store = useTooltipRootContext();
8762 const positioner = useTooltipPositionerContext();
8763 const instantType = store.useState("instantType");
8764 const {
8765 children: childrenToRender,
8766 state: viewportState
8767 } = usePopupViewport({
8768 store,
8769 side: positioner.side,
8770 cssVars: TooltipViewportCssVars,
8771 children
8772 });
8773 const state = {
8774 activationDirection: viewportState.activationDirection,
8775 transitioning: viewportState.transitioning,
8776 instant: instantType
8777 };
8778 return useRenderElement("div", componentProps, {
8779 state,
8780 ref: forwardedRef,
8781 props: [elementProps, {
8782 children: childrenToRender
8783 }],
8784 stateAttributesMapping: stateAttributesMapping2
8785 });
8786 });
8787 if (true) TooltipViewport.displayName = "TooltipViewport";
8788
8789 // node_modules/@base-ui/react/esm/tooltip/store/TooltipHandle.js
8790 var TooltipHandle = class {
8791 /**
8792 * Internal store holding the tooltip state.
8793 * @internal
8794 */
8795 constructor() {
8796 this.store = new TooltipStore();
8797 }
8798 /**
8799 * Opens the tooltip and associates it with the trigger with the given ID.
8800 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
8801 *
8802 * This method should only be called in an event handler or an effect (not during rendering).
8803 *
8804 * @param triggerId ID of the trigger to associate with the tooltip.
8805 */
8806 open(triggerId) {
8807 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
8808 if (triggerId && !triggerElement) {
8809 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
8810 }
8811 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
8812 }
8813 /**
8814 * Closes the tooltip.
8815 */
8816 close() {
8817 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
8818 }
8819 /**
8820 * Indicates whether the tooltip is currently open.
8821 */
8822 get isOpen() {
8823 return this.store.state.open;
8824 }
8825 };
8826 function createTooltipHandle() {
8827 return new TooltipHandle();
8828 }
8829
8830 // node_modules/@base-ui/react/esm/use-render/useRender.js
8831 function useRender(params) {
8832 return useRenderElement(params.defaultTagName ?? "div", params, params);
8833 }
8834
8835 // packages/ui/build-module/text/text.mjs
8836 var import_element9 = __toESM(require_element(), 1);
8837 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
8838 function getRuntime() {
8839 const globalScope = globalThis;
8840 if (globalScope.__wpStyleRuntime) {
8841 return globalScope.__wpStyleRuntime;
8842 }
8843 globalScope.__wpStyleRuntime = {
8844 documents: /* @__PURE__ */ new Map(),
8845 styles: /* @__PURE__ */ new Map(),
8846 injectedStyles: /* @__PURE__ */ new WeakMap()
8847 };
8848 if (typeof document !== "undefined") {
8849 registerDocument(document);
8850 }
8851 return globalScope.__wpStyleRuntime;
8852 }
8853 function documentContainsStyleHash(targetDocument, hash) {
8854 if (!targetDocument.head) {
8855 return false;
8856 }
8857 for (const style of targetDocument.head.querySelectorAll(
8858 `style[${STYLE_HASH_ATTRIBUTE}]`
8859 )) {
8860 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
8861 return true;
8862 }
8863 }
8864 return false;
8865 }
8866 function injectStyle(targetDocument, hash, css) {
8867 if (!targetDocument.head) {
8868 return;
8869 }
8870 const runtime = getRuntime();
8871 let injectedStyles = runtime.injectedStyles.get(targetDocument);
8872 if (!injectedStyles) {
8873 injectedStyles = /* @__PURE__ */ new Set();
8874 runtime.injectedStyles.set(targetDocument, injectedStyles);
8875 }
8876 if (injectedStyles.has(hash)) {
8877 return;
8878 }
8879 if (documentContainsStyleHash(targetDocument, hash)) {
8880 injectedStyles.add(hash);
8881 return;
8882 }
8883 const style = targetDocument.createElement("style");
8884 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
8885 style.appendChild(targetDocument.createTextNode(css));
8886 targetDocument.head.appendChild(style);
8887 injectedStyles.add(hash);
8888 }
8889 function registerDocument(targetDocument) {
8890 const runtime = getRuntime();
8891 runtime.documents.set(
8892 targetDocument,
8893 (runtime.documents.get(targetDocument) ?? 0) + 1
8894 );
8895 for (const [hash, css] of runtime.styles) {
8896 injectStyle(targetDocument, hash, css);
8897 }
8898 return () => {
8899 const count = runtime.documents.get(targetDocument);
8900 if (count === void 0) {
8901 return;
8902 }
8903 if (count <= 1) {
8904 runtime.documents.delete(targetDocument);
8905 return;
8906 }
8907 runtime.documents.set(targetDocument, count - 1);
8908 };
8909 }
8910 function registerStyle(hash, css) {
8911 const runtime = getRuntime();
8912 runtime.styles.set(hash, css);
8913 for (const targetDocument of runtime.documents.keys()) {
8914 injectStyle(targetDocument, hash, css);
8915 }
8916 }
8917 if (typeof process === "undefined" || true) {
8918 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)}}');
8919 }
8920 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" };
8921 if (typeof process === "undefined" || true) {
8922 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)}");
8923 }
8924 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" };
8925 var Text = (0, import_element9.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
8926 const element = useRender({
8927 render: render4,
8928 defaultTagName: "span",
8929 ref,
8930 props: mergeProps(props, {
8931 className: clsx_default(
8932 style_default.text,
8933 global_css_defense_default.heading,
8934 global_css_defense_default.p,
8935 style_default[variant],
8936 className
8937 )
8938 })
8939 });
8940 return element;
8941 });
8942
8943 // packages/ui/build-module/icon/icon.mjs
8944 var import_element10 = __toESM(require_element(), 1);
8945 var import_primitives26 = __toESM(require_primitives(), 1);
8946 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
8947 var Icon = (0, import_element10.forwardRef)(function Icon2({ icon, size: size4 = 24, ...restProps }, ref) {
8948 return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
8949 import_primitives26.SVG,
8950 {
8951 ref,
8952 fill: "currentColor",
8953 ...icon.props,
8954 ...restProps,
8955 width: size4,
8956 height: size4
8957 }
8958 );
8959 });
8960
8961 // packages/ui/build-module/utils/render-slot-with-children.mjs
8962 var import_element11 = __toESM(require_element(), 1);
8963 function renderSlotWithChildren(slot, defaultSlot, children) {
8964 return (0, import_element11.cloneElement)(slot ?? defaultSlot, { children });
8965 }
8966
8967 // packages/ui/build-module/lock-unlock.mjs
8968 var import_private_apis = __toESM(require_private_apis(), 1);
8969 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
8970 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
8971 "@wordpress/ui"
8972 );
8973
8974 // packages/ui/build-module/stack/stack.mjs
8975 var import_element12 = __toESM(require_element(), 1);
8976 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
8977 function getRuntime2() {
8978 const globalScope = globalThis;
8979 if (globalScope.__wpStyleRuntime) {
8980 return globalScope.__wpStyleRuntime;
8981 }
8982 globalScope.__wpStyleRuntime = {
8983 documents: /* @__PURE__ */ new Map(),
8984 styles: /* @__PURE__ */ new Map(),
8985 injectedStyles: /* @__PURE__ */ new WeakMap()
8986 };
8987 if (typeof document !== "undefined") {
8988 registerDocument2(document);
8989 }
8990 return globalScope.__wpStyleRuntime;
8991 }
8992 function documentContainsStyleHash2(targetDocument, hash) {
8993 if (!targetDocument.head) {
8994 return false;
8995 }
8996 for (const style of targetDocument.head.querySelectorAll(
8997 `style[${STYLE_HASH_ATTRIBUTE2}]`
8998 )) {
8999 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
9000 return true;
9001 }
9002 }
9003 return false;
9004 }
9005 function injectStyle2(targetDocument, hash, css) {
9006 if (!targetDocument.head) {
9007 return;
9008 }
9009 const runtime = getRuntime2();
9010 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9011 if (!injectedStyles) {
9012 injectedStyles = /* @__PURE__ */ new Set();
9013 runtime.injectedStyles.set(targetDocument, injectedStyles);
9014 }
9015 if (injectedStyles.has(hash)) {
9016 return;
9017 }
9018 if (documentContainsStyleHash2(targetDocument, hash)) {
9019 injectedStyles.add(hash);
9020 return;
9021 }
9022 const style = targetDocument.createElement("style");
9023 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
9024 style.appendChild(targetDocument.createTextNode(css));
9025 targetDocument.head.appendChild(style);
9026 injectedStyles.add(hash);
9027 }
9028 function registerDocument2(targetDocument) {
9029 const runtime = getRuntime2();
9030 runtime.documents.set(
9031 targetDocument,
9032 (runtime.documents.get(targetDocument) ?? 0) + 1
9033 );
9034 for (const [hash, css] of runtime.styles) {
9035 injectStyle2(targetDocument, hash, css);
9036 }
9037 return () => {
9038 const count = runtime.documents.get(targetDocument);
9039 if (count === void 0) {
9040 return;
9041 }
9042 if (count <= 1) {
9043 runtime.documents.delete(targetDocument);
9044 return;
9045 }
9046 runtime.documents.set(targetDocument, count - 1);
9047 };
9048 }
9049 function registerStyle2(hash, css) {
9050 const runtime = getRuntime2();
9051 runtime.styles.set(hash, css);
9052 for (const targetDocument of runtime.documents.keys()) {
9053 injectStyle2(targetDocument, hash, css);
9054 }
9055 }
9056 if (typeof process === "undefined" || true) {
9057 registerStyle2("b51ff41489", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._19ce0419607e1896__stack{display:flex}}");
9058 }
9059 var style_default2 = { "stack": "_19ce0419607e1896__stack" };
9060 var gapTokens = {
9061 xs: "var(--wpds-dimension-gap-xs, 4px)",
9062 sm: "var(--wpds-dimension-gap-sm, 8px)",
9063 md: "var(--wpds-dimension-gap-md, 12px)",
9064 lg: "var(--wpds-dimension-gap-lg, 16px)",
9065 xl: "var(--wpds-dimension-gap-xl, 24px)",
9066 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
9067 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
9068 };
9069 var Stack = (0, import_element12.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
9070 const style = {
9071 gap: gap && gapTokens[gap],
9072 alignItems: align,
9073 justifyContent: justify,
9074 flexDirection: direction,
9075 flexWrap: wrap
9076 };
9077 const element = useRender({
9078 render: render4,
9079 ref,
9080 props: mergeProps(props, { style, className: style_default2.stack })
9081 });
9082 return element;
9083 });
9084
9085 // packages/ui/build-module/tooltip/index.mjs
9086 var tooltip_exports = {};
9087 __export(tooltip_exports, {
9088 Popup: () => Popup,
9089 Portal: () => Portal,
9090 Positioner: () => Positioner,
9091 Provider: () => Provider,
9092 Root: () => Root,
9093 Trigger: () => Trigger
9094 });
9095
9096 // packages/ui/build-module/tooltip/popup.mjs
9097 var import_element15 = __toESM(require_element(), 1);
9098 var import_theme = __toESM(require_theme(), 1);
9099
9100 // packages/ui/build-module/tooltip/portal.mjs
9101 var import_element13 = __toESM(require_element(), 1);
9102
9103 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
9104 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
9105 function getRuntime3() {
9106 const globalScope = globalThis;
9107 if (globalScope.__wpStyleRuntime) {
9108 return globalScope.__wpStyleRuntime;
9109 }
9110 globalScope.__wpStyleRuntime = {
9111 documents: /* @__PURE__ */ new Map(),
9112 styles: /* @__PURE__ */ new Map(),
9113 injectedStyles: /* @__PURE__ */ new WeakMap()
9114 };
9115 if (typeof document !== "undefined") {
9116 registerDocument3(document);
9117 }
9118 return globalScope.__wpStyleRuntime;
9119 }
9120 function documentContainsStyleHash3(targetDocument, hash) {
9121 if (!targetDocument.head) {
9122 return false;
9123 }
9124 for (const style of targetDocument.head.querySelectorAll(
9125 `style[${STYLE_HASH_ATTRIBUTE3}]`
9126 )) {
9127 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
9128 return true;
9129 }
9130 }
9131 return false;
9132 }
9133 function injectStyle3(targetDocument, hash, css) {
9134 if (!targetDocument.head) {
9135 return;
9136 }
9137 const runtime = getRuntime3();
9138 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9139 if (!injectedStyles) {
9140 injectedStyles = /* @__PURE__ */ new Set();
9141 runtime.injectedStyles.set(targetDocument, injectedStyles);
9142 }
9143 if (injectedStyles.has(hash)) {
9144 return;
9145 }
9146 if (documentContainsStyleHash3(targetDocument, hash)) {
9147 injectedStyles.add(hash);
9148 return;
9149 }
9150 const style = targetDocument.createElement("style");
9151 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
9152 style.appendChild(targetDocument.createTextNode(css));
9153 targetDocument.head.appendChild(style);
9154 injectedStyles.add(hash);
9155 }
9156 function registerDocument3(targetDocument) {
9157 const runtime = getRuntime3();
9158 runtime.documents.set(
9159 targetDocument,
9160 (runtime.documents.get(targetDocument) ?? 0) + 1
9161 );
9162 for (const [hash, css] of runtime.styles) {
9163 injectStyle3(targetDocument, hash, css);
9164 }
9165 return () => {
9166 const count = runtime.documents.get(targetDocument);
9167 if (count === void 0) {
9168 return;
9169 }
9170 if (count <= 1) {
9171 runtime.documents.delete(targetDocument);
9172 return;
9173 }
9174 runtime.documents.set(targetDocument, count - 1);
9175 };
9176 }
9177 function registerStyle3(hash, css) {
9178 const runtime = getRuntime3();
9179 runtime.styles.set(hash, css);
9180 for (const targetDocument of runtime.documents.keys()) {
9181 injectStyle3(targetDocument, hash, css);
9182 }
9183 }
9184 if (typeof process === "undefined" || true) {
9185 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}}");
9186 }
9187 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
9188 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
9189 function resolveOwnerDocument() {
9190 return typeof document === "undefined" ? null : document;
9191 }
9192 function isInWordPressEnvironment() {
9193 let topWp;
9194 try {
9195 topWp = window.top?.wp;
9196 } catch {
9197 }
9198 const wp = topWp ?? window.wp;
9199 return typeof wp?.components === "object" && wp.components !== null;
9200 }
9201 var cachedSlot = null;
9202 function createSlot(ownerDocument2) {
9203 const element = ownerDocument2.createElement("div");
9204 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
9205 if (wp_compat_overlay_slot_default.slot) {
9206 element.classList.add(wp_compat_overlay_slot_default.slot);
9207 }
9208 ownerDocument2.body.appendChild(element);
9209 return element;
9210 }
9211 function getWpCompatOverlaySlot() {
9212 if (typeof window === "undefined") {
9213 return void 0;
9214 }
9215 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
9216 return void 0;
9217 }
9218 const ownerDocument2 = resolveOwnerDocument();
9219 if (!ownerDocument2 || !ownerDocument2.body) {
9220 return void 0;
9221 }
9222 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
9223 return cachedSlot;
9224 }
9225 const existing = ownerDocument2.querySelector(
9226 `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
9227 );
9228 if (existing instanceof HTMLDivElement) {
9229 cachedSlot = existing;
9230 return existing;
9231 }
9232 if (cachedSlot?.isConnected) {
9233 cachedSlot.remove();
9234 }
9235 cachedSlot = createSlot(ownerDocument2);
9236 return cachedSlot;
9237 }
9238
9239 // packages/ui/build-module/tooltip/portal.mjs
9240 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
9241 var Portal = (0, import_element13.forwardRef)(
9242 function TooltipPortal3({ container, ...restProps }, ref) {
9243 return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
9244 index_parts_exports.Portal,
9245 {
9246 container: container ?? getWpCompatOverlaySlot(),
9247 ...restProps,
9248 ref
9249 }
9250 );
9251 }
9252 );
9253
9254 // packages/ui/build-module/tooltip/positioner.mjs
9255 var import_element14 = __toESM(require_element(), 1);
9256 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
9257 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
9258 function getRuntime4() {
9259 const globalScope = globalThis;
9260 if (globalScope.__wpStyleRuntime) {
9261 return globalScope.__wpStyleRuntime;
9262 }
9263 globalScope.__wpStyleRuntime = {
9264 documents: /* @__PURE__ */ new Map(),
9265 styles: /* @__PURE__ */ new Map(),
9266 injectedStyles: /* @__PURE__ */ new WeakMap()
9267 };
9268 if (typeof document !== "undefined") {
9269 registerDocument4(document);
9270 }
9271 return globalScope.__wpStyleRuntime;
9272 }
9273 function documentContainsStyleHash4(targetDocument, hash) {
9274 if (!targetDocument.head) {
9275 return false;
9276 }
9277 for (const style of targetDocument.head.querySelectorAll(
9278 `style[${STYLE_HASH_ATTRIBUTE4}]`
9279 )) {
9280 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
9281 return true;
9282 }
9283 }
9284 return false;
9285 }
9286 function injectStyle4(targetDocument, hash, css) {
9287 if (!targetDocument.head) {
9288 return;
9289 }
9290 const runtime = getRuntime4();
9291 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9292 if (!injectedStyles) {
9293 injectedStyles = /* @__PURE__ */ new Set();
9294 runtime.injectedStyles.set(targetDocument, injectedStyles);
9295 }
9296 if (injectedStyles.has(hash)) {
9297 return;
9298 }
9299 if (documentContainsStyleHash4(targetDocument, hash)) {
9300 injectedStyles.add(hash);
9301 return;
9302 }
9303 const style = targetDocument.createElement("style");
9304 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
9305 style.appendChild(targetDocument.createTextNode(css));
9306 targetDocument.head.appendChild(style);
9307 injectedStyles.add(hash);
9308 }
9309 function registerDocument4(targetDocument) {
9310 const runtime = getRuntime4();
9311 runtime.documents.set(
9312 targetDocument,
9313 (runtime.documents.get(targetDocument) ?? 0) + 1
9314 );
9315 for (const [hash, css] of runtime.styles) {
9316 injectStyle4(targetDocument, hash, css);
9317 }
9318 return () => {
9319 const count = runtime.documents.get(targetDocument);
9320 if (count === void 0) {
9321 return;
9322 }
9323 if (count <= 1) {
9324 runtime.documents.delete(targetDocument);
9325 return;
9326 }
9327 runtime.documents.set(targetDocument, count - 1);
9328 };
9329 }
9330 function registerStyle4(hash, css) {
9331 const runtime = getRuntime4();
9332 runtime.styles.set(hash, css);
9333 for (const targetDocument of runtime.documents.keys()) {
9334 injectStyle4(targetDocument, hash, css);
9335 }
9336 }
9337 if (typeof process === "undefined" || true) {
9338 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}}}");
9339 }
9340 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
9341 if (typeof process === "undefined" || true) {
9342 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}}}');
9343 }
9344 var style_default3 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9345 var Positioner = (0, import_element14.forwardRef)(
9346 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
9347 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
9348 index_parts_exports.Positioner,
9349 {
9350 ref,
9351 align,
9352 side,
9353 sideOffset,
9354 ...props,
9355 className: clsx_default(
9356 resets_default["box-sizing"],
9357 style_default3.positioner,
9358 className
9359 )
9360 }
9361 );
9362 }
9363 );
9364
9365 // packages/ui/build-module/tooltip/popup.mjs
9366 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
9367 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
9368 function getRuntime5() {
9369 const globalScope = globalThis;
9370 if (globalScope.__wpStyleRuntime) {
9371 return globalScope.__wpStyleRuntime;
9372 }
9373 globalScope.__wpStyleRuntime = {
9374 documents: /* @__PURE__ */ new Map(),
9375 styles: /* @__PURE__ */ new Map(),
9376 injectedStyles: /* @__PURE__ */ new WeakMap()
9377 };
9378 if (typeof document !== "undefined") {
9379 registerDocument5(document);
9380 }
9381 return globalScope.__wpStyleRuntime;
9382 }
9383 function documentContainsStyleHash5(targetDocument, hash) {
9384 if (!targetDocument.head) {
9385 return false;
9386 }
9387 for (const style of targetDocument.head.querySelectorAll(
9388 `style[${STYLE_HASH_ATTRIBUTE5}]`
9389 )) {
9390 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
9391 return true;
9392 }
9393 }
9394 return false;
9395 }
9396 function injectStyle5(targetDocument, hash, css) {
9397 if (!targetDocument.head) {
9398 return;
9399 }
9400 const runtime = getRuntime5();
9401 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9402 if (!injectedStyles) {
9403 injectedStyles = /* @__PURE__ */ new Set();
9404 runtime.injectedStyles.set(targetDocument, injectedStyles);
9405 }
9406 if (injectedStyles.has(hash)) {
9407 return;
9408 }
9409 if (documentContainsStyleHash5(targetDocument, hash)) {
9410 injectedStyles.add(hash);
9411 return;
9412 }
9413 const style = targetDocument.createElement("style");
9414 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
9415 style.appendChild(targetDocument.createTextNode(css));
9416 targetDocument.head.appendChild(style);
9417 injectedStyles.add(hash);
9418 }
9419 function registerDocument5(targetDocument) {
9420 const runtime = getRuntime5();
9421 runtime.documents.set(
9422 targetDocument,
9423 (runtime.documents.get(targetDocument) ?? 0) + 1
9424 );
9425 for (const [hash, css] of runtime.styles) {
9426 injectStyle5(targetDocument, hash, css);
9427 }
9428 return () => {
9429 const count = runtime.documents.get(targetDocument);
9430 if (count === void 0) {
9431 return;
9432 }
9433 if (count <= 1) {
9434 runtime.documents.delete(targetDocument);
9435 return;
9436 }
9437 runtime.documents.set(targetDocument, count - 1);
9438 };
9439 }
9440 function registerStyle5(hash, css) {
9441 const runtime = getRuntime5();
9442 runtime.styles.set(hash, css);
9443 for (const targetDocument of runtime.documents.keys()) {
9444 injectStyle5(targetDocument, hash, css);
9445 }
9446 }
9447 if (typeof process === "undefined" || true) {
9448 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}}}');
9449 }
9450 var style_default4 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9451 var ThemeProvider = unlock(import_theme.privateApis).ThemeProvider;
9452 var Popup = (0, import_element15.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
9453 const popupContent = (
9454 /* This should ideally use whatever dark color makes sense,
9455 * and not be hardcoded to #1e1e1e. The solutions would be to:
9456 * - review the design of the tooltip, in case we want to stop
9457 * hardcoding it to a dark background
9458 * - create new semantic tokens as needed (aliasing either the
9459 * "inverted bg" or "perma-dark bg" private tokens) and have
9460 * Tooltip.Popup use them;
9461 * - remove the hardcoded `bg` setting from the `ThemeProvider`
9462 * below
9463 */
9464 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ThemeProvider, { color: { bg: "#1e1e1e" }, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
9465 index_parts_exports.Popup,
9466 {
9467 ref,
9468 className: clsx_default(style_default4.popup, className),
9469 ...props,
9470 children
9471 }
9472 ) })
9473 );
9474 const positionedPopup = renderSlotWithChildren(
9475 positioner,
9476 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Positioner, {}),
9477 popupContent
9478 );
9479 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Portal, {}), positionedPopup);
9480 });
9481
9482 // packages/ui/build-module/tooltip/trigger.mjs
9483 var import_element16 = __toESM(require_element(), 1);
9484 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
9485 var Trigger = (0, import_element16.forwardRef)(
9486 function TooltipTrigger3(props, ref) {
9487 return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(index_parts_exports.Trigger, { ref, ...props });
9488 }
9489 );
9490
9491 // packages/ui/build-module/tooltip/root.mjs
9492 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
9493 function Root(props) {
9494 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(index_parts_exports.Root, { ...props });
9495 }
9496
9497 // packages/ui/build-module/tooltip/provider.mjs
9498 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
9499 function Provider({ ...props }) {
9500 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(index_parts_exports.Provider, { ...props });
9501 }
9502
9503 // packages/ui/build-module/empty-state/index.mjs
9504 var empty_state_exports = {};
9505 __export(empty_state_exports, {
9506 Actions: () => Actions,
9507 Description: () => Description,
9508 Icon: () => Icon3,
9509 Root: () => Root2,
9510 Title: () => Title,
9511 Visual: () => Visual
9512 });
9513
9514 // packages/ui/build-module/empty-state/root.mjs
9515 var import_element17 = __toESM(require_element(), 1);
9516 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash";
9517 function getRuntime6() {
9518 const globalScope = globalThis;
9519 if (globalScope.__wpStyleRuntime) {
9520 return globalScope.__wpStyleRuntime;
9521 }
9522 globalScope.__wpStyleRuntime = {
9523 documents: /* @__PURE__ */ new Map(),
9524 styles: /* @__PURE__ */ new Map(),
9525 injectedStyles: /* @__PURE__ */ new WeakMap()
9526 };
9527 if (typeof document !== "undefined") {
9528 registerDocument6(document);
9529 }
9530 return globalScope.__wpStyleRuntime;
9531 }
9532 function documentContainsStyleHash6(targetDocument, hash) {
9533 if (!targetDocument.head) {
9534 return false;
9535 }
9536 for (const style of targetDocument.head.querySelectorAll(
9537 `style[${STYLE_HASH_ATTRIBUTE6}]`
9538 )) {
9539 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) {
9540 return true;
9541 }
9542 }
9543 return false;
9544 }
9545 function injectStyle6(targetDocument, hash, css) {
9546 if (!targetDocument.head) {
9547 return;
9548 }
9549 const runtime = getRuntime6();
9550 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9551 if (!injectedStyles) {
9552 injectedStyles = /* @__PURE__ */ new Set();
9553 runtime.injectedStyles.set(targetDocument, injectedStyles);
9554 }
9555 if (injectedStyles.has(hash)) {
9556 return;
9557 }
9558 if (documentContainsStyleHash6(targetDocument, hash)) {
9559 injectedStyles.add(hash);
9560 return;
9561 }
9562 const style = targetDocument.createElement("style");
9563 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash);
9564 style.appendChild(targetDocument.createTextNode(css));
9565 targetDocument.head.appendChild(style);
9566 injectedStyles.add(hash);
9567 }
9568 function registerDocument6(targetDocument) {
9569 const runtime = getRuntime6();
9570 runtime.documents.set(
9571 targetDocument,
9572 (runtime.documents.get(targetDocument) ?? 0) + 1
9573 );
9574 for (const [hash, css] of runtime.styles) {
9575 injectStyle6(targetDocument, hash, css);
9576 }
9577 return () => {
9578 const count = runtime.documents.get(targetDocument);
9579 if (count === void 0) {
9580 return;
9581 }
9582 if (count <= 1) {
9583 runtime.documents.delete(targetDocument);
9584 return;
9585 }
9586 runtime.documents.set(targetDocument, count - 1);
9587 };
9588 }
9589 function registerStyle6(hash, css) {
9590 const runtime = getRuntime6();
9591 runtime.styles.set(hash, css);
9592 for (const targetDocument of runtime.documents.keys()) {
9593 injectStyle6(targetDocument, hash, css);
9594 }
9595 }
9596 if (typeof process === "undefined" || true) {
9597 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}}}');
9598 }
9599 var style_default5 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9600 var Root2 = (0, import_element17.forwardRef)(
9601 function EmptyStateRoot({ render: render4, ...props }, ref) {
9602 const className = clsx_default(style_default5.root);
9603 const element = useRender({
9604 defaultTagName: "div",
9605 render: render4,
9606 ref,
9607 props: mergeProps({ className }, props)
9608 });
9609 return element;
9610 }
9611 );
9612
9613 // packages/ui/build-module/empty-state/visual.mjs
9614 var import_element18 = __toESM(require_element(), 1);
9615 var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash";
9616 function getRuntime7() {
9617 const globalScope = globalThis;
9618 if (globalScope.__wpStyleRuntime) {
9619 return globalScope.__wpStyleRuntime;
9620 }
9621 globalScope.__wpStyleRuntime = {
9622 documents: /* @__PURE__ */ new Map(),
9623 styles: /* @__PURE__ */ new Map(),
9624 injectedStyles: /* @__PURE__ */ new WeakMap()
9625 };
9626 if (typeof document !== "undefined") {
9627 registerDocument7(document);
9628 }
9629 return globalScope.__wpStyleRuntime;
9630 }
9631 function documentContainsStyleHash7(targetDocument, hash) {
9632 if (!targetDocument.head) {
9633 return false;
9634 }
9635 for (const style of targetDocument.head.querySelectorAll(
9636 `style[${STYLE_HASH_ATTRIBUTE7}]`
9637 )) {
9638 if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) {
9639 return true;
9640 }
9641 }
9642 return false;
9643 }
9644 function injectStyle7(targetDocument, hash, css) {
9645 if (!targetDocument.head) {
9646 return;
9647 }
9648 const runtime = getRuntime7();
9649 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9650 if (!injectedStyles) {
9651 injectedStyles = /* @__PURE__ */ new Set();
9652 runtime.injectedStyles.set(targetDocument, injectedStyles);
9653 }
9654 if (injectedStyles.has(hash)) {
9655 return;
9656 }
9657 if (documentContainsStyleHash7(targetDocument, hash)) {
9658 injectedStyles.add(hash);
9659 return;
9660 }
9661 const style = targetDocument.createElement("style");
9662 style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash);
9663 style.appendChild(targetDocument.createTextNode(css));
9664 targetDocument.head.appendChild(style);
9665 injectedStyles.add(hash);
9666 }
9667 function registerDocument7(targetDocument) {
9668 const runtime = getRuntime7();
9669 runtime.documents.set(
9670 targetDocument,
9671 (runtime.documents.get(targetDocument) ?? 0) + 1
9672 );
9673 for (const [hash, css] of runtime.styles) {
9674 injectStyle7(targetDocument, hash, css);
9675 }
9676 return () => {
9677 const count = runtime.documents.get(targetDocument);
9678 if (count === void 0) {
9679 return;
9680 }
9681 if (count <= 1) {
9682 runtime.documents.delete(targetDocument);
9683 return;
9684 }
9685 runtime.documents.set(targetDocument, count - 1);
9686 };
9687 }
9688 function registerStyle7(hash, css) {
9689 const runtime = getRuntime7();
9690 runtime.styles.set(hash, css);
9691 for (const targetDocument of runtime.documents.keys()) {
9692 injectStyle7(targetDocument, hash, css);
9693 }
9694 }
9695 if (typeof process === "undefined" || true) {
9696 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}}}');
9697 }
9698 var style_default6 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9699 var Visual = (0, import_element18.forwardRef)(
9700 function EmptyStateVisual({ render: render4, ...props }, ref) {
9701 const className = clsx_default(style_default6.visual);
9702 const element = useRender({
9703 defaultTagName: "div",
9704 render: render4,
9705 ref,
9706 props: mergeProps({ className }, props)
9707 });
9708 return element;
9709 }
9710 );
9711
9712 // packages/ui/build-module/empty-state/icon.mjs
9713 var import_element19 = __toESM(require_element(), 1);
9714 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
9715 var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash";
9716 function getRuntime8() {
9717 const globalScope = globalThis;
9718 if (globalScope.__wpStyleRuntime) {
9719 return globalScope.__wpStyleRuntime;
9720 }
9721 globalScope.__wpStyleRuntime = {
9722 documents: /* @__PURE__ */ new Map(),
9723 styles: /* @__PURE__ */ new Map(),
9724 injectedStyles: /* @__PURE__ */ new WeakMap()
9725 };
9726 if (typeof document !== "undefined") {
9727 registerDocument8(document);
9728 }
9729 return globalScope.__wpStyleRuntime;
9730 }
9731 function documentContainsStyleHash8(targetDocument, hash) {
9732 if (!targetDocument.head) {
9733 return false;
9734 }
9735 for (const style of targetDocument.head.querySelectorAll(
9736 `style[${STYLE_HASH_ATTRIBUTE8}]`
9737 )) {
9738 if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) {
9739 return true;
9740 }
9741 }
9742 return false;
9743 }
9744 function injectStyle8(targetDocument, hash, css) {
9745 if (!targetDocument.head) {
9746 return;
9747 }
9748 const runtime = getRuntime8();
9749 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9750 if (!injectedStyles) {
9751 injectedStyles = /* @__PURE__ */ new Set();
9752 runtime.injectedStyles.set(targetDocument, injectedStyles);
9753 }
9754 if (injectedStyles.has(hash)) {
9755 return;
9756 }
9757 if (documentContainsStyleHash8(targetDocument, hash)) {
9758 injectedStyles.add(hash);
9759 return;
9760 }
9761 const style = targetDocument.createElement("style");
9762 style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash);
9763 style.appendChild(targetDocument.createTextNode(css));
9764 targetDocument.head.appendChild(style);
9765 injectedStyles.add(hash);
9766 }
9767 function registerDocument8(targetDocument) {
9768 const runtime = getRuntime8();
9769 runtime.documents.set(
9770 targetDocument,
9771 (runtime.documents.get(targetDocument) ?? 0) + 1
9772 );
9773 for (const [hash, css] of runtime.styles) {
9774 injectStyle8(targetDocument, hash, css);
9775 }
9776 return () => {
9777 const count = runtime.documents.get(targetDocument);
9778 if (count === void 0) {
9779 return;
9780 }
9781 if (count <= 1) {
9782 runtime.documents.delete(targetDocument);
9783 return;
9784 }
9785 runtime.documents.set(targetDocument, count - 1);
9786 };
9787 }
9788 function registerStyle8(hash, css) {
9789 const runtime = getRuntime8();
9790 runtime.styles.set(hash, css);
9791 for (const targetDocument of runtime.documents.keys()) {
9792 injectStyle8(targetDocument, hash, css);
9793 }
9794 }
9795 if (typeof process === "undefined" || true) {
9796 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}}}');
9797 }
9798 var style_default7 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9799 var Icon3 = (0, import_element19.forwardRef)(
9800 function EmptyStateIcon({ icon, className, ...restProps }, ref) {
9801 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
9802 Visual,
9803 {
9804 ref,
9805 className: clsx_default(style_default7.icon, className),
9806 ...restProps,
9807 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Icon, { icon })
9808 }
9809 );
9810 }
9811 );
9812
9813 // packages/ui/build-module/empty-state/title.mjs
9814 var import_element20 = __toESM(require_element(), 1);
9815 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
9816 var STYLE_HASH_ATTRIBUTE9 = "data-wp-hash";
9817 function getRuntime9() {
9818 const globalScope = globalThis;
9819 if (globalScope.__wpStyleRuntime) {
9820 return globalScope.__wpStyleRuntime;
9821 }
9822 globalScope.__wpStyleRuntime = {
9823 documents: /* @__PURE__ */ new Map(),
9824 styles: /* @__PURE__ */ new Map(),
9825 injectedStyles: /* @__PURE__ */ new WeakMap()
9826 };
9827 if (typeof document !== "undefined") {
9828 registerDocument9(document);
9829 }
9830 return globalScope.__wpStyleRuntime;
9831 }
9832 function documentContainsStyleHash9(targetDocument, hash) {
9833 if (!targetDocument.head) {
9834 return false;
9835 }
9836 for (const style of targetDocument.head.querySelectorAll(
9837 `style[${STYLE_HASH_ATTRIBUTE9}]`
9838 )) {
9839 if (style.getAttribute(STYLE_HASH_ATTRIBUTE9) === hash) {
9840 return true;
9841 }
9842 }
9843 return false;
9844 }
9845 function injectStyle9(targetDocument, hash, css) {
9846 if (!targetDocument.head) {
9847 return;
9848 }
9849 const runtime = getRuntime9();
9850 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9851 if (!injectedStyles) {
9852 injectedStyles = /* @__PURE__ */ new Set();
9853 runtime.injectedStyles.set(targetDocument, injectedStyles);
9854 }
9855 if (injectedStyles.has(hash)) {
9856 return;
9857 }
9858 if (documentContainsStyleHash9(targetDocument, hash)) {
9859 injectedStyles.add(hash);
9860 return;
9861 }
9862 const style = targetDocument.createElement("style");
9863 style.setAttribute(STYLE_HASH_ATTRIBUTE9, hash);
9864 style.appendChild(targetDocument.createTextNode(css));
9865 targetDocument.head.appendChild(style);
9866 injectedStyles.add(hash);
9867 }
9868 function registerDocument9(targetDocument) {
9869 const runtime = getRuntime9();
9870 runtime.documents.set(
9871 targetDocument,
9872 (runtime.documents.get(targetDocument) ?? 0) + 1
9873 );
9874 for (const [hash, css] of runtime.styles) {
9875 injectStyle9(targetDocument, hash, css);
9876 }
9877 return () => {
9878 const count = runtime.documents.get(targetDocument);
9879 if (count === void 0) {
9880 return;
9881 }
9882 if (count <= 1) {
9883 runtime.documents.delete(targetDocument);
9884 return;
9885 }
9886 runtime.documents.set(targetDocument, count - 1);
9887 };
9888 }
9889 function registerStyle9(hash, css) {
9890 const runtime = getRuntime9();
9891 runtime.styles.set(hash, css);
9892 for (const targetDocument of runtime.documents.keys()) {
9893 injectStyle9(targetDocument, hash, css);
9894 }
9895 }
9896 if (typeof process === "undefined" || true) {
9897 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}}}');
9898 }
9899 var style_default8 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9900 var DEFAULT_TAG = /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("h2", {});
9901 var Title = (0, import_element20.forwardRef)(
9902 function EmptyStateTitle({ render: render4 = DEFAULT_TAG, className, children, ...props }, ref) {
9903 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
9904 Text,
9905 {
9906 ref,
9907 variant: "heading-lg",
9908 render: render4,
9909 className: clsx_default(style_default8.title, className),
9910 ...props,
9911 children
9912 }
9913 );
9914 }
9915 );
9916
9917 // packages/ui/build-module/empty-state/description.mjs
9918 var import_element21 = __toESM(require_element(), 1);
9919 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
9920 var STYLE_HASH_ATTRIBUTE10 = "data-wp-hash";
9921 function getRuntime10() {
9922 const globalScope = globalThis;
9923 if (globalScope.__wpStyleRuntime) {
9924 return globalScope.__wpStyleRuntime;
9925 }
9926 globalScope.__wpStyleRuntime = {
9927 documents: /* @__PURE__ */ new Map(),
9928 styles: /* @__PURE__ */ new Map(),
9929 injectedStyles: /* @__PURE__ */ new WeakMap()
9930 };
9931 if (typeof document !== "undefined") {
9932 registerDocument10(document);
9933 }
9934 return globalScope.__wpStyleRuntime;
9935 }
9936 function documentContainsStyleHash10(targetDocument, hash) {
9937 if (!targetDocument.head) {
9938 return false;
9939 }
9940 for (const style of targetDocument.head.querySelectorAll(
9941 `style[${STYLE_HASH_ATTRIBUTE10}]`
9942 )) {
9943 if (style.getAttribute(STYLE_HASH_ATTRIBUTE10) === hash) {
9944 return true;
9945 }
9946 }
9947 return false;
9948 }
9949 function injectStyle10(targetDocument, hash, css) {
9950 if (!targetDocument.head) {
9951 return;
9952 }
9953 const runtime = getRuntime10();
9954 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9955 if (!injectedStyles) {
9956 injectedStyles = /* @__PURE__ */ new Set();
9957 runtime.injectedStyles.set(targetDocument, injectedStyles);
9958 }
9959 if (injectedStyles.has(hash)) {
9960 return;
9961 }
9962 if (documentContainsStyleHash10(targetDocument, hash)) {
9963 injectedStyles.add(hash);
9964 return;
9965 }
9966 const style = targetDocument.createElement("style");
9967 style.setAttribute(STYLE_HASH_ATTRIBUTE10, hash);
9968 style.appendChild(targetDocument.createTextNode(css));
9969 targetDocument.head.appendChild(style);
9970 injectedStyles.add(hash);
9971 }
9972 function registerDocument10(targetDocument) {
9973 const runtime = getRuntime10();
9974 runtime.documents.set(
9975 targetDocument,
9976 (runtime.documents.get(targetDocument) ?? 0) + 1
9977 );
9978 for (const [hash, css] of runtime.styles) {
9979 injectStyle10(targetDocument, hash, css);
9980 }
9981 return () => {
9982 const count = runtime.documents.get(targetDocument);
9983 if (count === void 0) {
9984 return;
9985 }
9986 if (count <= 1) {
9987 runtime.documents.delete(targetDocument);
9988 return;
9989 }
9990 runtime.documents.set(targetDocument, count - 1);
9991 };
9992 }
9993 function registerStyle10(hash, css) {
9994 const runtime = getRuntime10();
9995 runtime.styles.set(hash, css);
9996 for (const targetDocument of runtime.documents.keys()) {
9997 injectStyle10(targetDocument, hash, css);
9998 }
9999 }
10000 if (typeof process === "undefined" || true) {
10001 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}}}');
10002 }
10003 var style_default9 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
10004 var DEFAULT_TAG2 = /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", {});
10005 var Description = (0, import_element21.forwardRef)(function EmptyStateDescription({ render: render4 = DEFAULT_TAG2, className, children, ...props }, ref) {
10006 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
10007 Text,
10008 {
10009 ref,
10010 variant: "body-md",
10011 render: render4,
10012 className: clsx_default(style_default9.description, className),
10013 ...props,
10014 children
10015 }
10016 );
10017 });
10018
10019 // packages/ui/build-module/empty-state/actions.mjs
10020 var import_element22 = __toESM(require_element(), 1);
10021 var STYLE_HASH_ATTRIBUTE11 = "data-wp-hash";
10022 function getRuntime11() {
10023 const globalScope = globalThis;
10024 if (globalScope.__wpStyleRuntime) {
10025 return globalScope.__wpStyleRuntime;
10026 }
10027 globalScope.__wpStyleRuntime = {
10028 documents: /* @__PURE__ */ new Map(),
10029 styles: /* @__PURE__ */ new Map(),
10030 injectedStyles: /* @__PURE__ */ new WeakMap()
10031 };
10032 if (typeof document !== "undefined") {
10033 registerDocument11(document);
10034 }
10035 return globalScope.__wpStyleRuntime;
10036 }
10037 function documentContainsStyleHash11(targetDocument, hash) {
10038 if (!targetDocument.head) {
10039 return false;
10040 }
10041 for (const style of targetDocument.head.querySelectorAll(
10042 `style[${STYLE_HASH_ATTRIBUTE11}]`
10043 )) {
10044 if (style.getAttribute(STYLE_HASH_ATTRIBUTE11) === hash) {
10045 return true;
10046 }
10047 }
10048 return false;
10049 }
10050 function injectStyle11(targetDocument, hash, css) {
10051 if (!targetDocument.head) {
10052 return;
10053 }
10054 const runtime = getRuntime11();
10055 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10056 if (!injectedStyles) {
10057 injectedStyles = /* @__PURE__ */ new Set();
10058 runtime.injectedStyles.set(targetDocument, injectedStyles);
10059 }
10060 if (injectedStyles.has(hash)) {
10061 return;
10062 }
10063 if (documentContainsStyleHash11(targetDocument, hash)) {
10064 injectedStyles.add(hash);
10065 return;
10066 }
10067 const style = targetDocument.createElement("style");
10068 style.setAttribute(STYLE_HASH_ATTRIBUTE11, hash);
10069 style.appendChild(targetDocument.createTextNode(css));
10070 targetDocument.head.appendChild(style);
10071 injectedStyles.add(hash);
10072 }
10073 function registerDocument11(targetDocument) {
10074 const runtime = getRuntime11();
10075 runtime.documents.set(
10076 targetDocument,
10077 (runtime.documents.get(targetDocument) ?? 0) + 1
10078 );
10079 for (const [hash, css] of runtime.styles) {
10080 injectStyle11(targetDocument, hash, css);
10081 }
10082 return () => {
10083 const count = runtime.documents.get(targetDocument);
10084 if (count === void 0) {
10085 return;
10086 }
10087 if (count <= 1) {
10088 runtime.documents.delete(targetDocument);
10089 return;
10090 }
10091 runtime.documents.set(targetDocument, count - 1);
10092 };
10093 }
10094 function registerStyle11(hash, css) {
10095 const runtime = getRuntime11();
10096 runtime.styles.set(hash, css);
10097 for (const targetDocument of runtime.documents.keys()) {
10098 injectStyle11(targetDocument, hash, css);
10099 }
10100 }
10101 if (typeof process === "undefined" || true) {
10102 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}}}');
10103 }
10104 var style_default10 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
10105 var Actions = (0, import_element22.forwardRef)(
10106 function EmptyStateActions({ render: render4, ...props }, ref) {
10107 const className = clsx_default(style_default10.actions);
10108 const element = useRender({
10109 defaultTagName: "div",
10110 render: render4,
10111 ref,
10112 props: mergeProps({ className }, props)
10113 });
10114 return element;
10115 }
10116 );
10117
10118 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
10119 var import_element23 = __toESM(require_element(), 1);
10120 var STYLE_HASH_ATTRIBUTE12 = "data-wp-hash";
10121 function getRuntime12() {
10122 const globalScope = globalThis;
10123 if (globalScope.__wpStyleRuntime) {
10124 return globalScope.__wpStyleRuntime;
10125 }
10126 globalScope.__wpStyleRuntime = {
10127 documents: /* @__PURE__ */ new Map(),
10128 styles: /* @__PURE__ */ new Map(),
10129 injectedStyles: /* @__PURE__ */ new WeakMap()
10130 };
10131 if (typeof document !== "undefined") {
10132 registerDocument12(document);
10133 }
10134 return globalScope.__wpStyleRuntime;
10135 }
10136 function documentContainsStyleHash12(targetDocument, hash) {
10137 if (!targetDocument.head) {
10138 return false;
10139 }
10140 for (const style of targetDocument.head.querySelectorAll(
10141 `style[${STYLE_HASH_ATTRIBUTE12}]`
10142 )) {
10143 if (style.getAttribute(STYLE_HASH_ATTRIBUTE12) === hash) {
10144 return true;
10145 }
10146 }
10147 return false;
10148 }
10149 function injectStyle12(targetDocument, hash, css) {
10150 if (!targetDocument.head) {
10151 return;
10152 }
10153 const runtime = getRuntime12();
10154 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10155 if (!injectedStyles) {
10156 injectedStyles = /* @__PURE__ */ new Set();
10157 runtime.injectedStyles.set(targetDocument, injectedStyles);
10158 }
10159 if (injectedStyles.has(hash)) {
10160 return;
10161 }
10162 if (documentContainsStyleHash12(targetDocument, hash)) {
10163 injectedStyles.add(hash);
10164 return;
10165 }
10166 const style = targetDocument.createElement("style");
10167 style.setAttribute(STYLE_HASH_ATTRIBUTE12, hash);
10168 style.appendChild(targetDocument.createTextNode(css));
10169 targetDocument.head.appendChild(style);
10170 injectedStyles.add(hash);
10171 }
10172 function registerDocument12(targetDocument) {
10173 const runtime = getRuntime12();
10174 runtime.documents.set(
10175 targetDocument,
10176 (runtime.documents.get(targetDocument) ?? 0) + 1
10177 );
10178 for (const [hash, css] of runtime.styles) {
10179 injectStyle12(targetDocument, hash, css);
10180 }
10181 return () => {
10182 const count = runtime.documents.get(targetDocument);
10183 if (count === void 0) {
10184 return;
10185 }
10186 if (count <= 1) {
10187 runtime.documents.delete(targetDocument);
10188 return;
10189 }
10190 runtime.documents.set(targetDocument, count - 1);
10191 };
10192 }
10193 function registerStyle12(hash, css) {
10194 const runtime = getRuntime12();
10195 runtime.styles.set(hash, css);
10196 for (const targetDocument of runtime.documents.keys()) {
10197 injectStyle12(targetDocument, hash, css);
10198 }
10199 }
10200 if (typeof process === "undefined" || true) {
10201 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}}");
10202 }
10203 var style_default11 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
10204 var VisuallyHidden = (0, import_element23.forwardRef)(
10205 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
10206 const element = useRender({
10207 render: render4,
10208 ref,
10209 props: mergeProps(
10210 { className: style_default11["visually-hidden"] },
10211 restProps,
10212 {
10213 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
10214 "data-visually-hidden": ""
10215 }
10216 )
10217 });
10218 return element;
10219 }
10220 );
10221
10222 // packages/ui/build-module/link/link.mjs
10223 var import_element24 = __toESM(require_element(), 1);
10224 var import_i18n = __toESM(require_i18n(), 1);
10225 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
10226 var STYLE_HASH_ATTRIBUTE13 = "data-wp-hash";
10227 function getRuntime13() {
10228 const globalScope = globalThis;
10229 if (globalScope.__wpStyleRuntime) {
10230 return globalScope.__wpStyleRuntime;
10231 }
10232 globalScope.__wpStyleRuntime = {
10233 documents: /* @__PURE__ */ new Map(),
10234 styles: /* @__PURE__ */ new Map(),
10235 injectedStyles: /* @__PURE__ */ new WeakMap()
10236 };
10237 if (typeof document !== "undefined") {
10238 registerDocument13(document);
10239 }
10240 return globalScope.__wpStyleRuntime;
10241 }
10242 function documentContainsStyleHash13(targetDocument, hash) {
10243 if (!targetDocument.head) {
10244 return false;
10245 }
10246 for (const style of targetDocument.head.querySelectorAll(
10247 `style[${STYLE_HASH_ATTRIBUTE13}]`
10248 )) {
10249 if (style.getAttribute(STYLE_HASH_ATTRIBUTE13) === hash) {
10250 return true;
10251 }
10252 }
10253 return false;
10254 }
10255 function injectStyle13(targetDocument, hash, css) {
10256 if (!targetDocument.head) {
10257 return;
10258 }
10259 const runtime = getRuntime13();
10260 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10261 if (!injectedStyles) {
10262 injectedStyles = /* @__PURE__ */ new Set();
10263 runtime.injectedStyles.set(targetDocument, injectedStyles);
10264 }
10265 if (injectedStyles.has(hash)) {
10266 return;
10267 }
10268 if (documentContainsStyleHash13(targetDocument, hash)) {
10269 injectedStyles.add(hash);
10270 return;
10271 }
10272 const style = targetDocument.createElement("style");
10273 style.setAttribute(STYLE_HASH_ATTRIBUTE13, hash);
10274 style.appendChild(targetDocument.createTextNode(css));
10275 targetDocument.head.appendChild(style);
10276 injectedStyles.add(hash);
10277 }
10278 function registerDocument13(targetDocument) {
10279 const runtime = getRuntime13();
10280 runtime.documents.set(
10281 targetDocument,
10282 (runtime.documents.get(targetDocument) ?? 0) + 1
10283 );
10284 for (const [hash, css] of runtime.styles) {
10285 injectStyle13(targetDocument, hash, css);
10286 }
10287 return () => {
10288 const count = runtime.documents.get(targetDocument);
10289 if (count === void 0) {
10290 return;
10291 }
10292 if (count <= 1) {
10293 runtime.documents.delete(targetDocument);
10294 return;
10295 }
10296 runtime.documents.set(targetDocument, count - 1);
10297 };
10298 }
10299 function registerStyle13(hash, css) {
10300 const runtime = getRuntime13();
10301 runtime.styles.set(hash, css);
10302 for (const targetDocument of runtime.documents.keys()) {
10303 injectStyle13(targetDocument, hash, css);
10304 }
10305 }
10306 if (typeof process === "undefined" || true) {
10307 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}}}");
10308 }
10309 var resets_default2 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
10310 if (typeof process === "undefined" || true) {
10311 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))}}");
10312 }
10313 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" };
10314 if (typeof process === "undefined" || true) {
10315 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"}}');
10316 }
10317 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" };
10318 if (typeof process === "undefined" || true) {
10319 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)}");
10320 }
10321 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" };
10322 var Link = (0, import_element24.forwardRef)(function Link2({
10323 children,
10324 variant = "default",
10325 tone = "brand",
10326 openInNewTab = false,
10327 render: render4,
10328 className,
10329 ...props
10330 }, ref) {
10331 const element = useRender({
10332 render: render4,
10333 defaultTagName: "a",
10334 ref,
10335 props: mergeProps(props, {
10336 className: clsx_default(
10337 global_css_defense_default2.a,
10338 resets_default2["box-sizing"],
10339 focus_default["outset-ring--focus"],
10340 variant !== "unstyled" && style_default12.link,
10341 variant !== "unstyled" && style_default12[`is-${tone}`],
10342 variant === "unstyled" && style_default12["is-unstyled"],
10343 className
10344 ),
10345 target: openInNewTab ? "_blank" : void 0,
10346 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_jsx_runtime46.Fragment, { children: [
10347 children,
10348 openInNewTab && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
10349 "span",
10350 {
10351 className: style_default12["link-icon"],
10352 role: "img",
10353 "aria-label": (
10354 /* translators: accessibility text appended to link text */
10355 (0, import_i18n.__)("(opens in a new tab)")
10356 )
10357 }
10358 )
10359 ] })
10360 })
10361 });
10362 return element;
10363 });
10364
10365 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10366 var import_element25 = __toESM(require_element(), 1);
10367
10368 // packages/dataviews/build-module/constants.mjs
10369 var import_i18n2 = __toESM(require_i18n(), 1);
10370 var OPERATOR_IS_ANY = "isAny";
10371 var OPERATOR_IS_NONE = "isNone";
10372 var OPERATOR_IS_ALL = "isAll";
10373 var OPERATOR_IS_NOT_ALL = "isNotAll";
10374 var OPERATOR_BETWEEN = "between";
10375 var OPERATOR_IN_THE_PAST = "inThePast";
10376 var OPERATOR_OVER = "over";
10377 var OPERATOR_IS = "is";
10378 var OPERATOR_IS_NOT = "isNot";
10379 var OPERATOR_LESS_THAN = "lessThan";
10380 var OPERATOR_GREATER_THAN = "greaterThan";
10381 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
10382 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
10383 var OPERATOR_BEFORE = "before";
10384 var OPERATOR_AFTER = "after";
10385 var OPERATOR_BEFORE_INC = "beforeInc";
10386 var OPERATOR_AFTER_INC = "afterInc";
10387 var OPERATOR_CONTAINS = "contains";
10388 var OPERATOR_NOT_CONTAINS = "notContains";
10389 var OPERATOR_STARTS_WITH = "startsWith";
10390 var OPERATOR_ON = "on";
10391 var OPERATOR_NOT_ON = "notOn";
10392 var SORTING_DIRECTIONS = ["asc", "desc"];
10393 var sortArrows = { asc: "\u2191", desc: "\u2193" };
10394 var sortValues = { asc: "ascending", desc: "descending" };
10395 var sortLabels = {
10396 asc: (0, import_i18n2.__)("Sort ascending"),
10397 desc: (0, import_i18n2.__)("Sort descending")
10398 };
10399 var sortIcons = {
10400 asc: arrow_up_default,
10401 desc: arrow_down_default
10402 };
10403 var LAYOUT_TABLE = "table";
10404 var LAYOUT_GRID = "grid";
10405 var LAYOUT_LIST = "list";
10406 var LAYOUT_ACTIVITY = "activity";
10407 var LAYOUT_PICKER_GRID = "pickerGrid";
10408 var LAYOUT_PICKER_TABLE = "pickerTable";
10409
10410 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10411 var DataViewsContext = (0, import_element25.createContext)({
10412 view: { type: LAYOUT_TABLE },
10413 onChangeView: () => {
10414 },
10415 fields: [],
10416 data: [],
10417 paginationInfo: {
10418 totalItems: 0,
10419 totalPages: 0
10420 },
10421 selection: [],
10422 onChangeSelection: () => {
10423 },
10424 setOpenedFilter: () => {
10425 },
10426 openedFilter: null,
10427 getItemId: (item) => item.id,
10428 isItemClickable: () => true,
10429 renderItemLink: void 0,
10430 containerWidth: 0,
10431 containerRef: (0, import_element25.createRef)(),
10432 resizeObserverRef: () => {
10433 },
10434 defaultLayouts: { list: {}, grid: {}, table: {} },
10435 filters: [],
10436 isShowingFilter: false,
10437 setIsShowingFilter: () => {
10438 },
10439 hasInitiallyLoaded: false,
10440 config: {
10441 perPageSizes: []
10442 },
10443 intersectionObserver: null
10444 });
10445 DataViewsContext.displayName = "DataViewsContext";
10446 var dataviews_context_default = DataViewsContext;
10447
10448 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
10449 var import_i18n22 = __toESM(require_i18n(), 1);
10450
10451 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
10452 var import_i18n10 = __toESM(require_i18n(), 1);
10453 var import_components6 = __toESM(require_components(), 1);
10454 var import_element33 = __toESM(require_element(), 1);
10455 var import_keycodes = __toESM(require_keycodes(), 1);
10456
10457 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
10458 var import_components = __toESM(require_components(), 1);
10459 var import_i18n3 = __toESM(require_i18n(), 1);
10460 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
10461 function DataViewsSelectionCheckbox({
10462 selection,
10463 onChangeSelection,
10464 item,
10465 getItemId,
10466 titleField,
10467 disabled: disabled2,
10468 ...extraProps
10469 }) {
10470 const id = getItemId(item);
10471 const isInSelectionArray = selection.includes(id);
10472 const checked = !disabled2 && isInSelectionArray;
10473 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n3.__)("(no title)");
10474 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
10475 import_components.CheckboxControl,
10476 {
10477 className: "dataviews-selection-checkbox",
10478 "aria-label": selectionLabel,
10479 "aria-disabled": disabled2,
10480 checked,
10481 onChange: () => {
10482 if (disabled2) {
10483 return;
10484 }
10485 onChangeSelection(
10486 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
10487 );
10488 },
10489 ...extraProps
10490 }
10491 );
10492 }
10493
10494 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10495 var import_components2 = __toESM(require_components(), 1);
10496 var import_i18n4 = __toESM(require_i18n(), 1);
10497 var import_element26 = __toESM(require_element(), 1);
10498 var import_data = __toESM(require_data(), 1);
10499 var import_compose = __toESM(require_compose(), 1);
10500
10501 // packages/dataviews/build-module/lock-unlock.mjs
10502 var import_private_apis2 = __toESM(require_private_apis(), 1);
10503 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
10504 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
10505 "@wordpress/dataviews"
10506 );
10507
10508 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10509 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
10510 var { Menu, kebabCase } = unlock2(import_components2.privateApis);
10511 function ButtonTrigger({
10512 action,
10513 onClick,
10514 items,
10515 variant
10516 }) {
10517 const label = typeof action.label === "string" ? action.label : action.label(items);
10518 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10519 import_components2.Button,
10520 {
10521 disabled: !!action.disabled,
10522 accessibleWhenDisabled: true,
10523 size: "compact",
10524 variant,
10525 onClick,
10526 children: label
10527 }
10528 );
10529 }
10530 function MenuItemTrigger({
10531 action,
10532 onClick,
10533 items
10534 }) {
10535 const label = typeof action.label === "string" ? action.label : action.label(items);
10536 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Menu.ItemLabel, { children: label }) });
10537 }
10538 function ActionModal({
10539 action,
10540 items,
10541 closeModal
10542 }) {
10543 const label = typeof action.label === "string" ? action.label : action.label(items);
10544 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
10545 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10546 import_components2.Modal,
10547 {
10548 title: modalHeader || label,
10549 __experimentalHideHeader: !!action.hideModalHeader,
10550 onRequestClose: closeModal,
10551 focusOnMount: action.modalFocusOnMount ?? true,
10552 size: action.modalSize || "medium",
10553 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
10554 action.id
10555 )}`,
10556 children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(action.RenderModal, { items, closeModal })
10557 }
10558 );
10559 }
10560 function ActionsMenuGroup({
10561 actions,
10562 item,
10563 registry,
10564 setActiveModalAction
10565 }) {
10566 const { primaryActions, regularActions } = (0, import_element26.useMemo)(() => {
10567 return actions.reduce(
10568 (acc, action) => {
10569 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
10570 return acc;
10571 },
10572 {
10573 primaryActions: [],
10574 regularActions: []
10575 }
10576 );
10577 }, [actions]);
10578 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10579 MenuItemTrigger,
10580 {
10581 action,
10582 onClick: () => {
10583 if ("RenderModal" in action) {
10584 setActiveModalAction(action);
10585 return;
10586 }
10587 action.callback([item], { registry });
10588 },
10589 items: [item]
10590 },
10591 action.id
10592 ));
10593 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(Menu.Group, { children: [
10594 renderActionGroup(primaryActions),
10595 renderActionGroup(regularActions)
10596 ] });
10597 }
10598 function ItemActions({
10599 item,
10600 actions,
10601 isCompact
10602 }) {
10603 const registry = (0, import_data.useRegistry)();
10604 const { primaryActions, eligibleActions } = (0, import_element26.useMemo)(() => {
10605 const _eligibleActions = actions.filter(
10606 (action) => !action.isEligible || action.isEligible(item)
10607 );
10608 const _primaryActions = _eligibleActions.filter(
10609 (action) => action.isPrimary
10610 );
10611 return {
10612 primaryActions: _primaryActions,
10613 eligibleActions: _eligibleActions
10614 };
10615 }, [actions, item]);
10616 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10617 if (isCompact) {
10618 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10619 CompactItemActions,
10620 {
10621 item,
10622 actions: eligibleActions,
10623 isSmall: true,
10624 registry
10625 }
10626 );
10627 }
10628 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
10629 Stack,
10630 {
10631 direction: "row",
10632 justify: "flex-end",
10633 className: "dataviews-item-actions",
10634 style: {
10635 flexShrink: 0,
10636 width: "auto"
10637 },
10638 children: [
10639 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10640 PrimaryActions,
10641 {
10642 item,
10643 actions: primaryActions,
10644 registry
10645 }
10646 ),
10647 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
10648 // there if there are any actions at all.
10649 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10650 CompactItemActions,
10651 {
10652 item,
10653 actions: eligibleActions,
10654 registry
10655 }
10656 )
10657 ]
10658 }
10659 );
10660 }
10661 function CompactItemActions({
10662 item,
10663 actions,
10664 isSmall,
10665 registry
10666 }) {
10667 const [activeModalAction, setActiveModalAction] = (0, import_element26.useState)(
10668 null
10669 );
10670 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(import_jsx_runtime48.Fragment, { children: [
10671 /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(Menu, { placement: "bottom-end", children: [
10672 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10673 Menu.TriggerButton,
10674 {
10675 render: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10676 import_components2.Button,
10677 {
10678 size: isSmall ? "small" : "compact",
10679 icon: more_vertical_default,
10680 label: (0, import_i18n4.__)("Actions"),
10681 accessibleWhenDisabled: true,
10682 disabled: !actions.length,
10683 className: "dataviews-all-actions-button"
10684 }
10685 )
10686 }
10687 ),
10688 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10689 ActionsMenuGroup,
10690 {
10691 actions,
10692 item,
10693 registry,
10694 setActiveModalAction
10695 }
10696 ) })
10697 ] }),
10698 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10699 ActionModal,
10700 {
10701 action: activeModalAction,
10702 items: [item],
10703 closeModal: () => setActiveModalAction(null)
10704 }
10705 )
10706 ] });
10707 }
10708 function PrimaryActions({
10709 item,
10710 actions,
10711 registry,
10712 buttonVariant
10713 }) {
10714 const [activeModalAction, setActiveModalAction] = (0, import_element26.useState)(null);
10715 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10716 if (isMobileViewport) {
10717 return null;
10718 }
10719 if (!Array.isArray(actions) || actions.length === 0) {
10720 return null;
10721 }
10722 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(import_jsx_runtime48.Fragment, { children: [
10723 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10724 ButtonTrigger,
10725 {
10726 action,
10727 onClick: () => {
10728 if ("RenderModal" in action) {
10729 setActiveModalAction(action);
10730 return;
10731 }
10732 action.callback([item], { registry });
10733 },
10734 items: [item],
10735 variant: buttonVariant
10736 },
10737 action.id
10738 )),
10739 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10740 ActionModal,
10741 {
10742 action: activeModalAction,
10743 items: [item],
10744 closeModal: () => setActiveModalAction(null)
10745 }
10746 )
10747 ] });
10748 }
10749
10750 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10751 var import_components3 = __toESM(require_components(), 1);
10752 var import_i18n6 = __toESM(require_i18n(), 1);
10753 var import_element27 = __toESM(require_element(), 1);
10754 var import_data2 = __toESM(require_data(), 1);
10755 var import_compose2 = __toESM(require_compose(), 1);
10756
10757 // packages/dataviews/build-module/utils/get-footer-message.mjs
10758 var import_i18n5 = __toESM(require_i18n(), 1);
10759 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
10760 if (selectionCount > 0) {
10761 return (0, import_i18n5.sprintf)(
10762 /* translators: %d: number of items. */
10763 (0, import_i18n5._n)("%d Item selected", "%d Items selected", selectionCount),
10764 selectionCount
10765 );
10766 }
10767 if (onlyTotalCount || totalItems <= itemsCount) {
10768 return (0, import_i18n5.sprintf)(
10769 /* translators: %d: number of items. */
10770 (0, import_i18n5._n)("%d Item", "%d Items", totalItems),
10771 totalItems
10772 );
10773 }
10774 return (0, import_i18n5.sprintf)(
10775 /* translators: %1$d: number of items. %2$d: total number of items. */
10776 (0, import_i18n5._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
10777 itemsCount,
10778 totalItems
10779 );
10780 }
10781
10782 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10783 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
10784 function ActionWithModal({
10785 action,
10786 items,
10787 ActionTriggerComponent
10788 }) {
10789 const [isModalOpen, setIsModalOpen] = (0, import_element27.useState)(false);
10790 const actionTriggerProps = {
10791 action,
10792 onClick: () => {
10793 setIsModalOpen(true);
10794 },
10795 items
10796 };
10797 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
10798 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(ActionTriggerComponent, { ...actionTriggerProps }),
10799 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10800 ActionModal,
10801 {
10802 action,
10803 items,
10804 closeModal: () => setIsModalOpen(false)
10805 }
10806 )
10807 ] });
10808 }
10809 function useHasAPossibleBulkAction(actions, item) {
10810 return (0, import_element27.useMemo)(() => {
10811 return actions.some((action) => {
10812 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
10813 });
10814 }, [actions, item]);
10815 }
10816 function useSomeItemHasAPossibleBulkAction(actions, data) {
10817 return (0, import_element27.useMemo)(() => {
10818 return data.some((item) => {
10819 return actions.some((action) => {
10820 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
10821 });
10822 });
10823 }, [actions, data]);
10824 }
10825 function BulkSelectionCheckbox({
10826 selection,
10827 onChangeSelection,
10828 data,
10829 actions,
10830 getItemId,
10831 disableSelectAll = false
10832 }) {
10833 const selectableItems = (0, import_element27.useMemo)(() => {
10834 return data.filter((item) => {
10835 return actions.some(
10836 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
10837 );
10838 });
10839 }, [data, actions]);
10840 const selectedItems = data.filter(
10841 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
10842 );
10843 const hasSelection = selection.length > 0;
10844 const areAllSelected = selectedItems.length === selectableItems.length;
10845 if (disableSelectAll) {
10846 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10847 import_components3.CheckboxControl,
10848 {
10849 className: "dataviews-view-table-selection-checkbox",
10850 checked: hasSelection,
10851 disabled: !hasSelection,
10852 onChange: () => {
10853 onChangeSelection([]);
10854 },
10855 "aria-label": (0, import_i18n6.__)("Deselect all")
10856 }
10857 );
10858 }
10859 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10860 import_components3.CheckboxControl,
10861 {
10862 className: "dataviews-view-table-selection-checkbox",
10863 checked: areAllSelected,
10864 indeterminate: !areAllSelected && !!selectedItems.length,
10865 onChange: () => {
10866 if (areAllSelected) {
10867 onChangeSelection([]);
10868 } else {
10869 onChangeSelection(
10870 selectableItems.map((item) => getItemId(item))
10871 );
10872 }
10873 },
10874 "aria-label": areAllSelected ? (0, import_i18n6.__)("Deselect all") : (0, import_i18n6.__)("Select all")
10875 }
10876 );
10877 }
10878 function ActionTrigger({
10879 action,
10880 onClick,
10881 isBusy,
10882 items
10883 }) {
10884 const label = typeof action.label === "string" ? action.label : action.label(items);
10885 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
10886 if (isMobile) {
10887 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10888 import_components3.Button,
10889 {
10890 disabled: isBusy,
10891 accessibleWhenDisabled: true,
10892 label,
10893 icon: action.icon,
10894 size: "compact",
10895 onClick,
10896 isBusy
10897 }
10898 );
10899 }
10900 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10901 import_components3.Button,
10902 {
10903 disabled: isBusy,
10904 accessibleWhenDisabled: true,
10905 size: "compact",
10906 onClick,
10907 isBusy,
10908 children: label
10909 }
10910 );
10911 }
10912 var EMPTY_ARRAY2 = [];
10913 function ActionButton({
10914 action,
10915 selectedItems,
10916 actionInProgress,
10917 setActionInProgress
10918 }) {
10919 const registry = (0, import_data2.useRegistry)();
10920 const selectedEligibleItems = (0, import_element27.useMemo)(() => {
10921 return selectedItems.filter((item) => {
10922 return !action.isEligible || action.isEligible(item);
10923 });
10924 }, [action, selectedItems]);
10925 if ("RenderModal" in action) {
10926 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10927 ActionWithModal,
10928 {
10929 action,
10930 items: selectedEligibleItems,
10931 ActionTriggerComponent: ActionTrigger
10932 },
10933 action.id
10934 );
10935 }
10936 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10937 ActionTrigger,
10938 {
10939 action,
10940 onClick: async () => {
10941 setActionInProgress(action.id);
10942 await action.callback(selectedItems, {
10943 registry
10944 });
10945 setActionInProgress(null);
10946 },
10947 items: selectedEligibleItems,
10948 isBusy: actionInProgress === action.id
10949 },
10950 action.id
10951 );
10952 }
10953 function renderFooterContent(data, actions, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) {
10954 const message2 = getFooterMessage(
10955 selection.length,
10956 data.length,
10957 paginationInfo.totalItems,
10958 isInfiniteScroll
10959 );
10960 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
10961 Stack,
10962 {
10963 direction: "row",
10964 className: "dataviews-bulk-actions-footer__container",
10965 gap: "md",
10966 align: "center",
10967 children: [
10968 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10969 BulkSelectionCheckbox,
10970 {
10971 selection,
10972 onChangeSelection,
10973 data,
10974 actions,
10975 getItemId,
10976 disableSelectAll: isInfiniteScroll
10977 }
10978 ),
10979 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }),
10980 /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
10981 Stack,
10982 {
10983 direction: "row",
10984 className: "dataviews-bulk-actions-footer__action-buttons",
10985 gap: "xs",
10986 children: [
10987 actionsToShow.map((action) => {
10988 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10989 ActionButton,
10990 {
10991 action,
10992 selectedItems,
10993 actionInProgress,
10994 setActionInProgress
10995 },
10996 action.id
10997 );
10998 }),
10999 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11000 import_components3.Button,
11001 {
11002 icon: close_small_default,
11003 showTooltip: true,
11004 tooltipPosition: "top",
11005 size: "compact",
11006 label: (0, import_i18n6.__)("Cancel"),
11007 disabled: !!actionInProgress,
11008 accessibleWhenDisabled: false,
11009 onClick: () => {
11010 onChangeSelection(EMPTY_ARRAY2);
11011 }
11012 }
11013 )
11014 ]
11015 }
11016 )
11017 ]
11018 }
11019 );
11020 }
11021 function FooterContent({
11022 selection,
11023 actions,
11024 onChangeSelection,
11025 data,
11026 getItemId,
11027 isInfiniteScroll,
11028 paginationInfo
11029 }) {
11030 const [actionInProgress, setActionInProgress] = (0, import_element27.useState)(
11031 null
11032 );
11033 const footerContentRef = (0, import_element27.useRef)(void 0);
11034 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
11035 const bulkActions = (0, import_element27.useMemo)(
11036 () => actions.filter((action) => action.supportsBulk),
11037 [actions]
11038 );
11039 const selectableItems = (0, import_element27.useMemo)(() => {
11040 return data.filter((item) => {
11041 return bulkActions.some(
11042 (action) => !action.isEligible || action.isEligible(item)
11043 );
11044 });
11045 }, [data, bulkActions]);
11046 const selectedItems = (0, import_element27.useMemo)(() => {
11047 return data.filter(
11048 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
11049 );
11050 }, [selection, data, getItemId, selectableItems]);
11051 const actionsToShow = (0, import_element27.useMemo)(
11052 () => actions.filter((action) => {
11053 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some(
11054 (item) => !action.isEligible || action.isEligible(item)
11055 );
11056 }),
11057 [actions, selectedItems, isMobile]
11058 );
11059 if (!actionInProgress) {
11060 if (footerContentRef.current) {
11061 footerContentRef.current = void 0;
11062 }
11063 return renderFooterContent(
11064 data,
11065 actions,
11066 getItemId,
11067 isInfiniteScroll,
11068 selection,
11069 actionsToShow,
11070 selectedItems,
11071 actionInProgress,
11072 setActionInProgress,
11073 onChangeSelection,
11074 paginationInfo
11075 );
11076 } else if (!footerContentRef.current) {
11077 footerContentRef.current = renderFooterContent(
11078 data,
11079 actions,
11080 getItemId,
11081 isInfiniteScroll,
11082 selection,
11083 actionsToShow,
11084 selectedItems,
11085 actionInProgress,
11086 setActionInProgress,
11087 onChangeSelection,
11088 paginationInfo
11089 );
11090 }
11091 return footerContentRef.current;
11092 }
11093 function BulkActionsFooter() {
11094 const {
11095 data,
11096 selection,
11097 actions = EMPTY_ARRAY2,
11098 onChangeSelection,
11099 getItemId,
11100 paginationInfo,
11101 view
11102 } = (0, import_element27.useContext)(dataviews_context_default);
11103 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11104 FooterContent,
11105 {
11106 selection,
11107 onChangeSelection,
11108 data,
11109 actions,
11110 getItemId,
11111 isInfiniteScroll: !!view.infiniteScrollEnabled,
11112 paginationInfo
11113 }
11114 );
11115 }
11116
11117 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
11118 var import_i18n7 = __toESM(require_i18n(), 1);
11119 var import_components4 = __toESM(require_components(), 1);
11120 var import_element28 = __toESM(require_element(), 1);
11121
11122 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
11123 function getHideableFields(view, fields) {
11124 const togglableFields = [
11125 view?.titleField,
11126 view?.mediaField,
11127 view?.descriptionField
11128 ].filter(Boolean);
11129 return fields.filter(
11130 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
11131 );
11132 }
11133
11134 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
11135 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
11136 var { Menu: Menu2 } = unlock2(import_components4.privateApis);
11137 function WithMenuSeparators({ children }) {
11138 return import_element28.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_element28.Fragment, { children: [
11139 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Separator, {}),
11140 child
11141 ] }, i2));
11142 }
11143 var _HeaderMenu = (0, import_element28.forwardRef)(function HeaderMenu({
11144 fieldId,
11145 view,
11146 fields,
11147 onChangeView,
11148 onHide,
11149 setOpenedFilter,
11150 canMove = true,
11151 canInsertLeft = true,
11152 canInsertRight = true
11153 }, ref) {
11154 const visibleFieldIds = view.fields ?? [];
11155 const index2 = visibleFieldIds?.indexOf(fieldId);
11156 const isSorted = view.sort?.field === fieldId;
11157 let isHidable = false;
11158 let isSortable = false;
11159 let canAddFilter = false;
11160 let operators = [];
11161 const field = fields.find((f2) => f2.id === fieldId);
11162 const { setIsShowingFilter } = (0, import_element28.useContext)(dataviews_context_default);
11163 if (!field) {
11164 return null;
11165 }
11166 isHidable = field.enableHiding !== false;
11167 isSortable = field.enableSorting !== false;
11168 const header = field.header;
11169 operators = !!field.filterBy && field.filterBy?.operators || [];
11170 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
11171 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
11172 return header;
11173 }
11174 const hiddenFields = getHideableFields(view, fields).filter(
11175 (f2) => !visibleFieldIds.includes(f2.id)
11176 );
11177 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
11178 const isRtl = (0, import_i18n7.isRTL)();
11179 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Menu2, { children: [
11180 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
11181 Menu2.TriggerButton,
11182 {
11183 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11184 import_components4.Button,
11185 {
11186 size: "compact",
11187 className: "dataviews-view-table-header-button",
11188 ref,
11189 variant: "tertiary"
11190 }
11191 ),
11192 children: [
11193 header,
11194 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
11195 ]
11196 }
11197 ),
11198 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(WithMenuSeparators, { children: [
11199 isSortable && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
11200 (direction) => {
11201 const isChecked = view.sort && isSorted && view.sort.direction === direction;
11202 const value = `${fieldId}-${direction}`;
11203 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11204 Menu2.RadioItem,
11205 {
11206 name: "view-table-sorting",
11207 value,
11208 checked: isChecked,
11209 onChange: () => {
11210 onChangeView({
11211 ...view,
11212 sort: {
11213 field: fieldId,
11214 direction
11215 },
11216 showLevels: false
11217 });
11218 },
11219 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
11220 },
11221 value
11222 );
11223 }
11224 ) }),
11225 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11226 Menu2.Item,
11227 {
11228 prefix: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components4.Icon, { icon: funnel_default }),
11229 onClick: () => {
11230 setOpenedFilter(fieldId);
11231 setIsShowingFilter(true);
11232 onChangeView({
11233 ...view,
11234 page: 1,
11235 filters: [
11236 ...view.filters || [],
11237 {
11238 field: fieldId,
11239 value: void 0,
11240 operator: operators[0]
11241 }
11242 ]
11243 });
11244 },
11245 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Add filter") })
11246 }
11247 ) }),
11248 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Menu2.Group, { children: [
11249 canMove && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11250 Menu2.Item,
11251 {
11252 prefix: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components4.Icon, { icon: arrow_left_default }),
11253 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1,
11254 onClick: () => {
11255 const targetIndex = isRtl ? index2 + 1 : index2 - 1;
11256 const newFields = [
11257 ...visibleFieldIds
11258 ];
11259 newFields.splice(index2, 1);
11260 newFields.splice(
11261 targetIndex,
11262 0,
11263 fieldId
11264 );
11265 onChangeView({
11266 ...view,
11267 fields: newFields
11268 });
11269 },
11270 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Move left") })
11271 }
11272 ),
11273 canMove && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11274 Menu2.Item,
11275 {
11276 prefix: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components4.Icon, { icon: arrow_right_default }),
11277 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1,
11278 onClick: () => {
11279 const targetIndex = isRtl ? index2 - 1 : index2 + 1;
11280 const newFields = [
11281 ...visibleFieldIds
11282 ];
11283 newFields.splice(index2, 1);
11284 newFields.splice(
11285 targetIndex,
11286 0,
11287 fieldId
11288 );
11289 onChangeView({
11290 ...view,
11291 fields: newFields
11292 });
11293 },
11294 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Move right") })
11295 }
11296 ),
11297 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Menu2, { children: [
11298 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Insert left") }) }),
11299 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11300 const insertIndex = isRtl ? index2 + 1 : index2;
11301 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11302 Menu2.Item,
11303 {
11304 onClick: () => {
11305 onChangeView({
11306 ...view,
11307 fields: [
11308 ...visibleFieldIds.slice(
11309 0,
11310 insertIndex
11311 ),
11312 hiddenField.id,
11313 ...visibleFieldIds.slice(
11314 insertIndex
11315 )
11316 ]
11317 });
11318 },
11319 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11320 },
11321 hiddenField.id
11322 );
11323 }) })
11324 ] }),
11325 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Menu2, { children: [
11326 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Insert right") }) }),
11327 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11328 const insertIndex = isRtl ? index2 : index2 + 1;
11329 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11330 Menu2.Item,
11331 {
11332 onClick: () => {
11333 onChangeView({
11334 ...view,
11335 fields: [
11336 ...visibleFieldIds.slice(
11337 0,
11338 insertIndex
11339 ),
11340 hiddenField.id,
11341 ...visibleFieldIds.slice(
11342 insertIndex
11343 )
11344 ]
11345 });
11346 },
11347 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11348 },
11349 hiddenField.id
11350 );
11351 }) })
11352 ] }),
11353 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11354 Menu2.Item,
11355 {
11356 prefix: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components4.Icon, { icon: unseen_default }),
11357 onClick: () => {
11358 onHide(field);
11359 onChangeView({
11360 ...view,
11361 fields: visibleFieldIds.filter(
11362 (id) => id !== fieldId
11363 )
11364 });
11365 },
11366 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Hide column") })
11367 }
11368 )
11369 ] })
11370 ] }) })
11371 ] });
11372 });
11373 var ColumnHeaderMenu = _HeaderMenu;
11374 var column_header_menu_default = ColumnHeaderMenu;
11375
11376 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
11377 var import_element29 = __toESM(require_element(), 1);
11378 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
11379 function getClickableItemProps({
11380 item,
11381 isItemClickable,
11382 onClickItem,
11383 className
11384 }) {
11385 if (!isItemClickable(item) || !onClickItem) {
11386 return { className };
11387 }
11388 return {
11389 className: className ? `${className} ${className}--clickable` : void 0,
11390 role: "button",
11391 tabIndex: 0,
11392 onClick: (event) => {
11393 event.stopPropagation();
11394 onClickItem(item);
11395 },
11396 onKeyDown: (event) => {
11397 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11398 event.stopPropagation();
11399 onClickItem(item);
11400 }
11401 }
11402 };
11403 }
11404 function ItemClickWrapper({
11405 item,
11406 isItemClickable,
11407 onClickItem,
11408 renderItemLink,
11409 className,
11410 children,
11411 ...extraProps
11412 }) {
11413 if (!isItemClickable(item)) {
11414 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className, ...extraProps, children });
11415 }
11416 if (renderItemLink) {
11417 const renderedElement = renderItemLink({
11418 item,
11419 className: `${className} ${className}--clickable`,
11420 ...extraProps,
11421 children
11422 });
11423 return (0, import_element29.cloneElement)(renderedElement, {
11424 onClick: (event) => {
11425 event.stopPropagation();
11426 if (renderedElement.props.onClick) {
11427 renderedElement.props.onClick(event);
11428 }
11429 },
11430 onKeyDown: (event) => {
11431 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11432 event.stopPropagation();
11433 if (renderedElement.props.onKeyDown) {
11434 renderedElement.props.onKeyDown(event);
11435 }
11436 }
11437 }
11438 });
11439 }
11440 const clickProps = getClickableItemProps({
11441 item,
11442 isItemClickable,
11443 onClickItem,
11444 className
11445 });
11446 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { ...clickProps, ...extraProps, children });
11447 }
11448
11449 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
11450 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
11451 function ColumnPrimary({
11452 item,
11453 level,
11454 titleField,
11455 mediaField,
11456 descriptionField,
11457 onClickItem,
11458 renderItemLink,
11459 isItemClickable
11460 }) {
11461 return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
11462 mediaField && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
11463 ItemClickWrapper,
11464 {
11465 item,
11466 isItemClickable,
11467 onClickItem,
11468 renderItemLink,
11469 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
11470 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
11471 children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
11472 mediaField.render,
11473 {
11474 item,
11475 field: mediaField,
11476 config: { sizes: "32px" }
11477 }
11478 )
11479 }
11480 ),
11481 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
11482 Stack,
11483 {
11484 direction: "column",
11485 align: "flex-start",
11486 className: "dataviews-view-table__primary-column-content",
11487 children: [
11488 titleField && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
11489 ItemClickWrapper,
11490 {
11491 item,
11492 isItemClickable,
11493 onClickItem,
11494 renderItemLink,
11495 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
11496 children: [
11497 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("span", { className: "dataviews-view-table__level", children: [
11498 Array(level).fill("\u2014").join(" "),
11499 "\xA0"
11500 ] }),
11501 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(titleField.render, { item, field: titleField })
11502 ]
11503 }
11504 ),
11505 descriptionField && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
11506 descriptionField.render,
11507 {
11508 item,
11509 field: descriptionField
11510 }
11511 )
11512 ]
11513 }
11514 )
11515 ] });
11516 }
11517 var column_primary_default = ColumnPrimary;
11518
11519 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
11520 var import_element30 = __toESM(require_element(), 1);
11521 var import_i18n8 = __toESM(require_i18n(), 1);
11522 var isScrolledToEnd = (element) => {
11523 if ((0, import_i18n8.isRTL)()) {
11524 const scrollLeft = Math.abs(element.scrollLeft);
11525 return scrollLeft <= 1;
11526 }
11527 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
11528 };
11529 function useScrollState({
11530 scrollContainerRef,
11531 enabledHorizontal = false
11532 }) {
11533 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element30.useState)(false);
11534 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element30.useState)(false);
11535 const handleScroll = (0, import_element30.useCallback)(() => {
11536 const scrollContainer = scrollContainerRef.current;
11537 if (!scrollContainer) {
11538 return;
11539 }
11540 if (enabledHorizontal) {
11541 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
11542 }
11543 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
11544 }, [scrollContainerRef, enabledHorizontal]);
11545 (0, import_element30.useEffect)(() => {
11546 if (typeof window === "undefined" || !scrollContainerRef.current) {
11547 return () => {
11548 };
11549 }
11550 const scrollContainer = scrollContainerRef.current;
11551 handleScroll();
11552 scrollContainer.addEventListener("scroll", handleScroll);
11553 window.addEventListener("resize", handleScroll);
11554 return () => {
11555 scrollContainer.removeEventListener("scroll", handleScroll);
11556 window.removeEventListener("resize", handleScroll);
11557 };
11558 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
11559 return { isHorizontalScrollEnd, isVerticallyScrolled };
11560 }
11561
11562 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
11563 function getDataByGroup(data, groupByField) {
11564 return data.reduce((groups, item) => {
11565 const groupName = groupByField.getValue({ item });
11566 if (!groups.has(groupName)) {
11567 groups.set(groupName, []);
11568 }
11569 groups.get(groupName)?.push(item);
11570 return groups;
11571 }, /* @__PURE__ */ new Map());
11572 }
11573
11574 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
11575 var import_components5 = __toESM(require_components(), 1);
11576 var import_i18n9 = __toESM(require_i18n(), 1);
11577 var import_element31 = __toESM(require_element(), 1);
11578 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
11579 function FieldItem({
11580 field,
11581 isVisible: isVisible2,
11582 onToggleVisibility
11583 }) {
11584 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: [
11585 /* @__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 }) }),
11586 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
11587 ] }) });
11588 }
11589 function isDefined(item) {
11590 return !!item;
11591 }
11592 function PropertiesSection({
11593 showLabel = true
11594 }) {
11595 const { view, fields, onChangeView } = (0, import_element31.useContext)(dataviews_context_default);
11596 const regularFields = getHideableFields(view, fields);
11597 if (!regularFields?.length) {
11598 return null;
11599 }
11600 const titleField = fields.find((f2) => f2.id === view.titleField);
11601 const previewField = fields.find((f2) => f2.id === view.mediaField);
11602 const descriptionField = fields.find(
11603 (f2) => f2.id === view.descriptionField
11604 );
11605 const lockedFields = [
11606 {
11607 field: titleField,
11608 isVisibleFlag: "showTitle"
11609 },
11610 {
11611 field: previewField,
11612 isVisibleFlag: "showMedia"
11613 },
11614 {
11615 field: descriptionField,
11616 isVisibleFlag: "showDescription"
11617 }
11618 ].filter(({ field }) => isDefined(field));
11619 const visibleFieldIds = view.fields ?? [];
11620 const visibleRegularFieldsCount = regularFields.filter(
11621 (f2) => visibleFieldIds.includes(f2.id)
11622 ).length;
11623 const visibleLockedFields = lockedFields.filter(
11624 ({ isVisibleFlag }) => (
11625 // @ts-expect-error
11626 view[isVisibleFlag] ?? true
11627 )
11628 );
11629 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
11630 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
11631 return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
11632 showLabel && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_components5.BaseControl.VisualLabel, { children: (0, import_i18n9.__)("Properties") }),
11633 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11634 Stack,
11635 {
11636 direction: "column",
11637 className: "dataviews-view-config__properties",
11638 children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_components5.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
11639 lockedFields.map(({ field, isVisibleFlag }) => {
11640 const isVisible2 = view[isVisibleFlag] ?? true;
11641 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
11642 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11643 FieldItem,
11644 {
11645 field: fieldToRender,
11646 isVisible: isVisible2,
11647 onToggleVisibility: () => {
11648 onChangeView({
11649 ...view,
11650 [isVisibleFlag]: !isVisible2
11651 });
11652 }
11653 },
11654 field.id
11655 );
11656 }),
11657 regularFields.map((field) => {
11658 const isVisible2 = visibleFieldIds.includes(field.id);
11659 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
11660 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11661 FieldItem,
11662 {
11663 field: fieldToRender,
11664 isVisible: isVisible2,
11665 onToggleVisibility: () => {
11666 onChangeView({
11667 ...view,
11668 fields: isVisible2 ? visibleFieldIds.filter(
11669 (fieldId) => fieldId !== field.id
11670 ) : [...visibleFieldIds, field.id]
11671 });
11672 }
11673 },
11674 field.id
11675 );
11676 })
11677 ] })
11678 }
11679 )
11680 ] });
11681 }
11682
11683 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
11684 var import_element32 = __toESM(require_element(), 1);
11685 function useDelayedLoading(isLoading, options = { delay: 400 }) {
11686 const [showLoader, setShowLoader] = (0, import_element32.useState)(false);
11687 (0, import_element32.useEffect)(() => {
11688 if (!isLoading) {
11689 return;
11690 }
11691 const timeout = setTimeout(() => {
11692 setShowLoader(true);
11693 }, options.delay);
11694 return () => {
11695 clearTimeout(timeout);
11696 setShowLoader(false);
11697 };
11698 }, [isLoading, options.delay]);
11699 return showLoader;
11700 }
11701
11702 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
11703 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
11704 function getEffectiveAlign(explicitAlign, fieldType) {
11705 if (explicitAlign) {
11706 return explicitAlign;
11707 }
11708 if (fieldType === "integer" || fieldType === "number") {
11709 return "end";
11710 }
11711 return void 0;
11712 }
11713 function TableColumnField({
11714 item,
11715 fields,
11716 column,
11717 align
11718 }) {
11719 const field = fields.find((f2) => f2.id === column);
11720 if (!field) {
11721 return null;
11722 }
11723 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
11724 "dataviews-view-table__cell-align-end": align === "end",
11725 "dataviews-view-table__cell-align-center": align === "center"
11726 });
11727 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(field.render, { item, field }) });
11728 }
11729 function TableRow({
11730 hasBulkActions,
11731 item,
11732 level,
11733 actions,
11734 fields,
11735 id,
11736 view,
11737 titleField,
11738 mediaField,
11739 descriptionField,
11740 selection,
11741 getItemId,
11742 isItemClickable,
11743 onClickItem,
11744 renderItemLink,
11745 onChangeSelection,
11746 isActionsColumnSticky,
11747 posinset
11748 }) {
11749 const { paginationInfo } = (0, import_element33.useContext)(dataviews_context_default);
11750 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
11751 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
11752 const {
11753 showTitle = true,
11754 showMedia = true,
11755 showDescription = true,
11756 infiniteScrollEnabled
11757 } = view;
11758 const isTouchDeviceRef = (0, import_element33.useRef)(false);
11759 const columns = view.fields ?? [];
11760 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
11761 return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
11762 "tr",
11763 {
11764 className: clsx_default("dataviews-view-table__row", {
11765 "is-selected": hasPossibleBulkAction && isSelected2,
11766 "has-bulk-actions": hasPossibleBulkAction
11767 }),
11768 onTouchStart: () => {
11769 isTouchDeviceRef.current = true;
11770 },
11771 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
11772 "aria-posinset": posinset,
11773 role: infiniteScrollEnabled ? "article" : void 0,
11774 onMouseDown: (event) => {
11775 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11776 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
11777 event?.preventDefault();
11778 }
11779 },
11780 onClick: (event) => {
11781 if (!hasPossibleBulkAction) {
11782 return;
11783 }
11784 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11785 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") {
11786 onChangeSelection(
11787 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
11788 );
11789 }
11790 },
11791 children: [
11792 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)(
11793 DataViewsSelectionCheckbox,
11794 {
11795 item,
11796 selection,
11797 onChangeSelection,
11798 getItemId,
11799 titleField,
11800 disabled: !hasPossibleBulkAction
11801 }
11802 ) }) }),
11803 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11804 column_primary_default,
11805 {
11806 item,
11807 level,
11808 titleField: showTitle ? titleField : void 0,
11809 mediaField: showMedia ? mediaField : void 0,
11810 descriptionField: showDescription ? descriptionField : void 0,
11811 isItemClickable,
11812 onClickItem,
11813 renderItemLink
11814 }
11815 ) }),
11816 columns.map((column) => {
11817 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
11818 const field = fields.find((f2) => f2.id === column);
11819 const effectiveAlign = getEffectiveAlign(align, field?.type);
11820 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11821 "td",
11822 {
11823 style: {
11824 width,
11825 maxWidth,
11826 minWidth
11827 },
11828 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11829 TableColumnField,
11830 {
11831 fields,
11832 item,
11833 column,
11834 align: effectiveAlign
11835 }
11836 )
11837 },
11838 column
11839 );
11840 }),
11841 !!actions?.length && // Disable reason: we are not making the element interactive,
11842 // but preventing any click events from bubbling up to the
11843 // table row. This allows us to add a click handler to the row
11844 // itself (to toggle row selection) without erroneously
11845 // intercepting click events from ItemActions.
11846 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11847 "td",
11848 {
11849 className: clsx_default("dataviews-view-table__actions-column", {
11850 "dataviews-view-table__actions-column--sticky": true,
11851 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
11852 }),
11853 onClick: (e2) => e2.stopPropagation(),
11854 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(ItemActions, { item, actions })
11855 }
11856 )
11857 ]
11858 }
11859 );
11860 }
11861 function ViewTable({
11862 actions,
11863 data,
11864 fields,
11865 getItemId,
11866 getItemLevel,
11867 isLoading = false,
11868 onChangeView,
11869 onChangeSelection,
11870 selection,
11871 setOpenedFilter,
11872 onClickItem,
11873 isItemClickable,
11874 renderItemLink,
11875 view,
11876 className,
11877 empty
11878 }) {
11879 const { containerRef } = (0, import_element33.useContext)(dataviews_context_default);
11880 const isDelayedLoading = useDelayedLoading(isLoading);
11881 const headerMenuRefs = (0, import_element33.useRef)(/* @__PURE__ */ new Map());
11882 const headerMenuToFocusRef = (0, import_element33.useRef)(void 0);
11883 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element33.useState)();
11884 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element33.useState)(null);
11885 (0, import_element33.useEffect)(() => {
11886 if (headerMenuToFocusRef.current) {
11887 headerMenuToFocusRef.current.focus();
11888 headerMenuToFocusRef.current = void 0;
11889 }
11890 });
11891 const tableNoticeId = (0, import_element33.useId)();
11892 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
11893 scrollContainerRef: containerRef,
11894 enabledHorizontal: !!actions?.length
11895 });
11896 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
11897 if (nextHeaderMenuToFocus) {
11898 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
11899 setNextHeaderMenuToFocus(void 0);
11900 return;
11901 }
11902 const onHide = (field) => {
11903 const hidden = headerMenuRefs.current.get(field.id);
11904 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
11905 setNextHeaderMenuToFocus(fallback?.node);
11906 };
11907 const handleHeaderContextMenu = (event) => {
11908 event.preventDefault();
11909 event.stopPropagation();
11910 const virtualAnchor = {
11911 getBoundingClientRect: () => ({
11912 x: event.clientX,
11913 y: event.clientY,
11914 top: event.clientY,
11915 left: event.clientX,
11916 right: event.clientX,
11917 bottom: event.clientY,
11918 width: 0,
11919 height: 0,
11920 toJSON: () => ({})
11921 })
11922 };
11923 window.requestAnimationFrame(() => {
11924 setContextMenuAnchor(virtualAnchor);
11925 });
11926 };
11927 const hasData = !!data?.length;
11928 const titleField = fields.find((field) => field.id === view.titleField);
11929 const mediaField = fields.find((field) => field.id === view.mediaField);
11930 const descriptionField = fields.find(
11931 (field) => field.id === view.descriptionField
11932 );
11933 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
11934 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
11935 const { showTitle = true, showMedia = true, showDescription = true } = view;
11936 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
11937 const columns = view.fields ?? [];
11938 const headerMenuRef = (column, index2) => (node) => {
11939 if (node) {
11940 headerMenuRefs.current.set(column, {
11941 node,
11942 fallback: columns[index2 > 0 ? index2 - 1 : 1]
11943 });
11944 } else {
11945 headerMenuRefs.current.delete(column);
11946 }
11947 };
11948 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
11949 const isRtl = (0, import_i18n10.isRTL)();
11950 if (!hasData) {
11951 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11952 "div",
11953 {
11954 className: clsx_default("dataviews-no-results", {
11955 "is-refreshing": isDelayedLoading
11956 }),
11957 id: tableNoticeId,
11958 children: empty
11959 }
11960 );
11961 }
11962 return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(import_jsx_runtime54.Fragment, { children: [
11963 /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
11964 "table",
11965 {
11966 className: clsx_default("dataviews-view-table", className, {
11967 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
11968 view.layout.density
11969 ),
11970 "has-bulk-actions": hasBulkActions,
11971 "is-refreshing": !isInfiniteScroll && isDelayedLoading
11972 }),
11973 "aria-busy": isLoading,
11974 "aria-describedby": tableNoticeId,
11975 role: isInfiniteScroll ? "feed" : void 0,
11976 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
11977 children: [
11978 /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("colgroup", { children: [
11979 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
11980 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
11981 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11982 "col",
11983 {
11984 className: clsx_default(
11985 `dataviews-view-table__col-${column}`,
11986 {
11987 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1
11988 }
11989 )
11990 },
11991 `col-${column}`
11992 )),
11993 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("col", { className: "dataviews-view-table__col-actions" })
11994 ] }),
11995 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11996 import_components6.Popover,
11997 {
11998 anchor: contextMenuAnchor,
11999 onClose: () => setContextMenuAnchor(null),
12000 placement: "bottom-start",
12001 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(PropertiesSection, { showLabel: false })
12002 }
12003 ),
12004 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12005 "thead",
12006 {
12007 className: clsx_default({
12008 "dataviews-view-table__thead--stuck": isVerticallyScrolled
12009 }),
12010 onContextMenu: handleHeaderContextMenu,
12011 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("tr", { className: "dataviews-view-table__row", children: [
12012 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12013 "th",
12014 {
12015 className: "dataviews-view-table__checkbox-column",
12016 scope: "col",
12017 onContextMenu: handleHeaderContextMenu,
12018 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12019 BulkSelectionCheckbox,
12020 {
12021 selection,
12022 onChangeSelection,
12023 data,
12024 actions,
12025 getItemId
12026 }
12027 )
12028 }
12029 ),
12030 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12031 column_header_menu_default,
12032 {
12033 ref: headerMenuRef(
12034 titleField.id,
12035 0
12036 ),
12037 fieldId: titleField.id,
12038 view,
12039 fields,
12040 onChangeView,
12041 onHide,
12042 setOpenedFilter,
12043 canMove: false,
12044 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
12045 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
12046 }
12047 ) }),
12048 columns.map((column, index2) => {
12049 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
12050 const field = fields.find(
12051 (f2) => f2.id === column
12052 );
12053 const effectiveAlign = getEffectiveAlign(
12054 align,
12055 field?.type
12056 );
12057 const canInsertOrMove = view.layout?.enableMoving ?? true;
12058 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12059 "th",
12060 {
12061 style: {
12062 width,
12063 maxWidth,
12064 minWidth,
12065 textAlign: effectiveAlign
12066 },
12067 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
12068 scope: "col",
12069 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12070 column_header_menu_default,
12071 {
12072 ref: headerMenuRef(column, index2),
12073 fieldId: column,
12074 view,
12075 fields,
12076 onChangeView,
12077 onHide,
12078 setOpenedFilter,
12079 canMove: canInsertOrMove,
12080 canInsertLeft: canInsertOrMove,
12081 canInsertRight: canInsertOrMove
12082 }
12083 )
12084 },
12085 column
12086 );
12087 }),
12088 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12089 "th",
12090 {
12091 className: clsx_default(
12092 "dataviews-view-table__actions-column",
12093 {
12094 "dataviews-view-table__actions-column--sticky": true,
12095 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
12096 }
12097 ),
12098 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n10.__)("Actions") })
12099 }
12100 )
12101 ] })
12102 }
12103 ),
12104 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
12105 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("tbody", { children: [
12106 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12107 "td",
12108 {
12109 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
12110 className: "dataviews-view-table__group-header-cell",
12111 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n10.sprintf)(
12112 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12113 (0, import_i18n10.__)("%1$s: %2$s"),
12114 groupField.label,
12115 groupName
12116 )
12117 }
12118 ) }),
12119 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12120 TableRow,
12121 {
12122 item,
12123 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
12124 hasBulkActions,
12125 actions,
12126 fields,
12127 id: getItemId(item) || index2.toString(),
12128 view,
12129 titleField,
12130 mediaField,
12131 descriptionField,
12132 selection,
12133 getItemId,
12134 onChangeSelection,
12135 onClickItem,
12136 renderItemLink,
12137 isItemClickable,
12138 isActionsColumnSticky: !isHorizontalScrollEnd
12139 },
12140 getItemId(item)
12141 ))
12142 ] }, `group-${groupName}`)
12143 ) : /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("tbody", { children: hasData && data.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12144 TableRow,
12145 {
12146 item,
12147 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
12148 hasBulkActions,
12149 actions,
12150 fields,
12151 id: getItemId(item) || index2.toString(),
12152 view,
12153 titleField,
12154 mediaField,
12155 descriptionField,
12156 selection,
12157 getItemId,
12158 onChangeSelection,
12159 onClickItem,
12160 renderItemLink,
12161 isItemClickable,
12162 isActionsColumnSticky: !isHorizontalScrollEnd,
12163 posinset: isInfiniteScroll ? index2 + 1 : void 0
12164 },
12165 getItemId(item)
12166 )) })
12167 ]
12168 }
12169 ),
12170 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, {}) }) })
12171 ] });
12172 }
12173 var table_default = ViewTable;
12174
12175 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12176 var import_components9 = __toESM(require_components(), 1);
12177 var import_i18n13 = __toESM(require_i18n(), 1);
12178
12179 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
12180 var import_components8 = __toESM(require_components(), 1);
12181 var import_i18n12 = __toESM(require_i18n(), 1);
12182 var import_compose3 = __toESM(require_compose(), 1);
12183 var import_keycodes2 = __toESM(require_keycodes(), 1);
12184 var import_element37 = __toESM(require_element(), 1);
12185
12186 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
12187 var import_components7 = __toESM(require_components(), 1);
12188 var import_i18n11 = __toESM(require_i18n(), 1);
12189 var import_element34 = __toESM(require_element(), 1);
12190 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
12191 var imageSizes = [
12192 {
12193 value: 120,
12194 breakpoint: 1
12195 },
12196 {
12197 value: 170,
12198 breakpoint: 1
12199 },
12200 {
12201 value: 230,
12202 breakpoint: 1
12203 },
12204 {
12205 value: 290,
12206 breakpoint: 1112
12207 // at minimum image width, 4 images display at this container size
12208 },
12209 {
12210 value: 350,
12211 breakpoint: 1636
12212 // at minimum image width, 6 images display at this container size
12213 },
12214 {
12215 value: 430,
12216 breakpoint: 588
12217 // at minimum image width, 2 images display at this container size
12218 }
12219 ];
12220 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
12221 function useGridColumns() {
12222 const context = (0, import_element34.useContext)(dataviews_context_default);
12223 const view = context.view;
12224 return (0, import_element34.useMemo)(() => {
12225 const containerWidth = context.containerWidth;
12226 const gap = 32;
12227 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
12228 const columns = Math.floor(
12229 (containerWidth + gap) / (previewSize + gap)
12230 );
12231 return Math.max(1, columns);
12232 }, [context.containerWidth, view.layout?.previewSize]);
12233 }
12234
12235 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
12236 var import_element35 = __toESM(require_element(), 1);
12237 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
12238 var GridItems = (0, import_element35.forwardRef)(({ className, previewSize, ...props }, ref) => {
12239 return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
12240 "div",
12241 {
12242 ref,
12243 className: clsx_default("dataviews-view-grid-items", className),
12244 style: {
12245 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
12246 },
12247 ...props
12248 }
12249 );
12250 });
12251
12252 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
12253 var import_element36 = __toESM(require_element(), 1);
12254 function useIntersectionObserver(elementRef, posinset) {
12255 const { intersectionObserver } = (0, import_element36.useContext)(dataviews_context_default);
12256 (0, import_element36.useEffect)(() => {
12257 const element = elementRef.current;
12258 if (!element || posinset === void 0 || !intersectionObserver) {
12259 return;
12260 }
12261 intersectionObserver.observe(element);
12262 return () => {
12263 intersectionObserver.unobserve(element);
12264 };
12265 }, [elementRef, intersectionObserver, posinset]);
12266 }
12267 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
12268 const hasData = !!data?.length;
12269 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
12270 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
12271 }
12272
12273 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
12274 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
12275 var { Badge: WCBadge } = unlock2(import_components8.privateApis);
12276 function chunk(array, size4) {
12277 const chunks = [];
12278 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) {
12279 chunks.push(array.slice(i2, i2 + size4));
12280 }
12281 return chunks;
12282 }
12283 var GridItem = (0, import_element37.forwardRef)(
12284 function GridItem2({
12285 view,
12286 selection,
12287 onChangeSelection,
12288 onClickItem,
12289 isItemClickable,
12290 renderItemLink,
12291 getItemId,
12292 item,
12293 actions,
12294 mediaField,
12295 titleField,
12296 descriptionField,
12297 regularFields,
12298 badgeFields,
12299 hasBulkActions,
12300 config,
12301 posinset,
12302 setsize,
12303 ...props
12304 }, forwardedRef) {
12305 const {
12306 showTitle = true,
12307 showMedia = true,
12308 showDescription = true
12309 } = view;
12310 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
12311 const id = getItemId(item);
12312 const elementRef = (0, import_element37.useRef)(null);
12313 const setRefs = (0, import_element37.useCallback)(
12314 (node) => {
12315 elementRef.current = node;
12316 if (typeof forwardedRef === "function") {
12317 forwardedRef(node);
12318 } else if (forwardedRef) {
12319 forwardedRef.current = node;
12320 }
12321 },
12322 [forwardedRef]
12323 );
12324 useIntersectionObserver(elementRef, posinset);
12325 const instanceId = (0, import_compose3.useInstanceId)(GridItem2);
12326 const isSelected2 = selection.includes(id);
12327 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
12328 const rendersMediaField = showMedia && mediaField?.render;
12329 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12330 mediaField.render,
12331 {
12332 item,
12333 field: mediaField,
12334 config
12335 }
12336 ) : mediaPlaceholder;
12337 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(titleField.render, { item, field: titleField }) : null;
12338 let mediaA11yProps;
12339 let titleA11yProps;
12340 if (isItemClickable(item) && onClickItem) {
12341 if (renderedTitleField) {
12342 mediaA11yProps = {
12343 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
12344 };
12345 titleA11yProps = {
12346 id: `dataviews-view-grid__title-field-${instanceId}`
12347 };
12348 } else {
12349 mediaA11yProps = {
12350 "aria-label": (0, import_i18n12.__)("Navigate to item")
12351 };
12352 }
12353 }
12354 return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
12355 Stack,
12356 {
12357 direction: "column",
12358 ...props,
12359 ref: setRefs,
12360 "aria-setsize": setsize,
12361 "aria-posinset": posinset,
12362 className: clsx_default(
12363 props.className,
12364 "dataviews-view-grid__row__gridcell",
12365 "dataviews-view-grid__card",
12366 {
12367 "is-selected": hasBulkAction && isSelected2
12368 }
12369 ),
12370 onClickCapture: (event) => {
12371 props.onClickCapture?.(event);
12372 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) {
12373 event.stopPropagation();
12374 event.preventDefault();
12375 if (!hasBulkAction) {
12376 return;
12377 }
12378 onChangeSelection(
12379 isSelected2 ? selection.filter(
12380 (itemId) => id !== itemId
12381 ) : [...selection, id]
12382 );
12383 }
12384 },
12385 children: [
12386 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12387 ItemClickWrapper,
12388 {
12389 item,
12390 isItemClickable,
12391 onClickItem,
12392 renderItemLink,
12393 className: clsx_default("dataviews-view-grid__media", {
12394 "dataviews-view-grid__media--placeholder": !rendersMediaField
12395 }),
12396 ...mediaA11yProps,
12397 children: renderedMediaField
12398 }
12399 ),
12400 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12401 DataViewsSelectionCheckbox,
12402 {
12403 item,
12404 selection,
12405 onChangeSelection,
12406 getItemId,
12407 titleField,
12408 disabled: !hasBulkAction
12409 }
12410 ),
12411 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12412 ItemActions,
12413 {
12414 item,
12415 actions,
12416 isCompact: true
12417 }
12418 ) }),
12419 showTitle && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12420 ItemClickWrapper,
12421 {
12422 item,
12423 isItemClickable,
12424 onClickItem,
12425 renderItemLink,
12426 className: "dataviews-view-grid__title-field dataviews-title-field",
12427 ...titleA11yProps,
12428 title: titleField?.getValueFormatted({
12429 item,
12430 field: titleField
12431 }) || void 0,
12432 children: renderedTitleField
12433 }
12434 ) }),
12435 /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(Stack, { direction: "column", gap: "xs", children: [
12436 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12437 descriptionField.render,
12438 {
12439 item,
12440 field: descriptionField
12441 }
12442 ),
12443 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12444 Stack,
12445 {
12446 direction: "row",
12447 className: "dataviews-view-grid__badge-fields",
12448 gap: "sm",
12449 wrap: "wrap",
12450 align: "top",
12451 justify: "flex-start",
12452 children: badgeFields.map((field) => {
12453 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12454 WCBadge,
12455 {
12456 className: "dataviews-view-grid__field-value",
12457 children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12458 field.render,
12459 {
12460 item,
12461 field
12462 }
12463 )
12464 },
12465 field.id
12466 );
12467 })
12468 }
12469 ),
12470 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12471 Stack,
12472 {
12473 direction: "column",
12474 className: "dataviews-view-grid__fields",
12475 gap: "xs",
12476 children: regularFields.map((field) => {
12477 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12478 import_components8.Flex,
12479 {
12480 className: "dataviews-view-grid__field",
12481 gap: 1,
12482 justify: "flex-start",
12483 expanded: true,
12484 style: { height: "auto" },
12485 direction: "row",
12486 children: /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_jsx_runtime57.Fragment, { children: [
12487 /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(tooltip_exports.Root, { children: [
12488 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12489 tooltip_exports.Trigger,
12490 {
12491 render: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_components8.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header })
12492 }
12493 ),
12494 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(tooltip_exports.Popup, { children: field.label })
12495 ] }),
12496 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12497 import_components8.FlexItem,
12498 {
12499 className: "dataviews-view-grid__field-value",
12500 style: { maxHeight: "none" },
12501 children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12502 field.render,
12503 {
12504 item,
12505 field
12506 }
12507 )
12508 }
12509 )
12510 ] })
12511 },
12512 field.id
12513 );
12514 })
12515 }
12516 )
12517 ] })
12518 ]
12519 }
12520 );
12521 }
12522 );
12523 function CompositeGrid({
12524 data,
12525 isInfiniteScroll,
12526 className,
12527 inert,
12528 isLoading,
12529 view,
12530 fields,
12531 selection,
12532 onChangeSelection,
12533 onClickItem,
12534 isItemClickable,
12535 renderItemLink,
12536 getItemId,
12537 actions
12538 }) {
12539 const { paginationInfo, resizeObserverRef } = (0, import_element37.useContext)(dataviews_context_default);
12540 const gridColumns = useGridColumns();
12541 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
12542 const titleField = fields.find(
12543 (field) => field.id === view?.titleField
12544 );
12545 const mediaField = fields.find(
12546 (field) => field.id === view?.mediaField
12547 );
12548 const descriptionField = fields.find(
12549 (field) => field.id === view?.descriptionField
12550 );
12551 const otherFields = view.fields ?? [];
12552 const { regularFields, badgeFields } = otherFields.reduce(
12553 (accumulator, fieldId) => {
12554 const field = fields.find((f2) => f2.id === fieldId);
12555 if (!field) {
12556 return accumulator;
12557 }
12558 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
12559 accumulator[key].push(field);
12560 return accumulator;
12561 },
12562 { regularFields: [], badgeFields: [] }
12563 );
12564 const size4 = "900px";
12565 const totalRows = Math.ceil(data.length / gridColumns);
12566 const placeholdersNeeded = usePlaceholdersNeeded(
12567 data,
12568 isInfiniteScroll,
12569 gridColumns
12570 );
12571 return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_jsx_runtime57.Fragment, {
12572 // Render infinite scroll layout (no rows, feed semantics)
12573 children: [
12574 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
12575 import_components8.Composite,
12576 {
12577 render: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12578 GridItems,
12579 {
12580 className: clsx_default(
12581 "dataviews-view-grid-infinite-scroll",
12582 className,
12583 {
12584 [`has-${view.layout?.density}-density`]: view.layout?.density && [
12585 "compact",
12586 "comfortable"
12587 ].includes(view.layout.density)
12588 }
12589 ),
12590 previewSize: view.layout?.previewSize,
12591 "aria-busy": isLoading,
12592 ref: resizeObserverRef
12593 }
12594 ),
12595 role: "feed",
12596 focusWrap: true,
12597 inert,
12598 children: [
12599 Array.from({ length: placeholdersNeeded }).map(
12600 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12601 import_components8.Composite.Item,
12602 {
12603 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12604 Stack,
12605 {
12606 ...props,
12607 direction: "column",
12608 role: "article",
12609 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
12610 }
12611 ),
12612 "aria-hidden": true,
12613 tabIndex: -1
12614 },
12615 `placeholder-${index2}`
12616 )
12617 ),
12618 data.map((item) => {
12619 const itemId = getItemId(item);
12620 const stablePosition = item.position;
12621 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12622 import_components8.Composite.Item,
12623 {
12624 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12625 GridItem,
12626 {
12627 ...props,
12628 id: itemId,
12629 role: "article",
12630 view,
12631 selection,
12632 onChangeSelection,
12633 onClickItem,
12634 isItemClickable,
12635 renderItemLink,
12636 getItemId,
12637 item,
12638 actions,
12639 mediaField,
12640 titleField,
12641 descriptionField,
12642 regularFields,
12643 badgeFields,
12644 hasBulkActions,
12645 posinset: stablePosition,
12646 setsize: paginationInfo.totalItems,
12647 config: {
12648 sizes: size4
12649 }
12650 }
12651 )
12652 },
12653 itemId
12654 );
12655 })
12656 ]
12657 }
12658 ),
12659 // Render standard grid layout (with rows, grid semantics)
12660 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12661 import_components8.Composite,
12662 {
12663 role: "grid",
12664 className: clsx_default("dataviews-view-grid", className, {
12665 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12666 view.layout.density
12667 )
12668 }),
12669 focusWrap: true,
12670 "aria-busy": isLoading,
12671 "aria-rowcount": totalRows,
12672 ref: resizeObserverRef,
12673 inert,
12674 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12675 import_components8.Composite.Row,
12676 {
12677 render: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12678 "div",
12679 {
12680 role: "row",
12681 "aria-rowindex": i2 + 1,
12682 "aria-label": (0, import_i18n12.sprintf)(
12683 /* translators: %d: The row number in the grid */
12684 (0, import_i18n12.__)("Row %d"),
12685 i2 + 1
12686 ),
12687 className: "dataviews-view-grid__row",
12688 style: {
12689 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
12690 }
12691 }
12692 ),
12693 children: row.map((item) => {
12694 const itemId = getItemId(item);
12695 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12696 import_components8.Composite.Item,
12697 {
12698 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12699 GridItem,
12700 {
12701 ...props,
12702 id: itemId,
12703 role: "gridcell",
12704 view,
12705 selection,
12706 onChangeSelection,
12707 onClickItem,
12708 isItemClickable,
12709 renderItemLink,
12710 getItemId,
12711 item,
12712 actions,
12713 mediaField,
12714 titleField,
12715 descriptionField,
12716 regularFields,
12717 badgeFields,
12718 hasBulkActions,
12719 config: {
12720 sizes: size4
12721 }
12722 }
12723 )
12724 },
12725 itemId
12726 );
12727 })
12728 },
12729 i2
12730 ))
12731 }
12732 )
12733 ]
12734 });
12735 }
12736
12737 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12738 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
12739 function ViewGrid({
12740 actions,
12741 data,
12742 fields,
12743 getItemId,
12744 isLoading,
12745 onChangeSelection,
12746 onClickItem,
12747 isItemClickable,
12748 renderItemLink,
12749 selection,
12750 view,
12751 className,
12752 empty
12753 }) {
12754 const isDelayedLoading = useDelayedLoading(!!isLoading);
12755 const hasData = !!data?.length;
12756 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
12757 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
12758 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12759 if (!hasData) {
12760 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12761 "div",
12762 {
12763 className: clsx_default("dataviews-no-results", {
12764 "is-refreshing": isDelayedLoading
12765 }),
12766 children: empty
12767 }
12768 );
12769 }
12770 const gridProps = {
12771 className: clsx_default(className, {
12772 "is-refreshing": !isInfiniteScroll && isDelayedLoading
12773 }),
12774 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
12775 isLoading,
12776 view,
12777 fields,
12778 selection,
12779 onChangeSelection,
12780 onClickItem,
12781 isItemClickable,
12782 renderItemLink,
12783 getItemId,
12784 actions
12785 };
12786 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, {
12787 // Render multiple groups.
12788 children: [
12789 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
12790 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
12791 Stack,
12792 {
12793 direction: "column",
12794 gap: "sm",
12795 children: [
12796 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n13.sprintf)(
12797 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12798 (0, import_i18n13.__)("%1$s: %2$s"),
12799 groupField.label,
12800 groupName
12801 ) }),
12802 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12803 CompositeGrid,
12804 {
12805 ...gridProps,
12806 data: groupItems,
12807 isInfiniteScroll: false
12808 }
12809 )
12810 ]
12811 },
12812 groupName
12813 )
12814 ) }),
12815 // Render a single grid with all data.
12816 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12817 CompositeGrid,
12818 {
12819 ...gridProps,
12820 data,
12821 isInfiniteScroll: !!isInfiniteScroll
12822 }
12823 ),
12824 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components9.Spinner, {}) })
12825 ]
12826 });
12827 }
12828 var grid_default = ViewGrid;
12829
12830 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
12831 var import_compose4 = __toESM(require_compose(), 1);
12832 var import_components10 = __toESM(require_components(), 1);
12833 var import_element38 = __toESM(require_element(), 1);
12834 var import_i18n14 = __toESM(require_i18n(), 1);
12835 var import_data3 = __toESM(require_data(), 1);
12836 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
12837 var { Menu: Menu3 } = unlock2(import_components10.privateApis);
12838 function generateItemWrapperCompositeId(idPrefix) {
12839 return `${idPrefix}-item-wrapper`;
12840 }
12841 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
12842 return `${idPrefix}-primary-action-${primaryActionId}`;
12843 }
12844 function generateDropdownTriggerCompositeId(idPrefix) {
12845 return `${idPrefix}-dropdown`;
12846 }
12847 function PrimaryActionGridCell({
12848 idPrefix,
12849 primaryAction,
12850 item
12851 }) {
12852 const registry = (0, import_data3.useRegistry)();
12853 const [isModalOpen, setIsModalOpen] = (0, import_element38.useState)(false);
12854 const compositeItemId = generatePrimaryActionCompositeId(
12855 idPrefix,
12856 primaryAction.id
12857 );
12858 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
12859 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12860 import_components10.Composite.Item,
12861 {
12862 id: compositeItemId,
12863 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12864 import_components10.Button,
12865 {
12866 disabled: !!primaryAction.disabled,
12867 accessibleWhenDisabled: true,
12868 text: label,
12869 size: "small",
12870 onClick: () => setIsModalOpen(true)
12871 }
12872 ),
12873 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12874 ActionModal,
12875 {
12876 action: primaryAction,
12877 items: [item],
12878 closeModal: () => setIsModalOpen(false)
12879 }
12880 )
12881 }
12882 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12883 import_components10.Composite.Item,
12884 {
12885 id: compositeItemId,
12886 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12887 import_components10.Button,
12888 {
12889 disabled: !!primaryAction.disabled,
12890 accessibleWhenDisabled: true,
12891 size: "small",
12892 onClick: () => {
12893 primaryAction.callback([item], { registry });
12894 },
12895 children: label
12896 }
12897 )
12898 }
12899 ) }, primaryAction.id);
12900 }
12901 function ListItem({
12902 view,
12903 actions,
12904 idPrefix,
12905 isSelected: isSelected2,
12906 item,
12907 titleField,
12908 mediaField,
12909 descriptionField,
12910 onSelect,
12911 otherFields,
12912 onDropdownTriggerKeyDown,
12913 posinset
12914 }) {
12915 const {
12916 showTitle = true,
12917 showMedia = true,
12918 showDescription = true,
12919 infiniteScrollEnabled
12920 } = view;
12921 const itemRef = (0, import_element38.useRef)(null);
12922 const labelId = `${idPrefix}-label`;
12923 const descriptionId = `${idPrefix}-description`;
12924 const registry = (0, import_data3.useRegistry)();
12925 const [isHovered, setIsHovered] = (0, import_element38.useState)(false);
12926 const [activeModalAction, setActiveModalAction] = (0, import_element38.useState)(
12927 null
12928 );
12929 const handleHover = ({ type }) => {
12930 const isHover = type === "mouseenter";
12931 setIsHovered(isHover);
12932 };
12933 const { paginationInfo } = (0, import_element38.useContext)(dataviews_context_default);
12934 (0, import_element38.useEffect)(() => {
12935 if (isSelected2) {
12936 itemRef.current?.scrollIntoView({
12937 behavior: "auto",
12938 block: "nearest",
12939 inline: "nearest"
12940 });
12941 }
12942 }, [isSelected2]);
12943 const { primaryAction, eligibleActions } = (0, import_element38.useMemo)(() => {
12944 const _eligibleActions = actions.filter(
12945 (action) => !action.isEligible || action.isEligible(item)
12946 );
12947 const _primaryActions = _eligibleActions.filter(
12948 (action) => action.isPrimary
12949 );
12950 return {
12951 primaryAction: _primaryActions[0],
12952 eligibleActions: _eligibleActions
12953 };
12954 }, [actions, item]);
12955 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
12956 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)(
12957 mediaField.render,
12958 {
12959 item,
12960 field: mediaField,
12961 config: { sizes: "52px" }
12962 }
12963 ) }) : null;
12964 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(titleField.render, { item, field: titleField }) : null;
12965 const renderDescription = showDescription && descriptionField?.render;
12966 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
12967 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
12968 Stack,
12969 {
12970 direction: "row",
12971 gap: "md",
12972 className: "dataviews-view-list__item-actions",
12973 children: [
12974 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12975 PrimaryActionGridCell,
12976 {
12977 idPrefix,
12978 primaryAction,
12979 item
12980 }
12981 ),
12982 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("div", { role: "gridcell", children: [
12983 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(Menu3, { placement: "bottom-end", children: [
12984 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12985 Menu3.TriggerButton,
12986 {
12987 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12988 import_components10.Composite.Item,
12989 {
12990 id: generateDropdownTriggerCompositeId(
12991 idPrefix
12992 ),
12993 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12994 import_components10.Button,
12995 {
12996 size: "small",
12997 icon: more_vertical_default,
12998 label: (0, import_i18n14.__)("Actions"),
12999 accessibleWhenDisabled: true,
13000 disabled: !actions.length,
13001 onKeyDown: onDropdownTriggerKeyDown
13002 }
13003 )
13004 }
13005 )
13006 }
13007 ),
13008 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13009 ActionsMenuGroup,
13010 {
13011 actions: eligibleActions,
13012 item,
13013 registry,
13014 setActiveModalAction
13015 }
13016 ) })
13017 ] }),
13018 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13019 ActionModal,
13020 {
13021 action: activeModalAction,
13022 items: [item],
13023 closeModal: () => setActiveModalAction(null)
13024 }
13025 )
13026 ] })
13027 ]
13028 }
13029 );
13030 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13031 import_components10.Composite.Row,
13032 {
13033 ref: itemRef,
13034 render: (
13035 /* aria-posinset breaks Composite.Row if passed to it directly. */
13036 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13037 "div",
13038 {
13039 "aria-posinset": posinset,
13040 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
13041 }
13042 )
13043 ),
13044 role: infiniteScrollEnabled ? "article" : "row",
13045 className: clsx_default({
13046 "is-selected": isSelected2,
13047 "is-hovered": isHovered
13048 }),
13049 onMouseEnter: handleHover,
13050 onMouseLeave: handleHover,
13051 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13052 Stack,
13053 {
13054 direction: "row",
13055 className: "dataviews-view-list__item-wrapper",
13056 children: [
13057 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13058 import_components10.Composite.Item,
13059 {
13060 id: generateItemWrapperCompositeId(idPrefix),
13061 "aria-pressed": isSelected2,
13062 "aria-labelledby": labelId,
13063 "aria-describedby": descriptionId,
13064 className: "dataviews-view-list__item",
13065 onClick: () => onSelect(item)
13066 }
13067 ) }),
13068 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13069 Stack,
13070 {
13071 direction: "row",
13072 gap: "md",
13073 justify: "start",
13074 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
13075 style: { flex: 1, minWidth: 0 },
13076 children: [
13077 renderedMediaField,
13078 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13079 Stack,
13080 {
13081 direction: "column",
13082 gap: "xs",
13083 className: "dataviews-view-list__field-wrapper",
13084 children: [
13085 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(Stack, { direction: "row", align: "center", children: [
13086 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13087 "div",
13088 {
13089 className: "dataviews-title-field dataviews-view-list__title-field",
13090 id: labelId,
13091 children: renderedTitleField
13092 }
13093 ),
13094 usedActions
13095 ] }),
13096 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13097 descriptionField.render,
13098 {
13099 item,
13100 field: descriptionField
13101 }
13102 ) }),
13103 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13104 "div",
13105 {
13106 className: "dataviews-view-list__fields",
13107 id: descriptionId,
13108 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13109 "div",
13110 {
13111 className: "dataviews-view-list__field",
13112 children: [
13113 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13114 VisuallyHidden,
13115 {
13116 className: "dataviews-view-list__field-label",
13117 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", {}),
13118 children: field.label
13119 }
13120 ),
13121 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13122 field.render,
13123 {
13124 item,
13125 field
13126 }
13127 ) })
13128 ]
13129 },
13130 field.id
13131 ))
13132 }
13133 )
13134 ]
13135 }
13136 )
13137 ]
13138 }
13139 )
13140 ]
13141 }
13142 )
13143 }
13144 );
13145 }
13146 function isDefined2(item) {
13147 return !!item;
13148 }
13149 function ViewList(props) {
13150 const {
13151 actions,
13152 data,
13153 fields,
13154 getItemId,
13155 isLoading,
13156 onChangeSelection,
13157 selection,
13158 view,
13159 className,
13160 empty
13161 } = props;
13162 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list");
13163 const isDelayedLoading = useDelayedLoading(!!isLoading);
13164 const selectedItem = data?.findLast(
13165 (item) => selection.includes(getItemId(item))
13166 );
13167 const titleField = fields.find((field) => field.id === view.titleField);
13168 const mediaField = fields.find((field) => field.id === view.mediaField);
13169 const descriptionField = fields.find(
13170 (field) => field.id === view.descriptionField
13171 );
13172 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
13173 const onSelect = (item) => onChangeSelection([getItemId(item)]);
13174 const generateCompositeItemIdPrefix = (0, import_element38.useCallback)(
13175 (item) => `${baseId}-${getItemId(item)}`,
13176 [baseId, getItemId]
13177 );
13178 const isActiveCompositeItem = (0, import_element38.useCallback)(
13179 (item, idToCheck) => {
13180 return idToCheck.startsWith(
13181 generateCompositeItemIdPrefix(item)
13182 );
13183 },
13184 [generateCompositeItemIdPrefix]
13185 );
13186 const [activeCompositeId, setActiveCompositeId] = (0, import_element38.useState)(void 0);
13187 const compositeRef = (0, import_element38.useRef)(null);
13188 (0, import_element38.useEffect)(() => {
13189 if (selectedItem) {
13190 setActiveCompositeId(
13191 generateItemWrapperCompositeId(
13192 generateCompositeItemIdPrefix(selectedItem)
13193 )
13194 );
13195 }
13196 }, [selectedItem, generateCompositeItemIdPrefix]);
13197 const activeItemIndex = data.findIndex(
13198 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
13199 );
13200 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex);
13201 const isActiveIdInList = activeItemIndex !== -1;
13202 const selectCompositeItem = (0, import_element38.useCallback)(
13203 (targetIndex, generateCompositeId) => {
13204 const clampedIndex = Math.min(
13205 data.length - 1,
13206 Math.max(0, targetIndex)
13207 );
13208 if (!data[clampedIndex]) {
13209 return;
13210 }
13211 const itemIdPrefix = generateCompositeItemIdPrefix(
13212 data[clampedIndex]
13213 );
13214 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
13215 setActiveCompositeId(targetCompositeItemId);
13216 if (compositeRef.current?.contains(
13217 compositeRef.current.ownerDocument.activeElement
13218 )) {
13219 document.getElementById(targetCompositeItemId)?.focus();
13220 }
13221 },
13222 [data, generateCompositeItemIdPrefix]
13223 );
13224 (0, import_element38.useEffect)(() => {
13225 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
13226 if (!isActiveIdInList && wasActiveIdInList) {
13227 selectCompositeItem(
13228 previousActiveItemIndex,
13229 generateItemWrapperCompositeId
13230 );
13231 }
13232 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
13233 const onDropdownTriggerKeyDown = (0, import_element38.useCallback)(
13234 (event) => {
13235 if (event.key === "ArrowDown") {
13236 event.preventDefault();
13237 selectCompositeItem(
13238 activeItemIndex + 1,
13239 generateDropdownTriggerCompositeId
13240 );
13241 }
13242 if (event.key === "ArrowUp") {
13243 event.preventDefault();
13244 selectCompositeItem(
13245 activeItemIndex - 1,
13246 generateDropdownTriggerCompositeId
13247 );
13248 }
13249 },
13250 [selectCompositeItem, activeItemIndex]
13251 );
13252 const hasData = !!data?.length;
13253 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13254 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13255 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13256 if (!hasData) {
13257 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13258 "div",
13259 {
13260 className: clsx_default("dataviews-no-results", {
13261 "is-refreshing": isDelayedLoading
13262 }),
13263 children: empty
13264 }
13265 );
13266 }
13267 if (hasData && groupField && dataByGroup) {
13268 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13269 import_components10.Composite,
13270 {
13271 ref: compositeRef,
13272 id: `${baseId}`,
13273 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", {}),
13274 className: "dataviews-view-list__group",
13275 role: "grid",
13276 activeId: activeCompositeId,
13277 setActiveId: setActiveCompositeId,
13278 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13279 Stack,
13280 {
13281 direction: "column",
13282 gap: "lg",
13283 className: clsx_default("dataviews-view-list", className),
13284 children: Array.from(dataByGroup.entries()).map(
13285 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13286 Stack,
13287 {
13288 direction: "column",
13289 gap: "sm",
13290 children: [
13291 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n14.sprintf)(
13292 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
13293 (0, import_i18n14.__)("%1$s: %2$s"),
13294 groupField.label,
13295 groupName
13296 ) }),
13297 groupItems.map((item) => {
13298 const id = generateCompositeItemIdPrefix(item);
13299 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13300 ListItem,
13301 {
13302 view,
13303 idPrefix: id,
13304 actions,
13305 item,
13306 isSelected: item === selectedItem,
13307 onSelect,
13308 mediaField,
13309 titleField,
13310 descriptionField,
13311 otherFields,
13312 onDropdownTriggerKeyDown
13313 },
13314 id
13315 );
13316 })
13317 ]
13318 },
13319 groupName
13320 )
13321 )
13322 }
13323 )
13324 }
13325 );
13326 }
13327 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, { children: [
13328 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13329 import_components10.Composite,
13330 {
13331 ref: compositeRef,
13332 id: baseId,
13333 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", {}),
13334 className: clsx_default("dataviews-view-list", className, {
13335 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
13336 view.layout.density
13337 ),
13338 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13339 }),
13340 role: view.infiniteScrollEnabled ? "feed" : "grid",
13341 activeId: activeCompositeId,
13342 setActiveId: setActiveCompositeId,
13343 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
13344 children: data.map((item, index2) => {
13345 const id = generateCompositeItemIdPrefix(item);
13346 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13347 ListItem,
13348 {
13349 view,
13350 idPrefix: id,
13351 actions,
13352 item,
13353 isSelected: item === selectedItem,
13354 onSelect,
13355 mediaField,
13356 titleField,
13357 descriptionField,
13358 otherFields,
13359 onDropdownTriggerKeyDown,
13360 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13361 },
13362 id
13363 );
13364 })
13365 }
13366 ),
13367 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components10.Spinner, {}) })
13368 ] });
13369 }
13370
13371 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13372 var import_components11 = __toESM(require_components(), 1);
13373
13374 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
13375 var import_i18n15 = __toESM(require_i18n(), 1);
13376 var import_element39 = __toESM(require_element(), 1);
13377 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
13378 function ActivityGroup({
13379 groupName,
13380 groupData,
13381 groupField,
13382 showLabel = true,
13383 children
13384 }) {
13385 const groupHeader = showLabel ? (0, import_element39.createInterpolateElement)(
13386 // translators: %s: The label of the field e.g. "Status".
13387 (0, import_i18n15.sprintf)((0, import_i18n15.__)("%s: <groupName />"), groupField.label).trim(),
13388 {
13389 groupName: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13390 groupField.render,
13391 {
13392 item: groupData[0],
13393 field: groupField
13394 }
13395 )
13396 }
13397 ) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(groupField.render, { item: groupData[0], field: groupField });
13398 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13399 Stack,
13400 {
13401 direction: "column",
13402 className: "dataviews-view-activity__group",
13403 children: [
13404 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
13405 children
13406 ]
13407 },
13408 groupName
13409 );
13410 }
13411
13412 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
13413 var import_element40 = __toESM(require_element(), 1);
13414 var import_data4 = __toESM(require_data(), 1);
13415 var import_compose5 = __toESM(require_compose(), 1);
13416 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
13417 function ActivityItem(props) {
13418 const {
13419 view,
13420 actions,
13421 item,
13422 titleField,
13423 mediaField,
13424 descriptionField,
13425 otherFields,
13426 posinset,
13427 onClickItem,
13428 renderItemLink,
13429 isItemClickable
13430 } = props;
13431 const {
13432 showTitle = true,
13433 showMedia = true,
13434 showDescription = true,
13435 infiniteScrollEnabled
13436 } = view;
13437 const itemRef = (0, import_element40.useRef)(null);
13438 const registry = (0, import_data4.useRegistry)();
13439 const { paginationInfo } = (0, import_element40.useContext)(dataviews_context_default);
13440 const { primaryActions, eligibleActions } = (0, import_element40.useMemo)(() => {
13441 const _eligibleActions = actions.filter(
13442 (action) => !action.isEligible || action.isEligible(item)
13443 );
13444 const _primaryActions = _eligibleActions.filter(
13445 (action) => action.isPrimary
13446 );
13447 return {
13448 primaryActions: _primaryActions,
13449 eligibleActions: _eligibleActions
13450 };
13451 }, [actions, item]);
13452 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
13453 const density = view.layout?.density ?? "balanced";
13454 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13455 mediaField.render,
13456 {
13457 item,
13458 field: mediaField,
13459 config: {
13460 sizes: density === "comfortable" ? "32px" : "24px"
13461 }
13462 }
13463 ) : null;
13464 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13465 "span",
13466 {
13467 className: "dataviews-view-activity__item-bullet",
13468 "aria-hidden": "true"
13469 }
13470 ) });
13471 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(titleField.render, { item, field: titleField }) : null;
13472 const verticalGap = (0, import_element40.useMemo)(() => {
13473 switch (density) {
13474 case "comfortable":
13475 return "md";
13476 default:
13477 return "sm";
13478 }
13479 }, [density]);
13480 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13481 "div",
13482 {
13483 ref: itemRef,
13484 role: infiniteScrollEnabled ? "article" : void 0,
13485 "aria-posinset": posinset,
13486 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
13487 className: clsx_default(
13488 "dataviews-view-activity__item",
13489 density === "compact" && "is-compact",
13490 density === "balanced" && "is-balanced",
13491 density === "comfortable" && "is-comfortable"
13492 ),
13493 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
13494 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13495 Stack,
13496 {
13497 direction: "column",
13498 gap: "xs",
13499 align: "center",
13500 className: "dataviews-view-activity__item-type",
13501 children: renderedMediaField
13502 }
13503 ),
13504 /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
13505 Stack,
13506 {
13507 direction: "column",
13508 gap: verticalGap,
13509 align: "flex-start",
13510 className: "dataviews-view-activity__item-content",
13511 children: [
13512 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13513 ItemClickWrapper,
13514 {
13515 item,
13516 isItemClickable,
13517 onClickItem,
13518 renderItemLink,
13519 className: "dataviews-view-activity__item-title",
13520 children: renderedTitleField
13521 }
13522 ),
13523 showDescription && descriptionField && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13524 descriptionField.render,
13525 {
13526 item,
13527 field: descriptionField
13528 }
13529 ) }),
13530 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
13531 "div",
13532 {
13533 className: "dataviews-view-activity__item-field",
13534 children: [
13535 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13536 VisuallyHidden,
13537 {
13538 className: "dataviews-view-activity__item-field-label",
13539 render: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("span", {}),
13540 children: field.label
13541 }
13542 ),
13543 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13544 field.render,
13545 {
13546 item,
13547 field
13548 }
13549 ) })
13550 ]
13551 },
13552 field.id
13553 )) }),
13554 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13555 PrimaryActions,
13556 {
13557 item,
13558 actions: primaryActions,
13559 registry,
13560 buttonVariant: "secondary"
13561 }
13562 )
13563 ]
13564 }
13565 ),
13566 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
13567 // there if there are any actions at all.
13568 isMobileViewport && // At the same time, only show the menu if there are actions to show.
13569 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13570 ItemActions,
13571 {
13572 item,
13573 actions: eligibleActions,
13574 isCompact: true
13575 }
13576 ) })
13577 ] })
13578 }
13579 );
13580 }
13581 var activity_item_default = ActivityItem;
13582
13583 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
13584 var import_react10 = __toESM(require_react(), 1);
13585 function isDefined3(item) {
13586 return !!item;
13587 }
13588 function ActivityItems(props) {
13589 const { data, fields, getItemId, view } = props;
13590 const titleField = fields.find((field) => field.id === view.titleField);
13591 const mediaField = fields.find((field) => field.id === view.mediaField);
13592 const descriptionField = fields.find(
13593 (field) => field.id === view.descriptionField
13594 );
13595 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
13596 return data.map((item, index2) => {
13597 return /* @__PURE__ */ (0, import_react10.createElement)(
13598 activity_item_default,
13599 {
13600 ...props,
13601 key: getItemId(item),
13602 item,
13603 mediaField,
13604 titleField,
13605 descriptionField,
13606 otherFields,
13607 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13608 }
13609 );
13610 });
13611 }
13612
13613 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13614 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
13615 function ViewActivity(props) {
13616 const { empty, data, fields, isLoading, view, className } = props;
13617 const isDelayedLoading = useDelayedLoading(!!isLoading);
13618 const hasData = !!data?.length;
13619 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13620 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13621 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13622 if (!hasData) {
13623 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13624 "div",
13625 {
13626 className: clsx_default("dataviews-no-results", {
13627 "is-refreshing": isDelayedLoading
13628 }),
13629 children: empty
13630 }
13631 );
13632 }
13633 const isInert = !isInfiniteScroll && !!isLoading;
13634 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
13635 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13636 });
13637 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
13638 if (hasData && groupField && dataByGroup) {
13639 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13640 Stack,
13641 {
13642 direction: "column",
13643 gap: "sm",
13644 className: wrapperClassName,
13645 inert: isInert ? "true" : void 0,
13646 children: groupedEntries.map(
13647 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13648 ActivityGroup,
13649 {
13650 groupName,
13651 groupData,
13652 groupField,
13653 showLabel: view.groupBy?.showLabel !== false,
13654 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13655 ActivityItems,
13656 {
13657 ...props,
13658 data: groupData
13659 }
13660 )
13661 },
13662 groupName
13663 )
13664 )
13665 }
13666 );
13667 }
13668 return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_jsx_runtime62.Fragment, { children: [
13669 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13670 "div",
13671 {
13672 className: wrapperClassName,
13673 role: view.infiniteScrollEnabled ? "feed" : void 0,
13674 inert: isInert ? "true" : void 0,
13675 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(ActivityItems, { ...props })
13676 }
13677 ),
13678 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_components11.Spinner, {}) })
13679 ] });
13680 }
13681
13682 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13683 var import_components14 = __toESM(require_components(), 1);
13684 var import_i18n18 = __toESM(require_i18n(), 1);
13685 var import_compose6 = __toESM(require_compose(), 1);
13686 var import_element43 = __toESM(require_element(), 1);
13687
13688 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13689 var import_components13 = __toESM(require_components(), 1);
13690 var import_data5 = __toESM(require_data(), 1);
13691 var import_element42 = __toESM(require_element(), 1);
13692 var import_i18n17 = __toESM(require_i18n(), 1);
13693
13694 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
13695 var import_components12 = __toESM(require_components(), 1);
13696 var import_element41 = __toESM(require_element(), 1);
13697 var import_i18n16 = __toESM(require_i18n(), 1);
13698 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
13699 function DataViewsPagination() {
13700 const {
13701 view,
13702 onChangeView,
13703 paginationInfo: { totalItems = 0, totalPages }
13704 } = (0, import_element41.useContext)(dataviews_context_default);
13705 if (!totalItems || !totalPages || view.infiniteScrollEnabled) {
13706 return null;
13707 }
13708 const currentPage = view.page ?? 1;
13709 const pageSelectOptions = Array.from(Array(totalPages)).map(
13710 (_, i2) => {
13711 const page = i2 + 1;
13712 return {
13713 value: page.toString(),
13714 label: page.toString(),
13715 "aria-label": currentPage === page ? (0, import_i18n16.sprintf)(
13716 // translators: 1: current page number. 2: total number of pages.
13717 (0, import_i18n16.__)("Page %1$d of %2$d"),
13718 currentPage,
13719 totalPages
13720 ) : page.toString()
13721 };
13722 }
13723 );
13724 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(
13725 Stack,
13726 {
13727 direction: "row",
13728 className: "dataviews-pagination",
13729 justify: "end",
13730 align: "center",
13731 gap: "xl",
13732 children: [
13733 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13734 Stack,
13735 {
13736 direction: "row",
13737 justify: "flex-start",
13738 align: "center",
13739 gap: "xs",
13740 className: "dataviews-pagination__page-select",
13741 children: (0, import_element41.createInterpolateElement)(
13742 (0, import_i18n16.sprintf)(
13743 // translators: 1: Current page number, 2: Total number of pages.
13744 (0, import_i18n16._x)(
13745 "<div>Page</div>%1$s<div>of %2$d</div>",
13746 "paging"
13747 ),
13748 "<CurrentPage />",
13749 totalPages
13750 ),
13751 {
13752 div: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { "aria-hidden": true }),
13753 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
13754 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13755 import_components12.SelectControl,
13756 {
13757 "aria-label": (0, import_i18n16.__)("Current page"),
13758 value: currentPage.toString(),
13759 options: pageSelectOptions,
13760 onChange: (newValue) => {
13761 onChangeView({
13762 ...view,
13763 page: +newValue
13764 });
13765 },
13766 size: "small",
13767 variant: "minimal"
13768 }
13769 )
13770 }
13771 )
13772 }
13773 ),
13774 /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
13775 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13776 import_components12.Button,
13777 {
13778 onClick: () => onChangeView({
13779 ...view,
13780 page: currentPage - 1
13781 }),
13782 disabled: currentPage === 1,
13783 accessibleWhenDisabled: true,
13784 label: (0, import_i18n16.__)("Previous page"),
13785 icon: (0, import_i18n16.isRTL)() ? next_default : previous_default,
13786 showTooltip: true,
13787 size: "compact",
13788 tooltipPosition: "top"
13789 }
13790 ),
13791 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13792 import_components12.Button,
13793 {
13794 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
13795 disabled: currentPage >= totalPages,
13796 accessibleWhenDisabled: true,
13797 label: (0, import_i18n16.__)("Next page"),
13798 icon: (0, import_i18n16.isRTL)() ? previous_default : next_default,
13799 showTooltip: true,
13800 size: "compact",
13801 tooltipPosition: "top"
13802 }
13803 )
13804 ] })
13805 ]
13806 }
13807 );
13808 }
13809 var dataviews_pagination_default = (0, import_element41.memo)(DataViewsPagination);
13810
13811 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13812 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
13813 function useIsMultiselectPicker(actions) {
13814 return (0, import_element42.useMemo)(() => {
13815 return actions?.every((action) => action.supportsBulk);
13816 }, [actions]);
13817 }
13818
13819 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13820 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
13821 var { Badge: WCBadge2 } = unlock2(import_components14.privateApis);
13822 function GridItem3({
13823 view,
13824 multiselect,
13825 selection,
13826 onChangeSelection,
13827 getItemId,
13828 item,
13829 mediaField,
13830 titleField,
13831 descriptionField,
13832 regularFields,
13833 badgeFields,
13834 config,
13835 posinset,
13836 setsize
13837 }) {
13838 const { showTitle = true, showMedia = true, showDescription = true } = view;
13839 const id = getItemId(item);
13840 const elementRef = (0, import_element43.useRef)(null);
13841 const isSelected2 = selection.includes(id);
13842 useIntersectionObserver(elementRef, posinset);
13843 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13844 mediaField.render,
13845 {
13846 item,
13847 field: mediaField,
13848 config
13849 }
13850 ) : null;
13851 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(titleField.render, { item, field: titleField }) : null;
13852 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
13853 import_components14.Composite.Item,
13854 {
13855 ref: elementRef,
13856 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n18.__)("(no title)") : void 0,
13857 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(Stack, { direction: "column", children, ...props }),
13858 role: "option",
13859 "aria-posinset": posinset,
13860 "aria-setsize": setsize,
13861 className: clsx_default("dataviews-view-picker-grid__card", {
13862 "is-selected": isSelected2
13863 }),
13864 "aria-selected": isSelected2,
13865 onClick: () => {
13866 if (isSelected2) {
13867 onChangeSelection(
13868 selection.filter((itemId) => id !== itemId)
13869 );
13870 } else {
13871 const newSelection = multiselect ? [...selection, id] : [id];
13872 onChangeSelection(newSelection);
13873 }
13874 },
13875 children: [
13876 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
13877 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13878 DataViewsSelectionCheckbox,
13879 {
13880 item,
13881 selection,
13882 onChangeSelection,
13883 getItemId,
13884 titleField,
13885 disabled: false,
13886 "aria-hidden": true,
13887 tabIndex: -1
13888 }
13889 ),
13890 showTitle && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13891 Stack,
13892 {
13893 direction: "row",
13894 justify: "space-between",
13895 className: "dataviews-view-picker-grid__title-actions",
13896 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
13897 }
13898 ),
13899 /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(Stack, { direction: "column", gap: "xs", children: [
13900 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13901 descriptionField.render,
13902 {
13903 item,
13904 field: descriptionField
13905 }
13906 ),
13907 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13908 Stack,
13909 {
13910 direction: "row",
13911 className: "dataviews-view-picker-grid__badge-fields",
13912 gap: "sm",
13913 wrap: "wrap",
13914 align: "top",
13915 justify: "flex-start",
13916 children: badgeFields.map((field) => {
13917 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13918 WCBadge2,
13919 {
13920 className: "dataviews-view-picker-grid__field-value",
13921 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13922 field.render,
13923 {
13924 item,
13925 field
13926 }
13927 )
13928 },
13929 field.id
13930 );
13931 })
13932 }
13933 ),
13934 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13935 Stack,
13936 {
13937 direction: "column",
13938 className: "dataviews-view-picker-grid__fields",
13939 gap: "xs",
13940 children: regularFields.map((field) => {
13941 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13942 import_components14.Flex,
13943 {
13944 className: "dataviews-view-picker-grid__field",
13945 gap: 1,
13946 justify: "flex-start",
13947 expanded: true,
13948 style: { height: "auto" },
13949 direction: "row",
13950 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_jsx_runtime65.Fragment, { children: [
13951 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_components14.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
13952 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13953 import_components14.FlexItem,
13954 {
13955 className: "dataviews-view-picker-grid__field-value",
13956 style: { maxHeight: "none" },
13957 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13958 field.render,
13959 {
13960 item,
13961 field
13962 }
13963 )
13964 }
13965 )
13966 ] })
13967 },
13968 field.id
13969 );
13970 })
13971 }
13972 )
13973 ] })
13974 ]
13975 },
13976 id
13977 );
13978 }
13979 function GridGroup({
13980 groupName,
13981 groupField,
13982 showLabel = true,
13983 children
13984 }) {
13985 const headerId = (0, import_compose6.useInstanceId)(
13986 GridGroup,
13987 "dataviews-view-picker-grid-group__header"
13988 );
13989 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
13990 Stack,
13991 {
13992 direction: "column",
13993 gap: "sm",
13994 role: "group",
13995 "aria-labelledby": headerId,
13996 children: [
13997 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13998 "h3",
13999 {
14000 className: "dataviews-view-picker-grid-group__header",
14001 id: headerId,
14002 children: showLabel ? (0, import_i18n18.sprintf)(
14003 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14004 (0, import_i18n18.__)("%1$s: %2$s"),
14005 groupField.label,
14006 groupName
14007 ) : groupName
14008 }
14009 ),
14010 children
14011 ]
14012 },
14013 groupName
14014 );
14015 }
14016 function ViewPickerGrid({
14017 actions,
14018 data,
14019 fields,
14020 getItemId,
14021 isLoading,
14022 onChangeSelection,
14023 selection,
14024 view,
14025 className,
14026 empty
14027 }) {
14028 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element43.useContext)(dataviews_context_default);
14029 const titleField = fields.find(
14030 (field) => field.id === view?.titleField
14031 );
14032 const mediaField = fields.find(
14033 (field) => field.id === view?.mediaField
14034 );
14035 const descriptionField = fields.find(
14036 (field) => field.id === view?.descriptionField
14037 );
14038 const otherFields = view.fields ?? [];
14039 const { regularFields, badgeFields } = otherFields.reduce(
14040 (accumulator, fieldId) => {
14041 const field = fields.find((f2) => f2.id === fieldId);
14042 if (!field) {
14043 return accumulator;
14044 }
14045 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
14046 accumulator[key].push(field);
14047 return accumulator;
14048 },
14049 { regularFields: [], badgeFields: [] }
14050 );
14051 const hasData = !!data?.length;
14052 const usedPreviewSize = view.layout?.previewSize;
14053 const isMultiselect = useIsMultiselectPicker(actions);
14054 const size4 = "900px";
14055 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14056 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14057 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
14058 const currentPage = view?.page ?? 1;
14059 const perPage = view?.perPage ?? 0;
14060 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
14061 const gridColumns = useGridColumns();
14062 const placeholdersNeeded = usePlaceholdersNeeded(
14063 data,
14064 isInfiniteScroll,
14065 gridColumns
14066 );
14067 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_jsx_runtime65.Fragment, {
14068 // Render multiple groups.
14069 children: [
14070 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14071 import_components14.Composite,
14072 {
14073 virtualFocus: true,
14074 orientation: "horizontal",
14075 role: "listbox",
14076 "aria-multiselectable": isMultiselect,
14077 className: clsx_default(
14078 "dataviews-view-picker-grid",
14079 className,
14080 {
14081 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14082 view.layout.density
14083 )
14084 }
14085 ),
14086 "aria-label": itemListLabel,
14087 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14088 Stack,
14089 {
14090 direction: "column",
14091 gap: "lg",
14092 children,
14093 ...props
14094 }
14095 ),
14096 children: Array.from(dataByGroup.entries()).map(
14097 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14098 GridGroup,
14099 {
14100 groupName,
14101 groupField,
14102 showLabel: view.groupBy?.showLabel !== false,
14103 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14104 GridItems,
14105 {
14106 previewSize: usedPreviewSize,
14107 style: {
14108 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
14109 },
14110 "aria-busy": isLoading,
14111 ref: resizeObserverRef,
14112 children: groupItems.map((item) => {
14113 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
14114 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14115 GridItem3,
14116 {
14117 view,
14118 multiselect: isMultiselect,
14119 selection,
14120 onChangeSelection,
14121 getItemId,
14122 item,
14123 mediaField,
14124 titleField,
14125 descriptionField,
14126 regularFields,
14127 badgeFields,
14128 config: {
14129 sizes: size4
14130 },
14131 posinset: posInSet,
14132 setsize: setSize
14133 },
14134 getItemId(item)
14135 );
14136 })
14137 }
14138 )
14139 },
14140 groupName
14141 )
14142 )
14143 }
14144 ),
14145 // Render a single grid with all data.
14146 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
14147 import_components14.Composite,
14148 {
14149 render: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14150 GridItems,
14151 {
14152 className: clsx_default(
14153 "dataviews-view-picker-grid",
14154 className,
14155 {
14156 [`has-${view.layout?.density}-density`]: view.layout?.density && [
14157 "compact",
14158 "comfortable"
14159 ].includes(view.layout.density)
14160 }
14161 ),
14162 previewSize: usedPreviewSize,
14163 "aria-busy": isLoading,
14164 ref: resizeObserverRef
14165 }
14166 ),
14167 virtualFocus: true,
14168 orientation: "horizontal",
14169 role: "listbox",
14170 "aria-multiselectable": isMultiselect,
14171 "aria-label": itemListLabel,
14172 children: [
14173 Array.from({ length: placeholdersNeeded }).map(
14174 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14175 import_components14.Composite.Item,
14176 {
14177 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14178 Stack,
14179 {
14180 direction: "column",
14181 children,
14182 ...props
14183 }
14184 ),
14185 role: "option",
14186 "aria-hidden": true,
14187 tabIndex: -1,
14188 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
14189 },
14190 `placeholder-${index2}`
14191 )
14192 ),
14193 data.map((item) => {
14194 const posinset = item.position;
14195 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14196 GridItem3,
14197 {
14198 view,
14199 multiselect: isMultiselect,
14200 selection,
14201 onChangeSelection,
14202 getItemId,
14203 item,
14204 mediaField,
14205 titleField,
14206 descriptionField,
14207 regularFields,
14208 badgeFields,
14209 config: {
14210 sizes: size4
14211 },
14212 posinset,
14213 setsize: setSize
14214 },
14215 getItemId(item)
14216 );
14217 })
14218 ]
14219 }
14220 ),
14221 // Render empty state.
14222 !hasData && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14223 "div",
14224 {
14225 className: clsx_default({
14226 "dataviews-loading": isLoading,
14227 "dataviews-no-results": !isLoading
14228 }),
14229 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_components14.Spinner, {}) }) : empty
14230 }
14231 ),
14232 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_components14.Spinner, {}) })
14233 ]
14234 });
14235 }
14236 var picker_grid_default = ViewPickerGrid;
14237
14238 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
14239 var import_i18n19 = __toESM(require_i18n(), 1);
14240 var import_components15 = __toESM(require_components(), 1);
14241 var import_element44 = __toESM(require_element(), 1);
14242 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
14243 function TableColumnField2({
14244 item,
14245 fields,
14246 column,
14247 align
14248 }) {
14249 const field = fields.find((f2) => f2.id === column);
14250 if (!field) {
14251 return null;
14252 }
14253 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
14254 "dataviews-view-table__cell-align-end": align === "end",
14255 "dataviews-view-table__cell-align-center": align === "center"
14256 });
14257 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(field.render, { item, field }) });
14258 }
14259 function TableRow2({
14260 item,
14261 fields,
14262 id,
14263 view,
14264 titleField,
14265 mediaField,
14266 descriptionField,
14267 selection,
14268 getItemId,
14269 onChangeSelection,
14270 multiselect,
14271 posinset
14272 }) {
14273 const { paginationInfo } = (0, import_element44.useContext)(dataviews_context_default);
14274 const isSelected2 = selection.includes(id);
14275 const [isHovered, setIsHovered] = (0, import_element44.useState)(false);
14276 const elementRef = (0, import_element44.useRef)(null);
14277 useIntersectionObserver(elementRef, posinset);
14278 const {
14279 showTitle = true,
14280 showMedia = true,
14281 showDescription = true,
14282 infiniteScrollEnabled
14283 } = view;
14284 const handleMouseEnter = () => {
14285 setIsHovered(true);
14286 };
14287 const handleMouseLeave = () => {
14288 setIsHovered(false);
14289 };
14290 const columns = view.fields ?? [];
14291 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14292 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14293 import_components15.Composite.Item,
14294 {
14295 ref: elementRef,
14296 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14297 "tr",
14298 {
14299 className: clsx_default("dataviews-view-table__row", {
14300 "is-selected": isSelected2,
14301 "is-hovered": isHovered
14302 }),
14303 onMouseEnter: handleMouseEnter,
14304 onMouseLeave: handleMouseLeave,
14305 children,
14306 ...props
14307 }
14308 ),
14309 "aria-selected": isSelected2,
14310 "aria-setsize": paginationInfo.totalItems || void 0,
14311 "aria-posinset": posinset,
14312 role: infiniteScrollEnabled ? "article" : "option",
14313 onMouseDown: (event) => {
14314 if (event.button !== 0) {
14315 return;
14316 }
14317 event.currentTarget.parentElement?.focus({
14318 preventScroll: true
14319 });
14320 },
14321 onClick: () => {
14322 if (isSelected2) {
14323 onChangeSelection(
14324 selection.filter((itemId) => id !== itemId)
14325 );
14326 } else {
14327 const newSelection = multiselect ? [...selection, id] : [id];
14328 onChangeSelection(newSelection);
14329 }
14330 },
14331 children: [
14332 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14333 "td",
14334 {
14335 className: "dataviews-view-table__checkbox-column",
14336 role: "presentation",
14337 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14338 DataViewsSelectionCheckbox,
14339 {
14340 item,
14341 selection,
14342 onChangeSelection,
14343 getItemId,
14344 titleField,
14345 disabled: false,
14346 "aria-hidden": true,
14347 tabIndex: -1
14348 }
14349 ) })
14350 }
14351 ),
14352 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14353 "td",
14354 {
14355 role: "presentation",
14356 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14357 column_primary_default,
14358 {
14359 item,
14360 titleField: showTitle ? titleField : void 0,
14361 mediaField: showMedia ? mediaField : void 0,
14362 descriptionField: showDescription ? descriptionField : void 0,
14363 isItemClickable: () => false
14364 }
14365 )
14366 }
14367 ),
14368 columns.map((column) => {
14369 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14370 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14371 "td",
14372 {
14373 style: {
14374 width,
14375 maxWidth,
14376 minWidth
14377 },
14378 role: "presentation",
14379 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14380 TableColumnField2,
14381 {
14382 fields,
14383 item,
14384 column,
14385 align
14386 }
14387 )
14388 },
14389 column
14390 );
14391 })
14392 ]
14393 },
14394 id
14395 );
14396 }
14397 function ViewPickerTable({
14398 actions,
14399 data,
14400 fields,
14401 getItemId,
14402 isLoading = false,
14403 onChangeView,
14404 onChangeSelection,
14405 selection,
14406 setOpenedFilter,
14407 view,
14408 className,
14409 empty
14410 }) {
14411 const headerMenuRefs = (0, import_element44.useRef)(/* @__PURE__ */ new Map());
14412 const headerMenuToFocusRef = (0, import_element44.useRef)(void 0);
14413 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element44.useState)();
14414 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
14415 (0, import_element44.useEffect)(() => {
14416 if (headerMenuToFocusRef.current) {
14417 headerMenuToFocusRef.current.focus();
14418 headerMenuToFocusRef.current = void 0;
14419 }
14420 });
14421 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14422 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14423 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
14424 const tableNoticeId = (0, import_element44.useId)();
14425 if (nextHeaderMenuToFocus) {
14426 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
14427 setNextHeaderMenuToFocus(void 0);
14428 return;
14429 }
14430 const onHide = (field) => {
14431 const hidden = headerMenuRefs.current.get(field.id);
14432 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
14433 setNextHeaderMenuToFocus(fallback?.node);
14434 };
14435 const hasData = !!data?.length;
14436 const titleField = fields.find((field) => field.id === view.titleField);
14437 const mediaField = fields.find((field) => field.id === view.mediaField);
14438 const descriptionField = fields.find(
14439 (field) => field.id === view.descriptionField
14440 );
14441 const { showTitle = true, showMedia = true, showDescription = true } = view;
14442 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14443 const columns = view.fields ?? [];
14444 const headerMenuRef = (column, index2) => (node) => {
14445 if (node) {
14446 headerMenuRefs.current.set(column, {
14447 node,
14448 fallback: columns[index2 > 0 ? index2 - 1 : 1]
14449 });
14450 } else {
14451 headerMenuRefs.current.delete(column);
14452 }
14453 };
14454 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
14455 /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14456 "table",
14457 {
14458 className: clsx_default(
14459 "dataviews-view-table",
14460 "dataviews-view-picker-table",
14461 className,
14462 {
14463 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14464 view.layout.density
14465 )
14466 }
14467 ),
14468 "aria-busy": isLoading,
14469 "aria-describedby": tableNoticeId,
14470 role: isInfiniteScroll ? "feed" : "listbox",
14471 children: [
14472 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14473 "tr",
14474 {
14475 className: "dataviews-view-table__row",
14476 role: "presentation",
14477 children: [
14478 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14479 BulkSelectionCheckbox,
14480 {
14481 selection,
14482 onChangeSelection,
14483 data,
14484 actions,
14485 getItemId,
14486 disableSelectAll: isInfiniteScroll
14487 }
14488 ) }),
14489 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14490 column_header_menu_default,
14491 {
14492 ref: headerMenuRef(
14493 titleField.id,
14494 0
14495 ),
14496 fieldId: titleField.id,
14497 view,
14498 fields,
14499 onChangeView,
14500 onHide,
14501 setOpenedFilter,
14502 canMove: false
14503 }
14504 ) }),
14505 columns.map((column, index2) => {
14506 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14507 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14508 "th",
14509 {
14510 style: {
14511 width,
14512 maxWidth,
14513 minWidth,
14514 textAlign: align
14515 },
14516 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
14517 scope: "col",
14518 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14519 column_header_menu_default,
14520 {
14521 ref: headerMenuRef(column, index2),
14522 fieldId: column,
14523 view,
14524 fields,
14525 onChangeView,
14526 onHide,
14527 setOpenedFilter,
14528 canMove: view.layout?.enableMoving ?? true
14529 }
14530 )
14531 },
14532 column
14533 );
14534 })
14535 ]
14536 }
14537 ) }),
14538 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
14539 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14540 import_components15.Composite,
14541 {
14542 virtualFocus: true,
14543 orientation: "vertical",
14544 render: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("tbody", { role: "group" }),
14545 children: [
14546 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14547 "tr",
14548 {
14549 className: "dataviews-view-table__group-header-row",
14550 role: "presentation",
14551 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14552 "td",
14553 {
14554 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
14555 className: "dataviews-view-table__group-header-cell",
14556 role: "presentation",
14557 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n19.sprintf)(
14558 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14559 (0, import_i18n19.__)("%1$s: %2$s"),
14560 groupField.label,
14561 groupName
14562 )
14563 }
14564 )
14565 }
14566 ),
14567 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14568 TableRow2,
14569 {
14570 item,
14571 fields,
14572 id: getItemId(item) || index2.toString(),
14573 view,
14574 titleField,
14575 mediaField,
14576 descriptionField,
14577 selection,
14578 getItemId,
14579 onChangeSelection,
14580 multiselect: isMultiselect
14581 },
14582 getItemId(item)
14583 ))
14584 ]
14585 },
14586 `group-${groupName}`
14587 )
14588 ) : /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14589 import_components15.Composite,
14590 {
14591 render: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("tbody", { role: "presentation" }),
14592 virtualFocus: true,
14593 orientation: "vertical",
14594 children: hasData && data.map((item, index2) => {
14595 const itemId = getItemId(item);
14596 const posinset = item.position;
14597 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14598 TableRow2,
14599 {
14600 item,
14601 fields,
14602 id: itemId || index2.toString(),
14603 view,
14604 titleField,
14605 mediaField,
14606 descriptionField,
14607 selection,
14608 getItemId,
14609 onChangeSelection,
14610 multiselect: isMultiselect,
14611 posinset
14612 },
14613 itemId
14614 );
14615 })
14616 }
14617 )
14618 ]
14619 }
14620 ),
14621 /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14622 "div",
14623 {
14624 className: clsx_default({
14625 "dataviews-loading": isLoading,
14626 "dataviews-no-results": !hasData && !isLoading
14627 }),
14628 id: tableNoticeId,
14629 children: [
14630 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components15.Spinner, {}) }) : empty),
14631 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components15.Spinner, {}) })
14632 ]
14633 }
14634 )
14635 ] });
14636 }
14637 var picker_table_default = ViewPickerTable;
14638
14639 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
14640 var import_components16 = __toESM(require_components(), 1);
14641 var import_i18n20 = __toESM(require_i18n(), 1);
14642 var import_element45 = __toESM(require_element(), 1);
14643 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
14644 function DensityPicker() {
14645 const context = (0, import_element45.useContext)(dataviews_context_default);
14646 const view = context.view;
14647 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14648 import_components16.__experimentalToggleGroupControl,
14649 {
14650 size: "__unstable-large",
14651 label: (0, import_i18n20.__)("Density"),
14652 value: view.layout?.density || "balanced",
14653 onChange: (value) => {
14654 context.onChangeView({
14655 ...view,
14656 layout: {
14657 ...view.layout,
14658 density: value
14659 }
14660 });
14661 },
14662 isBlock: true,
14663 children: [
14664 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14665 import_components16.__experimentalToggleGroupControlOption,
14666 {
14667 value: "comfortable",
14668 label: (0, import_i18n20._x)(
14669 "Comfortable",
14670 "Density option for DataView layout"
14671 )
14672 },
14673 "comfortable"
14674 ),
14675 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14676 import_components16.__experimentalToggleGroupControlOption,
14677 {
14678 value: "balanced",
14679 label: (0, import_i18n20._x)("Balanced", "Density option for DataView layout")
14680 },
14681 "balanced"
14682 ),
14683 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14684 import_components16.__experimentalToggleGroupControlOption,
14685 {
14686 value: "compact",
14687 label: (0, import_i18n20._x)("Compact", "Density option for DataView layout")
14688 },
14689 "compact"
14690 )
14691 ]
14692 }
14693 );
14694 }
14695
14696 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
14697 var import_components17 = __toESM(require_components(), 1);
14698 var import_i18n21 = __toESM(require_i18n(), 1);
14699 var import_element46 = __toESM(require_element(), 1);
14700 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
14701 var imageSizes2 = [
14702 {
14703 value: 120,
14704 breakpoint: 1
14705 },
14706 {
14707 value: 170,
14708 breakpoint: 1
14709 },
14710 {
14711 value: 230,
14712 breakpoint: 1
14713 },
14714 {
14715 value: 290,
14716 breakpoint: 1112
14717 // at minimum image width, 4 images display at this container size
14718 },
14719 {
14720 value: 350,
14721 breakpoint: 1636
14722 // at minimum image width, 6 images display at this container size
14723 },
14724 {
14725 value: 430,
14726 breakpoint: 588
14727 // at minimum image width, 2 images display at this container size
14728 }
14729 ];
14730 function PreviewSizePicker() {
14731 const context = (0, import_element46.useContext)(dataviews_context_default);
14732 const view = context.view;
14733 const breakValues = imageSizes2.filter((size4) => {
14734 return context.containerWidth >= size4.breakpoint;
14735 });
14736 const layoutPreviewSize = view.layout?.previewSize ?? 230;
14737 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
14738 const marks = breakValues.map((size4, index2) => {
14739 return {
14740 value: index2
14741 };
14742 });
14743 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14744 import_components17.RangeControl,
14745 {
14746 __next40pxDefaultSize: true,
14747 showTooltip: false,
14748 label: (0, import_i18n21.__)("Preview size"),
14749 value: previewSizeToUse,
14750 min: 0,
14751 max: breakValues.length - 1,
14752 withInputField: false,
14753 onChange: (value = 0) => {
14754 context.onChangeView({
14755 ...view,
14756 layout: {
14757 ...view.layout,
14758 previewSize: breakValues[value].value
14759 }
14760 });
14761 },
14762 step: 1,
14763 marks
14764 }
14765 );
14766 }
14767
14768 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
14769 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
14770 function GridConfigOptions() {
14771 return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(import_jsx_runtime69.Fragment, { children: [
14772 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(DensityPicker, {}),
14773 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(PreviewSizePicker, {})
14774 ] });
14775 }
14776
14777 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
14778 var VIEW_LAYOUTS = [
14779 {
14780 type: LAYOUT_TABLE,
14781 label: (0, import_i18n22.__)("Table"),
14782 component: table_default,
14783 icon: block_table_default,
14784 viewConfigOptions: DensityPicker
14785 },
14786 {
14787 type: LAYOUT_GRID,
14788 label: (0, import_i18n22.__)("Grid"),
14789 component: grid_default,
14790 icon: category_default,
14791 viewConfigOptions: GridConfigOptions
14792 },
14793 {
14794 type: LAYOUT_LIST,
14795 label: (0, import_i18n22.__)("List"),
14796 component: ViewList,
14797 icon: (0, import_i18n22.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
14798 viewConfigOptions: DensityPicker
14799 },
14800 {
14801 type: LAYOUT_ACTIVITY,
14802 label: (0, import_i18n22.__)("Activity"),
14803 component: ViewActivity,
14804 icon: scheduled_default,
14805 viewConfigOptions: DensityPicker
14806 },
14807 {
14808 type: LAYOUT_PICKER_GRID,
14809 label: (0, import_i18n22.__)("Grid"),
14810 component: picker_grid_default,
14811 icon: category_default,
14812 viewConfigOptions: GridConfigOptions,
14813 isPicker: true
14814 },
14815 {
14816 type: LAYOUT_PICKER_TABLE,
14817 label: (0, import_i18n22.__)("Table"),
14818 component: picker_table_default,
14819 icon: block_table_default,
14820 viewConfigOptions: DensityPicker,
14821 isPicker: true
14822 }
14823 ];
14824
14825 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
14826 var import_element54 = __toESM(require_element(), 1);
14827
14828 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
14829 var import_components20 = __toESM(require_components(), 1);
14830 var import_i18n25 = __toESM(require_i18n(), 1);
14831 var import_element51 = __toESM(require_element(), 1);
14832
14833 // node_modules/@ariakit/core/esm/__chunks/XMCVU3LR.js
14834 function noop4(..._) {
14835 }
14836 function applyState(argument, currentValue) {
14837 if (isUpdater(argument)) {
14838 const value = isLazyValue(currentValue) ? currentValue() : currentValue;
14839 return argument(value);
14840 }
14841 return argument;
14842 }
14843 function isUpdater(argument) {
14844 return typeof argument === "function";
14845 }
14846 function isLazyValue(value) {
14847 return typeof value === "function";
14848 }
14849 function hasOwnProperty(object, prop) {
14850 if (typeof Object.hasOwn === "function") {
14851 return Object.hasOwn(object, prop);
14852 }
14853 return Object.prototype.hasOwnProperty.call(object, prop);
14854 }
14855 function chain(...fns) {
14856 return (...args) => {
14857 for (const fn of fns) {
14858 if (typeof fn === "function") {
14859 fn(...args);
14860 }
14861 }
14862 };
14863 }
14864 function normalizeString(str) {
14865 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
14866 }
14867 function omit(object, keys) {
14868 const result = { ...object };
14869 for (const key of keys) {
14870 if (hasOwnProperty(result, key)) {
14871 delete result[key];
14872 }
14873 }
14874 return result;
14875 }
14876 function pick(object, paths) {
14877 const result = {};
14878 for (const key of paths) {
14879 if (hasOwnProperty(object, key)) {
14880 result[key] = object[key];
14881 }
14882 }
14883 return result;
14884 }
14885 function identity(value) {
14886 return value;
14887 }
14888 function invariant(condition, message2) {
14889 if (condition) return;
14890 if (typeof message2 !== "string") throw new Error("Invariant failed");
14891 throw new Error(message2);
14892 }
14893 function getKeys(obj) {
14894 return Object.keys(obj);
14895 }
14896 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
14897 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
14898 if (result == null) return false;
14899 return !result;
14900 }
14901 function disabledFromProps(props) {
14902 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
14903 }
14904 function removeUndefinedValues(obj) {
14905 const result = {};
14906 for (const key in obj) {
14907 if (obj[key] !== void 0) {
14908 result[key] = obj[key];
14909 }
14910 }
14911 return result;
14912 }
14913 function defaultValue(...values) {
14914 for (const value of values) {
14915 if (value !== void 0) return value;
14916 }
14917 return void 0;
14918 }
14919
14920 // node_modules/@ariakit/react-core/esm/__chunks/YXGXYGQX.js
14921 var import_react11 = __toESM(require_react(), 1);
14922 function setRef(ref, value) {
14923 if (typeof ref === "function") {
14924 ref(value);
14925 } else if (ref) {
14926 ref.current = value;
14927 }
14928 }
14929 function isValidElementWithRef(element) {
14930 if (!element) return false;
14931 if (!(0, import_react11.isValidElement)(element)) return false;
14932 if ("ref" in element.props) return true;
14933 if ("ref" in element) return true;
14934 return false;
14935 }
14936 function getRefProperty(element) {
14937 if (!isValidElementWithRef(element)) return null;
14938 const props = { ...element.props };
14939 return props.ref || element.ref;
14940 }
14941 function mergeProps3(base, overrides) {
14942 const props = { ...base };
14943 for (const key in overrides) {
14944 if (!hasOwnProperty(overrides, key)) continue;
14945 if (key === "className") {
14946 const prop = "className";
14947 props[prop] = base[prop] ? `${base[prop]} ${overrides[prop]}` : overrides[prop];
14948 continue;
14949 }
14950 if (key === "style") {
14951 const prop = "style";
14952 props[prop] = base[prop] ? { ...base[prop], ...overrides[prop] } : overrides[prop];
14953 continue;
14954 }
14955 const overrideValue = overrides[key];
14956 if (typeof overrideValue === "function" && key.startsWith("on")) {
14957 const baseValue = base[key];
14958 if (typeof baseValue === "function") {
14959 props[key] = (...args) => {
14960 overrideValue(...args);
14961 baseValue(...args);
14962 };
14963 continue;
14964 }
14965 }
14966 props[key] = overrideValue;
14967 }
14968 return props;
14969 }
14970
14971 // node_modules/@ariakit/core/esm/__chunks/3DNM6L6E.js
14972 var canUseDOM = checkIsBrowser();
14973 function checkIsBrowser() {
14974 var _a;
14975 return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement);
14976 }
14977 function getDocument(node) {
14978 if (!node) return document;
14979 if ("self" in node) return node.document;
14980 return node.ownerDocument || document;
14981 }
14982 function getActiveElement(node, activeDescendant = false) {
14983 var _a;
14984 const { activeElement: activeElement2 } = getDocument(node);
14985 if (!(activeElement2 == null ? void 0 : activeElement2.nodeName)) {
14986 return null;
14987 }
14988 if (isFrame(activeElement2) && ((_a = activeElement2.contentDocument) == null ? void 0 : _a.body)) {
14989 return getActiveElement(
14990 activeElement2.contentDocument.body,
14991 activeDescendant
14992 );
14993 }
14994 if (activeDescendant) {
14995 const id = activeElement2.getAttribute("aria-activedescendant");
14996 if (id) {
14997 const element = getDocument(activeElement2).getElementById(id);
14998 if (element) {
14999 return element;
15000 }
15001 }
15002 }
15003 return activeElement2;
15004 }
15005 function contains2(parent, child) {
15006 return parent === child || parent.contains(child);
15007 }
15008 function isFrame(element) {
15009 return element.tagName === "IFRAME";
15010 }
15011 function isButton(element) {
15012 const tagName = element.tagName.toLowerCase();
15013 if (tagName === "button") return true;
15014 if (tagName === "input" && element.type) {
15015 return buttonInputTypes.indexOf(element.type) !== -1;
15016 }
15017 return false;
15018 }
15019 var buttonInputTypes = [
15020 "button",
15021 "color",
15022 "file",
15023 "image",
15024 "reset",
15025 "submit"
15026 ];
15027 function isVisible(element) {
15028 if (typeof element.checkVisibility === "function") {
15029 return element.checkVisibility();
15030 }
15031 const htmlElement = element;
15032 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
15033 }
15034 function isTextField(element) {
15035 try {
15036 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
15037 const isTextArea = element.tagName === "TEXTAREA";
15038 return isTextInput || isTextArea || false;
15039 } catch (_error) {
15040 return false;
15041 }
15042 }
15043 function isTextbox(element) {
15044 return element.isContentEditable || isTextField(element);
15045 }
15046 function getTextboxValue(element) {
15047 if (isTextField(element)) {
15048 return element.value;
15049 }
15050 if (element.isContentEditable) {
15051 const range = getDocument(element).createRange();
15052 range.selectNodeContents(element);
15053 return range.toString();
15054 }
15055 return "";
15056 }
15057 function getTextboxSelection(element) {
15058 let start = 0;
15059 let end = 0;
15060 if (isTextField(element)) {
15061 start = element.selectionStart || 0;
15062 end = element.selectionEnd || 0;
15063 } else if (element.isContentEditable) {
15064 const selection = getDocument(element).getSelection();
15065 if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) {
15066 const range = selection.getRangeAt(0);
15067 const nextRange = range.cloneRange();
15068 nextRange.selectNodeContents(element);
15069 nextRange.setEnd(range.startContainer, range.startOffset);
15070 start = nextRange.toString().length;
15071 nextRange.setEnd(range.endContainer, range.endOffset);
15072 end = nextRange.toString().length;
15073 }
15074 }
15075 return { start, end };
15076 }
15077 function getPopupRole(element, fallback) {
15078 const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"];
15079 const role = element == null ? void 0 : element.getAttribute("role");
15080 if (role && allowedPopupRoles.indexOf(role) !== -1) {
15081 return role;
15082 }
15083 return fallback;
15084 }
15085 function getScrollingElement(element) {
15086 if (!element) return null;
15087 const isScrollableOverflow = (overflow) => {
15088 if (overflow === "auto") return true;
15089 if (overflow === "scroll") return true;
15090 return false;
15091 };
15092 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
15093 const { overflowY } = getComputedStyle(element);
15094 if (isScrollableOverflow(overflowY)) return element;
15095 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
15096 const { overflowX } = getComputedStyle(element);
15097 if (isScrollableOverflow(overflowX)) return element;
15098 }
15099 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body;
15100 }
15101 function setSelectionRange(element, ...args) {
15102 if (/text|search|password|tel|url/i.test(element.type)) {
15103 element.setSelectionRange(...args);
15104 }
15105 }
15106 function sortBasedOnDOMPosition(items, getElement) {
15107 const pairs = items.map((item, index2) => [index2, item]);
15108 let isOrderDifferent = false;
15109 pairs.sort(([indexA, a2], [indexB, b2]) => {
15110 const elementA = getElement(a2);
15111 const elementB = getElement(b2);
15112 if (elementA === elementB) return 0;
15113 if (!elementA || !elementB) return 0;
15114 if (isElementPreceding(elementA, elementB)) {
15115 if (indexA > indexB) {
15116 isOrderDifferent = true;
15117 }
15118 return -1;
15119 }
15120 if (indexA < indexB) {
15121 isOrderDifferent = true;
15122 }
15123 return 1;
15124 });
15125 if (isOrderDifferent) {
15126 return pairs.map(([_, item]) => item);
15127 }
15128 return items;
15129 }
15130 function isElementPreceding(a2, b2) {
15131 return Boolean(
15132 b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING
15133 );
15134 }
15135
15136 // node_modules/@ariakit/core/esm/__chunks/SNHYQNEZ.js
15137 function isTouchDevice() {
15138 return canUseDOM && !!navigator.maxTouchPoints;
15139 }
15140 function isApple() {
15141 if (!canUseDOM) return false;
15142 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
15143 }
15144 function isSafari2() {
15145 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
15146 }
15147 function isFirefox2() {
15148 return canUseDOM && /firefox\//i.test(navigator.userAgent);
15149 }
15150
15151 // node_modules/@ariakit/core/esm/utils/events.js
15152 function isPortalEvent(event) {
15153 return Boolean(
15154 event.currentTarget && !contains2(event.currentTarget, event.target)
15155 );
15156 }
15157 function isSelfTarget(event) {
15158 return event.target === event.currentTarget;
15159 }
15160 function isOpeningInNewTab(event) {
15161 const element = event.currentTarget;
15162 if (!element) return false;
15163 const isAppleDevice = isApple();
15164 if (isAppleDevice && !event.metaKey) return false;
15165 if (!isAppleDevice && !event.ctrlKey) return false;
15166 const tagName = element.tagName.toLowerCase();
15167 if (tagName === "a") return true;
15168 if (tagName === "button" && element.type === "submit") return true;
15169 if (tagName === "input" && element.type === "submit") return true;
15170 return false;
15171 }
15172 function isDownloading(event) {
15173 const element = event.currentTarget;
15174 if (!element) return false;
15175 const tagName = element.tagName.toLowerCase();
15176 if (!event.altKey) return false;
15177 if (tagName === "a") return true;
15178 if (tagName === "button" && element.type === "submit") return true;
15179 if (tagName === "input" && element.type === "submit") return true;
15180 return false;
15181 }
15182 function fireBlurEvent(element, eventInit) {
15183 const event = new FocusEvent("blur", eventInit);
15184 const defaultAllowed = element.dispatchEvent(event);
15185 const bubbleInit = { ...eventInit, bubbles: true };
15186 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
15187 return defaultAllowed;
15188 }
15189 function fireKeyboardEvent(element, type, eventInit) {
15190 const event = new KeyboardEvent(type, eventInit);
15191 return element.dispatchEvent(event);
15192 }
15193 function fireClickEvent(element, eventInit) {
15194 const event = new MouseEvent("click", eventInit);
15195 return element.dispatchEvent(event);
15196 }
15197 function isFocusEventOutside(event, container) {
15198 const containerElement = container || event.currentTarget;
15199 const relatedTarget = event.relatedTarget;
15200 return !relatedTarget || !contains2(containerElement, relatedTarget);
15201 }
15202 function queueBeforeEvent(element, type, callback, timeout) {
15203 const createTimer = (callback2) => {
15204 if (timeout) {
15205 const timerId2 = setTimeout(callback2, timeout);
15206 return () => clearTimeout(timerId2);
15207 }
15208 const timerId = requestAnimationFrame(callback2);
15209 return () => cancelAnimationFrame(timerId);
15210 };
15211 const cancelTimer = createTimer(() => {
15212 element.removeEventListener(type, callSync, true);
15213 callback();
15214 });
15215 const callSync = () => {
15216 cancelTimer();
15217 callback();
15218 };
15219 element.addEventListener(type, callSync, { once: true, capture: true });
15220 return cancelTimer;
15221 }
15222 function addGlobalEventListener(type, listener, options, scope = window) {
15223 const children = [];
15224 try {
15225 scope.document.addEventListener(type, listener, options);
15226 for (const frame of Array.from(scope.frames)) {
15227 children.push(addGlobalEventListener(type, listener, options, frame));
15228 }
15229 } catch (e2) {
15230 }
15231 const removeEventListener = () => {
15232 try {
15233 scope.document.removeEventListener(type, listener, options);
15234 } catch (e2) {
15235 }
15236 for (const remove of children) {
15237 remove();
15238 }
15239 };
15240 return removeEventListener;
15241 }
15242
15243 // node_modules/@ariakit/react-core/esm/__chunks/KPHZR4MB.js
15244 var React48 = __toESM(require_react(), 1);
15245 var import_react12 = __toESM(require_react(), 1);
15246 var _React = { ...React48 };
15247 var useReactId = _React.useId;
15248 var useReactDeferredValue = _React.useDeferredValue;
15249 var useReactInsertionEffect = _React.useInsertionEffect;
15250 var useSafeLayoutEffect = canUseDOM ? import_react12.useLayoutEffect : import_react12.useEffect;
15251 function useInitialValue(value) {
15252 const [initialValue] = (0, import_react12.useState)(value);
15253 return initialValue;
15254 }
15255 function useLiveRef(value) {
15256 const ref = (0, import_react12.useRef)(value);
15257 useSafeLayoutEffect(() => {
15258 ref.current = value;
15259 });
15260 return ref;
15261 }
15262 function useEvent(callback) {
15263 const ref = (0, import_react12.useRef)(() => {
15264 throw new Error("Cannot call an event handler while rendering.");
15265 });
15266 if (useReactInsertionEffect) {
15267 useReactInsertionEffect(() => {
15268 ref.current = callback;
15269 });
15270 } else {
15271 ref.current = callback;
15272 }
15273 return (0, import_react12.useCallback)((...args) => {
15274 var _a;
15275 return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args);
15276 }, []);
15277 }
15278 function useTransactionState(callback) {
15279 const [state, setState] = (0, import_react12.useState)(null);
15280 useSafeLayoutEffect(() => {
15281 if (state == null) return;
15282 if (!callback) return;
15283 let prevState = null;
15284 callback((prev) => {
15285 prevState = prev;
15286 return state;
15287 });
15288 return () => {
15289 callback(prevState);
15290 };
15291 }, [state, callback]);
15292 return [state, setState];
15293 }
15294 function useMergeRefs(...refs) {
15295 return (0, import_react12.useMemo)(() => {
15296 if (!refs.some(Boolean)) return;
15297 return (value) => {
15298 for (const ref of refs) {
15299 setRef(ref, value);
15300 }
15301 };
15302 }, refs);
15303 }
15304 function useId4(defaultId) {
15305 if (useReactId) {
15306 const reactId = useReactId();
15307 if (defaultId) return defaultId;
15308 return reactId;
15309 }
15310 const [id, setId] = (0, import_react12.useState)(defaultId);
15311 useSafeLayoutEffect(() => {
15312 if (defaultId || id) return;
15313 const random = Math.random().toString(36).slice(2, 8);
15314 setId(`id-${random}`);
15315 }, [defaultId, id]);
15316 return defaultId || id;
15317 }
15318 function useTagName(refOrElement, type) {
15319 const stringOrUndefined = (type2) => {
15320 if (typeof type2 !== "string") return;
15321 return type2;
15322 };
15323 const [tagName, setTagName] = (0, import_react12.useState)(() => stringOrUndefined(type));
15324 useSafeLayoutEffect(() => {
15325 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
15326 setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type));
15327 }, [refOrElement, type]);
15328 return tagName;
15329 }
15330 function useAttribute(refOrElement, attributeName, defaultValue2) {
15331 const initialValue = useInitialValue(defaultValue2);
15332 const [attribute, setAttribute] = (0, import_react12.useState)(initialValue);
15333 (0, import_react12.useEffect)(() => {
15334 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
15335 if (!element) return;
15336 const callback = () => {
15337 const value = element.getAttribute(attributeName);
15338 setAttribute(value == null ? initialValue : value);
15339 };
15340 const observer = new MutationObserver(callback);
15341 observer.observe(element, { attributeFilter: [attributeName] });
15342 callback();
15343 return () => observer.disconnect();
15344 }, [refOrElement, attributeName, initialValue]);
15345 return attribute;
15346 }
15347 function useUpdateEffect(effect, deps) {
15348 const mounted = (0, import_react12.useRef)(false);
15349 (0, import_react12.useEffect)(() => {
15350 if (mounted.current) {
15351 return effect();
15352 }
15353 mounted.current = true;
15354 }, deps);
15355 (0, import_react12.useEffect)(
15356 () => () => {
15357 mounted.current = false;
15358 },
15359 []
15360 );
15361 }
15362 function useUpdateLayoutEffect(effect, deps) {
15363 const mounted = (0, import_react12.useRef)(false);
15364 useSafeLayoutEffect(() => {
15365 if (mounted.current) {
15366 return effect();
15367 }
15368 mounted.current = true;
15369 }, deps);
15370 useSafeLayoutEffect(
15371 () => () => {
15372 mounted.current = false;
15373 },
15374 []
15375 );
15376 }
15377 function useForceUpdate() {
15378 return (0, import_react12.useReducer)(() => [], []);
15379 }
15380 function useBooleanEvent(booleanOrCallback) {
15381 return useEvent(
15382 typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback
15383 );
15384 }
15385 function useWrapElement(props, callback, deps = []) {
15386 const wrapElement = (0, import_react12.useCallback)(
15387 (element) => {
15388 if (props.wrapElement) {
15389 element = props.wrapElement(element);
15390 }
15391 return callback(element);
15392 },
15393 [...deps, props.wrapElement]
15394 );
15395 return { ...props, wrapElement };
15396 }
15397 function useMetadataProps(props, key, value) {
15398 const parent = props.onLoadedMetadataCapture;
15399 const onLoadedMetadataCapture = (0, import_react12.useMemo)(() => {
15400 return Object.assign(() => {
15401 }, { ...parent, [key]: value });
15402 }, [parent, key, value]);
15403 return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }];
15404 }
15405 var hasInstalledGlobalEventListeners = false;
15406 function useIsMouseMoving() {
15407 (0, import_react12.useEffect)(() => {
15408 if (hasInstalledGlobalEventListeners) return;
15409 addGlobalEventListener("mousemove", setMouseMoving, true);
15410 addGlobalEventListener("mousedown", resetMouseMoving, true);
15411 addGlobalEventListener("mouseup", resetMouseMoving, true);
15412 addGlobalEventListener("keydown", resetMouseMoving, true);
15413 addGlobalEventListener("scroll", resetMouseMoving, true);
15414 hasInstalledGlobalEventListeners = true;
15415 }, []);
15416 const isMouseMoving = useEvent(() => mouseMoving);
15417 return isMouseMoving;
15418 }
15419 var mouseMoving = false;
15420 var previousScreenX = 0;
15421 var previousScreenY = 0;
15422 function hasMouseMovement(event) {
15423 const movementX = event.movementX || event.screenX - previousScreenX;
15424 const movementY = event.movementY || event.screenY - previousScreenY;
15425 previousScreenX = event.screenX;
15426 previousScreenY = event.screenY;
15427 return movementX || movementY || false;
15428 }
15429 function setMouseMoving(event) {
15430 if (!hasMouseMovement(event)) return;
15431 mouseMoving = true;
15432 }
15433 function resetMouseMoving() {
15434 mouseMoving = false;
15435 }
15436
15437 // node_modules/@ariakit/react-core/esm/__chunks/GWSL6KNJ.js
15438 var React49 = __toESM(require_react(), 1);
15439 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
15440 function forwardRef210(render4) {
15441 const Role = React49.forwardRef(
15442 // @ts-ignore Incompatible with React 19 types. Ignore for now.
15443 (props, ref) => render4({ ...props, ref })
15444 );
15445 Role.displayName = render4.displayName || render4.name;
15446 return Role;
15447 }
15448 function memo22(Component, propsAreEqual) {
15449 return React49.memo(Component, propsAreEqual);
15450 }
15451 function createElement3(Type, props) {
15452 const { wrapElement, render: render4, ...rest } = props;
15453 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
15454 let element;
15455 if (React49.isValidElement(render4)) {
15456 const renderProps = {
15457 // @ts-ignore Incompatible with React 19 types. Ignore for now.
15458 ...render4.props,
15459 ref: mergedRef
15460 };
15461 element = React49.cloneElement(render4, mergeProps3(rest, renderProps));
15462 } else if (render4) {
15463 element = render4(rest);
15464 } else {
15465 element = /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Type, { ...rest });
15466 }
15467 if (wrapElement) {
15468 return wrapElement(element);
15469 }
15470 return element;
15471 }
15472 function createHook(useProps) {
15473 const useRole = (props = {}) => {
15474 return useProps(props);
15475 };
15476 useRole.displayName = useProps.name;
15477 return useRole;
15478 }
15479 function createStoreContext(providers = [], scopedProviders = []) {
15480 const context = React49.createContext(void 0);
15481 const scopedContext = React49.createContext(void 0);
15482 const useContext210 = () => React49.useContext(context);
15483 const useScopedContext = (onlyScoped = false) => {
15484 const scoped = React49.useContext(scopedContext);
15485 const store = useContext210();
15486 if (onlyScoped) return scoped;
15487 return scoped || store;
15488 };
15489 const useProviderContext = () => {
15490 const scoped = React49.useContext(scopedContext);
15491 const store = useContext210();
15492 if (scoped && scoped === store) return;
15493 return store;
15494 };
15495 const ContextProvider = (props) => {
15496 return providers.reduceRight(
15497 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Provider2, { ...props, children }),
15498 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(context.Provider, { ...props })
15499 );
15500 };
15501 const ScopedContextProvider = (props) => {
15502 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ContextProvider, { ...props, children: scopedProviders.reduceRight(
15503 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Provider2, { ...props, children }),
15504 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(scopedContext.Provider, { ...props })
15505 ) });
15506 };
15507 return {
15508 context,
15509 scopedContext,
15510 useContext: useContext210,
15511 useScopedContext,
15512 useProviderContext,
15513 ContextProvider,
15514 ScopedContextProvider
15515 };
15516 }
15517
15518 // node_modules/@ariakit/react-core/esm/__chunks/SMPCIMZM.js
15519 var ctx = createStoreContext();
15520 var useCollectionContext = ctx.useContext;
15521 var useCollectionScopedContext = ctx.useScopedContext;
15522 var useCollectionProviderContext = ctx.useProviderContext;
15523 var CollectionContextProvider = ctx.ContextProvider;
15524 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
15525
15526 // node_modules/@ariakit/react-core/esm/__chunks/AVVXDJMZ.js
15527 var import_react13 = __toESM(require_react(), 1);
15528 var ctx2 = createStoreContext(
15529 [CollectionContextProvider],
15530 [CollectionScopedContextProvider]
15531 );
15532 var useCompositeContext = ctx2.useContext;
15533 var useCompositeScopedContext = ctx2.useScopedContext;
15534 var useCompositeProviderContext = ctx2.useProviderContext;
15535 var CompositeContextProvider = ctx2.ContextProvider;
15536 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
15537 var CompositeItemContext = (0, import_react13.createContext)(
15538 void 0
15539 );
15540 var CompositeRowContext = (0, import_react13.createContext)(
15541 void 0
15542 );
15543
15544 // node_modules/@ariakit/react-core/esm/__chunks/5VQZOHHZ.js
15545 function findFirstEnabledItem(items, excludeId) {
15546 return items.find((item) => {
15547 if (excludeId) {
15548 return !item.disabled && item.id !== excludeId;
15549 }
15550 return !item.disabled;
15551 });
15552 }
15553 function getEnabledItem(store, id) {
15554 if (!id) return null;
15555 return store.item(id) || null;
15556 }
15557 function groupItemsByRows(items) {
15558 const rows = [];
15559 for (const item of items) {
15560 const row = rows.find((currentRow) => {
15561 var _a;
15562 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
15563 });
15564 if (row) {
15565 row.push(item);
15566 } else {
15567 rows.push([item]);
15568 }
15569 }
15570 return rows;
15571 }
15572 function selectTextField(element, collapseToEnd = false) {
15573 if (isTextField(element)) {
15574 element.setSelectionRange(
15575 collapseToEnd ? element.value.length : 0,
15576 element.value.length
15577 );
15578 } else if (element.isContentEditable) {
15579 const selection = getDocument(element).getSelection();
15580 selection == null ? void 0 : selection.selectAllChildren(element);
15581 if (collapseToEnd) {
15582 selection == null ? void 0 : selection.collapseToEnd();
15583 }
15584 }
15585 }
15586 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
15587 function focusSilently(element) {
15588 element[FOCUS_SILENTLY] = true;
15589 element.focus({ preventScroll: true });
15590 }
15591 function silentlyFocused(element) {
15592 const isSilentlyFocused = element[FOCUS_SILENTLY];
15593 delete element[FOCUS_SILENTLY];
15594 return isSilentlyFocused;
15595 }
15596 function isItem(store, element, exclude) {
15597 if (!element) return false;
15598 if (element === exclude) return false;
15599 const item = store.item(element.id);
15600 if (!item) return false;
15601 if (exclude && item.element === exclude) return false;
15602 return true;
15603 }
15604
15605 // node_modules/@ariakit/react-core/esm/__chunks/Z2O3VLAQ.js
15606 var import_react14 = __toESM(require_react(), 1);
15607 var TagName = "div";
15608 var useCollectionItem = createHook(
15609 function useCollectionItem2({
15610 store,
15611 shouldRegisterItem = true,
15612 getItem = identity,
15613 // @ts-expect-error This prop may come from a collection renderer.
15614 element,
15615 ...props
15616 }) {
15617 const context = useCollectionContext();
15618 store = store || context;
15619 const id = useId4(props.id);
15620 const ref = (0, import_react14.useRef)(element);
15621 (0, import_react14.useEffect)(() => {
15622 const element2 = ref.current;
15623 if (!id) return;
15624 if (!element2) return;
15625 if (!shouldRegisterItem) return;
15626 const item = getItem({ id, element: element2 });
15627 return store == null ? void 0 : store.renderItem(item);
15628 }, [id, shouldRegisterItem, getItem, store]);
15629 props = {
15630 ...props,
15631 ref: useMergeRefs(ref, props.ref)
15632 };
15633 return removeUndefinedValues(props);
15634 }
15635 );
15636 var CollectionItem = forwardRef210(function CollectionItem2(props) {
15637 const htmlProps = useCollectionItem(props);
15638 return createElement3(TagName, htmlProps);
15639 });
15640
15641 // node_modules/@ariakit/react-core/esm/__chunks/SWN3JYXT.js
15642 var import_react15 = __toESM(require_react(), 1);
15643 var FocusableContext = (0, import_react15.createContext)(true);
15644
15645 // node_modules/@ariakit/core/esm/utils/focus.js
15646 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'])";
15647 function isFocusable(element) {
15648 if (!element.matches(selector)) return false;
15649 if (!isVisible(element)) return false;
15650 if (element.closest("[inert]")) return false;
15651 return true;
15652 }
15653 function getClosestFocusable(element) {
15654 while (element && !isFocusable(element)) {
15655 element = element.closest(selector);
15656 }
15657 return element || null;
15658 }
15659 function hasFocus(element) {
15660 const activeElement2 = getActiveElement(element);
15661 if (!activeElement2) return false;
15662 if (activeElement2 === element) return true;
15663 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15664 if (!activeDescendant) return false;
15665 return activeDescendant === element.id;
15666 }
15667 function hasFocusWithin(element) {
15668 const activeElement2 = getActiveElement(element);
15669 if (!activeElement2) return false;
15670 if (contains2(element, activeElement2)) return true;
15671 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15672 if (!activeDescendant) return false;
15673 if (!("id" in element)) return false;
15674 if (activeDescendant === element.id) return true;
15675 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
15676 }
15677 function focusIfNeeded(element) {
15678 if (!hasFocusWithin(element) && isFocusable(element)) {
15679 element.focus();
15680 }
15681 }
15682 function focusIntoView(element, options) {
15683 if (!("scrollIntoView" in element)) {
15684 element.focus();
15685 } else {
15686 element.focus({ preventScroll: true });
15687 element.scrollIntoView({ block: "nearest", inline: "nearest", ...options });
15688 }
15689 }
15690
15691 // node_modules/@ariakit/react-core/esm/__chunks/U6HHPQDW.js
15692 var import_react16 = __toESM(require_react(), 1);
15693 var TagName2 = "div";
15694 var isSafariBrowser = isSafari2();
15695 var alwaysFocusVisibleInputTypes = [
15696 "text",
15697 "search",
15698 "url",
15699 "tel",
15700 "email",
15701 "password",
15702 "number",
15703 "date",
15704 "month",
15705 "week",
15706 "time",
15707 "datetime",
15708 "datetime-local"
15709 ];
15710 var safariFocusAncestorSymbol = /* @__PURE__ */ Symbol("safariFocusAncestor");
15711 function markSafariFocusAncestor(element, value) {
15712 if (!element) return;
15713 element[safariFocusAncestorSymbol] = value;
15714 }
15715 function isAlwaysFocusVisible(element) {
15716 const { tagName, readOnly, type } = element;
15717 if (tagName === "TEXTAREA" && !readOnly) return true;
15718 if (tagName === "SELECT" && !readOnly) return true;
15719 if (tagName === "INPUT" && !readOnly) {
15720 return alwaysFocusVisibleInputTypes.includes(type);
15721 }
15722 if (element.isContentEditable) return true;
15723 const role = element.getAttribute("role");
15724 if (role === "combobox" && element.dataset.name) {
15725 return true;
15726 }
15727 return false;
15728 }
15729 function getLabels(element) {
15730 if ("labels" in element) {
15731 return element.labels;
15732 }
15733 return null;
15734 }
15735 function isNativeCheckboxOrRadio(element) {
15736 const tagName = element.tagName.toLowerCase();
15737 if (tagName === "input" && element.type) {
15738 return element.type === "radio" || element.type === "checkbox";
15739 }
15740 return false;
15741 }
15742 function isNativeTabbable(tagName) {
15743 if (!tagName) return true;
15744 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
15745 }
15746 function supportsDisabledAttribute(tagName) {
15747 if (!tagName) return true;
15748 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
15749 }
15750 function getTabIndex2(focusable2, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) {
15751 if (!focusable2) {
15752 return tabIndexProp;
15753 }
15754 if (trulyDisabled) {
15755 if (nativeTabbable && !supportsDisabled) {
15756 return -1;
15757 }
15758 return;
15759 }
15760 if (nativeTabbable) {
15761 return tabIndexProp;
15762 }
15763 return tabIndexProp || 0;
15764 }
15765 function useDisableEvent(onEvent, disabled2) {
15766 return useEvent((event) => {
15767 onEvent == null ? void 0 : onEvent(event);
15768 if (event.defaultPrevented) return;
15769 if (disabled2) {
15770 event.stopPropagation();
15771 event.preventDefault();
15772 }
15773 });
15774 }
15775 var hasInstalledGlobalEventListeners2 = false;
15776 var isKeyboardModality = true;
15777 function onGlobalMouseDown(event) {
15778 const target = event.target;
15779 if (target && "hasAttribute" in target) {
15780 if (!target.hasAttribute("data-focus-visible")) {
15781 isKeyboardModality = false;
15782 }
15783 }
15784 }
15785 function onGlobalKeyDown(event) {
15786 if (event.metaKey) return;
15787 if (event.ctrlKey) return;
15788 if (event.altKey) return;
15789 isKeyboardModality = true;
15790 }
15791 var useFocusable = createHook(
15792 function useFocusable2({
15793 focusable: focusable2 = true,
15794 accessibleWhenDisabled,
15795 autoFocus,
15796 onFocusVisible,
15797 ...props
15798 }) {
15799 const ref = (0, import_react16.useRef)(null);
15800 (0, import_react16.useEffect)(() => {
15801 if (!focusable2) return;
15802 if (hasInstalledGlobalEventListeners2) return;
15803 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
15804 addGlobalEventListener("keydown", onGlobalKeyDown, true);
15805 hasInstalledGlobalEventListeners2 = true;
15806 }, [focusable2]);
15807 if (isSafariBrowser) {
15808 (0, import_react16.useEffect)(() => {
15809 if (!focusable2) return;
15810 const element = ref.current;
15811 if (!element) return;
15812 if (!isNativeCheckboxOrRadio(element)) return;
15813 const labels = getLabels(element);
15814 if (!labels) return;
15815 const onMouseUp = () => queueMicrotask(() => element.focus());
15816 for (const label of labels) {
15817 label.addEventListener("mouseup", onMouseUp);
15818 }
15819 return () => {
15820 for (const label of labels) {
15821 label.removeEventListener("mouseup", onMouseUp);
15822 }
15823 };
15824 }, [focusable2]);
15825 }
15826 const disabled2 = focusable2 && disabledFromProps(props);
15827 const trulyDisabled = !!disabled2 && !accessibleWhenDisabled;
15828 const [focusVisible, setFocusVisible] = (0, import_react16.useState)(false);
15829 (0, import_react16.useEffect)(() => {
15830 if (!focusable2) return;
15831 if (trulyDisabled && focusVisible) {
15832 setFocusVisible(false);
15833 }
15834 }, [focusable2, trulyDisabled, focusVisible]);
15835 (0, import_react16.useEffect)(() => {
15836 if (!focusable2) return;
15837 if (!focusVisible) return;
15838 const element = ref.current;
15839 if (!element) return;
15840 if (typeof IntersectionObserver === "undefined") return;
15841 const observer = new IntersectionObserver(() => {
15842 if (!isFocusable(element)) {
15843 setFocusVisible(false);
15844 }
15845 });
15846 observer.observe(element);
15847 return () => observer.disconnect();
15848 }, [focusable2, focusVisible]);
15849 const onKeyPressCapture = useDisableEvent(
15850 props.onKeyPressCapture,
15851 disabled2
15852 );
15853 const onMouseDownCapture = useDisableEvent(
15854 props.onMouseDownCapture,
15855 disabled2
15856 );
15857 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
15858 const onMouseDownProp = props.onMouseDown;
15859 const onMouseDown = useEvent((event) => {
15860 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
15861 if (event.defaultPrevented) return;
15862 if (!focusable2) return;
15863 const element = event.currentTarget;
15864 if (!isSafariBrowser) return;
15865 if (isPortalEvent(event)) return;
15866 if (!isButton(element) && !isNativeCheckboxOrRadio(element)) return;
15867 let receivedFocus = false;
15868 const onFocus = () => {
15869 receivedFocus = true;
15870 };
15871 const options = { capture: true, once: true };
15872 element.addEventListener("focusin", onFocus, options);
15873 const focusableContainer = getClosestFocusable(element.parentElement);
15874 markSafariFocusAncestor(focusableContainer, true);
15875 queueBeforeEvent(element, "mouseup", () => {
15876 element.removeEventListener("focusin", onFocus, true);
15877 markSafariFocusAncestor(focusableContainer, false);
15878 if (receivedFocus) return;
15879 focusIfNeeded(element);
15880 });
15881 });
15882 const handleFocusVisible = (event, currentTarget) => {
15883 if (currentTarget) {
15884 event.currentTarget = currentTarget;
15885 }
15886 if (!focusable2) return;
15887 const element = event.currentTarget;
15888 if (!element) return;
15889 if (!hasFocus(element)) return;
15890 onFocusVisible == null ? void 0 : onFocusVisible(event);
15891 if (event.defaultPrevented) return;
15892 element.dataset.focusVisible = "true";
15893 setFocusVisible(true);
15894 };
15895 const onKeyDownCaptureProp = props.onKeyDownCapture;
15896 const onKeyDownCapture = useEvent((event) => {
15897 onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event);
15898 if (event.defaultPrevented) return;
15899 if (!focusable2) return;
15900 if (focusVisible) return;
15901 if (event.metaKey) return;
15902 if (event.altKey) return;
15903 if (event.ctrlKey) return;
15904 if (!isSelfTarget(event)) return;
15905 const element = event.currentTarget;
15906 const applyFocusVisible = () => handleFocusVisible(event, element);
15907 queueBeforeEvent(element, "focusout", applyFocusVisible);
15908 });
15909 const onFocusCaptureProp = props.onFocusCapture;
15910 const onFocusCapture = useEvent((event) => {
15911 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
15912 if (event.defaultPrevented) return;
15913 if (!focusable2) return;
15914 if (!isSelfTarget(event)) {
15915 setFocusVisible(false);
15916 return;
15917 }
15918 const element = event.currentTarget;
15919 const applyFocusVisible = () => handleFocusVisible(event, element);
15920 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) {
15921 queueBeforeEvent(event.target, "focusout", applyFocusVisible);
15922 } else {
15923 setFocusVisible(false);
15924 }
15925 });
15926 const onBlurProp = props.onBlur;
15927 const onBlur = useEvent((event) => {
15928 onBlurProp == null ? void 0 : onBlurProp(event);
15929 if (!focusable2) return;
15930 if (!isFocusEventOutside(event)) return;
15931 event.currentTarget.removeAttribute("data-focus-visible");
15932 setFocusVisible(false);
15933 });
15934 const autoFocusOnShow = (0, import_react16.useContext)(FocusableContext);
15935 const autoFocusRef = useEvent((element) => {
15936 if (!focusable2) return;
15937 if (!autoFocus) return;
15938 if (!element) return;
15939 if (!autoFocusOnShow) return;
15940 queueMicrotask(() => {
15941 if (hasFocus(element)) return;
15942 if (!isFocusable(element)) return;
15943 element.focus();
15944 });
15945 });
15946 const tagName = useTagName(ref);
15947 const nativeTabbable = focusable2 && isNativeTabbable(tagName);
15948 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName);
15949 const styleProp = props.style;
15950 const style = (0, import_react16.useMemo)(() => {
15951 if (trulyDisabled) {
15952 return { pointerEvents: "none", ...styleProp };
15953 }
15954 return styleProp;
15955 }, [trulyDisabled, styleProp]);
15956 props = {
15957 "data-focus-visible": focusable2 && focusVisible || void 0,
15958 "data-autofocus": autoFocus || void 0,
15959 "aria-disabled": disabled2 || void 0,
15960 ...props,
15961 ref: useMergeRefs(ref, autoFocusRef, props.ref),
15962 style,
15963 tabIndex: getTabIndex2(
15964 focusable2,
15965 trulyDisabled,
15966 nativeTabbable,
15967 supportsDisabled,
15968 props.tabIndex
15969 ),
15970 disabled: supportsDisabled && trulyDisabled ? true : void 0,
15971 // TODO: Test Focusable contentEditable.
15972 contentEditable: disabled2 ? void 0 : props.contentEditable,
15973 onKeyPressCapture,
15974 onClickCapture,
15975 onMouseDownCapture,
15976 onMouseDown,
15977 onKeyDownCapture,
15978 onFocusCapture,
15979 onBlur
15980 };
15981 return removeUndefinedValues(props);
15982 }
15983 );
15984 var Focusable = forwardRef210(function Focusable2(props) {
15985 const htmlProps = useFocusable(props);
15986 return createElement3(TagName2, htmlProps);
15987 });
15988
15989 // node_modules/@ariakit/react-core/esm/__chunks/PZ3OL7I2.js
15990 var import_react17 = __toESM(require_react(), 1);
15991 var TagName3 = "button";
15992 function isNativeClick(event) {
15993 if (!event.isTrusted) return false;
15994 const element = event.currentTarget;
15995 if (event.key === "Enter") {
15996 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
15997 }
15998 if (event.key === " ") {
15999 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
16000 }
16001 return false;
16002 }
16003 var symbol = /* @__PURE__ */ Symbol("command");
16004 var useCommand = createHook(
16005 function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
16006 const ref = (0, import_react17.useRef)(null);
16007 const [isNativeButton, setIsNativeButton] = (0, import_react17.useState)(false);
16008 (0, import_react17.useEffect)(() => {
16009 if (!ref.current) return;
16010 setIsNativeButton(isButton(ref.current));
16011 }, []);
16012 const [active, setActive] = (0, import_react17.useState)(false);
16013 const activeRef = (0, import_react17.useRef)(false);
16014 const disabled2 = disabledFromProps(props);
16015 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
16016 const onKeyDownProp = props.onKeyDown;
16017 const onKeyDown = useEvent((event) => {
16018 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
16019 const element = event.currentTarget;
16020 if (event.defaultPrevented) return;
16021 if (isDuplicate) return;
16022 if (disabled2) return;
16023 if (!isSelfTarget(event)) return;
16024 if (isTextField(element)) return;
16025 if (element.isContentEditable) return;
16026 const isEnter = clickOnEnter && event.key === "Enter";
16027 const isSpace = clickOnSpace && event.key === " ";
16028 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
16029 const shouldPreventSpace = event.key === " " && !clickOnSpace;
16030 if (shouldPreventEnter || shouldPreventSpace) {
16031 event.preventDefault();
16032 return;
16033 }
16034 if (isEnter || isSpace) {
16035 const nativeClick = isNativeClick(event);
16036 if (isEnter) {
16037 if (!nativeClick) {
16038 event.preventDefault();
16039 const { view, ...eventInit } = event;
16040 const click = () => fireClickEvent(element, eventInit);
16041 if (isFirefox2()) {
16042 queueBeforeEvent(element, "keyup", click);
16043 } else {
16044 queueMicrotask(click);
16045 }
16046 }
16047 } else if (isSpace) {
16048 activeRef.current = true;
16049 if (!nativeClick) {
16050 event.preventDefault();
16051 setActive(true);
16052 }
16053 }
16054 }
16055 });
16056 const onKeyUpProp = props.onKeyUp;
16057 const onKeyUp = useEvent((event) => {
16058 onKeyUpProp == null ? void 0 : onKeyUpProp(event);
16059 if (event.defaultPrevented) return;
16060 if (isDuplicate) return;
16061 if (disabled2) return;
16062 if (event.metaKey) return;
16063 const isSpace = clickOnSpace && event.key === " ";
16064 if (activeRef.current && isSpace) {
16065 activeRef.current = false;
16066 if (!isNativeClick(event)) {
16067 event.preventDefault();
16068 setActive(false);
16069 const element = event.currentTarget;
16070 const { view, ...eventInit } = event;
16071 queueMicrotask(() => fireClickEvent(element, eventInit));
16072 }
16073 }
16074 });
16075 props = {
16076 "data-active": active || void 0,
16077 type: isNativeButton ? "button" : void 0,
16078 ...metadataProps,
16079 ...props,
16080 ref: useMergeRefs(ref, props.ref),
16081 onKeyDown,
16082 onKeyUp
16083 };
16084 props = useFocusable(props);
16085 return props;
16086 }
16087 );
16088 var Command = forwardRef210(function Command2(props) {
16089 const htmlProps = useCommand(props);
16090 return createElement3(TagName3, htmlProps);
16091 });
16092
16093 // node_modules/@ariakit/core/esm/__chunks/SXKM4CGU.js
16094 function getInternal(store, key) {
16095 const internals = store.__unstableInternals;
16096 invariant(internals, "Invalid store");
16097 return internals[key];
16098 }
16099 function createStore(initialState, ...stores) {
16100 let state = initialState;
16101 let prevStateBatch = state;
16102 let lastUpdate = /* @__PURE__ */ Symbol();
16103 let destroy = noop4;
16104 const instances = /* @__PURE__ */ new Set();
16105 const updatedKeys = /* @__PURE__ */ new Set();
16106 const setups = /* @__PURE__ */ new Set();
16107 const listeners = /* @__PURE__ */ new Set();
16108 const batchListeners = /* @__PURE__ */ new Set();
16109 const disposables = /* @__PURE__ */ new WeakMap();
16110 const listenerKeys = /* @__PURE__ */ new WeakMap();
16111 const storeSetup = (callback) => {
16112 setups.add(callback);
16113 return () => setups.delete(callback);
16114 };
16115 const storeInit = () => {
16116 const initialized = instances.size;
16117 const instance = /* @__PURE__ */ Symbol();
16118 instances.add(instance);
16119 const maybeDestroy = () => {
16120 instances.delete(instance);
16121 if (instances.size) return;
16122 destroy();
16123 };
16124 if (initialized) return maybeDestroy;
16125 const desyncs = getKeys(state).map(
16126 (key) => chain(
16127 ...stores.map((store) => {
16128 var _a;
16129 const storeState = (_a = store == null ? void 0 : store.getState) == null ? void 0 : _a.call(store);
16130 if (!storeState) return;
16131 if (!hasOwnProperty(storeState, key)) return;
16132 return sync(store, [key], (state2) => {
16133 setState(
16134 key,
16135 state2[key],
16136 // @ts-expect-error - Not public API. This is just to prevent
16137 // infinite loops.
16138 true
16139 );
16140 });
16141 })
16142 )
16143 );
16144 const teardowns = [];
16145 for (const setup2 of setups) {
16146 teardowns.push(setup2());
16147 }
16148 const cleanups = stores.map(init);
16149 destroy = chain(...desyncs, ...teardowns, ...cleanups);
16150 return maybeDestroy;
16151 };
16152 const sub = (keys, listener, set2 = listeners) => {
16153 set2.add(listener);
16154 listenerKeys.set(listener, keys);
16155 return () => {
16156 var _a;
16157 (_a = disposables.get(listener)) == null ? void 0 : _a();
16158 disposables.delete(listener);
16159 listenerKeys.delete(listener);
16160 set2.delete(listener);
16161 };
16162 };
16163 const storeSubscribe = (keys, listener) => sub(keys, listener);
16164 const storeSync = (keys, listener) => {
16165 disposables.set(listener, listener(state, state));
16166 return sub(keys, listener);
16167 };
16168 const storeBatch = (keys, listener) => {
16169 disposables.set(listener, listener(state, prevStateBatch));
16170 return sub(keys, listener, batchListeners);
16171 };
16172 const storePick = (keys) => createStore(pick(state, keys), finalStore);
16173 const storeOmit = (keys) => createStore(omit(state, keys), finalStore);
16174 const getState = () => state;
16175 const setState = (key, value, fromStores = false) => {
16176 var _a;
16177 if (!hasOwnProperty(state, key)) return;
16178 const nextValue = applyState(value, state[key]);
16179 if (nextValue === state[key]) return;
16180 if (!fromStores) {
16181 for (const store of stores) {
16182 (_a = store == null ? void 0 : store.setState) == null ? void 0 : _a.call(store, key, nextValue);
16183 }
16184 }
16185 const prevState = state;
16186 state = { ...state, [key]: nextValue };
16187 const thisUpdate = /* @__PURE__ */ Symbol();
16188 lastUpdate = thisUpdate;
16189 updatedKeys.add(key);
16190 const run = (listener, prev, uKeys) => {
16191 var _a2;
16192 const keys = listenerKeys.get(listener);
16193 const updated = (k) => uKeys ? uKeys.has(k) : k === key;
16194 if (!keys || keys.some(updated)) {
16195 (_a2 = disposables.get(listener)) == null ? void 0 : _a2();
16196 disposables.set(listener, listener(state, prev));
16197 }
16198 };
16199 for (const listener of listeners) {
16200 run(listener, prevState);
16201 }
16202 queueMicrotask(() => {
16203 if (lastUpdate !== thisUpdate) return;
16204 const snapshot = state;
16205 for (const listener of batchListeners) {
16206 run(listener, prevStateBatch, updatedKeys);
16207 }
16208 prevStateBatch = snapshot;
16209 updatedKeys.clear();
16210 });
16211 };
16212 const finalStore = {
16213 getState,
16214 setState,
16215 __unstableInternals: {
16216 setup: storeSetup,
16217 init: storeInit,
16218 subscribe: storeSubscribe,
16219 sync: storeSync,
16220 batch: storeBatch,
16221 pick: storePick,
16222 omit: storeOmit
16223 }
16224 };
16225 return finalStore;
16226 }
16227 function setup(store, ...args) {
16228 if (!store) return;
16229 return getInternal(store, "setup")(...args);
16230 }
16231 function init(store, ...args) {
16232 if (!store) return;
16233 return getInternal(store, "init")(...args);
16234 }
16235 function subscribe(store, ...args) {
16236 if (!store) return;
16237 return getInternal(store, "subscribe")(...args);
16238 }
16239 function sync(store, ...args) {
16240 if (!store) return;
16241 return getInternal(store, "sync")(...args);
16242 }
16243 function batch(store, ...args) {
16244 if (!store) return;
16245 return getInternal(store, "batch")(...args);
16246 }
16247 function omit2(store, ...args) {
16248 if (!store) return;
16249 return getInternal(store, "omit")(...args);
16250 }
16251 function pick2(store, ...args) {
16252 if (!store) return;
16253 return getInternal(store, "pick")(...args);
16254 }
16255 function mergeStore(...stores) {
16256 var _a;
16257 const initialState = {};
16258 for (const store2 of stores) {
16259 const nextState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2);
16260 if (nextState) {
16261 Object.assign(initialState, nextState);
16262 }
16263 }
16264 const store = createStore(initialState, ...stores);
16265 return Object.assign({}, ...stores, store);
16266 }
16267 function throwOnConflictingProps(props, store) {
16268 if (false) return;
16269 if (!store) return;
16270 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
16271 var _a;
16272 const stateKey = key.replace("default", "");
16273 return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}${stateKey.slice(1)}`;
16274 });
16275 if (!defaultKeys.length) return;
16276 const storeState = store.getState();
16277 const conflictingProps = defaultKeys.filter(
16278 (key) => hasOwnProperty(storeState, key)
16279 );
16280 if (!conflictingProps.length) return;
16281 throw new Error(
16282 `Passing a store prop in conjunction with a default state is not supported.
16283
16284 const store = useSelectStore();
16285 <SelectProvider store={store} defaultValue="Apple" />
16286 ^ ^
16287
16288 Instead, pass the default state to the topmost store:
16289
16290 const store = useSelectStore({ defaultValue: "Apple" });
16291 <SelectProvider store={store} />
16292
16293 See https://github.com/ariakit/ariakit/pull/2745 for more details.
16294
16295 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
16296 `
16297 );
16298 }
16299
16300 // node_modules/@ariakit/react-core/esm/__chunks/Q5W46E73.js
16301 var React50 = __toESM(require_react(), 1);
16302 var import_shim2 = __toESM(require_shim(), 1);
16303 var { useSyncExternalStore: useSyncExternalStore2 } = import_shim2.default;
16304 var noopSubscribe = () => () => {
16305 };
16306 function useStoreState(store, keyOrSelector = identity) {
16307 const storeSubscribe = React50.useCallback(
16308 (callback) => {
16309 if (!store) return noopSubscribe();
16310 return subscribe(store, null, callback);
16311 },
16312 [store]
16313 );
16314 const getSnapshot = () => {
16315 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
16316 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
16317 const state = store == null ? void 0 : store.getState();
16318 if (selector2) return selector2(state);
16319 if (!state) return;
16320 if (!key) return;
16321 if (!hasOwnProperty(state, key)) return;
16322 return state[key];
16323 };
16324 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot);
16325 }
16326 function useStoreStateObject(store, object) {
16327 const objRef = React50.useRef(
16328 {}
16329 );
16330 const storeSubscribe = React50.useCallback(
16331 (callback) => {
16332 if (!store) return noopSubscribe();
16333 return subscribe(store, null, callback);
16334 },
16335 [store]
16336 );
16337 const getSnapshot = () => {
16338 const state = store == null ? void 0 : store.getState();
16339 let updated = false;
16340 const obj = objRef.current;
16341 for (const prop in object) {
16342 const keyOrSelector = object[prop];
16343 if (typeof keyOrSelector === "function") {
16344 const value = keyOrSelector(state);
16345 if (value !== obj[prop]) {
16346 obj[prop] = value;
16347 updated = true;
16348 }
16349 }
16350 if (typeof keyOrSelector === "string") {
16351 if (!state) continue;
16352 if (!hasOwnProperty(state, keyOrSelector)) continue;
16353 const value = state[keyOrSelector];
16354 if (value !== obj[prop]) {
16355 obj[prop] = value;
16356 updated = true;
16357 }
16358 }
16359 }
16360 if (updated) {
16361 objRef.current = { ...obj };
16362 }
16363 return objRef.current;
16364 };
16365 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot);
16366 }
16367 function useStoreProps(store, props, key, setKey) {
16368 const value = hasOwnProperty(props, key) ? props[key] : void 0;
16369 const setValue = setKey ? props[setKey] : void 0;
16370 const propsRef = useLiveRef({ value, setValue });
16371 useSafeLayoutEffect(() => {
16372 return sync(store, [key], (state, prev) => {
16373 const { value: value2, setValue: setValue2 } = propsRef.current;
16374 if (!setValue2) return;
16375 if (state[key] === prev[key]) return;
16376 if (state[key] === value2) return;
16377 setValue2(state[key]);
16378 });
16379 }, [store, key]);
16380 useSafeLayoutEffect(() => {
16381 if (value === void 0) return;
16382 store.setState(key, value);
16383 return batch(store, [key], () => {
16384 if (value === void 0) return;
16385 store.setState(key, value);
16386 });
16387 });
16388 }
16389 function useStore2(createStore2, props) {
16390 const [store, setStore] = React50.useState(() => createStore2(props));
16391 useSafeLayoutEffect(() => init(store), [store]);
16392 const useState210 = React50.useCallback(
16393 (keyOrSelector) => useStoreState(store, keyOrSelector),
16394 [store]
16395 );
16396 const memoizedStore = React50.useMemo(
16397 () => ({ ...store, useState: useState210 }),
16398 [store, useState210]
16399 );
16400 const updateStore = useEvent(() => {
16401 setStore((store2) => createStore2({ ...props, ...store2.getState() }));
16402 });
16403 return [memoizedStore, updateStore];
16404 }
16405
16406 // node_modules/@ariakit/react-core/esm/__chunks/WZWDIE3S.js
16407 var import_react18 = __toESM(require_react(), 1);
16408 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
16409 var TagName4 = "button";
16410 function isEditableElement(element) {
16411 if (isTextbox(element)) return true;
16412 return element.tagName === "INPUT" && !isButton(element);
16413 }
16414 function getNextPageOffset(scrollingElement, pageUp = false) {
16415 const height = scrollingElement.clientHeight;
16416 const { top } = scrollingElement.getBoundingClientRect();
16417 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
16418 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
16419 if (scrollingElement.tagName === "HTML") {
16420 return pageOffset + scrollingElement.scrollTop;
16421 }
16422 return pageOffset;
16423 }
16424 function getItemOffset(itemElement, pageUp = false) {
16425 const { top } = itemElement.getBoundingClientRect();
16426 if (pageUp) {
16427 return top + itemElement.clientHeight;
16428 }
16429 return top;
16430 }
16431 function findNextPageItemId(element, store, next, pageUp = false) {
16432 var _a;
16433 if (!store) return;
16434 if (!next) return;
16435 const { renderedItems } = store.getState();
16436 const scrollingElement = getScrollingElement(element);
16437 if (!scrollingElement) return;
16438 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
16439 let id;
16440 let prevDifference;
16441 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
16442 const previousId = id;
16443 id = next(i2);
16444 if (!id) break;
16445 if (id === previousId) continue;
16446 const itemElement = (_a = getEnabledItem(store, id)) == null ? void 0 : _a.element;
16447 if (!itemElement) continue;
16448 const itemOffset = getItemOffset(itemElement, pageUp);
16449 const difference = itemOffset - nextPageOffset;
16450 const absDifference = Math.abs(difference);
16451 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
16452 if (prevDifference !== void 0 && prevDifference < absDifference) {
16453 id = previousId;
16454 }
16455 break;
16456 }
16457 prevDifference = absDifference;
16458 }
16459 return id;
16460 }
16461 function targetIsAnotherItem(event, store) {
16462 if (isSelfTarget(event)) return false;
16463 return isItem(store, event.target);
16464 }
16465 var useCompositeItem = createHook(
16466 function useCompositeItem2({
16467 store,
16468 rowId: rowIdProp,
16469 preventScrollOnKeyDown = false,
16470 moveOnKeyPress = true,
16471 tabbable: tabbable2 = false,
16472 getItem: getItemProp,
16473 "aria-setsize": ariaSetSizeProp,
16474 "aria-posinset": ariaPosInSetProp,
16475 ...props
16476 }) {
16477 const context = useCompositeContext();
16478 store = store || context;
16479 const id = useId4(props.id);
16480 const ref = (0, import_react18.useRef)(null);
16481 const row = (0, import_react18.useContext)(CompositeRowContext);
16482 const disabled2 = disabledFromProps(props);
16483 const trulyDisabled = disabled2 && !props.accessibleWhenDisabled;
16484 const {
16485 rowId,
16486 baseElement,
16487 isActiveItem,
16488 ariaSetSize,
16489 ariaPosInSet,
16490 isTabbable
16491 } = useStoreStateObject(store, {
16492 rowId(state) {
16493 if (rowIdProp) return rowIdProp;
16494 if (!state) return;
16495 if (!(row == null ? void 0 : row.baseElement)) return;
16496 if (row.baseElement !== state.baseElement) return;
16497 return row.id;
16498 },
16499 baseElement(state) {
16500 return (state == null ? void 0 : state.baseElement) || void 0;
16501 },
16502 isActiveItem(state) {
16503 return !!state && state.activeId === id;
16504 },
16505 ariaSetSize(state) {
16506 if (ariaSetSizeProp != null) return ariaSetSizeProp;
16507 if (!state) return;
16508 if (!(row == null ? void 0 : row.ariaSetSize)) return;
16509 if (row.baseElement !== state.baseElement) return;
16510 return row.ariaSetSize;
16511 },
16512 ariaPosInSet(state) {
16513 if (ariaPosInSetProp != null) return ariaPosInSetProp;
16514 if (!state) return;
16515 if (!(row == null ? void 0 : row.ariaPosInSet)) return;
16516 if (row.baseElement !== state.baseElement) return;
16517 const itemsInRow = state.renderedItems.filter(
16518 (item) => item.rowId === rowId
16519 );
16520 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
16521 },
16522 isTabbable(state) {
16523 if (!(state == null ? void 0 : state.renderedItems.length)) return true;
16524 if (state.virtualFocus) return false;
16525 if (tabbable2) return true;
16526 if (state.activeId === null) return false;
16527 const item = store == null ? void 0 : store.item(state.activeId);
16528 if (item == null ? void 0 : item.disabled) return true;
16529 if (!(item == null ? void 0 : item.element)) return true;
16530 return state.activeId === id;
16531 }
16532 });
16533 const getItem = (0, import_react18.useCallback)(
16534 (item) => {
16535 var _a;
16536 const nextItem = {
16537 ...item,
16538 id: id || item.id,
16539 rowId,
16540 disabled: !!trulyDisabled,
16541 children: (_a = item.element) == null ? void 0 : _a.textContent
16542 };
16543 if (getItemProp) {
16544 return getItemProp(nextItem);
16545 }
16546 return nextItem;
16547 },
16548 [id, rowId, trulyDisabled, getItemProp]
16549 );
16550 const onFocusProp = props.onFocus;
16551 const hasFocusedComposite = (0, import_react18.useRef)(false);
16552 const onFocus = useEvent((event) => {
16553 onFocusProp == null ? void 0 : onFocusProp(event);
16554 if (event.defaultPrevented) return;
16555 if (isPortalEvent(event)) return;
16556 if (!id) return;
16557 if (!store) return;
16558 if (targetIsAnotherItem(event, store)) return;
16559 const { virtualFocus, baseElement: baseElement2 } = store.getState();
16560 store.setActiveId(id);
16561 if (isTextbox(event.currentTarget)) {
16562 selectTextField(event.currentTarget);
16563 }
16564 if (!virtualFocus) return;
16565 if (!isSelfTarget(event)) return;
16566 if (isEditableElement(event.currentTarget)) return;
16567 if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) return;
16568 if (isSafari2() && event.currentTarget.hasAttribute("data-autofocus")) {
16569 event.currentTarget.scrollIntoView({
16570 block: "nearest",
16571 inline: "nearest"
16572 });
16573 }
16574 hasFocusedComposite.current = true;
16575 const fromComposite = event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget);
16576 if (fromComposite) {
16577 focusSilently(baseElement2);
16578 } else {
16579 baseElement2.focus();
16580 }
16581 });
16582 const onBlurCaptureProp = props.onBlurCapture;
16583 const onBlurCapture = useEvent((event) => {
16584 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
16585 if (event.defaultPrevented) return;
16586 const state = store == null ? void 0 : store.getState();
16587 if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) {
16588 hasFocusedComposite.current = false;
16589 event.preventDefault();
16590 event.stopPropagation();
16591 }
16592 });
16593 const onKeyDownProp = props.onKeyDown;
16594 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
16595 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
16596 const onKeyDown = useEvent((event) => {
16597 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
16598 if (event.defaultPrevented) return;
16599 if (!isSelfTarget(event)) return;
16600 if (!store) return;
16601 const { currentTarget } = event;
16602 const state = store.getState();
16603 const item = store.item(id);
16604 const isGrid2 = !!(item == null ? void 0 : item.rowId);
16605 const isVertical = state.orientation !== "horizontal";
16606 const isHorizontal = state.orientation !== "vertical";
16607 const canHomeEnd = () => {
16608 if (isGrid2) return true;
16609 if (isHorizontal) return true;
16610 if (!state.baseElement) return true;
16611 if (!isTextField(state.baseElement)) return true;
16612 return false;
16613 };
16614 const keyMap = {
16615 ArrowUp: (isGrid2 || isVertical) && store.up,
16616 ArrowRight: (isGrid2 || isHorizontal) && store.next,
16617 ArrowDown: (isGrid2 || isVertical) && store.down,
16618 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
16619 Home: () => {
16620 if (!canHomeEnd()) return;
16621 if (!isGrid2 || event.ctrlKey) {
16622 return store == null ? void 0 : store.first();
16623 }
16624 return store == null ? void 0 : store.previous(-1);
16625 },
16626 End: () => {
16627 if (!canHomeEnd()) return;
16628 if (!isGrid2 || event.ctrlKey) {
16629 return store == null ? void 0 : store.last();
16630 }
16631 return store == null ? void 0 : store.next(-1);
16632 },
16633 PageUp: () => {
16634 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.up, true);
16635 },
16636 PageDown: () => {
16637 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.down);
16638 }
16639 };
16640 const action = keyMap[event.key];
16641 if (action) {
16642 if (isTextbox(currentTarget)) {
16643 const selection = getTextboxSelection(currentTarget);
16644 const isLeft = isHorizontal && event.key === "ArrowLeft";
16645 const isRight = isHorizontal && event.key === "ArrowRight";
16646 const isUp = isVertical && event.key === "ArrowUp";
16647 const isDown = isVertical && event.key === "ArrowDown";
16648 if (isRight || isDown) {
16649 const { length: valueLength } = getTextboxValue(currentTarget);
16650 if (selection.end !== valueLength) return;
16651 } else if ((isLeft || isUp) && selection.start !== 0) return;
16652 }
16653 const nextId = action();
16654 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
16655 if (!moveOnKeyPressProp(event)) return;
16656 event.preventDefault();
16657 store.move(nextId);
16658 }
16659 }
16660 });
16661 const providerValue = (0, import_react18.useMemo)(
16662 () => ({ id, baseElement }),
16663 [id, baseElement]
16664 );
16665 props = useWrapElement(
16666 props,
16667 (element) => /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }),
16668 [providerValue]
16669 );
16670 props = {
16671 id,
16672 "data-active-item": isActiveItem || void 0,
16673 ...props,
16674 ref: useMergeRefs(ref, props.ref),
16675 tabIndex: isTabbable ? props.tabIndex : -1,
16676 onFocus,
16677 onBlurCapture,
16678 onKeyDown
16679 };
16680 props = useCommand(props);
16681 props = useCollectionItem({
16682 store,
16683 ...props,
16684 getItem,
16685 shouldRegisterItem: id ? props.shouldRegisterItem : false
16686 });
16687 return removeUndefinedValues({
16688 ...props,
16689 "aria-setsize": ariaSetSize,
16690 "aria-posinset": ariaPosInSet
16691 });
16692 }
16693 );
16694 var CompositeItem = memo22(
16695 forwardRef210(function CompositeItem2(props) {
16696 const htmlProps = useCompositeItem(props);
16697 return createElement3(TagName4, htmlProps);
16698 })
16699 );
16700
16701 // node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js
16702 function toArray(arg) {
16703 if (Array.isArray(arg)) {
16704 return arg;
16705 }
16706 return typeof arg !== "undefined" ? [arg] : [];
16707 }
16708 function flatten2DArray(array) {
16709 const flattened = [];
16710 for (const row of array) {
16711 flattened.push(...row);
16712 }
16713 return flattened;
16714 }
16715 function reverseArray(array) {
16716 return array.slice().reverse();
16717 }
16718
16719 // node_modules/@ariakit/react-core/esm/__chunks/ZMWF7ASR.js
16720 var import_react19 = __toESM(require_react(), 1);
16721 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
16722 var TagName5 = "div";
16723 function isGrid(items) {
16724 return items.some((item) => !!item.rowId);
16725 }
16726 function isPrintableKey(event) {
16727 const target = event.target;
16728 if (target && !isTextField(target)) return false;
16729 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
16730 }
16731 function isModifierKey(event) {
16732 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
16733 }
16734 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
16735 return useEvent((event) => {
16736 var _a;
16737 onKeyboardEvent == null ? void 0 : onKeyboardEvent(event);
16738 if (event.defaultPrevented) return;
16739 if (event.isPropagationStopped()) return;
16740 if (!isSelfTarget(event)) return;
16741 if (isModifierKey(event)) return;
16742 if (isPrintableKey(event)) return;
16743 const state = store.getState();
16744 const activeElement2 = (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.element;
16745 if (!activeElement2) return;
16746 const { view, ...eventInit } = event;
16747 const previousElement = previousElementRef == null ? void 0 : previousElementRef.current;
16748 if (activeElement2 !== previousElement) {
16749 activeElement2.focus();
16750 }
16751 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) {
16752 event.preventDefault();
16753 }
16754 if (event.currentTarget.contains(activeElement2)) {
16755 event.stopPropagation();
16756 }
16757 });
16758 }
16759 function findFirstEnabledItemInTheLastRow(items) {
16760 return findFirstEnabledItem(
16761 flatten2DArray(reverseArray(groupItemsByRows(items)))
16762 );
16763 }
16764 function useScheduleFocus(store) {
16765 const [scheduled, setScheduled] = (0, import_react19.useState)(false);
16766 const schedule = (0, import_react19.useCallback)(() => setScheduled(true), []);
16767 const activeItem = store.useState(
16768 (state) => getEnabledItem(store, state.activeId)
16769 );
16770 (0, import_react19.useEffect)(() => {
16771 const activeElement2 = activeItem == null ? void 0 : activeItem.element;
16772 if (!scheduled) return;
16773 if (!activeElement2) return;
16774 setScheduled(false);
16775 activeElement2.focus({ preventScroll: true });
16776 }, [activeItem, scheduled]);
16777 return schedule;
16778 }
16779 var useComposite = createHook(
16780 function useComposite2({
16781 store,
16782 composite = true,
16783 focusOnMove = composite,
16784 moveOnKeyPress = true,
16785 ...props
16786 }) {
16787 const context = useCompositeProviderContext();
16788 store = store || context;
16789 invariant(
16790 store,
16791 "Composite must receive a `store` prop or be wrapped in a CompositeProvider component."
16792 );
16793 const ref = (0, import_react19.useRef)(null);
16794 const previousElementRef = (0, import_react19.useRef)(null);
16795 const scheduleFocus = useScheduleFocus(store);
16796 const moves = store.useState("moves");
16797 const [, setBaseElement] = useTransactionState(
16798 composite ? store.setBaseElement : null
16799 );
16800 (0, import_react19.useEffect)(() => {
16801 var _a;
16802 if (!store) return;
16803 if (!moves) return;
16804 if (!composite) return;
16805 if (!focusOnMove) return;
16806 const { activeId: activeId2 } = store.getState();
16807 const itemElement = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
16808 if (!itemElement) return;
16809 focusIntoView(itemElement);
16810 }, [store, moves, composite, focusOnMove]);
16811 useSafeLayoutEffect(() => {
16812 if (!store) return;
16813 if (!moves) return;
16814 if (!composite) return;
16815 const { baseElement, activeId: activeId2 } = store.getState();
16816 const isSelfAcive = activeId2 === null;
16817 if (!isSelfAcive) return;
16818 if (!baseElement) return;
16819 const previousElement = previousElementRef.current;
16820 previousElementRef.current = null;
16821 if (previousElement) {
16822 fireBlurEvent(previousElement, { relatedTarget: baseElement });
16823 }
16824 if (!hasFocus(baseElement)) {
16825 baseElement.focus();
16826 }
16827 }, [store, moves, composite]);
16828 const activeId = store.useState("activeId");
16829 const virtualFocus = store.useState("virtualFocus");
16830 useSafeLayoutEffect(() => {
16831 var _a;
16832 if (!store) return;
16833 if (!composite) return;
16834 if (!virtualFocus) return;
16835 const previousElement = previousElementRef.current;
16836 previousElementRef.current = null;
16837 if (!previousElement) return;
16838 const activeElement2 = (_a = getEnabledItem(store, activeId)) == null ? void 0 : _a.element;
16839 const relatedTarget = activeElement2 || getActiveElement(previousElement);
16840 if (relatedTarget === previousElement) return;
16841 fireBlurEvent(previousElement, { relatedTarget });
16842 }, [store, activeId, virtualFocus, composite]);
16843 const onKeyDownCapture = useKeyboardEventProxy(
16844 store,
16845 props.onKeyDownCapture,
16846 previousElementRef
16847 );
16848 const onKeyUpCapture = useKeyboardEventProxy(
16849 store,
16850 props.onKeyUpCapture,
16851 previousElementRef
16852 );
16853 const onFocusCaptureProp = props.onFocusCapture;
16854 const onFocusCapture = useEvent((event) => {
16855 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
16856 if (event.defaultPrevented) return;
16857 if (!store) return;
16858 const { virtualFocus: virtualFocus2 } = store.getState();
16859 if (!virtualFocus2) return;
16860 const previousActiveElement = event.relatedTarget;
16861 const isSilentlyFocused = silentlyFocused(event.currentTarget);
16862 if (isSelfTarget(event) && isSilentlyFocused) {
16863 event.stopPropagation();
16864 previousElementRef.current = previousActiveElement;
16865 }
16866 });
16867 const onFocusProp = props.onFocus;
16868 const onFocus = useEvent((event) => {
16869 onFocusProp == null ? void 0 : onFocusProp(event);
16870 if (event.defaultPrevented) return;
16871 if (!composite) return;
16872 if (!store) return;
16873 const { relatedTarget } = event;
16874 const { virtualFocus: virtualFocus2 } = store.getState();
16875 if (virtualFocus2) {
16876 if (isSelfTarget(event) && !isItem(store, relatedTarget)) {
16877 queueMicrotask(scheduleFocus);
16878 }
16879 } else if (isSelfTarget(event)) {
16880 store.setActiveId(null);
16881 }
16882 });
16883 const onBlurCaptureProp = props.onBlurCapture;
16884 const onBlurCapture = useEvent((event) => {
16885 var _a;
16886 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
16887 if (event.defaultPrevented) return;
16888 if (!store) return;
16889 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
16890 if (!virtualFocus2) return;
16891 const activeElement2 = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
16892 const nextActiveElement = event.relatedTarget;
16893 const nextActiveElementIsItem = isItem(store, nextActiveElement);
16894 const previousElement = previousElementRef.current;
16895 previousElementRef.current = null;
16896 if (isSelfTarget(event) && nextActiveElementIsItem) {
16897 if (nextActiveElement === activeElement2) {
16898 if (previousElement && previousElement !== nextActiveElement) {
16899 fireBlurEvent(previousElement, event);
16900 }
16901 } else if (activeElement2) {
16902 fireBlurEvent(activeElement2, event);
16903 } else if (previousElement) {
16904 fireBlurEvent(previousElement, event);
16905 }
16906 event.stopPropagation();
16907 } else {
16908 const targetIsItem = isItem(store, event.target);
16909 if (!targetIsItem && activeElement2) {
16910 fireBlurEvent(activeElement2, event);
16911 }
16912 }
16913 });
16914 const onKeyDownProp = props.onKeyDown;
16915 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
16916 const onKeyDown = useEvent((event) => {
16917 var _a;
16918 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
16919 if (event.nativeEvent.isComposing) return;
16920 if (event.defaultPrevented) return;
16921 if (!store) return;
16922 if (!isSelfTarget(event)) return;
16923 const { orientation, renderedItems, activeId: activeId2 } = store.getState();
16924 const activeItem = getEnabledItem(store, activeId2);
16925 if ((_a = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a.isConnected) return;
16926 const isVertical = orientation !== "horizontal";
16927 const isHorizontal = orientation !== "vertical";
16928 const grid = isGrid(renderedItems);
16929 const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End";
16930 if (isHorizontalKey && isTextField(event.currentTarget)) return;
16931 const up = () => {
16932 if (grid) {
16933 const item = findFirstEnabledItemInTheLastRow(renderedItems);
16934 return item == null ? void 0 : item.id;
16935 }
16936 return store == null ? void 0 : store.last();
16937 };
16938 const keyMap = {
16939 ArrowUp: (grid || isVertical) && up,
16940 ArrowRight: (grid || isHorizontal) && store.first,
16941 ArrowDown: (grid || isVertical) && store.first,
16942 ArrowLeft: (grid || isHorizontal) && store.last,
16943 Home: store.first,
16944 End: store.last,
16945 PageUp: store.first,
16946 PageDown: store.last
16947 };
16948 const action = keyMap[event.key];
16949 if (action) {
16950 const id = action();
16951 if (id !== void 0) {
16952 if (!moveOnKeyPressProp(event)) return;
16953 event.preventDefault();
16954 store.move(id);
16955 }
16956 }
16957 });
16958 props = useWrapElement(
16959 props,
16960 (element) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(CompositeContextProvider, { value: store, children: element }),
16961 [store]
16962 );
16963 const activeDescendant = store.useState((state) => {
16964 var _a;
16965 if (!store) return;
16966 if (!composite) return;
16967 if (!state.virtualFocus) return;
16968 return (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.id;
16969 });
16970 props = {
16971 "aria-activedescendant": activeDescendant,
16972 ...props,
16973 ref: useMergeRefs(ref, setBaseElement, props.ref),
16974 onKeyDownCapture,
16975 onKeyUpCapture,
16976 onFocusCapture,
16977 onFocus,
16978 onBlurCapture,
16979 onKeyDown
16980 };
16981 const focusable2 = store.useState(
16982 (state) => composite && (state.virtualFocus || state.activeId === null)
16983 );
16984 props = useFocusable({ focusable: focusable2, ...props });
16985 return props;
16986 }
16987 );
16988 var Composite5 = forwardRef210(function Composite22(props) {
16989 const htmlProps = useComposite(props);
16990 return createElement3(TagName5, htmlProps);
16991 });
16992
16993 // node_modules/@ariakit/react-core/esm/__chunks/LVDQFHCH.js
16994 var ctx3 = createStoreContext();
16995 var useDisclosureContext = ctx3.useContext;
16996 var useDisclosureScopedContext = ctx3.useScopedContext;
16997 var useDisclosureProviderContext = ctx3.useProviderContext;
16998 var DisclosureContextProvider = ctx3.ContextProvider;
16999 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
17000
17001 // node_modules/@ariakit/react-core/esm/__chunks/A62MDFCW.js
17002 var import_react20 = __toESM(require_react(), 1);
17003 var ctx4 = createStoreContext(
17004 [DisclosureContextProvider],
17005 [DisclosureScopedContextProvider]
17006 );
17007 var useDialogContext = ctx4.useContext;
17008 var useDialogScopedContext = ctx4.useScopedContext;
17009 var useDialogProviderContext = ctx4.useProviderContext;
17010 var DialogContextProvider = ctx4.ContextProvider;
17011 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
17012 var DialogHeadingContext = (0, import_react20.createContext)(void 0);
17013 var DialogDescriptionContext = (0, import_react20.createContext)(void 0);
17014
17015 // node_modules/@ariakit/react-core/esm/__chunks/6B3RXHKP.js
17016 var import_react21 = __toESM(require_react(), 1);
17017 var import_react_dom4 = __toESM(require_react_dom(), 1);
17018 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
17019 var TagName6 = "div";
17020 function afterTimeout(timeoutMs, cb) {
17021 const timeoutId = setTimeout(cb, timeoutMs);
17022 return () => clearTimeout(timeoutId);
17023 }
17024 function afterPaint2(cb) {
17025 let raf = requestAnimationFrame(() => {
17026 raf = requestAnimationFrame(cb);
17027 });
17028 return () => cancelAnimationFrame(raf);
17029 }
17030 function parseCSSTime(...times) {
17031 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => {
17032 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3;
17033 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier;
17034 if (currentTime > longestTime) return currentTime;
17035 return longestTime;
17036 }, 0);
17037 }
17038 function isHidden(mounted, hidden, alwaysVisible) {
17039 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
17040 }
17041 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, ...props }) {
17042 const context = useDisclosureProviderContext();
17043 store = store || context;
17044 invariant(
17045 store,
17046 "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component."
17047 );
17048 const ref = (0, import_react21.useRef)(null);
17049 const id = useId4(props.id);
17050 const [transition, setTransition] = (0, import_react21.useState)(null);
17051 const open = store.useState("open");
17052 const mounted = store.useState("mounted");
17053 const animated = store.useState("animated");
17054 const contentElement = store.useState("contentElement");
17055 const otherElement = useStoreState(store.disclosure, "contentElement");
17056 useSafeLayoutEffect(() => {
17057 if (!ref.current) return;
17058 store == null ? void 0 : store.setContentElement(ref.current);
17059 }, [store]);
17060 useSafeLayoutEffect(() => {
17061 let previousAnimated;
17062 store == null ? void 0 : store.setState("animated", (animated2) => {
17063 previousAnimated = animated2;
17064 return true;
17065 });
17066 return () => {
17067 if (previousAnimated === void 0) return;
17068 store == null ? void 0 : store.setState("animated", previousAnimated);
17069 };
17070 }, [store]);
17071 useSafeLayoutEffect(() => {
17072 if (!animated) return;
17073 if (!(contentElement == null ? void 0 : contentElement.isConnected)) {
17074 setTransition(null);
17075 return;
17076 }
17077 return afterPaint2(() => {
17078 setTransition(open ? "enter" : mounted ? "leave" : null);
17079 });
17080 }, [animated, contentElement, open, mounted]);
17081 useSafeLayoutEffect(() => {
17082 if (!store) return;
17083 if (!animated) return;
17084 if (!transition) return;
17085 if (!contentElement) return;
17086 const stopAnimation = () => store == null ? void 0 : store.setState("animating", false);
17087 const stopAnimationSync = () => (0, import_react_dom4.flushSync)(stopAnimation);
17088 if (transition === "leave" && open) return;
17089 if (transition === "enter" && !open) return;
17090 if (typeof animated === "number") {
17091 const timeout2 = animated;
17092 return afterTimeout(timeout2, stopAnimationSync);
17093 }
17094 const {
17095 transitionDuration,
17096 animationDuration,
17097 transitionDelay,
17098 animationDelay
17099 } = getComputedStyle(contentElement);
17100 const {
17101 transitionDuration: transitionDuration2 = "0",
17102 animationDuration: animationDuration2 = "0",
17103 transitionDelay: transitionDelay2 = "0",
17104 animationDelay: animationDelay2 = "0"
17105 } = otherElement ? getComputedStyle(otherElement) : {};
17106 const delay = parseCSSTime(
17107 transitionDelay,
17108 animationDelay,
17109 transitionDelay2,
17110 animationDelay2
17111 );
17112 const duration = parseCSSTime(
17113 transitionDuration,
17114 animationDuration,
17115 transitionDuration2,
17116 animationDuration2
17117 );
17118 const timeout = delay + duration;
17119 if (!timeout) {
17120 if (transition === "enter") {
17121 store.setState("animated", false);
17122 }
17123 stopAnimation();
17124 return;
17125 }
17126 const frameRate = 1e3 / 60;
17127 const maxTimeout = Math.max(timeout - frameRate, 0);
17128 return afterTimeout(maxTimeout, stopAnimationSync);
17129 }, [store, animated, contentElement, otherElement, open, transition]);
17130 props = useWrapElement(
17131 props,
17132 (element) => /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DialogScopedContextProvider, { value: store, children: element }),
17133 [store]
17134 );
17135 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
17136 const styleProp = props.style;
17137 const style = (0, import_react21.useMemo)(() => {
17138 if (hidden) {
17139 return { ...styleProp, display: "none" };
17140 }
17141 return styleProp;
17142 }, [hidden, styleProp]);
17143 props = {
17144 id,
17145 "data-open": open || void 0,
17146 "data-enter": transition === "enter" || void 0,
17147 "data-leave": transition === "leave" || void 0,
17148 hidden,
17149 ...props,
17150 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref),
17151 style
17152 };
17153 return removeUndefinedValues(props);
17154 });
17155 var DisclosureContentImpl = forwardRef210(function DisclosureContentImpl2(props) {
17156 const htmlProps = useDisclosureContent(props);
17157 return createElement3(TagName6, htmlProps);
17158 });
17159 var DisclosureContent = forwardRef210(function DisclosureContent2({
17160 unmountOnHide,
17161 ...props
17162 }) {
17163 const context = useDisclosureProviderContext();
17164 const store = props.store || context;
17165 const mounted = useStoreState(
17166 store,
17167 (state) => !unmountOnHide || (state == null ? void 0 : state.mounted)
17168 );
17169 if (mounted === false) return null;
17170 return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DisclosureContentImpl, { ...props });
17171 });
17172
17173 // node_modules/@ariakit/core/esm/__chunks/75BJEVSH.js
17174 function createDisclosureStore(props = {}) {
17175 const store = mergeStore(
17176 props.store,
17177 omit2(props.disclosure, ["contentElement", "disclosureElement"])
17178 );
17179 throwOnConflictingProps(props, store);
17180 const syncState = store == null ? void 0 : store.getState();
17181 const open = defaultValue(
17182 props.open,
17183 syncState == null ? void 0 : syncState.open,
17184 props.defaultOpen,
17185 false
17186 );
17187 const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false);
17188 const initialState = {
17189 open,
17190 animated,
17191 animating: !!animated && open,
17192 mounted: open,
17193 contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null),
17194 disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null)
17195 };
17196 const disclosure = createStore(initialState, store);
17197 setup(
17198 disclosure,
17199 () => sync(disclosure, ["animated", "animating"], (state) => {
17200 if (state.animated) return;
17201 disclosure.setState("animating", false);
17202 })
17203 );
17204 setup(
17205 disclosure,
17206 () => subscribe(disclosure, ["open"], () => {
17207 if (!disclosure.getState().animated) return;
17208 disclosure.setState("animating", true);
17209 })
17210 );
17211 setup(
17212 disclosure,
17213 () => sync(disclosure, ["open", "animating"], (state) => {
17214 disclosure.setState("mounted", state.open || state.animating);
17215 })
17216 );
17217 return {
17218 ...disclosure,
17219 disclosure: props.disclosure,
17220 setOpen: (value) => disclosure.setState("open", value),
17221 show: () => disclosure.setState("open", true),
17222 hide: () => disclosure.setState("open", false),
17223 toggle: () => disclosure.setState("open", (open2) => !open2),
17224 stopAnimation: () => disclosure.setState("animating", false),
17225 setContentElement: (value) => disclosure.setState("contentElement", value),
17226 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
17227 };
17228 }
17229
17230 // node_modules/@ariakit/react-core/esm/__chunks/WLZ6H5FH.js
17231 function useDisclosureStoreProps(store, update2, props) {
17232 useUpdateEffect(update2, [props.store, props.disclosure]);
17233 useStoreProps(store, props, "open", "setOpen");
17234 useStoreProps(store, props, "mounted", "setMounted");
17235 useStoreProps(store, props, "animated");
17236 return Object.assign(store, { disclosure: props.disclosure });
17237 }
17238
17239 // node_modules/@ariakit/react-core/esm/__chunks/JMU4N4M5.js
17240 var ctx5 = createStoreContext(
17241 [DialogContextProvider],
17242 [DialogScopedContextProvider]
17243 );
17244 var usePopoverContext = ctx5.useContext;
17245 var usePopoverScopedContext = ctx5.useScopedContext;
17246 var usePopoverProviderContext = ctx5.useProviderContext;
17247 var PopoverContextProvider = ctx5.ContextProvider;
17248 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
17249
17250 // node_modules/@ariakit/core/esm/__chunks/N5XGANPW.js
17251 function getCommonParent(items) {
17252 var _a;
17253 const firstItem = items.find((item) => !!item.element);
17254 const lastItem = [...items].reverse().find((item) => !!item.element);
17255 let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement;
17256 while (parentElement && (lastItem == null ? void 0 : lastItem.element)) {
17257 const parent = parentElement;
17258 if (lastItem && parent.contains(lastItem.element)) {
17259 return parentElement;
17260 }
17261 parentElement = parentElement.parentElement;
17262 }
17263 return getDocument(parentElement).body;
17264 }
17265 function getPrivateStore(store) {
17266 return store == null ? void 0 : store.__unstablePrivateStore;
17267 }
17268 function createCollectionStore(props = {}) {
17269 var _a;
17270 throwOnConflictingProps(props, props.store);
17271 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
17272 const items = defaultValue(
17273 props.items,
17274 syncState == null ? void 0 : syncState.items,
17275 props.defaultItems,
17276 []
17277 );
17278 const itemsMap = new Map(items.map((item) => [item.id, item]));
17279 const initialState = {
17280 items,
17281 renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, [])
17282 };
17283 const syncPrivateStore = getPrivateStore(props.store);
17284 const privateStore = createStore(
17285 { items, renderedItems: initialState.renderedItems },
17286 syncPrivateStore
17287 );
17288 const collection = createStore(initialState, props.store);
17289 const sortItems = (renderedItems) => {
17290 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
17291 privateStore.setState("renderedItems", sortedItems);
17292 collection.setState("renderedItems", sortedItems);
17293 };
17294 setup(collection, () => init(privateStore));
17295 setup(privateStore, () => {
17296 return batch(privateStore, ["items"], (state) => {
17297 collection.setState("items", state.items);
17298 });
17299 });
17300 setup(privateStore, () => {
17301 return batch(privateStore, ["renderedItems"], (state) => {
17302 let firstRun = true;
17303 let raf = requestAnimationFrame(() => {
17304 const { renderedItems } = collection.getState();
17305 if (state.renderedItems === renderedItems) return;
17306 sortItems(state.renderedItems);
17307 });
17308 if (typeof IntersectionObserver !== "function") {
17309 return () => cancelAnimationFrame(raf);
17310 }
17311 const ioCallback = () => {
17312 if (firstRun) {
17313 firstRun = false;
17314 return;
17315 }
17316 cancelAnimationFrame(raf);
17317 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
17318 };
17319 const root = getCommonParent(state.renderedItems);
17320 const observer = new IntersectionObserver(ioCallback, { root });
17321 for (const item of state.renderedItems) {
17322 if (!item.element) continue;
17323 observer.observe(item.element);
17324 }
17325 return () => {
17326 cancelAnimationFrame(raf);
17327 observer.disconnect();
17328 };
17329 });
17330 });
17331 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
17332 let prevItem;
17333 setItems((items2) => {
17334 const index2 = items2.findIndex(({ id }) => id === item.id);
17335 const nextItems = items2.slice();
17336 if (index2 !== -1) {
17337 prevItem = items2[index2];
17338 const nextItem = { ...prevItem, ...item };
17339 nextItems[index2] = nextItem;
17340 itemsMap.set(item.id, nextItem);
17341 } else {
17342 nextItems.push(item);
17343 itemsMap.set(item.id, item);
17344 }
17345 return nextItems;
17346 });
17347 const unmergeItem = () => {
17348 setItems((items2) => {
17349 if (!prevItem) {
17350 if (canDeleteFromMap) {
17351 itemsMap.delete(item.id);
17352 }
17353 return items2.filter(({ id }) => id !== item.id);
17354 }
17355 const index2 = items2.findIndex(({ id }) => id === item.id);
17356 if (index2 === -1) return items2;
17357 const nextItems = items2.slice();
17358 nextItems[index2] = prevItem;
17359 itemsMap.set(item.id, prevItem);
17360 return nextItems;
17361 });
17362 };
17363 return unmergeItem;
17364 };
17365 const registerItem = (item) => mergeItem(
17366 item,
17367 (getItems) => privateStore.setState("items", getItems),
17368 true
17369 );
17370 return {
17371 ...collection,
17372 registerItem,
17373 renderItem: (item) => chain(
17374 registerItem(item),
17375 mergeItem(
17376 item,
17377 (getItems) => privateStore.setState("renderedItems", getItems)
17378 )
17379 ),
17380 item: (id) => {
17381 if (!id) return null;
17382 let item = itemsMap.get(id);
17383 if (!item) {
17384 const { items: items2 } = privateStore.getState();
17385 item = items2.find((item2) => item2.id === id);
17386 if (item) {
17387 itemsMap.set(id, item);
17388 }
17389 }
17390 return item || null;
17391 },
17392 // @ts-expect-error Internal
17393 __unstablePrivateStore: privateStore
17394 };
17395 }
17396
17397 // node_modules/@ariakit/react-core/esm/__chunks/GVAFFF2B.js
17398 function useCollectionStoreProps(store, update2, props) {
17399 useUpdateEffect(update2, [props.store]);
17400 useStoreProps(store, props, "items", "setItems");
17401 return store;
17402 }
17403
17404 // node_modules/@ariakit/core/esm/__chunks/RVTIKFRL.js
17405 var NULL_ITEM = { id: null };
17406 function findFirstEnabledItem2(items, excludeId) {
17407 return items.find((item) => {
17408 if (excludeId) {
17409 return !item.disabled && item.id !== excludeId;
17410 }
17411 return !item.disabled;
17412 });
17413 }
17414 function getEnabledItems(items, excludeId) {
17415 return items.filter((item) => {
17416 if (excludeId) {
17417 return !item.disabled && item.id !== excludeId;
17418 }
17419 return !item.disabled;
17420 });
17421 }
17422 function getItemsInRow(items, rowId) {
17423 return items.filter((item) => item.rowId === rowId);
17424 }
17425 function flipItems(items, activeId, shouldInsertNullItem = false) {
17426 const index2 = items.findIndex((item) => item.id === activeId);
17427 return [
17428 ...items.slice(index2 + 1),
17429 ...shouldInsertNullItem ? [NULL_ITEM] : [],
17430 ...items.slice(0, index2)
17431 ];
17432 }
17433 function groupItemsByRows2(items) {
17434 const rows = [];
17435 for (const item of items) {
17436 const row = rows.find((currentRow) => {
17437 var _a;
17438 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
17439 });
17440 if (row) {
17441 row.push(item);
17442 } else {
17443 rows.push([item]);
17444 }
17445 }
17446 return rows;
17447 }
17448 function getMaxRowLength(array) {
17449 let maxLength = 0;
17450 for (const { length } of array) {
17451 if (length > maxLength) {
17452 maxLength = length;
17453 }
17454 }
17455 return maxLength;
17456 }
17457 function createEmptyItem(rowId) {
17458 return {
17459 id: "__EMPTY_ITEM__",
17460 disabled: true,
17461 rowId
17462 };
17463 }
17464 function normalizeRows(rows, activeId, focusShift) {
17465 const maxLength = getMaxRowLength(rows);
17466 for (const row of rows) {
17467 for (let i2 = 0; i2 < maxLength; i2 += 1) {
17468 const item = row[i2];
17469 if (!item || focusShift && item.disabled) {
17470 const isFirst = i2 === 0;
17471 const previousItem = isFirst && focusShift ? findFirstEnabledItem2(row) : row[i2 - 1];
17472 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId);
17473 }
17474 }
17475 }
17476 return rows;
17477 }
17478 function verticalizeItems(items) {
17479 const rows = groupItemsByRows2(items);
17480 const maxLength = getMaxRowLength(rows);
17481 const verticalized = [];
17482 for (let i2 = 0; i2 < maxLength; i2 += 1) {
17483 for (const row of rows) {
17484 const item = row[i2];
17485 if (item) {
17486 verticalized.push({
17487 ...item,
17488 // If there's no rowId, it means that it's not a grid composite, but
17489 // a single row instead. So, instead of verticalizing it, that is,
17490 // assigning a different rowId based on the column index, we keep it
17491 // undefined so they will be part of the same row. This is useful
17492 // when using up/down on one-dimensional composites.
17493 rowId: item.rowId ? `${i2}` : void 0
17494 });
17495 }
17496 }
17497 }
17498 return verticalized;
17499 }
17500 function createCompositeStore(props = {}) {
17501 var _a;
17502 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
17503 const collection = createCollectionStore(props);
17504 const activeId = defaultValue(
17505 props.activeId,
17506 syncState == null ? void 0 : syncState.activeId,
17507 props.defaultActiveId
17508 );
17509 const initialState = {
17510 ...collection.getState(),
17511 id: defaultValue(
17512 props.id,
17513 syncState == null ? void 0 : syncState.id,
17514 `id-${Math.random().toString(36).slice(2, 8)}`
17515 ),
17516 activeId,
17517 baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null),
17518 includesBaseElement: defaultValue(
17519 props.includesBaseElement,
17520 syncState == null ? void 0 : syncState.includesBaseElement,
17521 activeId === null
17522 ),
17523 moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0),
17524 orientation: defaultValue(
17525 props.orientation,
17526 syncState == null ? void 0 : syncState.orientation,
17527 "both"
17528 ),
17529 rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false),
17530 virtualFocus: defaultValue(
17531 props.virtualFocus,
17532 syncState == null ? void 0 : syncState.virtualFocus,
17533 false
17534 ),
17535 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false),
17536 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false),
17537 focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false)
17538 };
17539 const composite = createStore(initialState, collection, props.store);
17540 setup(
17541 composite,
17542 () => sync(composite, ["renderedItems", "activeId"], (state) => {
17543 composite.setState("activeId", (activeId2) => {
17544 var _a2;
17545 if (activeId2 !== void 0) return activeId2;
17546 return (_a2 = findFirstEnabledItem2(state.renderedItems)) == null ? void 0 : _a2.id;
17547 });
17548 })
17549 );
17550 const getNextId = (direction = "next", options = {}) => {
17551 var _a2, _b;
17552 const defaultState = composite.getState();
17553 const {
17554 skip = 0,
17555 activeId: activeId2 = defaultState.activeId,
17556 focusShift = defaultState.focusShift,
17557 focusLoop = defaultState.focusLoop,
17558 focusWrap = defaultState.focusWrap,
17559 includesBaseElement = defaultState.includesBaseElement,
17560 renderedItems = defaultState.renderedItems,
17561 rtl = defaultState.rtl
17562 } = options;
17563 const isVerticalDirection = direction === "up" || direction === "down";
17564 const isNextDirection = direction === "next" || direction === "down";
17565 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
17566 const canShift = focusShift && !skip;
17567 let items = !isVerticalDirection ? renderedItems : flatten2DArray(
17568 normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift)
17569 );
17570 items = canReverse ? reverseArray(items) : items;
17571 items = isVerticalDirection ? verticalizeItems(items) : items;
17572 if (activeId2 == null) {
17573 return (_a2 = findFirstEnabledItem2(items)) == null ? void 0 : _a2.id;
17574 }
17575 const activeItem = items.find((item) => item.id === activeId2);
17576 if (!activeItem) {
17577 return (_b = findFirstEnabledItem2(items)) == null ? void 0 : _b.id;
17578 }
17579 const isGrid2 = items.some((item) => item.rowId);
17580 const activeIndex = items.indexOf(activeItem);
17581 const nextItems = items.slice(activeIndex + 1);
17582 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
17583 if (skip) {
17584 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
17585 const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one.
17586 nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1];
17587 return nextItem2 == null ? void 0 : nextItem2.id;
17588 }
17589 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
17590 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
17591 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
17592 if (canLoop) {
17593 const loopItems = canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId);
17594 const sortedItems = flipItems(loopItems, activeId2, hasNullItem);
17595 const nextItem2 = findFirstEnabledItem2(sortedItems, activeId2);
17596 return nextItem2 == null ? void 0 : nextItem2.id;
17597 }
17598 if (canWrap) {
17599 const nextItem2 = findFirstEnabledItem2(
17600 // We can use nextItems, which contains all the next items, including
17601 // items from other rows, to wrap between rows. However, if there is a
17602 // null item (the composite container), we'll only use the next items in
17603 // the row. So moving next from the last item will focus on the
17604 // composite container. On grid composites, horizontal navigation never
17605 // focuses on the composite container, only vertical.
17606 hasNullItem ? nextItemsInRow : nextItems,
17607 activeId2
17608 );
17609 const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id;
17610 return nextId;
17611 }
17612 const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2);
17613 if (!nextItem && hasNullItem) {
17614 return null;
17615 }
17616 return nextItem == null ? void 0 : nextItem.id;
17617 };
17618 return {
17619 ...collection,
17620 ...composite,
17621 setBaseElement: (element) => composite.setState("baseElement", element),
17622 setActiveId: (id) => composite.setState("activeId", id),
17623 move: (id) => {
17624 if (id === void 0) return;
17625 composite.setState("activeId", id);
17626 composite.setState("moves", (moves) => moves + 1);
17627 },
17628 first: () => {
17629 var _a2;
17630 return (_a2 = findFirstEnabledItem2(composite.getState().renderedItems)) == null ? void 0 : _a2.id;
17631 },
17632 last: () => {
17633 var _a2;
17634 return (_a2 = findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id;
17635 },
17636 next: (options) => {
17637 if (options !== void 0 && typeof options === "number") {
17638 options = { skip: options };
17639 }
17640 return getNextId("next", options);
17641 },
17642 previous: (options) => {
17643 if (options !== void 0 && typeof options === "number") {
17644 options = { skip: options };
17645 }
17646 return getNextId("previous", options);
17647 },
17648 down: (options) => {
17649 if (options !== void 0 && typeof options === "number") {
17650 options = { skip: options };
17651 }
17652 return getNextId("down", options);
17653 },
17654 up: (options) => {
17655 if (options !== void 0 && typeof options === "number") {
17656 options = { skip: options };
17657 }
17658 return getNextId("up", options);
17659 }
17660 };
17661 }
17662
17663 // node_modules/@ariakit/react-core/esm/__chunks/IQYAUKXT.js
17664 function useCompositeStoreOptions(props) {
17665 const id = useId4(props.id);
17666 return { id, ...props };
17667 }
17668 function useCompositeStoreProps(store, update2, props) {
17669 store = useCollectionStoreProps(store, update2, props);
17670 useStoreProps(store, props, "activeId", "setActiveId");
17671 useStoreProps(store, props, "includesBaseElement");
17672 useStoreProps(store, props, "virtualFocus");
17673 useStoreProps(store, props, "orientation");
17674 useStoreProps(store, props, "rtl");
17675 useStoreProps(store, props, "focusLoop");
17676 useStoreProps(store, props, "focusWrap");
17677 useStoreProps(store, props, "focusShift");
17678 return store;
17679 }
17680
17681 // node_modules/@ariakit/react-core/esm/__chunks/CVCFNOHX.js
17682 var import_react22 = __toESM(require_react(), 1);
17683 var ComboboxListRoleContext = (0, import_react22.createContext)(
17684 void 0
17685 );
17686 var ctx6 = createStoreContext(
17687 [PopoverContextProvider, CompositeContextProvider],
17688 [PopoverScopedContextProvider, CompositeScopedContextProvider]
17689 );
17690 var useComboboxContext = ctx6.useContext;
17691 var useComboboxScopedContext = ctx6.useScopedContext;
17692 var useComboboxProviderContext = ctx6.useProviderContext;
17693 var ComboboxContextProvider = ctx6.ContextProvider;
17694 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
17695 var ComboboxItemValueContext = (0, import_react22.createContext)(
17696 void 0
17697 );
17698 var ComboboxItemCheckedContext = (0, import_react22.createContext)(false);
17699
17700 // node_modules/@ariakit/core/esm/__chunks/KMAUV3TY.js
17701 function createDialogStore(props = {}) {
17702 return createDisclosureStore(props);
17703 }
17704
17705 // node_modules/@ariakit/react-core/esm/__chunks/4NYSH4UO.js
17706 function useDialogStoreProps(store, update2, props) {
17707 return useDisclosureStoreProps(store, update2, props);
17708 }
17709
17710 // node_modules/@ariakit/core/esm/__chunks/BFGNM53A.js
17711 function createPopoverStore({
17712 popover: otherPopover,
17713 ...props
17714 } = {}) {
17715 const store = mergeStore(
17716 props.store,
17717 omit2(otherPopover, [
17718 "arrowElement",
17719 "anchorElement",
17720 "contentElement",
17721 "popoverElement",
17722 "disclosureElement"
17723 ])
17724 );
17725 throwOnConflictingProps(props, store);
17726 const syncState = store == null ? void 0 : store.getState();
17727 const dialog = createDialogStore({ ...props, store });
17728 const placement = defaultValue(
17729 props.placement,
17730 syncState == null ? void 0 : syncState.placement,
17731 "bottom"
17732 );
17733 const initialState = {
17734 ...dialog.getState(),
17735 placement,
17736 currentPlacement: placement,
17737 anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null),
17738 popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null),
17739 arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null),
17740 rendered: /* @__PURE__ */ Symbol("rendered")
17741 };
17742 const popover = createStore(initialState, dialog, store);
17743 return {
17744 ...dialog,
17745 ...popover,
17746 setAnchorElement: (element) => popover.setState("anchorElement", element),
17747 setPopoverElement: (element) => popover.setState("popoverElement", element),
17748 setArrowElement: (element) => popover.setState("arrowElement", element),
17749 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
17750 };
17751 }
17752
17753 // node_modules/@ariakit/react-core/esm/__chunks/B6FLPFJM.js
17754 function usePopoverStoreProps(store, update2, props) {
17755 useUpdateEffect(update2, [props.popover]);
17756 useStoreProps(store, props, "placement");
17757 return useDialogStoreProps(store, update2, props);
17758 }
17759
17760 // node_modules/@ariakit/react-core/esm/__chunks/4POTBZ2J.js
17761 var TagName7 = "div";
17762 var usePopoverAnchor = createHook(
17763 function usePopoverAnchor2({ store, ...props }) {
17764 const context = usePopoverProviderContext();
17765 store = store || context;
17766 props = {
17767 ...props,
17768 ref: useMergeRefs(store == null ? void 0 : store.setAnchorElement, props.ref)
17769 };
17770 return props;
17771 }
17772 );
17773 var PopoverAnchor = forwardRef210(function PopoverAnchor2(props) {
17774 const htmlProps = usePopoverAnchor(props);
17775 return createElement3(TagName7, htmlProps);
17776 });
17777
17778 // node_modules/@ariakit/react-core/esm/__chunks/X6LNAU2F.js
17779 var import_react23 = __toESM(require_react(), 1);
17780 var TagName8 = "div";
17781 function getMouseDestination(event) {
17782 const relatedTarget = event.relatedTarget;
17783 if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) {
17784 return relatedTarget;
17785 }
17786 return null;
17787 }
17788 function hoveringInside(event) {
17789 const nextElement = getMouseDestination(event);
17790 if (!nextElement) return false;
17791 return contains2(event.currentTarget, nextElement);
17792 }
17793 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
17794 function movingToAnotherItem(event) {
17795 let dest = getMouseDestination(event);
17796 if (!dest) return false;
17797 do {
17798 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
17799 dest = dest.parentElement;
17800 } while (dest);
17801 return false;
17802 }
17803 var useCompositeHover = createHook(
17804 function useCompositeHover2({
17805 store,
17806 focusOnHover = true,
17807 blurOnHoverEnd = !!focusOnHover,
17808 ...props
17809 }) {
17810 const context = useCompositeContext();
17811 store = store || context;
17812 invariant(
17813 store,
17814 "CompositeHover must be wrapped in a Composite component."
17815 );
17816 const isMouseMoving = useIsMouseMoving();
17817 const onMouseMoveProp = props.onMouseMove;
17818 const focusOnHoverProp = useBooleanEvent(focusOnHover);
17819 const onMouseMove = useEvent((event) => {
17820 onMouseMoveProp == null ? void 0 : onMouseMoveProp(event);
17821 if (event.defaultPrevented) return;
17822 if (!isMouseMoving()) return;
17823 if (!focusOnHoverProp(event)) return;
17824 if (!hasFocusWithin(event.currentTarget)) {
17825 const baseElement = store == null ? void 0 : store.getState().baseElement;
17826 if (baseElement && !hasFocus(baseElement)) {
17827 baseElement.focus();
17828 }
17829 }
17830 store == null ? void 0 : store.setActiveId(event.currentTarget.id);
17831 });
17832 const onMouseLeaveProp = props.onMouseLeave;
17833 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
17834 const onMouseLeave = useEvent((event) => {
17835 var _a;
17836 onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event);
17837 if (event.defaultPrevented) return;
17838 if (!isMouseMoving()) return;
17839 if (hoveringInside(event)) return;
17840 if (movingToAnotherItem(event)) return;
17841 if (!focusOnHoverProp(event)) return;
17842 if (!blurOnHoverEndProp(event)) return;
17843 store == null ? void 0 : store.setActiveId(null);
17844 (_a = store == null ? void 0 : store.getState().baseElement) == null ? void 0 : _a.focus();
17845 });
17846 const ref = (0, import_react23.useCallback)((element) => {
17847 if (!element) return;
17848 element[symbol2] = true;
17849 }, []);
17850 props = {
17851 ...props,
17852 ref: useMergeRefs(ref, props.ref),
17853 onMouseMove,
17854 onMouseLeave
17855 };
17856 return removeUndefinedValues(props);
17857 }
17858 );
17859 var CompositeHover = memo22(
17860 forwardRef210(function CompositeHover2(props) {
17861 const htmlProps = useCompositeHover(props);
17862 return createElement3(TagName8, htmlProps);
17863 })
17864 );
17865
17866 // node_modules/@ariakit/react-core/esm/combobox/combobox.js
17867 var import_react24 = __toESM(require_react(), 1);
17868 var TagName9 = "input";
17869 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
17870 if (!autoSelect) return false;
17871 const firstItem = items.find((item) => !item.disabled && item.value);
17872 return (firstItem == null ? void 0 : firstItem.value) === activeValue;
17873 }
17874 function hasCompletionString(value, activeValue) {
17875 if (!activeValue) return false;
17876 if (value == null) return false;
17877 value = normalizeString(value);
17878 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0;
17879 }
17880 function isInputEvent(event) {
17881 return event.type === "input";
17882 }
17883 function isAriaAutoCompleteValue(value) {
17884 return value === "inline" || value === "list" || value === "both" || value === "none";
17885 }
17886 function getDefaultAutoSelectId(items) {
17887 const item = items.find((item2) => {
17888 var _a;
17889 if (item2.disabled) return false;
17890 return ((_a = item2.element) == null ? void 0 : _a.getAttribute("role")) !== "tab";
17891 });
17892 return item == null ? void 0 : item.id;
17893 }
17894 var useCombobox = createHook(
17895 function useCombobox2({
17896 store,
17897 focusable: focusable2 = true,
17898 autoSelect: autoSelectProp = false,
17899 getAutoSelectId,
17900 setValueOnChange,
17901 showMinLength = 0,
17902 showOnChange,
17903 showOnMouseDown,
17904 showOnClick = showOnMouseDown,
17905 showOnKeyDown,
17906 showOnKeyPress = showOnKeyDown,
17907 blurActiveItemOnClick,
17908 setValueOnClick = true,
17909 moveOnKeyPress = true,
17910 autoComplete = "list",
17911 ...props
17912 }) {
17913 const context = useComboboxProviderContext();
17914 store = store || context;
17915 invariant(
17916 store,
17917 "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component."
17918 );
17919 const ref = (0, import_react24.useRef)(null);
17920 const [valueUpdated, forceValueUpdate] = useForceUpdate();
17921 const canAutoSelectRef = (0, import_react24.useRef)(false);
17922 const composingRef = (0, import_react24.useRef)(false);
17923 const autoSelect = store.useState(
17924 (state) => state.virtualFocus && autoSelectProp
17925 );
17926 const inline4 = autoComplete === "inline" || autoComplete === "both";
17927 const [canInline, setCanInline] = (0, import_react24.useState)(inline4);
17928 useUpdateLayoutEffect(() => {
17929 if (!inline4) return;
17930 setCanInline(true);
17931 }, [inline4]);
17932 const storeValue = store.useState("value");
17933 const prevSelectedValueRef = (0, import_react24.useRef)(void 0);
17934 (0, import_react24.useEffect)(() => {
17935 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
17936 prevSelectedValueRef.current = prev.selectedValue;
17937 });
17938 }, []);
17939 const inlineActiveValue = store.useState((state) => {
17940 var _a;
17941 if (!inline4) return;
17942 if (!canInline) return;
17943 if (state.activeValue && Array.isArray(state.selectedValue)) {
17944 if (state.selectedValue.includes(state.activeValue)) return;
17945 if ((_a = prevSelectedValueRef.current) == null ? void 0 : _a.includes(state.activeValue)) return;
17946 }
17947 return state.activeValue;
17948 });
17949 const items = store.useState("renderedItems");
17950 const open = store.useState("open");
17951 const contentElement = store.useState("contentElement");
17952 const value = (0, import_react24.useMemo)(() => {
17953 if (!inline4) return storeValue;
17954 if (!canInline) return storeValue;
17955 const firstItemAutoSelected = isFirstItemAutoSelected(
17956 items,
17957 inlineActiveValue,
17958 autoSelect
17959 );
17960 if (firstItemAutoSelected) {
17961 if (hasCompletionString(storeValue, inlineActiveValue)) {
17962 const slice = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || "";
17963 return storeValue + slice;
17964 }
17965 return storeValue;
17966 }
17967 return inlineActiveValue || storeValue;
17968 }, [inline4, canInline, items, inlineActiveValue, autoSelect, storeValue]);
17969 (0, import_react24.useEffect)(() => {
17970 const element = ref.current;
17971 if (!element) return;
17972 const onCompositeItemMove = () => setCanInline(true);
17973 element.addEventListener("combobox-item-move", onCompositeItemMove);
17974 return () => {
17975 element.removeEventListener("combobox-item-move", onCompositeItemMove);
17976 };
17977 }, []);
17978 (0, import_react24.useEffect)(() => {
17979 if (!inline4) return;
17980 if (!canInline) return;
17981 if (!inlineActiveValue) return;
17982 const firstItemAutoSelected = isFirstItemAutoSelected(
17983 items,
17984 inlineActiveValue,
17985 autoSelect
17986 );
17987 if (!firstItemAutoSelected) return;
17988 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
17989 let cleanup = noop4;
17990 queueMicrotask(() => {
17991 const element = ref.current;
17992 if (!element) return;
17993 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
17994 const nextStart = storeValue.length;
17995 const nextEnd = inlineActiveValue.length;
17996 setSelectionRange(element, nextStart, nextEnd);
17997 cleanup = () => {
17998 if (!hasFocus(element)) return;
17999 const { start, end } = getTextboxSelection(element);
18000 if (start !== nextStart) return;
18001 if (end !== nextEnd) return;
18002 setSelectionRange(element, prevStart, prevEnd);
18003 };
18004 });
18005 return () => cleanup();
18006 }, [
18007 valueUpdated,
18008 inline4,
18009 canInline,
18010 inlineActiveValue,
18011 items,
18012 autoSelect,
18013 storeValue
18014 ]);
18015 const scrollingElementRef = (0, import_react24.useRef)(null);
18016 const getAutoSelectIdProp = useEvent(getAutoSelectId);
18017 const autoSelectIdRef = (0, import_react24.useRef)(null);
18018 (0, import_react24.useEffect)(() => {
18019 if (!open) return;
18020 if (!contentElement) return;
18021 const scrollingElement = getScrollingElement(contentElement);
18022 if (!scrollingElement) return;
18023 scrollingElementRef.current = scrollingElement;
18024 const onUserScroll = () => {
18025 canAutoSelectRef.current = false;
18026 };
18027 const onScroll = () => {
18028 if (!store) return;
18029 if (!canAutoSelectRef.current) return;
18030 const { activeId } = store.getState();
18031 if (activeId === null) return;
18032 if (activeId === autoSelectIdRef.current) return;
18033 canAutoSelectRef.current = false;
18034 };
18035 const options = { passive: true, capture: true };
18036 scrollingElement.addEventListener("wheel", onUserScroll, options);
18037 scrollingElement.addEventListener("touchmove", onUserScroll, options);
18038 scrollingElement.addEventListener("scroll", onScroll, options);
18039 return () => {
18040 scrollingElement.removeEventListener("wheel", onUserScroll, true);
18041 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
18042 scrollingElement.removeEventListener("scroll", onScroll, true);
18043 };
18044 }, [open, contentElement, store]);
18045 useSafeLayoutEffect(() => {
18046 if (!storeValue) return;
18047 if (composingRef.current) return;
18048 canAutoSelectRef.current = true;
18049 }, [storeValue]);
18050 useSafeLayoutEffect(() => {
18051 if (autoSelect !== "always" && open) return;
18052 canAutoSelectRef.current = open;
18053 }, [autoSelect, open]);
18054 const resetValueOnSelect = store.useState("resetValueOnSelect");
18055 useUpdateEffect(() => {
18056 var _a, _b;
18057 const canAutoSelect = canAutoSelectRef.current;
18058 if (!store) return;
18059 if (!open) return;
18060 if (!canAutoSelect && !resetValueOnSelect) return;
18061 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
18062 if (baseElement && !hasFocus(baseElement)) return;
18063 if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) {
18064 const observer = new MutationObserver(forceValueUpdate);
18065 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
18066 return () => observer.disconnect();
18067 }
18068 if (autoSelect && canAutoSelect) {
18069 const userAutoSelectId = getAutoSelectIdProp(items);
18070 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : (_a = getDefaultAutoSelectId(items)) != null ? _a : store.first();
18071 autoSelectIdRef.current = autoSelectId;
18072 store.move(autoSelectId != null ? autoSelectId : null);
18073 } else {
18074 const element = (_b = store.item(activeId || store.first())) == null ? void 0 : _b.element;
18075 if (element && "scrollIntoView" in element) {
18076 element.scrollIntoView({ block: "nearest", inline: "nearest" });
18077 }
18078 }
18079 return;
18080 }, [
18081 store,
18082 open,
18083 valueUpdated,
18084 storeValue,
18085 autoSelect,
18086 resetValueOnSelect,
18087 getAutoSelectIdProp,
18088 items
18089 ]);
18090 (0, import_react24.useEffect)(() => {
18091 if (!inline4) return;
18092 const combobox = ref.current;
18093 if (!combobox) return;
18094 const elements = [combobox, contentElement].filter(
18095 (value2) => !!value2
18096 );
18097 const onBlur2 = (event) => {
18098 if (elements.every((el) => isFocusEventOutside(event, el))) {
18099 store == null ? void 0 : store.setValue(value);
18100 }
18101 };
18102 for (const element of elements) {
18103 element.addEventListener("focusout", onBlur2);
18104 }
18105 return () => {
18106 for (const element of elements) {
18107 element.removeEventListener("focusout", onBlur2);
18108 }
18109 };
18110 }, [inline4, contentElement, store, value]);
18111 const canShow = (event) => {
18112 const currentTarget = event.currentTarget;
18113 return currentTarget.value.length >= showMinLength;
18114 };
18115 const onChangeProp = props.onChange;
18116 const showOnChangeProp = useBooleanEvent(showOnChange != null ? showOnChange : canShow);
18117 const setValueOnChangeProp = useBooleanEvent(
18118 // If the combobox is combined with tags, the value will be set by the tag
18119 // input component.
18120 setValueOnChange != null ? setValueOnChange : !store.tag
18121 );
18122 const onChange = useEvent((event) => {
18123 onChangeProp == null ? void 0 : onChangeProp(event);
18124 if (event.defaultPrevented) return;
18125 if (!store) return;
18126 const currentTarget = event.currentTarget;
18127 const { value: value2, selectionStart, selectionEnd } = currentTarget;
18128 const nativeEvent = event.nativeEvent;
18129 canAutoSelectRef.current = true;
18130 if (isInputEvent(nativeEvent)) {
18131 if (nativeEvent.isComposing) {
18132 canAutoSelectRef.current = false;
18133 composingRef.current = true;
18134 }
18135 if (inline4) {
18136 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
18137 const caretAtEnd = selectionStart === value2.length;
18138 setCanInline(textInserted && caretAtEnd);
18139 }
18140 }
18141 if (setValueOnChangeProp(event)) {
18142 const isSameValue = value2 === store.getState().value;
18143 store.setValue(value2);
18144 queueMicrotask(() => {
18145 setSelectionRange(currentTarget, selectionStart, selectionEnd);
18146 });
18147 if (inline4 && autoSelect && isSameValue) {
18148 forceValueUpdate();
18149 }
18150 }
18151 if (showOnChangeProp(event)) {
18152 store.show();
18153 }
18154 if (!autoSelect || !canAutoSelectRef.current) {
18155 store.setActiveId(null);
18156 }
18157 });
18158 const onCompositionEndProp = props.onCompositionEnd;
18159 const onCompositionEnd = useEvent((event) => {
18160 canAutoSelectRef.current = true;
18161 composingRef.current = false;
18162 onCompositionEndProp == null ? void 0 : onCompositionEndProp(event);
18163 if (event.defaultPrevented) return;
18164 if (!autoSelect) return;
18165 forceValueUpdate();
18166 });
18167 const onMouseDownProp = props.onMouseDown;
18168 const blurActiveItemOnClickProp = useBooleanEvent(
18169 blurActiveItemOnClick != null ? blurActiveItemOnClick : (() => !!(store == null ? void 0 : store.getState().includesBaseElement))
18170 );
18171 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18172 const showOnClickProp = useBooleanEvent(showOnClick != null ? showOnClick : canShow);
18173 const onMouseDown = useEvent((event) => {
18174 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
18175 if (event.defaultPrevented) return;
18176 if (event.button) return;
18177 if (event.ctrlKey) return;
18178 if (!store) return;
18179 if (blurActiveItemOnClickProp(event)) {
18180 store.setActiveId(null);
18181 }
18182 if (setValueOnClickProp(event)) {
18183 store.setValue(value);
18184 }
18185 if (showOnClickProp(event)) {
18186 queueBeforeEvent(event.currentTarget, "mouseup", store.show);
18187 }
18188 });
18189 const onKeyDownProp = props.onKeyDown;
18190 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress != null ? showOnKeyPress : canShow);
18191 const onKeyDown = useEvent((event) => {
18192 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
18193 if (!event.repeat) {
18194 canAutoSelectRef.current = false;
18195 }
18196 if (event.defaultPrevented) return;
18197 if (event.ctrlKey) return;
18198 if (event.altKey) return;
18199 if (event.shiftKey) return;
18200 if (event.metaKey) return;
18201 if (!store) return;
18202 const { open: open2 } = store.getState();
18203 if (open2) return;
18204 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
18205 if (showOnKeyPressProp(event)) {
18206 event.preventDefault();
18207 store.show();
18208 }
18209 }
18210 });
18211 const onBlurProp = props.onBlur;
18212 const onBlur = useEvent((event) => {
18213 canAutoSelectRef.current = false;
18214 onBlurProp == null ? void 0 : onBlurProp(event);
18215 if (event.defaultPrevented) return;
18216 });
18217 const id = useId4(props.id);
18218 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
18219 const isActiveItem = store.useState((state) => state.activeId === null);
18220 props = {
18221 id,
18222 role: "combobox",
18223 "aria-autocomplete": ariaAutoComplete,
18224 "aria-haspopup": getPopupRole(contentElement, "listbox"),
18225 "aria-expanded": open,
18226 "aria-controls": contentElement == null ? void 0 : contentElement.id,
18227 "data-active-item": isActiveItem || void 0,
18228 value,
18229 ...props,
18230 ref: useMergeRefs(ref, props.ref),
18231 onChange,
18232 onCompositionEnd,
18233 onMouseDown,
18234 onKeyDown,
18235 onBlur
18236 };
18237 props = useComposite({
18238 store,
18239 focusable: focusable2,
18240 ...props,
18241 // Enable inline autocomplete when the user moves from the combobox input
18242 // to an item.
18243 moveOnKeyPress: (event) => {
18244 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
18245 if (inline4) setCanInline(true);
18246 return true;
18247 }
18248 });
18249 props = usePopoverAnchor({ store, ...props });
18250 return { autoComplete: "off", ...props };
18251 }
18252 );
18253 var Combobox = forwardRef210(function Combobox2(props) {
18254 const htmlProps = useCombobox(props);
18255 return createElement3(TagName9, htmlProps);
18256 });
18257
18258 // node_modules/@ariakit/react-core/esm/__chunks/IBXZ2LQC.js
18259 var import_react25 = __toESM(require_react(), 1);
18260 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
18261 var TagName10 = "div";
18262 function isSelected(storeValue, itemValue) {
18263 if (itemValue == null) return;
18264 if (storeValue == null) return false;
18265 if (Array.isArray(storeValue)) {
18266 return storeValue.includes(itemValue);
18267 }
18268 return storeValue === itemValue;
18269 }
18270 function getItemRole(popupRole) {
18271 var _a;
18272 const itemRoleByPopupRole = {
18273 menu: "menuitem",
18274 listbox: "option",
18275 tree: "treeitem"
18276 };
18277 const key = popupRole;
18278 return (_a = itemRoleByPopupRole[key]) != null ? _a : "option";
18279 }
18280 var useComboboxItem = createHook(
18281 function useComboboxItem2({
18282 store,
18283 value,
18284 hideOnClick,
18285 setValueOnClick,
18286 selectValueOnClick = true,
18287 resetValueOnSelect,
18288 focusOnHover = false,
18289 moveOnKeyPress = true,
18290 getItem: getItemProp,
18291 ...props
18292 }) {
18293 var _a;
18294 const context = useComboboxScopedContext();
18295 store = store || context;
18296 invariant(
18297 store,
18298 "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component."
18299 );
18300 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
18301 resetValueOnSelectState: "resetValueOnSelect",
18302 multiSelectable(state) {
18303 return Array.isArray(state.selectedValue);
18304 },
18305 selected(state) {
18306 return isSelected(state.selectedValue, value);
18307 }
18308 });
18309 const getItem = (0, import_react25.useCallback)(
18310 (item) => {
18311 const nextItem = { ...item, value };
18312 if (getItemProp) {
18313 return getItemProp(nextItem);
18314 }
18315 return nextItem;
18316 },
18317 [value, getItemProp]
18318 );
18319 setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable;
18320 hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable;
18321 const onClickProp = props.onClick;
18322 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18323 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
18324 const resetValueOnSelectProp = useBooleanEvent(
18325 (_a = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a : multiSelectable
18326 );
18327 const hideOnClickProp = useBooleanEvent(hideOnClick);
18328 const onClick = useEvent((event) => {
18329 onClickProp == null ? void 0 : onClickProp(event);
18330 if (event.defaultPrevented) return;
18331 if (isDownloading(event)) return;
18332 if (isOpeningInNewTab(event)) return;
18333 if (value != null) {
18334 if (selectValueOnClickProp(event)) {
18335 if (resetValueOnSelectProp(event)) {
18336 store == null ? void 0 : store.resetValue();
18337 }
18338 store == null ? void 0 : store.setSelectedValue((prevValue) => {
18339 if (!Array.isArray(prevValue)) return value;
18340 if (prevValue.includes(value)) {
18341 return prevValue.filter((v2) => v2 !== value);
18342 }
18343 return [...prevValue, value];
18344 });
18345 }
18346 if (setValueOnClickProp(event)) {
18347 store == null ? void 0 : store.setValue(value);
18348 }
18349 }
18350 if (hideOnClickProp(event)) {
18351 store == null ? void 0 : store.hide();
18352 }
18353 });
18354 const onKeyDownProp = props.onKeyDown;
18355 const onKeyDown = useEvent((event) => {
18356 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
18357 if (event.defaultPrevented) return;
18358 const baseElement = store == null ? void 0 : store.getState().baseElement;
18359 if (!baseElement) return;
18360 if (hasFocus(baseElement)) return;
18361 const printable = event.key.length === 1;
18362 if (printable || event.key === "Backspace" || event.key === "Delete") {
18363 queueMicrotask(() => baseElement.focus());
18364 if (isTextField(baseElement)) {
18365 store == null ? void 0 : store.setValue(baseElement.value);
18366 }
18367 }
18368 });
18369 if (multiSelectable && selected != null) {
18370 props = {
18371 "aria-selected": selected,
18372 ...props
18373 };
18374 }
18375 props = useWrapElement(
18376 props,
18377 (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 }) }),
18378 [value, selected]
18379 );
18380 const popupRole = (0, import_react25.useContext)(ComboboxListRoleContext);
18381 props = {
18382 role: getItemRole(popupRole),
18383 children: value,
18384 ...props,
18385 onClick,
18386 onKeyDown
18387 };
18388 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
18389 props = useCompositeItem({
18390 store,
18391 ...props,
18392 getItem,
18393 // Dispatch a custom event on the combobox input when moving to an item
18394 // with the keyboard so the Combobox component can enable inline
18395 // autocompletion.
18396 moveOnKeyPress: (event) => {
18397 if (!moveOnKeyPressProp(event)) return false;
18398 const moveEvent = new Event("combobox-item-move");
18399 const baseElement = store == null ? void 0 : store.getState().baseElement;
18400 baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent);
18401 return true;
18402 }
18403 });
18404 props = useCompositeHover({ store, focusOnHover, ...props });
18405 return props;
18406 }
18407 );
18408 var ComboboxItem = memo22(
18409 forwardRef210(function ComboboxItem2(props) {
18410 const htmlProps = useComboboxItem(props);
18411 return createElement3(TagName10, htmlProps);
18412 })
18413 );
18414
18415 // node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js
18416 var import_react26 = __toESM(require_react(), 1);
18417 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
18418 var TagName11 = "span";
18419 function normalizeValue(value) {
18420 return normalizeString(value).toLowerCase();
18421 }
18422 function getOffsets(string, values) {
18423 const offsets = [];
18424 for (const value of values) {
18425 let pos = 0;
18426 const length = value.length;
18427 while (string.indexOf(value, pos) !== -1) {
18428 const index2 = string.indexOf(value, pos);
18429 if (index2 !== -1) {
18430 offsets.push([index2, length]);
18431 }
18432 pos = index2 + 1;
18433 }
18434 }
18435 return offsets;
18436 }
18437 function filterOverlappingOffsets(offsets) {
18438 return offsets.filter(([offset4, length], i2, arr) => {
18439 return !arr.some(
18440 ([o2, l2], j2) => j2 !== i2 && o2 <= offset4 && o2 + l2 >= offset4 + length
18441 );
18442 });
18443 }
18444 function sortOffsets(offsets) {
18445 return offsets.sort(([a2], [b2]) => a2 - b2);
18446 }
18447 function splitValue(itemValue, userValue) {
18448 if (!itemValue) return itemValue;
18449 if (!userValue) return itemValue;
18450 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue);
18451 const parts = [];
18452 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
18453 "span",
18454 {
18455 "data-autocomplete-value": autocomplete ? "" : void 0,
18456 "data-user-value": autocomplete ? void 0 : "",
18457 children: value
18458 },
18459 parts.length
18460 );
18461 const offsets = sortOffsets(
18462 filterOverlappingOffsets(
18463 // Convert userValues into a set to avoid duplicates
18464 getOffsets(normalizeValue(itemValue), new Set(userValues))
18465 )
18466 );
18467 if (!offsets.length) {
18468 parts.push(span(itemValue, true));
18469 return parts;
18470 }
18471 const [firstOffset] = offsets[0];
18472 const values = [
18473 itemValue.slice(0, firstOffset),
18474 ...offsets.flatMap(([offset4, length], i2) => {
18475 var _a;
18476 const value = itemValue.slice(offset4, offset4 + length);
18477 const nextOffset = (_a = offsets[i2 + 1]) == null ? void 0 : _a[0];
18478 const nextValue = itemValue.slice(offset4 + length, nextOffset);
18479 return [value, nextValue];
18480 })
18481 ];
18482 values.forEach((value, i2) => {
18483 if (!value) return;
18484 parts.push(span(value, i2 % 2 === 0));
18485 });
18486 return parts;
18487 }
18488 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
18489 const context = useComboboxScopedContext();
18490 store = store || context;
18491 const itemContext = (0, import_react26.useContext)(ComboboxItemValueContext);
18492 const itemValue = value != null ? value : itemContext;
18493 const inputValue = useStoreState(store, (state) => userValue != null ? userValue : state == null ? void 0 : state.value);
18494 const children = (0, import_react26.useMemo)(() => {
18495 if (!itemValue) return;
18496 if (!inputValue) return itemValue;
18497 return splitValue(itemValue, inputValue);
18498 }, [itemValue, inputValue]);
18499 props = {
18500 children,
18501 ...props
18502 };
18503 return removeUndefinedValues(props);
18504 });
18505 var ComboboxItemValue = forwardRef210(function ComboboxItemValue2(props) {
18506 const htmlProps = useComboboxItemValue(props);
18507 return createElement3(TagName11, htmlProps);
18508 });
18509
18510 // node_modules/@ariakit/react-core/esm/combobox/combobox-label.js
18511 var TagName12 = "label";
18512 var useComboboxLabel = createHook(
18513 function useComboboxLabel2({ store, ...props }) {
18514 const context = useComboboxProviderContext();
18515 store = store || context;
18516 invariant(
18517 store,
18518 "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component."
18519 );
18520 const comboboxId = store.useState((state) => {
18521 var _a;
18522 return (_a = state.baseElement) == null ? void 0 : _a.id;
18523 });
18524 props = {
18525 htmlFor: comboboxId,
18526 ...props
18527 };
18528 return removeUndefinedValues(props);
18529 }
18530 );
18531 var ComboboxLabel = memo22(
18532 forwardRef210(function ComboboxLabel2(props) {
18533 const htmlProps = useComboboxLabel(props);
18534 return createElement3(TagName12, htmlProps);
18535 })
18536 );
18537
18538 // node_modules/@ariakit/react-core/esm/__chunks/2G6YEJT4.js
18539 var import_react27 = __toESM(require_react(), 1);
18540 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
18541 var TagName13 = "div";
18542 var useComboboxList = createHook(
18543 function useComboboxList2({ store, alwaysVisible, ...props }) {
18544 const scopedContext = useComboboxScopedContext(true);
18545 const context = useComboboxContext();
18546 store = store || context;
18547 const scopedContextSameStore = !!store && store === scopedContext;
18548 invariant(
18549 store,
18550 "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component."
18551 );
18552 const ref = (0, import_react27.useRef)(null);
18553 const id = useId4(props.id);
18554 const mounted = store.useState("mounted");
18555 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
18556 const style = hidden ? { ...props.style, display: "none" } : props.style;
18557 const multiSelectable = store.useState(
18558 (state) => Array.isArray(state.selectedValue)
18559 );
18560 const role = useAttribute(ref, "role", props.role);
18561 const isCompositeRole = role === "listbox" || role === "tree" || role === "grid";
18562 const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0;
18563 const [hasListboxInside, setHasListboxInside] = (0, import_react27.useState)(false);
18564 const contentElement = store.useState("contentElement");
18565 useSafeLayoutEffect(() => {
18566 if (!mounted) return;
18567 const element = ref.current;
18568 if (!element) return;
18569 if (contentElement !== element) return;
18570 const callback = () => {
18571 setHasListboxInside(!!element.querySelector("[role='listbox']"));
18572 };
18573 const observer = new MutationObserver(callback);
18574 observer.observe(element, {
18575 subtree: true,
18576 childList: true,
18577 attributeFilter: ["role"]
18578 });
18579 callback();
18580 return () => observer.disconnect();
18581 }, [mounted, contentElement]);
18582 if (!hasListboxInside) {
18583 props = {
18584 role: "listbox",
18585 "aria-multiselectable": ariaMultiSelectable,
18586 ...props
18587 };
18588 }
18589 props = useWrapElement(
18590 props,
18591 (element) => /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(ComboboxScopedContextProvider, { value: store, children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(ComboboxListRoleContext.Provider, { value: role, children: element }) }),
18592 [store, role]
18593 );
18594 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
18595 props = {
18596 id,
18597 hidden,
18598 ...props,
18599 ref: useMergeRefs(setContentElement, ref, props.ref),
18600 style
18601 };
18602 return removeUndefinedValues(props);
18603 }
18604 );
18605 var ComboboxList = forwardRef210(function ComboboxList2(props) {
18606 const htmlProps = useComboboxList(props);
18607 return createElement3(TagName13, htmlProps);
18608 });
18609
18610 // node_modules/@ariakit/react-core/esm/__chunks/XSIEPKGA.js
18611 var import_react28 = __toESM(require_react(), 1);
18612 var TagValueContext = (0, import_react28.createContext)(null);
18613 var TagRemoveIdContext = (0, import_react28.createContext)(
18614 null
18615 );
18616 var ctx7 = createStoreContext(
18617 [CompositeContextProvider],
18618 [CompositeScopedContextProvider]
18619 );
18620 var useTagContext = ctx7.useContext;
18621 var useTagScopedContext = ctx7.useScopedContext;
18622 var useTagProviderContext = ctx7.useProviderContext;
18623 var TagContextProvider = ctx7.ContextProvider;
18624 var TagScopedContextProvider = ctx7.ScopedContextProvider;
18625
18626 // node_modules/@ariakit/core/esm/combobox/combobox-store.js
18627 var isTouchSafari = isSafari2() && isTouchDevice();
18628 function createComboboxStore({
18629 tag,
18630 ...props
18631 } = {}) {
18632 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
18633 throwOnConflictingProps(props, store);
18634 const tagState = tag == null ? void 0 : tag.getState();
18635 const syncState = store == null ? void 0 : store.getState();
18636 const activeId = defaultValue(
18637 props.activeId,
18638 syncState == null ? void 0 : syncState.activeId,
18639 props.defaultActiveId,
18640 null
18641 );
18642 const composite = createCompositeStore({
18643 ...props,
18644 activeId,
18645 includesBaseElement: defaultValue(
18646 props.includesBaseElement,
18647 syncState == null ? void 0 : syncState.includesBaseElement,
18648 true
18649 ),
18650 orientation: defaultValue(
18651 props.orientation,
18652 syncState == null ? void 0 : syncState.orientation,
18653 "vertical"
18654 ),
18655 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true),
18656 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true),
18657 virtualFocus: defaultValue(
18658 props.virtualFocus,
18659 syncState == null ? void 0 : syncState.virtualFocus,
18660 true
18661 )
18662 });
18663 const popover = createPopoverStore({
18664 ...props,
18665 placement: defaultValue(
18666 props.placement,
18667 syncState == null ? void 0 : syncState.placement,
18668 "bottom-start"
18669 )
18670 });
18671 const value = defaultValue(
18672 props.value,
18673 syncState == null ? void 0 : syncState.value,
18674 props.defaultValue,
18675 ""
18676 );
18677 const selectedValue = defaultValue(
18678 props.selectedValue,
18679 syncState == null ? void 0 : syncState.selectedValue,
18680 tagState == null ? void 0 : tagState.values,
18681 props.defaultSelectedValue,
18682 ""
18683 );
18684 const multiSelectable = Array.isArray(selectedValue);
18685 const initialState = {
18686 ...composite.getState(),
18687 ...popover.getState(),
18688 value,
18689 selectedValue,
18690 resetValueOnSelect: defaultValue(
18691 props.resetValueOnSelect,
18692 syncState == null ? void 0 : syncState.resetValueOnSelect,
18693 multiSelectable
18694 ),
18695 resetValueOnHide: defaultValue(
18696 props.resetValueOnHide,
18697 syncState == null ? void 0 : syncState.resetValueOnHide,
18698 multiSelectable && !tag
18699 ),
18700 activeValue: syncState == null ? void 0 : syncState.activeValue
18701 };
18702 const combobox = createStore(initialState, composite, popover, store);
18703 if (isTouchSafari) {
18704 setup(
18705 combobox,
18706 () => sync(combobox, ["virtualFocus"], () => {
18707 combobox.setState("virtualFocus", false);
18708 })
18709 );
18710 }
18711 setup(combobox, () => {
18712 if (!tag) return;
18713 return chain(
18714 sync(combobox, ["selectedValue"], (state) => {
18715 if (!Array.isArray(state.selectedValue)) return;
18716 tag.setValues(state.selectedValue);
18717 }),
18718 sync(tag, ["values"], (state) => {
18719 combobox.setState("selectedValue", state.values);
18720 })
18721 );
18722 });
18723 setup(
18724 combobox,
18725 () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
18726 if (!state.resetValueOnHide) return;
18727 if (state.mounted) return;
18728 combobox.setState("value", value);
18729 })
18730 );
18731 setup(
18732 combobox,
18733 () => sync(combobox, ["open"], (state) => {
18734 if (state.open) return;
18735 combobox.setState("activeId", activeId);
18736 combobox.setState("moves", 0);
18737 })
18738 );
18739 setup(
18740 combobox,
18741 () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
18742 if (state.moves === prevState.moves) {
18743 combobox.setState("activeValue", void 0);
18744 }
18745 })
18746 );
18747 setup(
18748 combobox,
18749 () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
18750 if (state.moves === prev.moves) return;
18751 const { activeId: activeId2 } = combobox.getState();
18752 const activeItem = composite.item(activeId2);
18753 combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value);
18754 })
18755 );
18756 return {
18757 ...popover,
18758 ...composite,
18759 ...combobox,
18760 tag,
18761 setValue: (value2) => combobox.setState("value", value2),
18762 resetValue: () => combobox.setState("value", initialState.value),
18763 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
18764 };
18765 }
18766
18767 // node_modules/@ariakit/react-core/esm/__chunks/SVN33SY6.js
18768 function useComboboxStoreOptions(props) {
18769 const tag = useTagContext();
18770 props = {
18771 ...props,
18772 tag: props.tag !== void 0 ? props.tag : tag
18773 };
18774 return useCompositeStoreOptions(props);
18775 }
18776 function useComboboxStoreProps(store, update2, props) {
18777 useUpdateEffect(update2, [props.tag]);
18778 useStoreProps(store, props, "value", "setValue");
18779 useStoreProps(store, props, "selectedValue", "setSelectedValue");
18780 useStoreProps(store, props, "resetValueOnHide");
18781 useStoreProps(store, props, "resetValueOnSelect");
18782 return Object.assign(
18783 useCompositeStoreProps(
18784 usePopoverStoreProps(store, update2, props),
18785 update2,
18786 props
18787 ),
18788 { tag: props.tag }
18789 );
18790 }
18791 function useComboboxStore(props = {}) {
18792 props = useComboboxStoreOptions(props);
18793 const [store, update2] = useStore2(createComboboxStore, props);
18794 return useComboboxStoreProps(store, update2, props);
18795 }
18796
18797 // node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js
18798 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
18799 function ComboboxProvider(props = {}) {
18800 const store = useComboboxStore(props);
18801 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(ComboboxContextProvider, { value: store, children: props.children });
18802 }
18803
18804 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
18805 var import_remove_accents = __toESM(require_remove_accents(), 1);
18806 var import_compose7 = __toESM(require_compose(), 1);
18807 var import_i18n23 = __toESM(require_i18n(), 1);
18808 var import_element48 = __toESM(require_element(), 1);
18809 var import_components18 = __toESM(require_components(), 1);
18810
18811 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
18812 var EMPTY_ARRAY3 = [];
18813 var getCurrentValue = (filterDefinition, currentFilter) => {
18814 if (filterDefinition.singleSelection) {
18815 return currentFilter?.value;
18816 }
18817 if (Array.isArray(currentFilter?.value)) {
18818 return currentFilter.value;
18819 }
18820 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
18821 return [currentFilter.value];
18822 }
18823 return EMPTY_ARRAY3;
18824 };
18825
18826 // packages/dataviews/build-module/hooks/use-elements.mjs
18827 var import_element47 = __toESM(require_element(), 1);
18828 var EMPTY_ARRAY4 = [];
18829 function useElements({
18830 elements,
18831 getElements
18832 }) {
18833 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
18834 const [records, setRecords] = (0, import_element47.useState)(staticElements);
18835 const [isLoading, setIsLoading] = (0, import_element47.useState)(false);
18836 (0, import_element47.useEffect)(() => {
18837 if (!getElements) {
18838 setRecords(staticElements);
18839 return;
18840 }
18841 let cancelled = false;
18842 setIsLoading(true);
18843 getElements().then((fetchedElements) => {
18844 if (!cancelled) {
18845 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
18846 setRecords(dynamicElements);
18847 }
18848 }).catch(() => {
18849 if (!cancelled) {
18850 setRecords(staticElements);
18851 }
18852 }).finally(() => {
18853 if (!cancelled) {
18854 setIsLoading(false);
18855 }
18856 });
18857 return () => {
18858 cancelled = true;
18859 };
18860 }, [getElements, staticElements]);
18861 return {
18862 elements: records,
18863 isLoading
18864 };
18865 }
18866
18867 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
18868 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
18869 function normalizeSearchInput(input = "") {
18870 return (0, import_remove_accents.default)(input.trim().toLowerCase());
18871 }
18872 var getNewValue = (filterDefinition, currentFilter, value) => {
18873 if (filterDefinition.singleSelection) {
18874 return value;
18875 }
18876 if (Array.isArray(currentFilter?.value)) {
18877 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
18878 }
18879 return [value];
18880 };
18881 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
18882 return `${prefix}-${filterElementValue}`;
18883 }
18884 var MultiSelectionOption = ({ selected }) => {
18885 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
18886 "span",
18887 {
18888 className: clsx_default(
18889 "dataviews-filters__search-widget-listitem-multi-selection",
18890 { "is-selected": selected }
18891 ),
18892 children: selected && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components18.Icon, { icon: check_default })
18893 }
18894 );
18895 };
18896 var SingleSelectionOption = ({ selected }) => {
18897 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
18898 "span",
18899 {
18900 className: clsx_default(
18901 "dataviews-filters__search-widget-listitem-single-selection",
18902 { "is-selected": selected }
18903 )
18904 }
18905 );
18906 };
18907 function ListBox({ view, filter, onChangeView }) {
18908 const baseId = (0, import_compose7.useInstanceId)(ListBox, "dataviews-filter-list-box");
18909 const [activeCompositeId, setActiveCompositeId] = (0, import_element48.useState)(
18910 // When there are one or less operators, the first item is set as active
18911 // (by setting the initial `activeId` to `undefined`).
18912 // With 2 or more operators, the focus is moved on the operators control
18913 // (by setting the initial `activeId` to `null`), meaning that there won't
18914 // be an active item initially. Focus is then managed via the
18915 // `onFocusVisible` callback.
18916 filter.operators?.length === 1 ? void 0 : null
18917 );
18918 const currentFilter = view.filters?.find(
18919 (f2) => f2.field === filter.field
18920 );
18921 const currentValue = getCurrentValue(filter, currentFilter);
18922 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
18923 import_components18.Composite,
18924 {
18925 virtualFocus: true,
18926 focusLoop: true,
18927 activeId: activeCompositeId,
18928 setActiveId: setActiveCompositeId,
18929 role: "listbox",
18930 className: "dataviews-filters__search-widget-listbox",
18931 "aria-label": (0, import_i18n23.sprintf)(
18932 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
18933 (0, import_i18n23.__)("List of: %1$s"),
18934 filter.name
18935 ),
18936 onFocusVisible: () => {
18937 if (!activeCompositeId && filter.elements.length) {
18938 setActiveCompositeId(
18939 generateFilterElementCompositeItemId(
18940 baseId,
18941 filter.elements[0].value
18942 )
18943 );
18944 }
18945 },
18946 render: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components18.Composite.Typeahead, {}),
18947 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
18948 import_components18.Composite.Hover,
18949 {
18950 render: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
18951 import_components18.Composite.Item,
18952 {
18953 id: generateFilterElementCompositeItemId(
18954 baseId,
18955 element.value
18956 ),
18957 render: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
18958 "div",
18959 {
18960 "aria-label": element.label,
18961 role: "option",
18962 className: "dataviews-filters__search-widget-listitem"
18963 }
18964 ),
18965 onClick: () => {
18966 const newFilters = currentFilter ? [
18967 ...(view.filters ?? []).map(
18968 (_filter) => {
18969 if (_filter.field === filter.field) {
18970 return {
18971 ..._filter,
18972 operator: currentFilter.operator || filter.operators[0],
18973 value: getNewValue(
18974 filter,
18975 currentFilter,
18976 element.value
18977 )
18978 };
18979 }
18980 return _filter;
18981 }
18982 )
18983 ] : [
18984 ...view.filters ?? [],
18985 {
18986 field: filter.field,
18987 operator: filter.operators[0],
18988 value: getNewValue(
18989 filter,
18990 currentFilter,
18991 element.value
18992 )
18993 }
18994 ];
18995 onChangeView({
18996 ...view,
18997 page: 1,
18998 filters: newFilters
18999 });
19000 }
19001 }
19002 ),
19003 children: [
19004 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
19005 SingleSelectionOption,
19006 {
19007 selected: currentValue === element.value
19008 }
19009 ),
19010 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
19011 MultiSelectionOption,
19012 {
19013 selected: currentValue.includes(element.value)
19014 }
19015 ),
19016 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
19017 "span",
19018 {
19019 className: "dataviews-filters__search-widget-listitem-value",
19020 title: element.label,
19021 children: element.label
19022 }
19023 )
19024 ]
19025 },
19026 element.value
19027 ))
19028 }
19029 );
19030 }
19031 function ComboboxList22({ view, filter, onChangeView }) {
19032 const [searchValue, setSearchValue] = (0, import_element48.useState)("");
19033 const deferredSearchValue = (0, import_element48.useDeferredValue)(searchValue);
19034 const currentFilter = view.filters?.find(
19035 (_filter) => _filter.field === filter.field
19036 );
19037 const currentValue = getCurrentValue(filter, currentFilter);
19038 const matches = (0, import_element48.useMemo)(() => {
19039 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
19040 return filter.elements.filter(
19041 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
19042 );
19043 }, [filter.elements, deferredSearchValue]);
19044 return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
19045 ComboboxProvider,
19046 {
19047 selectedValue: currentValue,
19048 setSelectedValue: (value) => {
19049 const newFilters = currentFilter ? [
19050 ...(view.filters ?? []).map((_filter) => {
19051 if (_filter.field === filter.field) {
19052 return {
19053 ..._filter,
19054 operator: currentFilter.operator || filter.operators[0],
19055 value
19056 };
19057 }
19058 return _filter;
19059 })
19060 ] : [
19061 ...view.filters ?? [],
19062 {
19063 field: filter.field,
19064 operator: filter.operators[0],
19065 value
19066 }
19067 ];
19068 onChangeView({
19069 ...view,
19070 page: 1,
19071 filters: newFilters
19072 });
19073 },
19074 setValue: setSearchValue,
19075 children: [
19076 /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
19077 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(ComboboxLabel, {}), children: (0, import_i18n23.__)("Search items") }),
19078 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
19079 Combobox,
19080 {
19081 autoSelect: "always",
19082 placeholder: (0, import_i18n23.__)("Search"),
19083 className: "dataviews-filters__search-widget-filter-combobox__input"
19084 }
19085 ),
19086 /* @__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 }) })
19087 ] }),
19088 /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
19089 ComboboxList,
19090 {
19091 className: "dataviews-filters__search-widget-filter-combobox-list",
19092 alwaysVisible: true,
19093 children: [
19094 matches.map((element) => {
19095 return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
19096 ComboboxItem,
19097 {
19098 resetValueOnSelect: false,
19099 value: element.value,
19100 className: "dataviews-filters__search-widget-listitem",
19101 hideOnClick: false,
19102 setValueOnClick: false,
19103 focusOnHover: true,
19104 children: [
19105 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
19106 SingleSelectionOption,
19107 {
19108 selected: currentValue === element.value
19109 }
19110 ),
19111 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
19112 MultiSelectionOption,
19113 {
19114 selected: currentValue.includes(
19115 element.value
19116 )
19117 }
19118 ),
19119 /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
19120 "span",
19121 {
19122 className: "dataviews-filters__search-widget-listitem-value",
19123 title: element.label,
19124 children: [
19125 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
19126 ComboboxItemValue,
19127 {
19128 className: "dataviews-filters__search-widget-filter-combobox-item-value",
19129 value: element.label
19130 }
19131 ),
19132 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
19133 ]
19134 }
19135 )
19136 ]
19137 },
19138 element.value
19139 );
19140 }),
19141 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("p", { children: (0, import_i18n23.__)("No results found") })
19142 ]
19143 }
19144 )
19145 ]
19146 }
19147 );
19148 }
19149 function SearchWidget(props) {
19150 const { elements, isLoading } = useElements({
19151 elements: props.filter.elements,
19152 getElements: props.filter.getElements
19153 });
19154 if (isLoading) {
19155 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, {}) });
19156 }
19157 if (elements.length === 0) {
19158 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n23.__)("No elements found") });
19159 }
19160 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
19161 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
19162 }
19163
19164 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
19165 var import_es6 = __toESM(require_es6(), 1);
19166 var import_compose8 = __toESM(require_compose(), 1);
19167 var import_element49 = __toESM(require_element(), 1);
19168 var import_components19 = __toESM(require_components(), 1);
19169 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
19170 function InputWidget({
19171 filter,
19172 view,
19173 onChangeView,
19174 fields
19175 }) {
19176 const currentFilter = view.filters?.find(
19177 (f2) => f2.field === filter.field
19178 );
19179 const currentValue = getCurrentValue(filter, currentFilter);
19180 const field = (0, import_element49.useMemo)(() => {
19181 const currentField = fields.find((f2) => f2.id === filter.field);
19182 if (currentField) {
19183 return {
19184 ...currentField,
19185 // Deactivate validation for filters.
19186 isValid: {},
19187 // Filter controls are always enabled.
19188 isDisabled: () => false,
19189 // Filter controls are always visible.
19190 isVisible: () => true,
19191 // Configure getValue/setValue as if Item was a plain object.
19192 getValue: ({ item }) => item[currentField.id],
19193 setValue: ({ value }) => ({
19194 [currentField.id]: value
19195 })
19196 };
19197 }
19198 return currentField;
19199 }, [fields, filter.field]);
19200 const data = (0, import_element49.useMemo)(() => {
19201 return (view.filters ?? []).reduce(
19202 (acc, activeFilter) => {
19203 acc[activeFilter.field] = activeFilter.value;
19204 return acc;
19205 },
19206 {}
19207 );
19208 }, [view.filters]);
19209 const handleChange = (0, import_compose8.useEvent)((updatedData) => {
19210 if (!field || !currentFilter) {
19211 return;
19212 }
19213 const nextValue = field.getValue({ item: updatedData });
19214 if ((0, import_es6.default)(nextValue, currentValue)) {
19215 return;
19216 }
19217 onChangeView({
19218 ...view,
19219 filters: (view.filters ?? []).map(
19220 (_filter) => _filter.field === filter.field ? {
19221 ..._filter,
19222 operator: currentFilter.operator || filter.operators[0],
19223 // Consider empty strings as undefined:
19224 //
19225 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
19226 // - empty string as value means "search empty string": returns only the records that have an empty string as value
19227 //
19228 // In practice, this means the filter will not be able to find an empty string as the value.
19229 value: nextValue === "" ? void 0 : nextValue
19230 } : _filter
19231 )
19232 });
19233 });
19234 if (!field || !field.Edit || !currentFilter) {
19235 return null;
19236 }
19237 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19238 import_components19.Flex,
19239 {
19240 className: "dataviews-filters__user-input-widget",
19241 gap: 2.5,
19242 direction: "column",
19243 children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19244 field.Edit,
19245 {
19246 hideLabelFromVision: true,
19247 data,
19248 field,
19249 operator: currentFilter.operator,
19250 onChange: handleChange
19251 }
19252 )
19253 }
19254 );
19255 }
19256
19257 // node_modules/date-fns/constants.js
19258 var daysInYear = 365.2425;
19259 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
19260 var minTime = -maxTime;
19261 var millisecondsInWeek = 6048e5;
19262 var millisecondsInDay = 864e5;
19263 var secondsInHour = 3600;
19264 var secondsInDay = secondsInHour * 24;
19265 var secondsInWeek = secondsInDay * 7;
19266 var secondsInYear = secondsInDay * daysInYear;
19267 var secondsInMonth = secondsInYear / 12;
19268 var secondsInQuarter = secondsInMonth * 3;
19269 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
19270
19271 // node_modules/date-fns/constructFrom.js
19272 function constructFrom(date, value) {
19273 if (typeof date === "function") return date(value);
19274 if (date && typeof date === "object" && constructFromSymbol in date)
19275 return date[constructFromSymbol](value);
19276 if (date instanceof Date) return new date.constructor(value);
19277 return new Date(value);
19278 }
19279
19280 // node_modules/date-fns/toDate.js
19281 function toDate(argument, context) {
19282 return constructFrom(context || argument, argument);
19283 }
19284
19285 // node_modules/date-fns/addDays.js
19286 function addDays(date, amount, options) {
19287 const _date = toDate(date, options?.in);
19288 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19289 if (!amount) return _date;
19290 _date.setDate(_date.getDate() + amount);
19291 return _date;
19292 }
19293
19294 // node_modules/date-fns/addMonths.js
19295 function addMonths(date, amount, options) {
19296 const _date = toDate(date, options?.in);
19297 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19298 if (!amount) {
19299 return _date;
19300 }
19301 const dayOfMonth = _date.getDate();
19302 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
19303 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
19304 const daysInMonth = endOfDesiredMonth.getDate();
19305 if (dayOfMonth >= daysInMonth) {
19306 return endOfDesiredMonth;
19307 } else {
19308 _date.setFullYear(
19309 endOfDesiredMonth.getFullYear(),
19310 endOfDesiredMonth.getMonth(),
19311 dayOfMonth
19312 );
19313 return _date;
19314 }
19315 }
19316
19317 // node_modules/date-fns/_lib/defaultOptions.js
19318 var defaultOptions = {};
19319 function getDefaultOptions() {
19320 return defaultOptions;
19321 }
19322
19323 // node_modules/date-fns/startOfWeek.js
19324 function startOfWeek(date, options) {
19325 const defaultOptions2 = getDefaultOptions();
19326 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
19327 const _date = toDate(date, options?.in);
19328 const day = _date.getDay();
19329 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
19330 _date.setDate(_date.getDate() - diff);
19331 _date.setHours(0, 0, 0, 0);
19332 return _date;
19333 }
19334
19335 // node_modules/date-fns/startOfISOWeek.js
19336 function startOfISOWeek(date, options) {
19337 return startOfWeek(date, { ...options, weekStartsOn: 1 });
19338 }
19339
19340 // node_modules/date-fns/getISOWeekYear.js
19341 function getISOWeekYear(date, options) {
19342 const _date = toDate(date, options?.in);
19343 const year = _date.getFullYear();
19344 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
19345 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
19346 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
19347 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
19348 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
19349 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
19350 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
19351 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
19352 if (_date.getTime() >= startOfNextYear.getTime()) {
19353 return year + 1;
19354 } else if (_date.getTime() >= startOfThisYear.getTime()) {
19355 return year;
19356 } else {
19357 return year - 1;
19358 }
19359 }
19360
19361 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
19362 function getTimezoneOffsetInMilliseconds(date) {
19363 const _date = toDate(date);
19364 const utcDate = new Date(
19365 Date.UTC(
19366 _date.getFullYear(),
19367 _date.getMonth(),
19368 _date.getDate(),
19369 _date.getHours(),
19370 _date.getMinutes(),
19371 _date.getSeconds(),
19372 _date.getMilliseconds()
19373 )
19374 );
19375 utcDate.setUTCFullYear(_date.getFullYear());
19376 return +date - +utcDate;
19377 }
19378
19379 // node_modules/date-fns/_lib/normalizeDates.js
19380 function normalizeDates(context, ...dates) {
19381 const normalize = constructFrom.bind(
19382 null,
19383 context || dates.find((date) => typeof date === "object")
19384 );
19385 return dates.map(normalize);
19386 }
19387
19388 // node_modules/date-fns/startOfDay.js
19389 function startOfDay(date, options) {
19390 const _date = toDate(date, options?.in);
19391 _date.setHours(0, 0, 0, 0);
19392 return _date;
19393 }
19394
19395 // node_modules/date-fns/differenceInCalendarDays.js
19396 function differenceInCalendarDays(laterDate, earlierDate, options) {
19397 const [laterDate_, earlierDate_] = normalizeDates(
19398 options?.in,
19399 laterDate,
19400 earlierDate
19401 );
19402 const laterStartOfDay = startOfDay(laterDate_);
19403 const earlierStartOfDay = startOfDay(earlierDate_);
19404 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
19405 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
19406 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
19407 }
19408
19409 // node_modules/date-fns/startOfISOWeekYear.js
19410 function startOfISOWeekYear(date, options) {
19411 const year = getISOWeekYear(date, options);
19412 const fourthOfJanuary = constructFrom(options?.in || date, 0);
19413 fourthOfJanuary.setFullYear(year, 0, 4);
19414 fourthOfJanuary.setHours(0, 0, 0, 0);
19415 return startOfISOWeek(fourthOfJanuary);
19416 }
19417
19418 // node_modules/date-fns/addWeeks.js
19419 function addWeeks(date, amount, options) {
19420 return addDays(date, amount * 7, options);
19421 }
19422
19423 // node_modules/date-fns/addYears.js
19424 function addYears(date, amount, options) {
19425 return addMonths(date, amount * 12, options);
19426 }
19427
19428 // node_modules/date-fns/isDate.js
19429 function isDate(value) {
19430 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
19431 }
19432
19433 // node_modules/date-fns/isValid.js
19434 function isValid(date) {
19435 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
19436 }
19437
19438 // node_modules/date-fns/startOfMonth.js
19439 function startOfMonth(date, options) {
19440 const _date = toDate(date, options?.in);
19441 _date.setDate(1);
19442 _date.setHours(0, 0, 0, 0);
19443 return _date;
19444 }
19445
19446 // node_modules/date-fns/startOfYear.js
19447 function startOfYear(date, options) {
19448 const date_ = toDate(date, options?.in);
19449 date_.setFullYear(date_.getFullYear(), 0, 1);
19450 date_.setHours(0, 0, 0, 0);
19451 return date_;
19452 }
19453
19454 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js
19455 var formatDistanceLocale = {
19456 lessThanXSeconds: {
19457 one: "less than a second",
19458 other: "less than {{count}} seconds"
19459 },
19460 xSeconds: {
19461 one: "1 second",
19462 other: "{{count}} seconds"
19463 },
19464 halfAMinute: "half a minute",
19465 lessThanXMinutes: {
19466 one: "less than a minute",
19467 other: "less than {{count}} minutes"
19468 },
19469 xMinutes: {
19470 one: "1 minute",
19471 other: "{{count}} minutes"
19472 },
19473 aboutXHours: {
19474 one: "about 1 hour",
19475 other: "about {{count}} hours"
19476 },
19477 xHours: {
19478 one: "1 hour",
19479 other: "{{count}} hours"
19480 },
19481 xDays: {
19482 one: "1 day",
19483 other: "{{count}} days"
19484 },
19485 aboutXWeeks: {
19486 one: "about 1 week",
19487 other: "about {{count}} weeks"
19488 },
19489 xWeeks: {
19490 one: "1 week",
19491 other: "{{count}} weeks"
19492 },
19493 aboutXMonths: {
19494 one: "about 1 month",
19495 other: "about {{count}} months"
19496 },
19497 xMonths: {
19498 one: "1 month",
19499 other: "{{count}} months"
19500 },
19501 aboutXYears: {
19502 one: "about 1 year",
19503 other: "about {{count}} years"
19504 },
19505 xYears: {
19506 one: "1 year",
19507 other: "{{count}} years"
19508 },
19509 overXYears: {
19510 one: "over 1 year",
19511 other: "over {{count}} years"
19512 },
19513 almostXYears: {
19514 one: "almost 1 year",
19515 other: "almost {{count}} years"
19516 }
19517 };
19518 var formatDistance = (token, count, options) => {
19519 let result;
19520 const tokenValue = formatDistanceLocale[token];
19521 if (typeof tokenValue === "string") {
19522 result = tokenValue;
19523 } else if (count === 1) {
19524 result = tokenValue.one;
19525 } else {
19526 result = tokenValue.other.replace("{{count}}", count.toString());
19527 }
19528 if (options?.addSuffix) {
19529 if (options.comparison && options.comparison > 0) {
19530 return "in " + result;
19531 } else {
19532 return result + " ago";
19533 }
19534 }
19535 return result;
19536 };
19537
19538 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js
19539 function buildFormatLongFn(args) {
19540 return (options = {}) => {
19541 const width = options.width ? String(options.width) : args.defaultWidth;
19542 const format6 = args.formats[width] || args.formats[args.defaultWidth];
19543 return format6;
19544 };
19545 }
19546
19547 // node_modules/date-fns/locale/en-US/_lib/formatLong.js
19548 var dateFormats = {
19549 full: "EEEE, MMMM do, y",
19550 long: "MMMM do, y",
19551 medium: "MMM d, y",
19552 short: "MM/dd/yyyy"
19553 };
19554 var timeFormats = {
19555 full: "h:mm:ss a zzzz",
19556 long: "h:mm:ss a z",
19557 medium: "h:mm:ss a",
19558 short: "h:mm a"
19559 };
19560 var dateTimeFormats = {
19561 full: "{{date}} 'at' {{time}}",
19562 long: "{{date}} 'at' {{time}}",
19563 medium: "{{date}}, {{time}}",
19564 short: "{{date}}, {{time}}"
19565 };
19566 var formatLong = {
19567 date: buildFormatLongFn({
19568 formats: dateFormats,
19569 defaultWidth: "full"
19570 }),
19571 time: buildFormatLongFn({
19572 formats: timeFormats,
19573 defaultWidth: "full"
19574 }),
19575 dateTime: buildFormatLongFn({
19576 formats: dateTimeFormats,
19577 defaultWidth: "full"
19578 })
19579 };
19580
19581 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js
19582 var formatRelativeLocale = {
19583 lastWeek: "'last' eeee 'at' p",
19584 yesterday: "'yesterday at' p",
19585 today: "'today at' p",
19586 tomorrow: "'tomorrow at' p",
19587 nextWeek: "eeee 'at' p",
19588 other: "P"
19589 };
19590 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
19591
19592 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js
19593 function buildLocalizeFn(args) {
19594 return (value, options) => {
19595 const context = options?.context ? String(options.context) : "standalone";
19596 let valuesArray;
19597 if (context === "formatting" && args.formattingValues) {
19598 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
19599 const width = options?.width ? String(options.width) : defaultWidth;
19600 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
19601 } else {
19602 const defaultWidth = args.defaultWidth;
19603 const width = options?.width ? String(options.width) : args.defaultWidth;
19604 valuesArray = args.values[width] || args.values[defaultWidth];
19605 }
19606 const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
19607 return valuesArray[index2];
19608 };
19609 }
19610
19611 // node_modules/date-fns/locale/en-US/_lib/localize.js
19612 var eraValues = {
19613 narrow: ["B", "A"],
19614 abbreviated: ["BC", "AD"],
19615 wide: ["Before Christ", "Anno Domini"]
19616 };
19617 var quarterValues = {
19618 narrow: ["1", "2", "3", "4"],
19619 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
19620 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
19621 };
19622 var monthValues = {
19623 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
19624 abbreviated: [
19625 "Jan",
19626 "Feb",
19627 "Mar",
19628 "Apr",
19629 "May",
19630 "Jun",
19631 "Jul",
19632 "Aug",
19633 "Sep",
19634 "Oct",
19635 "Nov",
19636 "Dec"
19637 ],
19638 wide: [
19639 "January",
19640 "February",
19641 "March",
19642 "April",
19643 "May",
19644 "June",
19645 "July",
19646 "August",
19647 "September",
19648 "October",
19649 "November",
19650 "December"
19651 ]
19652 };
19653 var dayValues = {
19654 narrow: ["S", "M", "T", "W", "T", "F", "S"],
19655 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
19656 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
19657 wide: [
19658 "Sunday",
19659 "Monday",
19660 "Tuesday",
19661 "Wednesday",
19662 "Thursday",
19663 "Friday",
19664 "Saturday"
19665 ]
19666 };
19667 var dayPeriodValues = {
19668 narrow: {
19669 am: "a",
19670 pm: "p",
19671 midnight: "mi",
19672 noon: "n",
19673 morning: "morning",
19674 afternoon: "afternoon",
19675 evening: "evening",
19676 night: "night"
19677 },
19678 abbreviated: {
19679 am: "AM",
19680 pm: "PM",
19681 midnight: "midnight",
19682 noon: "noon",
19683 morning: "morning",
19684 afternoon: "afternoon",
19685 evening: "evening",
19686 night: "night"
19687 },
19688 wide: {
19689 am: "a.m.",
19690 pm: "p.m.",
19691 midnight: "midnight",
19692 noon: "noon",
19693 morning: "morning",
19694 afternoon: "afternoon",
19695 evening: "evening",
19696 night: "night"
19697 }
19698 };
19699 var formattingDayPeriodValues = {
19700 narrow: {
19701 am: "a",
19702 pm: "p",
19703 midnight: "mi",
19704 noon: "n",
19705 morning: "in the morning",
19706 afternoon: "in the afternoon",
19707 evening: "in the evening",
19708 night: "at night"
19709 },
19710 abbreviated: {
19711 am: "AM",
19712 pm: "PM",
19713 midnight: "midnight",
19714 noon: "noon",
19715 morning: "in the morning",
19716 afternoon: "in the afternoon",
19717 evening: "in the evening",
19718 night: "at night"
19719 },
19720 wide: {
19721 am: "a.m.",
19722 pm: "p.m.",
19723 midnight: "midnight",
19724 noon: "noon",
19725 morning: "in the morning",
19726 afternoon: "in the afternoon",
19727 evening: "in the evening",
19728 night: "at night"
19729 }
19730 };
19731 var ordinalNumber = (dirtyNumber, _options) => {
19732 const number = Number(dirtyNumber);
19733 const rem100 = number % 100;
19734 if (rem100 > 20 || rem100 < 10) {
19735 switch (rem100 % 10) {
19736 case 1:
19737 return number + "st";
19738 case 2:
19739 return number + "nd";
19740 case 3:
19741 return number + "rd";
19742 }
19743 }
19744 return number + "th";
19745 };
19746 var localize = {
19747 ordinalNumber,
19748 era: buildLocalizeFn({
19749 values: eraValues,
19750 defaultWidth: "wide"
19751 }),
19752 quarter: buildLocalizeFn({
19753 values: quarterValues,
19754 defaultWidth: "wide",
19755 argumentCallback: (quarter) => quarter - 1
19756 }),
19757 month: buildLocalizeFn({
19758 values: monthValues,
19759 defaultWidth: "wide"
19760 }),
19761 day: buildLocalizeFn({
19762 values: dayValues,
19763 defaultWidth: "wide"
19764 }),
19765 dayPeriod: buildLocalizeFn({
19766 values: dayPeriodValues,
19767 defaultWidth: "wide",
19768 formattingValues: formattingDayPeriodValues,
19769 defaultFormattingWidth: "wide"
19770 })
19771 };
19772
19773 // node_modules/date-fns/locale/_lib/buildMatchFn.js
19774 function buildMatchFn(args) {
19775 return (string, options = {}) => {
19776 const width = options.width;
19777 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
19778 const matchResult = string.match(matchPattern);
19779 if (!matchResult) {
19780 return null;
19781 }
19782 const matchedString = matchResult[0];
19783 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
19784 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
19785 // [TODO] -- I challenge you to fix the type
19786 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
19787 );
19788 let value;
19789 value = args.valueCallback ? args.valueCallback(key) : key;
19790 value = options.valueCallback ? (
19791 // [TODO] -- I challenge you to fix the type
19792 options.valueCallback(value)
19793 ) : value;
19794 const rest = string.slice(matchedString.length);
19795 return { value, rest };
19796 };
19797 }
19798 function findKey(object, predicate) {
19799 for (const key in object) {
19800 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
19801 return key;
19802 }
19803 }
19804 return void 0;
19805 }
19806 function findIndex(array, predicate) {
19807 for (let key = 0; key < array.length; key++) {
19808 if (predicate(array[key])) {
19809 return key;
19810 }
19811 }
19812 return void 0;
19813 }
19814
19815 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
19816 function buildMatchPatternFn(args) {
19817 return (string, options = {}) => {
19818 const matchResult = string.match(args.matchPattern);
19819 if (!matchResult) return null;
19820 const matchedString = matchResult[0];
19821 const parseResult = string.match(args.parsePattern);
19822 if (!parseResult) return null;
19823 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
19824 value = options.valueCallback ? options.valueCallback(value) : value;
19825 const rest = string.slice(matchedString.length);
19826 return { value, rest };
19827 };
19828 }
19829
19830 // node_modules/date-fns/locale/en-US/_lib/match.js
19831 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
19832 var parseOrdinalNumberPattern = /\d+/i;
19833 var matchEraPatterns = {
19834 narrow: /^(b|a)/i,
19835 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
19836 wide: /^(before christ|before common era|anno domini|common era)/i
19837 };
19838 var parseEraPatterns = {
19839 any: [/^b/i, /^(a|c)/i]
19840 };
19841 var matchQuarterPatterns = {
19842 narrow: /^[1234]/i,
19843 abbreviated: /^q[1234]/i,
19844 wide: /^[1234](th|st|nd|rd)? quarter/i
19845 };
19846 var parseQuarterPatterns = {
19847 any: [/1/i, /2/i, /3/i, /4/i]
19848 };
19849 var matchMonthPatterns = {
19850 narrow: /^[jfmasond]/i,
19851 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
19852 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
19853 };
19854 var parseMonthPatterns = {
19855 narrow: [
19856 /^j/i,
19857 /^f/i,
19858 /^m/i,
19859 /^a/i,
19860 /^m/i,
19861 /^j/i,
19862 /^j/i,
19863 /^a/i,
19864 /^s/i,
19865 /^o/i,
19866 /^n/i,
19867 /^d/i
19868 ],
19869 any: [
19870 /^ja/i,
19871 /^f/i,
19872 /^mar/i,
19873 /^ap/i,
19874 /^may/i,
19875 /^jun/i,
19876 /^jul/i,
19877 /^au/i,
19878 /^s/i,
19879 /^o/i,
19880 /^n/i,
19881 /^d/i
19882 ]
19883 };
19884 var matchDayPatterns = {
19885 narrow: /^[smtwf]/i,
19886 short: /^(su|mo|tu|we|th|fr|sa)/i,
19887 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
19888 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
19889 };
19890 var parseDayPatterns = {
19891 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
19892 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
19893 };
19894 var matchDayPeriodPatterns = {
19895 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
19896 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
19897 };
19898 var parseDayPeriodPatterns = {
19899 any: {
19900 am: /^a/i,
19901 pm: /^p/i,
19902 midnight: /^mi/i,
19903 noon: /^no/i,
19904 morning: /morning/i,
19905 afternoon: /afternoon/i,
19906 evening: /evening/i,
19907 night: /night/i
19908 }
19909 };
19910 var match = {
19911 ordinalNumber: buildMatchPatternFn({
19912 matchPattern: matchOrdinalNumberPattern,
19913 parsePattern: parseOrdinalNumberPattern,
19914 valueCallback: (value) => parseInt(value, 10)
19915 }),
19916 era: buildMatchFn({
19917 matchPatterns: matchEraPatterns,
19918 defaultMatchWidth: "wide",
19919 parsePatterns: parseEraPatterns,
19920 defaultParseWidth: "any"
19921 }),
19922 quarter: buildMatchFn({
19923 matchPatterns: matchQuarterPatterns,
19924 defaultMatchWidth: "wide",
19925 parsePatterns: parseQuarterPatterns,
19926 defaultParseWidth: "any",
19927 valueCallback: (index2) => index2 + 1
19928 }),
19929 month: buildMatchFn({
19930 matchPatterns: matchMonthPatterns,
19931 defaultMatchWidth: "wide",
19932 parsePatterns: parseMonthPatterns,
19933 defaultParseWidth: "any"
19934 }),
19935 day: buildMatchFn({
19936 matchPatterns: matchDayPatterns,
19937 defaultMatchWidth: "wide",
19938 parsePatterns: parseDayPatterns,
19939 defaultParseWidth: "any"
19940 }),
19941 dayPeriod: buildMatchFn({
19942 matchPatterns: matchDayPeriodPatterns,
19943 defaultMatchWidth: "any",
19944 parsePatterns: parseDayPeriodPatterns,
19945 defaultParseWidth: "any"
19946 })
19947 };
19948
19949 // node_modules/date-fns/locale/en-US.js
19950 var enUS = {
19951 code: "en-US",
19952 formatDistance,
19953 formatLong,
19954 formatRelative,
19955 localize,
19956 match,
19957 options: {
19958 weekStartsOn: 0,
19959 firstWeekContainsDate: 1
19960 }
19961 };
19962
19963 // node_modules/date-fns/getDayOfYear.js
19964 function getDayOfYear(date, options) {
19965 const _date = toDate(date, options?.in);
19966 const diff = differenceInCalendarDays(_date, startOfYear(_date));
19967 const dayOfYear = diff + 1;
19968 return dayOfYear;
19969 }
19970
19971 // node_modules/date-fns/getISOWeek.js
19972 function getISOWeek(date, options) {
19973 const _date = toDate(date, options?.in);
19974 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
19975 return Math.round(diff / millisecondsInWeek) + 1;
19976 }
19977
19978 // node_modules/date-fns/getWeekYear.js
19979 function getWeekYear(date, options) {
19980 const _date = toDate(date, options?.in);
19981 const year = _date.getFullYear();
19982 const defaultOptions2 = getDefaultOptions();
19983 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
19984 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
19985 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
19986 firstWeekOfNextYear.setHours(0, 0, 0, 0);
19987 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
19988 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
19989 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
19990 firstWeekOfThisYear.setHours(0, 0, 0, 0);
19991 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
19992 if (+_date >= +startOfNextYear) {
19993 return year + 1;
19994 } else if (+_date >= +startOfThisYear) {
19995 return year;
19996 } else {
19997 return year - 1;
19998 }
19999 }
20000
20001 // node_modules/date-fns/startOfWeekYear.js
20002 function startOfWeekYear(date, options) {
20003 const defaultOptions2 = getDefaultOptions();
20004 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20005 const year = getWeekYear(date, options);
20006 const firstWeek = constructFrom(options?.in || date, 0);
20007 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
20008 firstWeek.setHours(0, 0, 0, 0);
20009 const _date = startOfWeek(firstWeek, options);
20010 return _date;
20011 }
20012
20013 // node_modules/date-fns/getWeek.js
20014 function getWeek(date, options) {
20015 const _date = toDate(date, options?.in);
20016 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
20017 return Math.round(diff / millisecondsInWeek) + 1;
20018 }
20019
20020 // node_modules/date-fns/_lib/addLeadingZeros.js
20021 function addLeadingZeros(number, targetLength) {
20022 const sign = number < 0 ? "-" : "";
20023 const output = Math.abs(number).toString().padStart(targetLength, "0");
20024 return sign + output;
20025 }
20026
20027 // node_modules/date-fns/_lib/format/lightFormatters.js
20028 var lightFormatters = {
20029 // Year
20030 y(date, token) {
20031 const signedYear = date.getFullYear();
20032 const year = signedYear > 0 ? signedYear : 1 - signedYear;
20033 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
20034 },
20035 // Month
20036 M(date, token) {
20037 const month = date.getMonth();
20038 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
20039 },
20040 // Day of the month
20041 d(date, token) {
20042 return addLeadingZeros(date.getDate(), token.length);
20043 },
20044 // AM or PM
20045 a(date, token) {
20046 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
20047 switch (token) {
20048 case "a":
20049 case "aa":
20050 return dayPeriodEnumValue.toUpperCase();
20051 case "aaa":
20052 return dayPeriodEnumValue;
20053 case "aaaaa":
20054 return dayPeriodEnumValue[0];
20055 case "aaaa":
20056 default:
20057 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
20058 }
20059 },
20060 // Hour [1-12]
20061 h(date, token) {
20062 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
20063 },
20064 // Hour [0-23]
20065 H(date, token) {
20066 return addLeadingZeros(date.getHours(), token.length);
20067 },
20068 // Minute
20069 m(date, token) {
20070 return addLeadingZeros(date.getMinutes(), token.length);
20071 },
20072 // Second
20073 s(date, token) {
20074 return addLeadingZeros(date.getSeconds(), token.length);
20075 },
20076 // Fraction of second
20077 S(date, token) {
20078 const numberOfDigits = token.length;
20079 const milliseconds = date.getMilliseconds();
20080 const fractionalSeconds = Math.trunc(
20081 milliseconds * Math.pow(10, numberOfDigits - 3)
20082 );
20083 return addLeadingZeros(fractionalSeconds, token.length);
20084 }
20085 };
20086
20087 // node_modules/date-fns/_lib/format/formatters.js
20088 var dayPeriodEnum = {
20089 am: "am",
20090 pm: "pm",
20091 midnight: "midnight",
20092 noon: "noon",
20093 morning: "morning",
20094 afternoon: "afternoon",
20095 evening: "evening",
20096 night: "night"
20097 };
20098 var formatters = {
20099 // Era
20100 G: function(date, token, localize2) {
20101 const era = date.getFullYear() > 0 ? 1 : 0;
20102 switch (token) {
20103 // AD, BC
20104 case "G":
20105 case "GG":
20106 case "GGG":
20107 return localize2.era(era, { width: "abbreviated" });
20108 // A, B
20109 case "GGGGG":
20110 return localize2.era(era, { width: "narrow" });
20111 // Anno Domini, Before Christ
20112 case "GGGG":
20113 default:
20114 return localize2.era(era, { width: "wide" });
20115 }
20116 },
20117 // Year
20118 y: function(date, token, localize2) {
20119 if (token === "yo") {
20120 const signedYear = date.getFullYear();
20121 const year = signedYear > 0 ? signedYear : 1 - signedYear;
20122 return localize2.ordinalNumber(year, { unit: "year" });
20123 }
20124 return lightFormatters.y(date, token);
20125 },
20126 // Local week-numbering year
20127 Y: function(date, token, localize2, options) {
20128 const signedWeekYear = getWeekYear(date, options);
20129 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
20130 if (token === "YY") {
20131 const twoDigitYear = weekYear % 100;
20132 return addLeadingZeros(twoDigitYear, 2);
20133 }
20134 if (token === "Yo") {
20135 return localize2.ordinalNumber(weekYear, { unit: "year" });
20136 }
20137 return addLeadingZeros(weekYear, token.length);
20138 },
20139 // ISO week-numbering year
20140 R: function(date, token) {
20141 const isoWeekYear = getISOWeekYear(date);
20142 return addLeadingZeros(isoWeekYear, token.length);
20143 },
20144 // Extended year. This is a single number designating the year of this calendar system.
20145 // The main difference between `y` and `u` localizers are B.C. years:
20146 // | Year | `y` | `u` |
20147 // |------|-----|-----|
20148 // | AC 1 | 1 | 1 |
20149 // | BC 1 | 1 | 0 |
20150 // | BC 2 | 2 | -1 |
20151 // Also `yy` always returns the last two digits of a year,
20152 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
20153 u: function(date, token) {
20154 const year = date.getFullYear();
20155 return addLeadingZeros(year, token.length);
20156 },
20157 // Quarter
20158 Q: function(date, token, localize2) {
20159 const quarter = Math.ceil((date.getMonth() + 1) / 3);
20160 switch (token) {
20161 // 1, 2, 3, 4
20162 case "Q":
20163 return String(quarter);
20164 // 01, 02, 03, 04
20165 case "QQ":
20166 return addLeadingZeros(quarter, 2);
20167 // 1st, 2nd, 3rd, 4th
20168 case "Qo":
20169 return localize2.ordinalNumber(quarter, { unit: "quarter" });
20170 // Q1, Q2, Q3, Q4
20171 case "QQQ":
20172 return localize2.quarter(quarter, {
20173 width: "abbreviated",
20174 context: "formatting"
20175 });
20176 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20177 case "QQQQQ":
20178 return localize2.quarter(quarter, {
20179 width: "narrow",
20180 context: "formatting"
20181 });
20182 // 1st quarter, 2nd quarter, ...
20183 case "QQQQ":
20184 default:
20185 return localize2.quarter(quarter, {
20186 width: "wide",
20187 context: "formatting"
20188 });
20189 }
20190 },
20191 // Stand-alone quarter
20192 q: function(date, token, localize2) {
20193 const quarter = Math.ceil((date.getMonth() + 1) / 3);
20194 switch (token) {
20195 // 1, 2, 3, 4
20196 case "q":
20197 return String(quarter);
20198 // 01, 02, 03, 04
20199 case "qq":
20200 return addLeadingZeros(quarter, 2);
20201 // 1st, 2nd, 3rd, 4th
20202 case "qo":
20203 return localize2.ordinalNumber(quarter, { unit: "quarter" });
20204 // Q1, Q2, Q3, Q4
20205 case "qqq":
20206 return localize2.quarter(quarter, {
20207 width: "abbreviated",
20208 context: "standalone"
20209 });
20210 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20211 case "qqqqq":
20212 return localize2.quarter(quarter, {
20213 width: "narrow",
20214 context: "standalone"
20215 });
20216 // 1st quarter, 2nd quarter, ...
20217 case "qqqq":
20218 default:
20219 return localize2.quarter(quarter, {
20220 width: "wide",
20221 context: "standalone"
20222 });
20223 }
20224 },
20225 // Month
20226 M: function(date, token, localize2) {
20227 const month = date.getMonth();
20228 switch (token) {
20229 case "M":
20230 case "MM":
20231 return lightFormatters.M(date, token);
20232 // 1st, 2nd, ..., 12th
20233 case "Mo":
20234 return localize2.ordinalNumber(month + 1, { unit: "month" });
20235 // Jan, Feb, ..., Dec
20236 case "MMM":
20237 return localize2.month(month, {
20238 width: "abbreviated",
20239 context: "formatting"
20240 });
20241 // J, F, ..., D
20242 case "MMMMM":
20243 return localize2.month(month, {
20244 width: "narrow",
20245 context: "formatting"
20246 });
20247 // January, February, ..., December
20248 case "MMMM":
20249 default:
20250 return localize2.month(month, { width: "wide", context: "formatting" });
20251 }
20252 },
20253 // Stand-alone month
20254 L: function(date, token, localize2) {
20255 const month = date.getMonth();
20256 switch (token) {
20257 // 1, 2, ..., 12
20258 case "L":
20259 return String(month + 1);
20260 // 01, 02, ..., 12
20261 case "LL":
20262 return addLeadingZeros(month + 1, 2);
20263 // 1st, 2nd, ..., 12th
20264 case "Lo":
20265 return localize2.ordinalNumber(month + 1, { unit: "month" });
20266 // Jan, Feb, ..., Dec
20267 case "LLL":
20268 return localize2.month(month, {
20269 width: "abbreviated",
20270 context: "standalone"
20271 });
20272 // J, F, ..., D
20273 case "LLLLL":
20274 return localize2.month(month, {
20275 width: "narrow",
20276 context: "standalone"
20277 });
20278 // January, February, ..., December
20279 case "LLLL":
20280 default:
20281 return localize2.month(month, { width: "wide", context: "standalone" });
20282 }
20283 },
20284 // Local week of year
20285 w: function(date, token, localize2, options) {
20286 const week = getWeek(date, options);
20287 if (token === "wo") {
20288 return localize2.ordinalNumber(week, { unit: "week" });
20289 }
20290 return addLeadingZeros(week, token.length);
20291 },
20292 // ISO week of year
20293 I: function(date, token, localize2) {
20294 const isoWeek = getISOWeek(date);
20295 if (token === "Io") {
20296 return localize2.ordinalNumber(isoWeek, { unit: "week" });
20297 }
20298 return addLeadingZeros(isoWeek, token.length);
20299 },
20300 // Day of the month
20301 d: function(date, token, localize2) {
20302 if (token === "do") {
20303 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
20304 }
20305 return lightFormatters.d(date, token);
20306 },
20307 // Day of year
20308 D: function(date, token, localize2) {
20309 const dayOfYear = getDayOfYear(date);
20310 if (token === "Do") {
20311 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
20312 }
20313 return addLeadingZeros(dayOfYear, token.length);
20314 },
20315 // Day of week
20316 E: function(date, token, localize2) {
20317 const dayOfWeek = date.getDay();
20318 switch (token) {
20319 // Tue
20320 case "E":
20321 case "EE":
20322 case "EEE":
20323 return localize2.day(dayOfWeek, {
20324 width: "abbreviated",
20325 context: "formatting"
20326 });
20327 // T
20328 case "EEEEE":
20329 return localize2.day(dayOfWeek, {
20330 width: "narrow",
20331 context: "formatting"
20332 });
20333 // Tu
20334 case "EEEEEE":
20335 return localize2.day(dayOfWeek, {
20336 width: "short",
20337 context: "formatting"
20338 });
20339 // Tuesday
20340 case "EEEE":
20341 default:
20342 return localize2.day(dayOfWeek, {
20343 width: "wide",
20344 context: "formatting"
20345 });
20346 }
20347 },
20348 // Local day of week
20349 e: function(date, token, localize2, options) {
20350 const dayOfWeek = date.getDay();
20351 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20352 switch (token) {
20353 // Numerical value (Nth day of week with current locale or weekStartsOn)
20354 case "e":
20355 return String(localDayOfWeek);
20356 // Padded numerical value
20357 case "ee":
20358 return addLeadingZeros(localDayOfWeek, 2);
20359 // 1st, 2nd, ..., 7th
20360 case "eo":
20361 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20362 case "eee":
20363 return localize2.day(dayOfWeek, {
20364 width: "abbreviated",
20365 context: "formatting"
20366 });
20367 // T
20368 case "eeeee":
20369 return localize2.day(dayOfWeek, {
20370 width: "narrow",
20371 context: "formatting"
20372 });
20373 // Tu
20374 case "eeeeee":
20375 return localize2.day(dayOfWeek, {
20376 width: "short",
20377 context: "formatting"
20378 });
20379 // Tuesday
20380 case "eeee":
20381 default:
20382 return localize2.day(dayOfWeek, {
20383 width: "wide",
20384 context: "formatting"
20385 });
20386 }
20387 },
20388 // Stand-alone local day of week
20389 c: function(date, token, localize2, options) {
20390 const dayOfWeek = date.getDay();
20391 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20392 switch (token) {
20393 // Numerical value (same as in `e`)
20394 case "c":
20395 return String(localDayOfWeek);
20396 // Padded numerical value
20397 case "cc":
20398 return addLeadingZeros(localDayOfWeek, token.length);
20399 // 1st, 2nd, ..., 7th
20400 case "co":
20401 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20402 case "ccc":
20403 return localize2.day(dayOfWeek, {
20404 width: "abbreviated",
20405 context: "standalone"
20406 });
20407 // T
20408 case "ccccc":
20409 return localize2.day(dayOfWeek, {
20410 width: "narrow",
20411 context: "standalone"
20412 });
20413 // Tu
20414 case "cccccc":
20415 return localize2.day(dayOfWeek, {
20416 width: "short",
20417 context: "standalone"
20418 });
20419 // Tuesday
20420 case "cccc":
20421 default:
20422 return localize2.day(dayOfWeek, {
20423 width: "wide",
20424 context: "standalone"
20425 });
20426 }
20427 },
20428 // ISO day of week
20429 i: function(date, token, localize2) {
20430 const dayOfWeek = date.getDay();
20431 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
20432 switch (token) {
20433 // 2
20434 case "i":
20435 return String(isoDayOfWeek);
20436 // 02
20437 case "ii":
20438 return addLeadingZeros(isoDayOfWeek, token.length);
20439 // 2nd
20440 case "io":
20441 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
20442 // Tue
20443 case "iii":
20444 return localize2.day(dayOfWeek, {
20445 width: "abbreviated",
20446 context: "formatting"
20447 });
20448 // T
20449 case "iiiii":
20450 return localize2.day(dayOfWeek, {
20451 width: "narrow",
20452 context: "formatting"
20453 });
20454 // Tu
20455 case "iiiiii":
20456 return localize2.day(dayOfWeek, {
20457 width: "short",
20458 context: "formatting"
20459 });
20460 // Tuesday
20461 case "iiii":
20462 default:
20463 return localize2.day(dayOfWeek, {
20464 width: "wide",
20465 context: "formatting"
20466 });
20467 }
20468 },
20469 // AM or PM
20470 a: function(date, token, localize2) {
20471 const hours = date.getHours();
20472 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
20473 switch (token) {
20474 case "a":
20475 case "aa":
20476 return localize2.dayPeriod(dayPeriodEnumValue, {
20477 width: "abbreviated",
20478 context: "formatting"
20479 });
20480 case "aaa":
20481 return localize2.dayPeriod(dayPeriodEnumValue, {
20482 width: "abbreviated",
20483 context: "formatting"
20484 }).toLowerCase();
20485 case "aaaaa":
20486 return localize2.dayPeriod(dayPeriodEnumValue, {
20487 width: "narrow",
20488 context: "formatting"
20489 });
20490 case "aaaa":
20491 default:
20492 return localize2.dayPeriod(dayPeriodEnumValue, {
20493 width: "wide",
20494 context: "formatting"
20495 });
20496 }
20497 },
20498 // AM, PM, midnight, noon
20499 b: function(date, token, localize2) {
20500 const hours = date.getHours();
20501 let dayPeriodEnumValue;
20502 if (hours === 12) {
20503 dayPeriodEnumValue = dayPeriodEnum.noon;
20504 } else if (hours === 0) {
20505 dayPeriodEnumValue = dayPeriodEnum.midnight;
20506 } else {
20507 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
20508 }
20509 switch (token) {
20510 case "b":
20511 case "bb":
20512 return localize2.dayPeriod(dayPeriodEnumValue, {
20513 width: "abbreviated",
20514 context: "formatting"
20515 });
20516 case "bbb":
20517 return localize2.dayPeriod(dayPeriodEnumValue, {
20518 width: "abbreviated",
20519 context: "formatting"
20520 }).toLowerCase();
20521 case "bbbbb":
20522 return localize2.dayPeriod(dayPeriodEnumValue, {
20523 width: "narrow",
20524 context: "formatting"
20525 });
20526 case "bbbb":
20527 default:
20528 return localize2.dayPeriod(dayPeriodEnumValue, {
20529 width: "wide",
20530 context: "formatting"
20531 });
20532 }
20533 },
20534 // in the morning, in the afternoon, in the evening, at night
20535 B: function(date, token, localize2) {
20536 const hours = date.getHours();
20537 let dayPeriodEnumValue;
20538 if (hours >= 17) {
20539 dayPeriodEnumValue = dayPeriodEnum.evening;
20540 } else if (hours >= 12) {
20541 dayPeriodEnumValue = dayPeriodEnum.afternoon;
20542 } else if (hours >= 4) {
20543 dayPeriodEnumValue = dayPeriodEnum.morning;
20544 } else {
20545 dayPeriodEnumValue = dayPeriodEnum.night;
20546 }
20547 switch (token) {
20548 case "B":
20549 case "BB":
20550 case "BBB":
20551 return localize2.dayPeriod(dayPeriodEnumValue, {
20552 width: "abbreviated",
20553 context: "formatting"
20554 });
20555 case "BBBBB":
20556 return localize2.dayPeriod(dayPeriodEnumValue, {
20557 width: "narrow",
20558 context: "formatting"
20559 });
20560 case "BBBB":
20561 default:
20562 return localize2.dayPeriod(dayPeriodEnumValue, {
20563 width: "wide",
20564 context: "formatting"
20565 });
20566 }
20567 },
20568 // Hour [1-12]
20569 h: function(date, token, localize2) {
20570 if (token === "ho") {
20571 let hours = date.getHours() % 12;
20572 if (hours === 0) hours = 12;
20573 return localize2.ordinalNumber(hours, { unit: "hour" });
20574 }
20575 return lightFormatters.h(date, token);
20576 },
20577 // Hour [0-23]
20578 H: function(date, token, localize2) {
20579 if (token === "Ho") {
20580 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
20581 }
20582 return lightFormatters.H(date, token);
20583 },
20584 // Hour [0-11]
20585 K: function(date, token, localize2) {
20586 const hours = date.getHours() % 12;
20587 if (token === "Ko") {
20588 return localize2.ordinalNumber(hours, { unit: "hour" });
20589 }
20590 return addLeadingZeros(hours, token.length);
20591 },
20592 // Hour [1-24]
20593 k: function(date, token, localize2) {
20594 let hours = date.getHours();
20595 if (hours === 0) hours = 24;
20596 if (token === "ko") {
20597 return localize2.ordinalNumber(hours, { unit: "hour" });
20598 }
20599 return addLeadingZeros(hours, token.length);
20600 },
20601 // Minute
20602 m: function(date, token, localize2) {
20603 if (token === "mo") {
20604 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
20605 }
20606 return lightFormatters.m(date, token);
20607 },
20608 // Second
20609 s: function(date, token, localize2) {
20610 if (token === "so") {
20611 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
20612 }
20613 return lightFormatters.s(date, token);
20614 },
20615 // Fraction of second
20616 S: function(date, token) {
20617 return lightFormatters.S(date, token);
20618 },
20619 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
20620 X: function(date, token, _localize) {
20621 const timezoneOffset = date.getTimezoneOffset();
20622 if (timezoneOffset === 0) {
20623 return "Z";
20624 }
20625 switch (token) {
20626 // Hours and optional minutes
20627 case "X":
20628 return formatTimezoneWithOptionalMinutes(timezoneOffset);
20629 // Hours, minutes and optional seconds without `:` delimiter
20630 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20631 // so this token always has the same output as `XX`
20632 case "XXXX":
20633 case "XX":
20634 return formatTimezone(timezoneOffset);
20635 // Hours, minutes and optional seconds with `:` delimiter
20636 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20637 // so this token always has the same output as `XXX`
20638 case "XXXXX":
20639 case "XXX":
20640 // Hours and minutes with `:` delimiter
20641 default:
20642 return formatTimezone(timezoneOffset, ":");
20643 }
20644 },
20645 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
20646 x: function(date, token, _localize) {
20647 const timezoneOffset = date.getTimezoneOffset();
20648 switch (token) {
20649 // Hours and optional minutes
20650 case "x":
20651 return formatTimezoneWithOptionalMinutes(timezoneOffset);
20652 // Hours, minutes and optional seconds without `:` delimiter
20653 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20654 // so this token always has the same output as `xx`
20655 case "xxxx":
20656 case "xx":
20657 return formatTimezone(timezoneOffset);
20658 // Hours, minutes and optional seconds with `:` delimiter
20659 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20660 // so this token always has the same output as `xxx`
20661 case "xxxxx":
20662 case "xxx":
20663 // Hours and minutes with `:` delimiter
20664 default:
20665 return formatTimezone(timezoneOffset, ":");
20666 }
20667 },
20668 // Timezone (GMT)
20669 O: function(date, token, _localize) {
20670 const timezoneOffset = date.getTimezoneOffset();
20671 switch (token) {
20672 // Short
20673 case "O":
20674 case "OO":
20675 case "OOO":
20676 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
20677 // Long
20678 case "OOOO":
20679 default:
20680 return "GMT" + formatTimezone(timezoneOffset, ":");
20681 }
20682 },
20683 // Timezone (specific non-location)
20684 z: function(date, token, _localize) {
20685 const timezoneOffset = date.getTimezoneOffset();
20686 switch (token) {
20687 // Short
20688 case "z":
20689 case "zz":
20690 case "zzz":
20691 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
20692 // Long
20693 case "zzzz":
20694 default:
20695 return "GMT" + formatTimezone(timezoneOffset, ":");
20696 }
20697 },
20698 // Seconds timestamp
20699 t: function(date, token, _localize) {
20700 const timestamp = Math.trunc(+date / 1e3);
20701 return addLeadingZeros(timestamp, token.length);
20702 },
20703 // Milliseconds timestamp
20704 T: function(date, token, _localize) {
20705 return addLeadingZeros(+date, token.length);
20706 }
20707 };
20708 function formatTimezoneShort(offset4, delimiter = "") {
20709 const sign = offset4 > 0 ? "-" : "+";
20710 const absOffset = Math.abs(offset4);
20711 const hours = Math.trunc(absOffset / 60);
20712 const minutes = absOffset % 60;
20713 if (minutes === 0) {
20714 return sign + String(hours);
20715 }
20716 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
20717 }
20718 function formatTimezoneWithOptionalMinutes(offset4, delimiter) {
20719 if (offset4 % 60 === 0) {
20720 const sign = offset4 > 0 ? "-" : "+";
20721 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2);
20722 }
20723 return formatTimezone(offset4, delimiter);
20724 }
20725 function formatTimezone(offset4, delimiter = "") {
20726 const sign = offset4 > 0 ? "-" : "+";
20727 const absOffset = Math.abs(offset4);
20728 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
20729 const minutes = addLeadingZeros(absOffset % 60, 2);
20730 return sign + hours + delimiter + minutes;
20731 }
20732
20733 // node_modules/date-fns/_lib/format/longFormatters.js
20734 var dateLongFormatter = (pattern, formatLong2) => {
20735 switch (pattern) {
20736 case "P":
20737 return formatLong2.date({ width: "short" });
20738 case "PP":
20739 return formatLong2.date({ width: "medium" });
20740 case "PPP":
20741 return formatLong2.date({ width: "long" });
20742 case "PPPP":
20743 default:
20744 return formatLong2.date({ width: "full" });
20745 }
20746 };
20747 var timeLongFormatter = (pattern, formatLong2) => {
20748 switch (pattern) {
20749 case "p":
20750 return formatLong2.time({ width: "short" });
20751 case "pp":
20752 return formatLong2.time({ width: "medium" });
20753 case "ppp":
20754 return formatLong2.time({ width: "long" });
20755 case "pppp":
20756 default:
20757 return formatLong2.time({ width: "full" });
20758 }
20759 };
20760 var dateTimeLongFormatter = (pattern, formatLong2) => {
20761 const matchResult = pattern.match(/(P+)(p+)?/) || [];
20762 const datePattern = matchResult[1];
20763 const timePattern = matchResult[2];
20764 if (!timePattern) {
20765 return dateLongFormatter(pattern, formatLong2);
20766 }
20767 let dateTimeFormat;
20768 switch (datePattern) {
20769 case "P":
20770 dateTimeFormat = formatLong2.dateTime({ width: "short" });
20771 break;
20772 case "PP":
20773 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
20774 break;
20775 case "PPP":
20776 dateTimeFormat = formatLong2.dateTime({ width: "long" });
20777 break;
20778 case "PPPP":
20779 default:
20780 dateTimeFormat = formatLong2.dateTime({ width: "full" });
20781 break;
20782 }
20783 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
20784 };
20785 var longFormatters = {
20786 p: timeLongFormatter,
20787 P: dateTimeLongFormatter
20788 };
20789
20790 // node_modules/date-fns/_lib/protectedTokens.js
20791 var dayOfYearTokenRE = /^D+$/;
20792 var weekYearTokenRE = /^Y+$/;
20793 var throwTokens = ["D", "DD", "YY", "YYYY"];
20794 function isProtectedDayOfYearToken(token) {
20795 return dayOfYearTokenRE.test(token);
20796 }
20797 function isProtectedWeekYearToken(token) {
20798 return weekYearTokenRE.test(token);
20799 }
20800 function warnOrThrowProtectedError(token, format6, input) {
20801 const _message = message(token, format6, input);
20802 console.warn(_message);
20803 if (throwTokens.includes(token)) throw new RangeError(_message);
20804 }
20805 function message(token, format6, input) {
20806 const subject = token[0] === "Y" ? "years" : "days of the month";
20807 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`;
20808 }
20809
20810 // node_modules/date-fns/format.js
20811 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
20812 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
20813 var escapedStringRegExp = /^'([^]*?)'?$/;
20814 var doubleQuoteRegExp = /''/g;
20815 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
20816 function format(date, formatStr, options) {
20817 const defaultOptions2 = getDefaultOptions();
20818 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
20819 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20820 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
20821 const originalDate = toDate(date, options?.in);
20822 if (!isValid(originalDate)) {
20823 throw new RangeError("Invalid time value");
20824 }
20825 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
20826 const firstCharacter = substring[0];
20827 if (firstCharacter === "p" || firstCharacter === "P") {
20828 const longFormatter = longFormatters[firstCharacter];
20829 return longFormatter(substring, locale.formatLong);
20830 }
20831 return substring;
20832 }).join("").match(formattingTokensRegExp).map((substring) => {
20833 if (substring === "''") {
20834 return { isToken: false, value: "'" };
20835 }
20836 const firstCharacter = substring[0];
20837 if (firstCharacter === "'") {
20838 return { isToken: false, value: cleanEscapedString(substring) };
20839 }
20840 if (formatters[firstCharacter]) {
20841 return { isToken: true, value: substring };
20842 }
20843 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
20844 throw new RangeError(
20845 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
20846 );
20847 }
20848 return { isToken: false, value: substring };
20849 });
20850 if (locale.localize.preprocessor) {
20851 parts = locale.localize.preprocessor(originalDate, parts);
20852 }
20853 const formatterOptions = {
20854 firstWeekContainsDate,
20855 weekStartsOn,
20856 locale
20857 };
20858 return parts.map((part) => {
20859 if (!part.isToken) return part.value;
20860 const token = part.value;
20861 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
20862 warnOrThrowProtectedError(token, formatStr, String(date));
20863 }
20864 const formatter = formatters[token[0]];
20865 return formatter(originalDate, token, locale.localize, formatterOptions);
20866 }).join("");
20867 }
20868 function cleanEscapedString(input) {
20869 const matched = input.match(escapedStringRegExp);
20870 if (!matched) {
20871 return input;
20872 }
20873 return matched[1].replace(doubleQuoteRegExp, "'");
20874 }
20875
20876 // node_modules/date-fns/subDays.js
20877 function subDays(date, amount, options) {
20878 return addDays(date, -amount, options);
20879 }
20880
20881 // node_modules/date-fns/subMonths.js
20882 function subMonths(date, amount, options) {
20883 return addMonths(date, -amount, options);
20884 }
20885
20886 // node_modules/date-fns/subWeeks.js
20887 function subWeeks(date, amount, options) {
20888 return addWeeks(date, -amount, options);
20889 }
20890
20891 // node_modules/date-fns/subYears.js
20892 function subYears(date, amount, options) {
20893 return addYears(date, -amount, options);
20894 }
20895
20896 // packages/dataviews/build-module/utils/operators.mjs
20897 var import_i18n24 = __toESM(require_i18n(), 1);
20898 var import_element50 = __toESM(require_element(), 1);
20899 var import_date = __toESM(require_date(), 1);
20900 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
20901 var filterTextWrappers = {
20902 Name: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
20903 Value: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
20904 };
20905 function getRelativeDate(value, unit) {
20906 switch (unit) {
20907 case "days":
20908 return subDays(/* @__PURE__ */ new Date(), value);
20909 case "weeks":
20910 return subWeeks(/* @__PURE__ */ new Date(), value);
20911 case "months":
20912 return subMonths(/* @__PURE__ */ new Date(), value);
20913 case "years":
20914 return subYears(/* @__PURE__ */ new Date(), value);
20915 default:
20916 return /* @__PURE__ */ new Date();
20917 }
20918 }
20919 var isNoneOperatorDefinition = {
20920 /* translators: DataViews operator name */
20921 label: (0, import_i18n24.__)("Is none of"),
20922 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
20923 (0, import_i18n24.sprintf)(
20924 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
20925 (0, import_i18n24.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
20926 filter.name,
20927 activeElements.map((element) => element.label).join(", ")
20928 ),
20929 filterTextWrappers
20930 ),
20931 filter: ((item, field, filterValue) => {
20932 if (!filterValue?.length) {
20933 return true;
20934 }
20935 const fieldValue = field.getValue({ item });
20936 if (Array.isArray(fieldValue)) {
20937 return !filterValue.some(
20938 (fv) => fieldValue.includes(fv)
20939 );
20940 } else if (typeof fieldValue === "string") {
20941 return !filterValue.includes(fieldValue);
20942 }
20943 return false;
20944 }),
20945 selection: "multi"
20946 };
20947 var OPERATORS = [
20948 {
20949 name: OPERATOR_IS_ANY,
20950 /* translators: DataViews operator name */
20951 label: (0, import_i18n24.__)("Includes"),
20952 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
20953 (0, import_i18n24.sprintf)(
20954 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
20955 (0, import_i18n24.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
20956 filter.name,
20957 activeElements.map((element) => element.label).join(", ")
20958 ),
20959 filterTextWrappers
20960 ),
20961 filter(item, field, filterValue) {
20962 if (!filterValue?.length) {
20963 return true;
20964 }
20965 const fieldValue = field.getValue({ item });
20966 if (Array.isArray(fieldValue)) {
20967 return filterValue.some(
20968 (fv) => fieldValue.includes(fv)
20969 );
20970 } else if (typeof fieldValue === "string") {
20971 return filterValue.includes(fieldValue);
20972 }
20973 return false;
20974 },
20975 selection: "multi"
20976 },
20977 {
20978 name: OPERATOR_IS_NONE,
20979 ...isNoneOperatorDefinition
20980 },
20981 {
20982 name: OPERATOR_IS_ALL,
20983 /* translators: DataViews operator name */
20984 label: (0, import_i18n24.__)("Includes all"),
20985 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
20986 (0, import_i18n24.sprintf)(
20987 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
20988 (0, import_i18n24.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
20989 filter.name,
20990 activeElements.map((element) => element.label).join(", ")
20991 ),
20992 filterTextWrappers
20993 ),
20994 filter(item, field, filterValue) {
20995 if (!filterValue?.length) {
20996 return true;
20997 }
20998 return filterValue.every((value) => {
20999 return field.getValue({ item })?.includes(value);
21000 });
21001 },
21002 selection: "multi"
21003 },
21004 {
21005 name: OPERATOR_IS_NOT_ALL,
21006 ...isNoneOperatorDefinition
21007 },
21008 {
21009 name: OPERATOR_BETWEEN,
21010 /* translators: DataViews operator name */
21011 label: (0, import_i18n24.__)("Between (inc)"),
21012 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21013 (0, import_i18n24.sprintf)(
21014 /* 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". */
21015 (0, import_i18n24.__)(
21016 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
21017 ),
21018 filter.name,
21019 activeElements[0].label[0],
21020 activeElements[0].label[1]
21021 ),
21022 filterTextWrappers
21023 ),
21024 filter(item, field, filterValue) {
21025 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
21026 return true;
21027 }
21028 const fieldValue = field.getValue({ item });
21029 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
21030 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
21031 }
21032 return false;
21033 },
21034 selection: "custom"
21035 },
21036 {
21037 name: OPERATOR_IN_THE_PAST,
21038 /* translators: DataViews operator name */
21039 label: (0, import_i18n24.__)("In the past"),
21040 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21041 (0, import_i18n24.sprintf)(
21042 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
21043 (0, import_i18n24.__)(
21044 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
21045 ),
21046 filter.name,
21047 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
21048 ),
21049 filterTextWrappers
21050 ),
21051 filter(item, field, filterValue) {
21052 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
21053 return true;
21054 }
21055 const targetDate = getRelativeDate(
21056 filterValue.value,
21057 filterValue.unit
21058 );
21059 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21060 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
21061 },
21062 selection: "custom"
21063 },
21064 {
21065 name: OPERATOR_OVER,
21066 /* translators: DataViews operator name */
21067 label: (0, import_i18n24.__)("Over"),
21068 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21069 (0, import_i18n24.sprintf)(
21070 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
21071 (0, import_i18n24.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
21072 filter.name,
21073 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
21074 ),
21075 filterTextWrappers
21076 ),
21077 filter(item, field, filterValue) {
21078 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
21079 return true;
21080 }
21081 const targetDate = getRelativeDate(
21082 filterValue.value,
21083 filterValue.unit
21084 );
21085 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21086 return fieldValue < targetDate;
21087 },
21088 selection: "custom"
21089 },
21090 {
21091 name: OPERATOR_IS,
21092 /* translators: DataViews operator name */
21093 label: (0, import_i18n24.__)("Is"),
21094 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21095 (0, import_i18n24.sprintf)(
21096 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
21097 (0, import_i18n24.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21098 filter.name,
21099 activeElements[0].label
21100 ),
21101 filterTextWrappers
21102 ),
21103 filter(item, field, filterValue) {
21104 return filterValue === field.getValue({ item }) || filterValue === void 0;
21105 },
21106 selection: "single"
21107 },
21108 {
21109 name: OPERATOR_IS_NOT,
21110 /* translators: DataViews operator name */
21111 label: (0, import_i18n24.__)("Is not"),
21112 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21113 (0, import_i18n24.sprintf)(
21114 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
21115 (0, import_i18n24.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21116 filter.name,
21117 activeElements[0].label
21118 ),
21119 filterTextWrappers
21120 ),
21121 filter(item, field, filterValue) {
21122 return filterValue !== field.getValue({ item });
21123 },
21124 selection: "single"
21125 },
21126 {
21127 name: OPERATOR_LESS_THAN,
21128 /* translators: DataViews operator name */
21129 label: (0, import_i18n24.__)("Less than"),
21130 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21131 (0, import_i18n24.sprintf)(
21132 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
21133 (0, import_i18n24.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
21134 filter.name,
21135 activeElements[0].label
21136 ),
21137 filterTextWrappers
21138 ),
21139 filter(item, field, filterValue) {
21140 if (filterValue === void 0) {
21141 return true;
21142 }
21143 const fieldValue = field.getValue({ item });
21144 return fieldValue < filterValue;
21145 },
21146 selection: "single"
21147 },
21148 {
21149 name: OPERATOR_GREATER_THAN,
21150 /* translators: DataViews operator name */
21151 label: (0, import_i18n24.__)("Greater than"),
21152 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21153 (0, import_i18n24.sprintf)(
21154 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
21155 (0, import_i18n24.__)(
21156 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
21157 ),
21158 filter.name,
21159 activeElements[0].label
21160 ),
21161 filterTextWrappers
21162 ),
21163 filter(item, field, filterValue) {
21164 if (filterValue === void 0) {
21165 return true;
21166 }
21167 const fieldValue = field.getValue({ item });
21168 return fieldValue > filterValue;
21169 },
21170 selection: "single"
21171 },
21172 {
21173 name: OPERATOR_LESS_THAN_OR_EQUAL,
21174 /* translators: DataViews operator name */
21175 label: (0, import_i18n24.__)("Less than or equal"),
21176 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21177 (0, import_i18n24.sprintf)(
21178 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
21179 (0, import_i18n24.__)(
21180 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
21181 ),
21182 filter.name,
21183 activeElements[0].label
21184 ),
21185 filterTextWrappers
21186 ),
21187 filter(item, field, filterValue) {
21188 if (filterValue === void 0) {
21189 return true;
21190 }
21191 const fieldValue = field.getValue({ item });
21192 return fieldValue <= filterValue;
21193 },
21194 selection: "single"
21195 },
21196 {
21197 name: OPERATOR_GREATER_THAN_OR_EQUAL,
21198 /* translators: DataViews operator name */
21199 label: (0, import_i18n24.__)("Greater than or equal"),
21200 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21201 (0, import_i18n24.sprintf)(
21202 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
21203 (0, import_i18n24.__)(
21204 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
21205 ),
21206 filter.name,
21207 activeElements[0].label
21208 ),
21209 filterTextWrappers
21210 ),
21211 filter(item, field, filterValue) {
21212 if (filterValue === void 0) {
21213 return true;
21214 }
21215 const fieldValue = field.getValue({ item });
21216 return fieldValue >= filterValue;
21217 },
21218 selection: "single"
21219 },
21220 {
21221 name: OPERATOR_BEFORE,
21222 /* translators: DataViews operator name */
21223 label: (0, import_i18n24.__)("Before"),
21224 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21225 (0, import_i18n24.sprintf)(
21226 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
21227 (0, import_i18n24.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
21228 filter.name,
21229 activeElements[0].label
21230 ),
21231 filterTextWrappers
21232 ),
21233 filter(item, field, filterValue) {
21234 if (filterValue === void 0) {
21235 return true;
21236 }
21237 const filterDate = (0, import_date.getDate)(filterValue);
21238 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21239 return fieldDate < filterDate;
21240 },
21241 selection: "single"
21242 },
21243 {
21244 name: OPERATOR_AFTER,
21245 /* translators: DataViews operator name */
21246 label: (0, import_i18n24.__)("After"),
21247 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21248 (0, import_i18n24.sprintf)(
21249 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
21250 (0, import_i18n24.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
21251 filter.name,
21252 activeElements[0].label
21253 ),
21254 filterTextWrappers
21255 ),
21256 filter(item, field, filterValue) {
21257 if (filterValue === void 0) {
21258 return true;
21259 }
21260 const filterDate = (0, import_date.getDate)(filterValue);
21261 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21262 return fieldDate > filterDate;
21263 },
21264 selection: "single"
21265 },
21266 {
21267 name: OPERATOR_BEFORE_INC,
21268 /* translators: DataViews operator name */
21269 label: (0, import_i18n24.__)("Before (inc)"),
21270 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21271 (0, import_i18n24.sprintf)(
21272 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
21273 (0, import_i18n24.__)(
21274 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
21275 ),
21276 filter.name,
21277 activeElements[0].label
21278 ),
21279 filterTextWrappers
21280 ),
21281 filter(item, field, filterValue) {
21282 if (filterValue === void 0) {
21283 return true;
21284 }
21285 const filterDate = (0, import_date.getDate)(filterValue);
21286 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21287 return fieldDate <= filterDate;
21288 },
21289 selection: "single"
21290 },
21291 {
21292 name: OPERATOR_AFTER_INC,
21293 /* translators: DataViews operator name */
21294 label: (0, import_i18n24.__)("After (inc)"),
21295 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21296 (0, import_i18n24.sprintf)(
21297 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
21298 (0, import_i18n24.__)(
21299 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
21300 ),
21301 filter.name,
21302 activeElements[0].label
21303 ),
21304 filterTextWrappers
21305 ),
21306 filter(item, field, filterValue) {
21307 if (filterValue === void 0) {
21308 return true;
21309 }
21310 const filterDate = (0, import_date.getDate)(filterValue);
21311 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21312 return fieldDate >= filterDate;
21313 },
21314 selection: "single"
21315 },
21316 {
21317 name: OPERATOR_CONTAINS,
21318 /* translators: DataViews operator name */
21319 label: (0, import_i18n24.__)("Contains"),
21320 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21321 (0, import_i18n24.sprintf)(
21322 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
21323 (0, import_i18n24.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
21324 filter.name,
21325 activeElements[0].label
21326 ),
21327 filterTextWrappers
21328 ),
21329 filter(item, field, filterValue) {
21330 if (filterValue === void 0) {
21331 return true;
21332 }
21333 const fieldValue = field.getValue({ item });
21334 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21335 },
21336 selection: "single"
21337 },
21338 {
21339 name: OPERATOR_NOT_CONTAINS,
21340 /* translators: DataViews operator name */
21341 label: (0, import_i18n24.__)("Doesn't contain"),
21342 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21343 (0, import_i18n24.sprintf)(
21344 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
21345 (0, import_i18n24.__)(
21346 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
21347 ),
21348 filter.name,
21349 activeElements[0].label
21350 ),
21351 filterTextWrappers
21352 ),
21353 filter(item, field, filterValue) {
21354 if (filterValue === void 0) {
21355 return true;
21356 }
21357 const fieldValue = field.getValue({ item });
21358 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21359 },
21360 selection: "single"
21361 },
21362 {
21363 name: OPERATOR_STARTS_WITH,
21364 /* translators: DataViews operator name */
21365 label: (0, import_i18n24.__)("Starts with"),
21366 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21367 (0, import_i18n24.sprintf)(
21368 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
21369 (0, import_i18n24.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
21370 filter.name,
21371 activeElements[0].label
21372 ),
21373 filterTextWrappers
21374 ),
21375 filter(item, field, filterValue) {
21376 if (filterValue === void 0) {
21377 return true;
21378 }
21379 const fieldValue = field.getValue({ item });
21380 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
21381 },
21382 selection: "single"
21383 },
21384 {
21385 name: OPERATOR_ON,
21386 /* translators: DataViews operator name */
21387 label: (0, import_i18n24.__)("On"),
21388 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21389 (0, import_i18n24.sprintf)(
21390 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
21391 (0, import_i18n24.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21392 filter.name,
21393 activeElements[0].label
21394 ),
21395 filterTextWrappers
21396 ),
21397 filter(item, field, filterValue) {
21398 if (filterValue === void 0) {
21399 return true;
21400 }
21401 const filterDate = (0, import_date.getDate)(filterValue);
21402 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21403 return filterDate.getTime() === fieldDate.getTime();
21404 },
21405 selection: "single"
21406 },
21407 {
21408 name: OPERATOR_NOT_ON,
21409 /* translators: DataViews operator name */
21410 label: (0, import_i18n24.__)("Not on"),
21411 filterText: (filter, activeElements) => (0, import_element50.createInterpolateElement)(
21412 (0, import_i18n24.sprintf)(
21413 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
21414 (0, import_i18n24.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21415 filter.name,
21416 activeElements[0].label
21417 ),
21418 filterTextWrappers
21419 ),
21420 filter(item, field, filterValue) {
21421 if (filterValue === void 0) {
21422 return true;
21423 }
21424 const filterDate = (0, import_date.getDate)(filterValue);
21425 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21426 return filterDate.getTime() !== fieldDate.getTime();
21427 },
21428 selection: "single"
21429 }
21430 ];
21431 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
21432 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
21433 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
21434 (op) => op.name === name
21435 );
21436 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
21437
21438 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
21439 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
21440 var ENTER = "Enter";
21441 var SPACE = " ";
21442 var FilterText = ({
21443 activeElements,
21444 filterInView,
21445 filter
21446 }) => {
21447 if (activeElements === void 0 || activeElements.length === 0) {
21448 return filter.name;
21449 }
21450 const operator = getOperatorByName(filterInView?.operator);
21451 if (operator !== void 0) {
21452 return operator.filterText(filter, activeElements);
21453 }
21454 return (0, import_i18n25.sprintf)(
21455 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
21456 (0, import_i18n25.__)("Unknown status for %1$s"),
21457 filter.name
21458 );
21459 };
21460 function OperatorSelector({
21461 filter,
21462 view,
21463 onChangeView
21464 }) {
21465 const operatorOptions = filter.operators?.map((operator) => ({
21466 value: operator,
21467 label: getOperatorByName(operator)?.label || operator
21468 }));
21469 const currentFilter = view.filters?.find(
21470 (_filter) => _filter.field === filter.field
21471 );
21472 const value = currentFilter?.operator || filter.operators[0];
21473 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(
21474 Stack,
21475 {
21476 direction: "row",
21477 gap: "sm",
21478 justify: "flex-start",
21479 className: "dataviews-filters__summary-operators-container",
21480 align: "center",
21481 children: [
21482 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_components20.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
21483 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
21484 import_components20.SelectControl,
21485 {
21486 className: "dataviews-filters__summary-operators-filter-select",
21487 label: (0, import_i18n25.__)("Conditions"),
21488 value,
21489 options: operatorOptions,
21490 onChange: (newValue) => {
21491 const newOperator = newValue;
21492 const currentOperator = currentFilter?.operator;
21493 const newFilters = currentFilter ? [
21494 ...(view.filters ?? []).map(
21495 (_filter) => {
21496 if (_filter.field === filter.field) {
21497 const currentOpSelectionModel = getOperatorByName(
21498 currentOperator
21499 )?.selection;
21500 const newOpSelectionModel = getOperatorByName(
21501 newOperator
21502 )?.selection;
21503 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
21504 currentOpSelectionModel,
21505 newOpSelectionModel
21506 ].includes("custom");
21507 return {
21508 ..._filter,
21509 value: shouldResetValue ? void 0 : _filter.value,
21510 operator: newOperator
21511 };
21512 }
21513 return _filter;
21514 }
21515 )
21516 ] : [
21517 ...view.filters ?? [],
21518 {
21519 field: filter.field,
21520 operator: newOperator,
21521 value: void 0
21522 }
21523 ];
21524 onChangeView({
21525 ...view,
21526 page: 1,
21527 filters: newFilters
21528 });
21529 },
21530 size: "small",
21531 variant: "minimal",
21532 hideLabelFromVision: true
21533 }
21534 )
21535 ]
21536 }
21537 );
21538 }
21539 function Filter({
21540 addFilterRef,
21541 openedFilter,
21542 fields,
21543 ...commonProps
21544 }) {
21545 const toggleRef = (0, import_element51.useRef)(null);
21546 const { filter, view, onChangeView } = commonProps;
21547 const filterInView = view.filters?.find(
21548 (f2) => f2.field === filter.field
21549 );
21550 let activeElements = [];
21551 const field = (0, import_element51.useMemo)(() => {
21552 const currentField = fields.find((f2) => f2.id === filter.field);
21553 if (currentField) {
21554 return {
21555 ...currentField,
21556 // Configure getValue as if Item was a plain object.
21557 // See related input-widget.tsx
21558 getValue: ({ item }) => item[currentField.id]
21559 };
21560 }
21561 return currentField;
21562 }, [fields, filter.field]);
21563 const { elements } = useElements({
21564 elements: filter.elements,
21565 getElements: filter.getElements
21566 });
21567 if (elements.length > 0) {
21568 activeElements = elements.filter((element) => {
21569 if (filter.singleSelection) {
21570 return element.value === filterInView?.value;
21571 }
21572 return filterInView?.value?.includes(element.value);
21573 });
21574 } else if (Array.isArray(filterInView?.value)) {
21575 const label = filterInView.value.map((v2) => {
21576 const formattedValue = field?.getValueFormatted({
21577 item: { [field.id]: v2 },
21578 field
21579 });
21580 return formattedValue || String(v2);
21581 });
21582 activeElements = [
21583 {
21584 value: filterInView.value,
21585 // @ts-ignore
21586 label
21587 }
21588 ];
21589 } else if (typeof filterInView?.value === "object") {
21590 activeElements = [
21591 { value: filterInView.value, label: filterInView.value }
21592 ];
21593 } else if (filterInView?.value !== void 0) {
21594 const label = field !== void 0 ? field.getValueFormatted({
21595 item: { [field.id]: filterInView.value },
21596 field
21597 }) : String(filterInView.value);
21598 activeElements = [
21599 {
21600 value: filterInView.value,
21601 label
21602 }
21603 ];
21604 }
21605 const isPrimary = filter.isPrimary;
21606 const isLocked = filterInView?.isLocked;
21607 const hasValues = !isLocked && filterInView?.value !== void 0;
21608 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
21609 const resetOrRemoveLabel = isPrimary ? (0, import_i18n25.__)("Reset") : (0, import_i18n25.__)("Remove");
21610 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
21611 import_components20.Dropdown,
21612 {
21613 defaultOpen: openedFilter === filter.field,
21614 contentClassName: "dataviews-filters__summary-popover",
21615 popoverProps: { placement: "bottom-start", role: "dialog" },
21616 onClose: () => {
21617 toggleRef.current?.focus();
21618 },
21619 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
21620 /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(tooltip_exports.Root, { children: [
21621 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
21622 tooltip_exports.Trigger,
21623 {
21624 render: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
21625 "div",
21626 {
21627 className: clsx_default(
21628 "dataviews-filters__summary-chip",
21629 {
21630 "has-reset": canResetOrRemove,
21631 "has-values": hasValues,
21632 "is-not-clickable": isLocked
21633 }
21634 ),
21635 role: "button",
21636 tabIndex: isLocked ? -1 : 0,
21637 onClick: () => {
21638 if (!isLocked) {
21639 onToggle();
21640 }
21641 },
21642 onKeyDown: (event) => {
21643 if (!isLocked && [ENTER, SPACE].includes(
21644 event.key
21645 )) {
21646 onToggle();
21647 event.preventDefault();
21648 }
21649 },
21650 "aria-disabled": isLocked,
21651 "aria-pressed": isOpen,
21652 "aria-expanded": isOpen,
21653 ref: toggleRef,
21654 children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
21655 FilterText,
21656 {
21657 activeElements,
21658 filterInView,
21659 filter
21660 }
21661 )
21662 }
21663 )
21664 }
21665 ),
21666 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(tooltip_exports.Popup, { children: (0, import_i18n25.sprintf)(
21667 /* translators: 1: Filter name. */
21668 (0, import_i18n25.__)("Filter by: %1$s"),
21669 filter.name.toLowerCase()
21670 ) })
21671 ] }),
21672 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(tooltip_exports.Root, { children: [
21673 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
21674 tooltip_exports.Trigger,
21675 {
21676 render: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
21677 "button",
21678 {
21679 className: clsx_default(
21680 "dataviews-filters__summary-chip-remove",
21681 { "has-values": hasValues }
21682 ),
21683 "aria-label": resetOrRemoveLabel,
21684 onClick: () => {
21685 onChangeView({
21686 ...view,
21687 page: 1,
21688 filters: view.filters?.filter(
21689 (_filter) => _filter.field !== filter.field
21690 )
21691 });
21692 if (!isPrimary) {
21693 addFilterRef.current?.focus();
21694 } else {
21695 toggleRef.current?.focus();
21696 }
21697 },
21698 children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_components20.Icon, { icon: close_small_default })
21699 }
21700 )
21701 }
21702 ),
21703 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel })
21704 ] })
21705 ] }),
21706 renderContent: () => {
21707 return /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
21708 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(OperatorSelector, { ...commonProps }),
21709 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
21710 SearchWidget,
21711 {
21712 ...commonProps,
21713 filter: {
21714 ...commonProps.filter,
21715 elements
21716 }
21717 }
21718 ) : /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(InputWidget, { ...commonProps, fields })
21719 ] });
21720 }
21721 }
21722 );
21723 }
21724
21725 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
21726 var import_components21 = __toESM(require_components(), 1);
21727 var import_i18n26 = __toESM(require_i18n(), 1);
21728 var import_element52 = __toESM(require_element(), 1);
21729 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
21730 var { Menu: Menu4 } = unlock2(import_components21.privateApis);
21731 function AddFilterMenu({
21732 filters,
21733 view,
21734 onChangeView,
21735 setOpenedFilter,
21736 triggerProps
21737 }) {
21738 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
21739 return /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(Menu4, { children: [
21740 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Menu4.TriggerButton, { ...triggerProps }),
21741 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
21742 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21743 Menu4.Item,
21744 {
21745 onClick: () => {
21746 setOpenedFilter(filter.field);
21747 onChangeView({
21748 ...view,
21749 page: 1,
21750 filters: [
21751 ...view.filters || [],
21752 {
21753 field: filter.field,
21754 value: void 0,
21755 operator: filter.operators[0]
21756 }
21757 ]
21758 });
21759 },
21760 children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Menu4.ItemLabel, { children: filter.name })
21761 },
21762 filter.field
21763 );
21764 }) })
21765 ] });
21766 }
21767 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
21768 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
21769 return null;
21770 }
21771 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
21772 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21773 AddFilterMenu,
21774 {
21775 triggerProps: {
21776 render: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21777 import_components21.Button,
21778 {
21779 accessibleWhenDisabled: true,
21780 size: "compact",
21781 className: "dataviews-filters-button",
21782 variant: "tertiary",
21783 disabled: !inactiveFilters.length,
21784 ref
21785 }
21786 ),
21787 children: (0, import_i18n26.__)("Add filter")
21788 },
21789 ...{ filters, view, onChangeView, setOpenedFilter }
21790 }
21791 );
21792 }
21793 var add_filter_default = (0, import_element52.forwardRef)(AddFilter);
21794
21795 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
21796 var import_components22 = __toESM(require_components(), 1);
21797 var import_i18n27 = __toESM(require_i18n(), 1);
21798 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
21799 function ResetFilter({
21800 filters,
21801 view,
21802 onChangeView
21803 }) {
21804 const isPrimary = (field) => filters.some(
21805 (_filter) => _filter.field === field && _filter.isPrimary
21806 );
21807 const isDisabled = !view.search && !view.filters?.some(
21808 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
21809 );
21810 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21811 import_components22.Button,
21812 {
21813 disabled: isDisabled,
21814 accessibleWhenDisabled: true,
21815 size: "compact",
21816 variant: "tertiary",
21817 className: "dataviews-filters__reset-button",
21818 onClick: () => {
21819 onChangeView({
21820 ...view,
21821 page: 1,
21822 search: "",
21823 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
21824 });
21825 },
21826 children: (0, import_i18n27.__)("Reset")
21827 }
21828 );
21829 }
21830
21831 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
21832 var import_element53 = __toESM(require_element(), 1);
21833 function useFilters(fields, view) {
21834 return (0, import_element53.useMemo)(() => {
21835 const filters = [];
21836 fields.forEach((field) => {
21837 if (field.filterBy === false || !field.hasElements && !field.Edit) {
21838 return;
21839 }
21840 const operators = field.filterBy.operators;
21841 const isPrimary = !!field.filterBy?.isPrimary;
21842 const isLocked = view.filters?.some(
21843 (f2) => f2.field === field.id && !!f2.isLocked
21844 ) ?? false;
21845 filters.push({
21846 field: field.id,
21847 name: field.label,
21848 elements: field.elements,
21849 getElements: field.getElements,
21850 hasElements: field.hasElements,
21851 singleSelection: operators.some(
21852 (op) => isSingleSelectionOperator(op)
21853 ),
21854 operators,
21855 isVisible: isLocked || isPrimary || !!view.filters?.some(
21856 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
21857 ),
21858 isPrimary,
21859 isLocked
21860 });
21861 });
21862 filters.sort((a2, b2) => {
21863 if (a2.isLocked && !b2.isLocked) {
21864 return -1;
21865 }
21866 if (!a2.isLocked && b2.isLocked) {
21867 return 1;
21868 }
21869 if (a2.isPrimary && !b2.isPrimary) {
21870 return -1;
21871 }
21872 if (!a2.isPrimary && b2.isPrimary) {
21873 return 1;
21874 }
21875 return a2.name.localeCompare(b2.name);
21876 });
21877 return filters;
21878 }, [fields, view]);
21879 }
21880 var use_filters_default = useFilters;
21881
21882 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
21883 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
21884 function Filters({ className }) {
21885 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element54.useContext)(dataviews_context_default);
21886 const addFilterRef = (0, import_element54.useRef)(null);
21887 const filters = use_filters_default(fields, view);
21888 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21889 add_filter_default,
21890 {
21891 filters,
21892 view,
21893 onChangeView,
21894 ref: addFilterRef,
21895 setOpenedFilter
21896 },
21897 "add-filter"
21898 );
21899 const visibleFilters = filters.filter((filter) => filter.isVisible);
21900 if (visibleFilters.length === 0) {
21901 return null;
21902 }
21903 const filterComponents = [
21904 ...visibleFilters.map((filter) => {
21905 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21906 Filter,
21907 {
21908 filter,
21909 view,
21910 fields,
21911 onChangeView,
21912 addFilterRef,
21913 openedFilter
21914 },
21915 filter.field
21916 );
21917 }),
21918 addFilter
21919 ];
21920 filterComponents.push(
21921 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21922 ResetFilter,
21923 {
21924 filters,
21925 view,
21926 onChangeView
21927 },
21928 "reset-filters"
21929 )
21930 );
21931 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21932 Stack,
21933 {
21934 direction: "row",
21935 justify: "flex-start",
21936 gap: "sm",
21937 style: { width: "fit-content" },
21938 wrap: "wrap",
21939 className,
21940 children: filterComponents
21941 }
21942 );
21943 }
21944 var filters_default = (0, import_element54.memo)(Filters);
21945
21946 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
21947 var import_element55 = __toESM(require_element(), 1);
21948 var import_components23 = __toESM(require_components(), 1);
21949 var import_i18n28 = __toESM(require_i18n(), 1);
21950 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
21951 function FiltersToggle() {
21952 const {
21953 filters,
21954 view,
21955 onChangeView,
21956 setOpenedFilter,
21957 isShowingFilter,
21958 setIsShowingFilter
21959 } = (0, import_element55.useContext)(dataviews_context_default);
21960 const buttonRef = (0, import_element55.useRef)(null);
21961 const onChangeViewWithFilterVisibility = (0, import_element55.useCallback)(
21962 (_view) => {
21963 onChangeView(_view);
21964 setIsShowingFilter(true);
21965 },
21966 [onChangeView, setIsShowingFilter]
21967 );
21968 if (filters.length === 0) {
21969 return null;
21970 }
21971 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
21972 const addFilterButtonProps = {
21973 label: (0, import_i18n28.__)("Add filter"),
21974 "aria-expanded": false,
21975 isPressed: false
21976 };
21977 const toggleFiltersButtonProps = {
21978 label: (0, import_i18n28._x)("Filter", "verb"),
21979 "aria-expanded": isShowingFilter,
21980 isPressed: isShowingFilter,
21981 onClick: () => {
21982 if (!isShowingFilter) {
21983 setOpenedFilter(null);
21984 }
21985 setIsShowingFilter(!isShowingFilter);
21986 }
21987 };
21988 const hasPrimaryOrLockedFilters = filters.some(
21989 (filter) => filter.isPrimary || filter.isLocked
21990 );
21991 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
21992 import_components23.Button,
21993 {
21994 ref: buttonRef,
21995 className: "dataviews-filters__visibility-toggle",
21996 size: "compact",
21997 icon: funnel_default,
21998 disabled: hasPrimaryOrLockedFilters,
21999 accessibleWhenDisabled: true,
22000 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
22001 }
22002 );
22003 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
22004 AddFilterMenu,
22005 {
22006 filters,
22007 view,
22008 onChangeView: onChangeViewWithFilterVisibility,
22009 setOpenedFilter,
22010 triggerProps: { render: buttonComponent }
22011 }
22012 ) : /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
22013 FilterVisibilityToggle,
22014 {
22015 buttonRef,
22016 filtersCount: view.filters?.length,
22017 children: buttonComponent
22018 }
22019 ) });
22020 }
22021 function FilterVisibilityToggle({
22022 buttonRef,
22023 filtersCount,
22024 children
22025 }) {
22026 (0, import_element55.useEffect)(
22027 () => () => {
22028 buttonRef.current?.focus();
22029 },
22030 [buttonRef]
22031 );
22032 return /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(import_jsx_runtime85.Fragment, { children: [
22033 children,
22034 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
22035 ] });
22036 }
22037 var toggle_default = FiltersToggle;
22038
22039 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
22040 var import_element56 = __toESM(require_element(), 1);
22041 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
22042 function FiltersToggled(props) {
22043 const { isShowingFilter } = (0, import_element56.useContext)(dataviews_context_default);
22044 if (!isShowingFilter) {
22045 return null;
22046 }
22047 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(filters_default, { ...props });
22048 }
22049 var filters_toggled_default = FiltersToggled;
22050
22051 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
22052 var import_element57 = __toESM(require_element(), 1);
22053 var import_components24 = __toESM(require_components(), 1);
22054 var import_i18n29 = __toESM(require_i18n(), 1);
22055 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
22056 function DataViewsLayout({ className }) {
22057 const {
22058 actions = [],
22059 data,
22060 fields,
22061 getItemId,
22062 getItemLevel,
22063 hasInitiallyLoaded,
22064 isLoading,
22065 view,
22066 onChangeView,
22067 selection,
22068 onChangeSelection,
22069 setOpenedFilter,
22070 onClickItem,
22071 isItemClickable,
22072 renderItemLink,
22073 defaultLayouts,
22074 containerRef,
22075 empty = /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("p", { children: (0, import_i18n29.__)("No results") })
22076 } = (0, import_element57.useContext)(dataviews_context_default);
22077 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
22078 delay: 200
22079 });
22080 if (!hasInitiallyLoaded) {
22081 if (!isDelayedInitialLoading) {
22082 return null;
22083 }
22084 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, {}) }) });
22085 }
22086 const ViewComponent = VIEW_LAYOUTS.find(
22087 (v2) => v2.type === view.type && defaultLayouts[v2.type]
22088 )?.component;
22089 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22090 ViewComponent,
22091 {
22092 className,
22093 actions,
22094 data,
22095 fields,
22096 getItemId,
22097 getItemLevel,
22098 isLoading,
22099 onChangeView,
22100 onChangeSelection,
22101 selection,
22102 setOpenedFilter,
22103 onClickItem,
22104 renderItemLink,
22105 isItemClickable,
22106 view,
22107 empty
22108 }
22109 ) });
22110 }
22111
22112 // packages/dataviews/build-module/components/dataviews-footer/index.mjs
22113 var import_element58 = __toESM(require_element(), 1);
22114 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
22115 var EMPTY_ARRAY5 = [];
22116 function DataViewsFooter() {
22117 const {
22118 view,
22119 paginationInfo: { totalItems = 0, totalPages },
22120 data,
22121 actions = EMPTY_ARRAY5,
22122 isLoading,
22123 hasInitiallyLoaded
22124 } = (0, import_element58.useContext)(dataviews_context_default);
22125 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length;
22126 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
22127 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type);
22128 if (!isRefreshing && (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions)) {
22129 return null;
22130 }
22131 return (!!totalItems || isRefreshing) && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22132 "div",
22133 {
22134 className: "dataviews-footer",
22135 inert: isRefreshing ? "true" : void 0,
22136 children: /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(
22137 Stack,
22138 {
22139 direction: "row",
22140 justify: "end",
22141 align: "center",
22142 className: clsx_default("dataviews-footer__content", {
22143 "is-refreshing": isDelayedRefreshing
22144 }),
22145 gap: "sm",
22146 children: [
22147 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(BulkActionsFooter, {}),
22148 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(dataviews_pagination_default, {})
22149 ]
22150 }
22151 )
22152 }
22153 );
22154 }
22155
22156 // packages/dataviews/build-module/components/dataviews-search/index.mjs
22157 var import_i18n30 = __toESM(require_i18n(), 1);
22158 var import_element59 = __toESM(require_element(), 1);
22159 var import_components25 = __toESM(require_components(), 1);
22160 var import_compose9 = __toESM(require_compose(), 1);
22161 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
22162 var DataViewsSearch = (0, import_element59.memo)(function Search({ label }) {
22163 const { view, onChangeView } = (0, import_element59.useContext)(dataviews_context_default);
22164 const [search, setSearch, debouncedSearch] = (0, import_compose9.useDebouncedInput)(
22165 view.search
22166 );
22167 (0, import_element59.useEffect)(() => {
22168 if (view.search !== debouncedSearch) {
22169 setSearch(view.search ?? "");
22170 }
22171 }, [view.search, setSearch]);
22172 const onChangeViewRef = (0, import_element59.useRef)(onChangeView);
22173 const viewRef = (0, import_element59.useRef)(view);
22174 (0, import_element59.useEffect)(() => {
22175 onChangeViewRef.current = onChangeView;
22176 viewRef.current = view;
22177 }, [onChangeView, view]);
22178 (0, import_element59.useEffect)(() => {
22179 if (debouncedSearch !== viewRef.current?.search) {
22180 onChangeViewRef.current({
22181 ...viewRef.current,
22182 page: view.page ? 1 : void 0,
22183 startPosition: view.startPosition ? 1 : void 0,
22184 search: debouncedSearch
22185 });
22186 }
22187 }, [debouncedSearch]);
22188 const searchLabel = label || (0, import_i18n30.__)("Search");
22189 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22190 import_components25.SearchControl,
22191 {
22192 className: "dataviews-search",
22193 onChange: setSearch,
22194 value: search,
22195 label: searchLabel,
22196 placeholder: searchLabel,
22197 size: "compact"
22198 }
22199 );
22200 });
22201 var dataviews_search_default = DataViewsSearch;
22202
22203 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
22204 var import_components26 = __toESM(require_components(), 1);
22205 var import_i18n31 = __toESM(require_i18n(), 1);
22206 var import_element60 = __toESM(require_element(), 1);
22207 var import_warning = __toESM(require_warning(), 1);
22208 var import_compose10 = __toESM(require_compose(), 1);
22209 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
22210 var { Menu: Menu5 } = unlock2(import_components26.privateApis);
22211 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
22212 className: "dataviews-config__popover",
22213 placement: "bottom-end",
22214 offset: 9
22215 };
22216 function ViewTypeMenu() {
22217 const { view, onChangeView, defaultLayouts } = (0, import_element60.useContext)(dataviews_context_default);
22218 const availableLayouts = Object.keys(defaultLayouts);
22219 if (availableLayouts.length <= 1) {
22220 return null;
22221 }
22222 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
22223 return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(Menu5, { children: [
22224 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22225 Menu5.TriggerButton,
22226 {
22227 render: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22228 import_components26.Button,
22229 {
22230 size: "compact",
22231 icon: activeView?.icon,
22232 label: (0, import_i18n31.__)("Layout")
22233 }
22234 )
22235 }
22236 ),
22237 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
22238 const config = VIEW_LAYOUTS.find(
22239 (v2) => v2.type === layout
22240 );
22241 if (!config) {
22242 return null;
22243 }
22244 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22245 Menu5.RadioItem,
22246 {
22247 value: layout,
22248 name: "view-actions-available-view",
22249 checked: layout === view.type,
22250 hideOnClick: true,
22251 onChange: (e2) => {
22252 switch (e2.target.value) {
22253 case "list":
22254 case "grid":
22255 case "table":
22256 case "pickerGrid":
22257 case "pickerTable":
22258 case "activity":
22259 const viewWithoutLayout = { ...view };
22260 if ("layout" in viewWithoutLayout) {
22261 delete viewWithoutLayout.layout;
22262 }
22263 return onChangeView({
22264 ...viewWithoutLayout,
22265 type: e2.target.value,
22266 ...defaultLayouts[e2.target.value]
22267 });
22268 }
22269 (0, import_warning.default)("Invalid dataview");
22270 },
22271 children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Menu5.ItemLabel, { children: config.label })
22272 },
22273 layout
22274 );
22275 }) })
22276 ] });
22277 }
22278 function SortFieldControl() {
22279 const { view, fields, onChangeView } = (0, import_element60.useContext)(dataviews_context_default);
22280 const orderOptions = (0, import_element60.useMemo)(() => {
22281 const sortableFields = fields.filter(
22282 (field) => field.enableSorting !== false
22283 );
22284 return sortableFields.map((field) => {
22285 return {
22286 label: field.label,
22287 value: field.id
22288 };
22289 });
22290 }, [fields]);
22291 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22292 import_components26.SelectControl,
22293 {
22294 __next40pxDefaultSize: true,
22295 label: (0, import_i18n31.__)("Sort by"),
22296 value: view.sort?.field,
22297 options: orderOptions,
22298 onChange: (value) => {
22299 onChangeView({
22300 ...view,
22301 sort: {
22302 direction: view?.sort?.direction || "desc",
22303 field: value
22304 },
22305 showLevels: false
22306 });
22307 }
22308 }
22309 );
22310 }
22311 function SortDirectionControl() {
22312 const { view, fields, onChangeView } = (0, import_element60.useContext)(dataviews_context_default);
22313 const sortableFields = fields.filter(
22314 (field) => field.enableSorting !== false
22315 );
22316 if (sortableFields.length === 0) {
22317 return null;
22318 }
22319 let value = view.sort?.direction;
22320 if (!value && view.sort?.field) {
22321 value = "desc";
22322 }
22323 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22324 import_components26.__experimentalToggleGroupControl,
22325 {
22326 className: "dataviews-view-config__sort-direction",
22327 __next40pxDefaultSize: true,
22328 isBlock: true,
22329 label: (0, import_i18n31.__)("Order"),
22330 value,
22331 onChange: (newDirection) => {
22332 if (newDirection === "asc" || newDirection === "desc") {
22333 onChangeView({
22334 ...view,
22335 sort: {
22336 direction: newDirection,
22337 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
22338 fields.find(
22339 (field) => field.enableSorting !== false
22340 )?.id || ""
22341 },
22342 showLevels: false
22343 });
22344 return;
22345 }
22346 (0, import_warning.default)("Invalid direction");
22347 },
22348 children: SORTING_DIRECTIONS.map((direction) => {
22349 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22350 import_components26.__experimentalToggleGroupControlOptionIcon,
22351 {
22352 value: direction,
22353 icon: sortIcons[direction],
22354 label: sortLabels[direction]
22355 },
22356 direction
22357 );
22358 })
22359 }
22360 );
22361 }
22362 function ItemsPerPageControl() {
22363 const { view, config, onChangeView } = (0, import_element60.useContext)(dataviews_context_default);
22364 const { infiniteScrollEnabled } = view;
22365 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
22366 return null;
22367 }
22368 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22369 import_components26.__experimentalToggleGroupControl,
22370 {
22371 __next40pxDefaultSize: true,
22372 isBlock: true,
22373 label: (0, import_i18n31.__)("Items per page"),
22374 value: view.perPage || 10,
22375 disabled: !view?.sort?.field,
22376 onChange: (newItemsPerPage) => {
22377 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
22378 onChangeView({
22379 ...view,
22380 perPage: newItemsPerPageNumber,
22381 page: 1
22382 });
22383 },
22384 children: config.perPageSizes.map((value) => {
22385 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22386 import_components26.__experimentalToggleGroupControlOption,
22387 {
22388 value,
22389 label: value.toString()
22390 },
22391 value
22392 );
22393 })
22394 }
22395 );
22396 }
22397 function ResetViewButton() {
22398 const { onReset } = (0, import_element60.useContext)(dataviews_context_default);
22399 if (onReset === void 0) {
22400 return null;
22401 }
22402 const isDisabled = onReset === false;
22403 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22404 import_components26.Button,
22405 {
22406 variant: "tertiary",
22407 size: "compact",
22408 disabled: isDisabled,
22409 accessibleWhenDisabled: true,
22410 className: "dataviews-view-config__reset-button",
22411 onClick: () => {
22412 if (typeof onReset === "function") {
22413 onReset();
22414 }
22415 },
22416 children: (0, import_i18n31.__)("Reset view")
22417 }
22418 );
22419 }
22420 function DataviewsViewConfigDropdown() {
22421 const { view, onReset } = (0, import_element60.useContext)(dataviews_context_default);
22422 const popoverId = (0, import_compose10.useInstanceId)(
22423 _DataViewsViewConfig,
22424 "dataviews-view-config-dropdown"
22425 );
22426 const activeLayout = VIEW_LAYOUTS.find(
22427 (layout) => layout.type === view.type
22428 );
22429 const isModified = typeof onReset === "function";
22430 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22431 import_components26.Dropdown,
22432 {
22433 expandOnMobile: true,
22434 popoverProps: {
22435 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
22436 id: popoverId
22437 },
22438 renderToggle: ({ onToggle, isOpen }) => {
22439 return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
22440 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22441 import_components26.Button,
22442 {
22443 size: "compact",
22444 icon: cog_default,
22445 label: (0, import_i18n31._x)(
22446 "View options",
22447 "View is used as a noun"
22448 ),
22449 onClick: onToggle,
22450 "aria-expanded": isOpen ? "true" : "false",
22451 "aria-controls": popoverId
22452 }
22453 ),
22454 isModified && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
22455 ] });
22456 },
22457 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22458 import_components26.__experimentalDropdownContentWrapper,
22459 {
22460 paddingSize: "medium",
22461 className: "dataviews-config__popover-content-wrapper",
22462 children: /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(
22463 Stack,
22464 {
22465 direction: "column",
22466 className: "dataviews-view-config",
22467 gap: "xl",
22468 children: [
22469 /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(
22470 Stack,
22471 {
22472 direction: "row",
22473 justify: "space-between",
22474 align: "center",
22475 className: "dataviews-view-config__header",
22476 children: [
22477 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22478 import_components26.__experimentalHeading,
22479 {
22480 level: 2,
22481 className: "dataviews-settings-section__title",
22482 children: (0, import_i18n31.__)("Appearance")
22483 }
22484 ),
22485 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(ResetViewButton, {})
22486 ]
22487 }
22488 ),
22489 /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22490 /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(
22491 Stack,
22492 {
22493 direction: "row",
22494 gap: "sm",
22495 className: "dataviews-view-config__sort-controls",
22496 children: [
22497 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(SortFieldControl, {}),
22498 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(SortDirectionControl, {})
22499 ]
22500 }
22501 ),
22502 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(activeLayout.viewConfigOptions, {}),
22503 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(ItemsPerPageControl, {}),
22504 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(PropertiesSection, {})
22505 ] })
22506 ]
22507 }
22508 )
22509 }
22510 )
22511 }
22512 );
22513 }
22514 function _DataViewsViewConfig() {
22515 return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(import_jsx_runtime90.Fragment, { children: [
22516 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(ViewTypeMenu, {}),
22517 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(DataviewsViewConfigDropdown, {})
22518 ] });
22519 }
22520 var DataViewsViewConfig = (0, import_element60.memo)(_DataViewsViewConfig);
22521 var dataviews_view_config_default = DataViewsViewConfig;
22522
22523 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22524 var import_components27 = __toESM(require_components(), 1);
22525 var import_element61 = __toESM(require_element(), 1);
22526
22527 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
22528 function getCustomValidity(isValid2, validity) {
22529 let customValidity;
22530 if (isValid2?.required && validity?.required) {
22531 customValidity = validity?.required?.message ? validity.required : void 0;
22532 } else if (isValid2?.pattern && validity?.pattern) {
22533 customValidity = validity.pattern;
22534 } else if (isValid2?.min && validity?.min) {
22535 customValidity = validity.min;
22536 } else if (isValid2?.max && validity?.max) {
22537 customValidity = validity.max;
22538 } else if (isValid2?.minLength && validity?.minLength) {
22539 customValidity = validity.minLength;
22540 } else if (isValid2?.maxLength && validity?.maxLength) {
22541 customValidity = validity.maxLength;
22542 } else if (isValid2?.elements && validity?.elements) {
22543 customValidity = validity.elements;
22544 } else if (validity?.custom) {
22545 customValidity = validity.custom;
22546 }
22547 return customValidity;
22548 }
22549
22550 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22551 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
22552 var { ValidatedCheckboxControl } = unlock2(import_components27.privateApis);
22553 function Checkbox({
22554 field,
22555 onChange,
22556 data,
22557 hideLabelFromVision,
22558 markWhenOptional,
22559 validity
22560 }) {
22561 const { getValue, setValue, label, description, isValid: isValid2 } = field;
22562 const disabled2 = field.isDisabled({ item: data, field });
22563 const onChangeControl = (0, import_element61.useCallback)(() => {
22564 onChange(
22565 setValue({ item: data, value: !getValue({ item: data }) })
22566 );
22567 }, [data, getValue, onChange, setValue]);
22568 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22569 ValidatedCheckboxControl,
22570 {
22571 required: !!field.isValid?.required,
22572 markWhenOptional,
22573 customValidity: getCustomValidity(isValid2, validity),
22574 hidden: hideLabelFromVision,
22575 label,
22576 help: description,
22577 checked: getValue({ item: data }),
22578 onChange: onChangeControl,
22579 disabled: disabled2
22580 }
22581 );
22582 }
22583
22584 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
22585 var import_components28 = __toESM(require_components(), 1);
22586 var import_element62 = __toESM(require_element(), 1);
22587 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
22588 var { ValidatedComboboxControl } = unlock2(import_components28.privateApis);
22589 function Combobox3({
22590 data,
22591 field,
22592 onChange,
22593 hideLabelFromVision,
22594 validity
22595 }) {
22596 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
22597 const value = getValue({ item: data }) ?? "";
22598 const onChangeControl = (0, import_element62.useCallback)(
22599 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
22600 [data, onChange, setValue]
22601 );
22602 const { elements, isLoading } = useElements({
22603 elements: field.elements,
22604 getElements: field.getElements
22605 });
22606 if (isLoading) {
22607 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_components28.Spinner, {});
22608 }
22609 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22610 ValidatedComboboxControl,
22611 {
22612 required: !!field.isValid?.required,
22613 customValidity: getCustomValidity(isValid2, validity),
22614 label,
22615 value,
22616 help: description,
22617 placeholder,
22618 options: elements,
22619 onChange: onChangeControl,
22620 hideLabelFromVision,
22621 allowReset: true,
22622 expandOnFocus: true
22623 }
22624 );
22625 }
22626
22627 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
22628 var import_components30 = __toESM(require_components(), 1);
22629 var import_element65 = __toESM(require_element(), 1);
22630 var import_i18n33 = __toESM(require_i18n(), 1);
22631 var import_date3 = __toESM(require_date(), 1);
22632
22633 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
22634 var import_components29 = __toESM(require_components(), 1);
22635 var import_element63 = __toESM(require_element(), 1);
22636 var import_i18n32 = __toESM(require_i18n(), 1);
22637 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
22638 var TIME_UNITS_OPTIONS = {
22639 [OPERATOR_IN_THE_PAST]: [
22640 { value: "days", label: (0, import_i18n32.__)("Days") },
22641 { value: "weeks", label: (0, import_i18n32.__)("Weeks") },
22642 { value: "months", label: (0, import_i18n32.__)("Months") },
22643 { value: "years", label: (0, import_i18n32.__)("Years") }
22644 ],
22645 [OPERATOR_OVER]: [
22646 { value: "days", label: (0, import_i18n32.__)("Days ago") },
22647 { value: "weeks", label: (0, import_i18n32.__)("Weeks ago") },
22648 { value: "months", label: (0, import_i18n32.__)("Months ago") },
22649 { value: "years", label: (0, import_i18n32.__)("Years ago") }
22650 ]
22651 };
22652 function RelativeDateControl({
22653 className,
22654 data,
22655 field,
22656 onChange,
22657 hideLabelFromVision,
22658 operator
22659 }) {
22660 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
22661 const { id, label, description, getValue, setValue } = field;
22662 const disabled2 = field.isDisabled({ item: data, field });
22663 const fieldValue = getValue({ item: data });
22664 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
22665 const onChangeValue = (0, import_element63.useCallback)(
22666 (newValue) => onChange(
22667 setValue({
22668 item: data,
22669 value: { value: Number(newValue), unit }
22670 })
22671 ),
22672 [onChange, setValue, data, unit]
22673 );
22674 const onChangeUnit = (0, import_element63.useCallback)(
22675 (newUnit) => onChange(
22676 setValue({
22677 item: data,
22678 value: { value: relValue, unit: newUnit }
22679 })
22680 ),
22681 [onChange, setValue, data, relValue]
22682 );
22683 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
22684 import_components29.BaseControl,
22685 {
22686 id,
22687 className: clsx_default(className, "dataviews-controls__relative-date"),
22688 label,
22689 hideLabelFromVision,
22690 help: description,
22691 children: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(Stack, { direction: "row", gap: "sm", children: [
22692 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
22693 import_components29.__experimentalNumberControl,
22694 {
22695 __next40pxDefaultSize: true,
22696 className: "dataviews-controls__relative-date-number",
22697 spinControls: "none",
22698 min: 1,
22699 step: 1,
22700 value: relValue,
22701 onChange: onChangeValue,
22702 disabled: disabled2
22703 }
22704 ),
22705 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
22706 import_components29.SelectControl,
22707 {
22708 className: "dataviews-controls__relative-date-unit",
22709 __next40pxDefaultSize: true,
22710 label: (0, import_i18n32.__)("Unit"),
22711 value: unit,
22712 options,
22713 onChange: onChangeUnit,
22714 hideLabelFromVision: true,
22715 disabled: disabled2
22716 }
22717 )
22718 ] })
22719 }
22720 );
22721 }
22722
22723 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
22724 var import_element64 = __toESM(require_element(), 1);
22725 function useDisabledDateMatchers(isValid2, parseDateFn) {
22726 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
22727 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
22728 const disabledMatchers = (0, import_element64.useMemo)(() => {
22729 const matchers = [];
22730 if (minConstraint) {
22731 const minDate = parseDateFn(minConstraint);
22732 if (minDate) {
22733 matchers.push({ before: minDate });
22734 }
22735 }
22736 if (maxConstraint) {
22737 const maxDate = parseDateFn(maxConstraint);
22738 if (maxDate) {
22739 matchers.push({ after: maxDate });
22740 }
22741 }
22742 return matchers.length > 0 ? matchers : void 0;
22743 }, [minConstraint, maxConstraint, parseDateFn]);
22744 return { minConstraint, maxConstraint, disabledMatchers };
22745 }
22746
22747 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
22748 var import_date2 = __toESM(require_date(), 1);
22749 function parseDateTime(dateTimeString) {
22750 if (!dateTimeString) {
22751 return null;
22752 }
22753 const parsed = (0, import_date2.getDate)(dateTimeString);
22754 return parsed && isValid(parsed) ? parsed : null;
22755 }
22756
22757 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
22758 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
22759 var { DateCalendar, ValidatedInputControl } = unlock2(import_components30.privateApis);
22760 var formatDateTime = (value) => {
22761 if (!value) {
22762 return "";
22763 }
22764 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
22765 };
22766 function CalendarDateTimeControl({
22767 data,
22768 field,
22769 onChange,
22770 hideLabelFromVision,
22771 markWhenOptional,
22772 validity,
22773 config
22774 }) {
22775 const { compact } = config || {};
22776 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
22777 const disabled2 = field.isDisabled({ item: data, field });
22778 const fieldValue = getValue({ item: data });
22779 const value = typeof fieldValue === "string" ? fieldValue : void 0;
22780 const [calendarMonth, setCalendarMonth] = (0, import_element65.useState)(() => {
22781 const parsedDate = parseDateTime(value);
22782 return parsedDate || /* @__PURE__ */ new Date();
22783 });
22784 const inputControlRef = (0, import_element65.useRef)(null);
22785 const validationTimeoutRef = (0, import_element65.useRef)(void 0);
22786 const previousFocusRef = (0, import_element65.useRef)(null);
22787 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
22788 const onChangeCallback = (0, import_element65.useCallback)(
22789 (newValue) => onChange(setValue({ item: data, value: newValue })),
22790 [data, onChange, setValue]
22791 );
22792 (0, import_element65.useEffect)(() => {
22793 return () => {
22794 if (validationTimeoutRef.current) {
22795 clearTimeout(validationTimeoutRef.current);
22796 }
22797 };
22798 }, []);
22799 const onSelectDate = (0, import_element65.useCallback)(
22800 (newDate) => {
22801 let dateTimeValue;
22802 if (newDate) {
22803 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
22804 let wpTime;
22805 if (value) {
22806 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
22807 } else {
22808 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
22809 }
22810 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
22811 dateTimeValue = finalDateTime.toISOString();
22812 onChangeCallback(dateTimeValue);
22813 if (validationTimeoutRef.current) {
22814 clearTimeout(validationTimeoutRef.current);
22815 }
22816 } else {
22817 onChangeCallback(void 0);
22818 }
22819 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
22820 validationTimeoutRef.current = setTimeout(() => {
22821 if (inputControlRef.current) {
22822 inputControlRef.current.focus();
22823 inputControlRef.current.blur();
22824 onChangeCallback(dateTimeValue);
22825 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
22826 previousFocusRef.current.focus();
22827 }
22828 }
22829 }, 0);
22830 },
22831 [onChangeCallback, value]
22832 );
22833 const handleManualDateTimeChange = (0, import_element65.useCallback)(
22834 (newValue) => {
22835 if (newValue) {
22836 const dateTime = (0, import_date3.getDate)(newValue);
22837 onChangeCallback(dateTime.toISOString());
22838 const parsedDate = parseDateTime(dateTime.toISOString());
22839 if (parsedDate) {
22840 setCalendarMonth(parsedDate);
22841 }
22842 } else {
22843 onChangeCallback(void 0);
22844 }
22845 },
22846 [onChangeCallback]
22847 );
22848 const { format: fieldFormat } = field;
22849 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
22850 const {
22851 timezone: { string: timezoneString }
22852 } = (0, import_date3.getSettings)();
22853 let displayLabel = label;
22854 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
22855 displayLabel = `${label} (${(0, import_i18n33.__)("Required")})`;
22856 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
22857 displayLabel = `${label} (${(0, import_i18n33.__)("Optional")})`;
22858 }
22859 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
22860 import_components30.BaseControl,
22861 {
22862 id,
22863 label: displayLabel,
22864 help: description,
22865 hideLabelFromVision,
22866 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22867 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
22868 ValidatedInputControl,
22869 {
22870 ref: inputControlRef,
22871 __next40pxDefaultSize: true,
22872 required: !!isValid2?.required,
22873 customValidity: getCustomValidity(isValid2, validity),
22874 type: "datetime-local",
22875 label: (0, import_i18n33.__)("Date time"),
22876 hideLabelFromVision: true,
22877 value: formatDateTime(value),
22878 onChange: handleManualDateTimeChange,
22879 disabled: disabled2,
22880 min: minConstraint ? formatDateTime(minConstraint) : void 0,
22881 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
22882 }
22883 ),
22884 !compact && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
22885 DateCalendar,
22886 {
22887 style: { width: "100%" },
22888 selected: value ? parseDateTime(value) || void 0 : void 0,
22889 onSelect: onSelectDate,
22890 month: calendarMonth,
22891 onMonthChange: setCalendarMonth,
22892 timeZone: timezoneString || void 0,
22893 weekStartsOn,
22894 disabled: disabled2 || disabledMatchers
22895 }
22896 )
22897 ] })
22898 }
22899 );
22900 }
22901 function DateTime({
22902 data,
22903 field,
22904 onChange,
22905 hideLabelFromVision,
22906 markWhenOptional,
22907 operator,
22908 validity,
22909 config
22910 }) {
22911 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
22912 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
22913 RelativeDateControl,
22914 {
22915 className: "dataviews-controls__datetime",
22916 data,
22917 field,
22918 onChange,
22919 hideLabelFromVision,
22920 operator
22921 }
22922 );
22923 }
22924 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
22925 CalendarDateTimeControl,
22926 {
22927 data,
22928 field,
22929 onChange,
22930 hideLabelFromVision,
22931 markWhenOptional,
22932 validity,
22933 config
22934 }
22935 );
22936 }
22937
22938 // packages/dataviews/build-module/components/dataform-controls/date.mjs
22939 var import_components31 = __toESM(require_components(), 1);
22940 var import_element66 = __toESM(require_element(), 1);
22941 var import_i18n34 = __toESM(require_i18n(), 1);
22942 var import_date4 = __toESM(require_date(), 1);
22943 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
22944 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock2(import_components31.privateApis);
22945 var DATE_PRESETS = [
22946 {
22947 id: "today",
22948 label: (0, import_i18n34.__)("Today"),
22949 getValue: () => (0, import_date4.getDate)(null)
22950 },
22951 {
22952 id: "yesterday",
22953 label: (0, import_i18n34.__)("Yesterday"),
22954 getValue: () => {
22955 const today = (0, import_date4.getDate)(null);
22956 return subDays(today, 1);
22957 }
22958 },
22959 {
22960 id: "past-week",
22961 label: (0, import_i18n34.__)("Past week"),
22962 getValue: () => {
22963 const today = (0, import_date4.getDate)(null);
22964 return subDays(today, 7);
22965 }
22966 },
22967 {
22968 id: "past-month",
22969 label: (0, import_i18n34.__)("Past month"),
22970 getValue: () => {
22971 const today = (0, import_date4.getDate)(null);
22972 return subMonths(today, 1);
22973 }
22974 }
22975 ];
22976 var DATE_RANGE_PRESETS = [
22977 {
22978 id: "last-7-days",
22979 label: (0, import_i18n34.__)("Last 7 days"),
22980 getValue: () => {
22981 const today = (0, import_date4.getDate)(null);
22982 return [subDays(today, 7), today];
22983 }
22984 },
22985 {
22986 id: "last-30-days",
22987 label: (0, import_i18n34.__)("Last 30 days"),
22988 getValue: () => {
22989 const today = (0, import_date4.getDate)(null);
22990 return [subDays(today, 30), today];
22991 }
22992 },
22993 {
22994 id: "month-to-date",
22995 label: (0, import_i18n34.__)("Month to date"),
22996 getValue: () => {
22997 const today = (0, import_date4.getDate)(null);
22998 return [startOfMonth(today), today];
22999 }
23000 },
23001 {
23002 id: "last-year",
23003 label: (0, import_i18n34.__)("Last year"),
23004 getValue: () => {
23005 const today = (0, import_date4.getDate)(null);
23006 return [subYears(today, 1), today];
23007 }
23008 },
23009 {
23010 id: "year-to-date",
23011 label: (0, import_i18n34.__)("Year to date"),
23012 getValue: () => {
23013 const today = (0, import_date4.getDate)(null);
23014 return [startOfYear(today), today];
23015 }
23016 }
23017 ];
23018 var parseDate = (dateString) => {
23019 if (!dateString) {
23020 return null;
23021 }
23022 const parsed = (0, import_date4.getDate)(dateString);
23023 return parsed && isValid(parsed) ? parsed : null;
23024 };
23025 var formatDate = (date) => {
23026 if (!date) {
23027 return "";
23028 }
23029 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
23030 };
23031 function ValidatedDateControl({
23032 field,
23033 validity,
23034 inputRefs,
23035 isTouched,
23036 setIsTouched,
23037 children
23038 }) {
23039 const { isValid: isValid2 } = field;
23040 const [customValidity, setCustomValidity] = (0, import_element66.useState)(void 0);
23041 const validateRefs = (0, import_element66.useCallback)(() => {
23042 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23043 for (const ref of refs) {
23044 const input = ref.current;
23045 if (input && !input.validity.valid) {
23046 setCustomValidity({
23047 type: "invalid",
23048 message: input.validationMessage
23049 });
23050 return;
23051 }
23052 }
23053 setCustomValidity(void 0);
23054 }, [inputRefs]);
23055 (0, import_element66.useEffect)(() => {
23056 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23057 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23058 for (const ref of refs) {
23059 const input = ref.current;
23060 if (input) {
23061 input.setCustomValidity(
23062 result?.type === "invalid" && result.message ? result.message : ""
23063 );
23064 }
23065 }
23066 }, [inputRefs, isValid2, validity]);
23067 (0, import_element66.useEffect)(() => {
23068 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23069 const handleInvalid = (event) => {
23070 event.preventDefault();
23071 setIsTouched(true);
23072 };
23073 for (const ref of refs) {
23074 ref.current?.addEventListener("invalid", handleInvalid);
23075 }
23076 return () => {
23077 for (const ref of refs) {
23078 ref.current?.removeEventListener("invalid", handleInvalid);
23079 }
23080 };
23081 }, [inputRefs, setIsTouched]);
23082 (0, import_element66.useEffect)(() => {
23083 if (!isTouched) {
23084 return;
23085 }
23086 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23087 if (result) {
23088 setCustomValidity(result);
23089 } else {
23090 validateRefs();
23091 }
23092 }, [isTouched, isValid2, validity, validateRefs]);
23093 const onBlur = (event) => {
23094 if (isTouched) {
23095 return;
23096 }
23097 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
23098 setIsTouched(true);
23099 }
23100 };
23101 return /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)("div", { onBlur, children: [
23102 children,
23103 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(
23104 "p",
23105 {
23106 className: clsx_default(
23107 "components-validated-control__indicator",
23108 customValidity.type === "invalid" ? "is-invalid" : void 0
23109 ),
23110 children: [
23111 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23112 import_components31.Icon,
23113 {
23114 className: "components-validated-control__indicator-icon",
23115 icon: error_default,
23116 size: 16,
23117 fill: "currentColor"
23118 }
23119 ),
23120 customValidity.message
23121 ]
23122 }
23123 ) })
23124 ] });
23125 }
23126 function CalendarDateControl({
23127 data,
23128 field,
23129 onChange,
23130 hideLabelFromVision,
23131 markWhenOptional,
23132 validity
23133 }) {
23134 const {
23135 id,
23136 label,
23137 description,
23138 setValue,
23139 getValue,
23140 isValid: isValid2,
23141 format: fieldFormat
23142 } = field;
23143 const disabled2 = field.isDisabled({ item: data, field });
23144 const [selectedPresetId, setSelectedPresetId] = (0, import_element66.useState)(
23145 null
23146 );
23147 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23148 const fieldValue = getValue({ item: data });
23149 const value = typeof fieldValue === "string" ? fieldValue : void 0;
23150 const [calendarMonth, setCalendarMonth] = (0, import_element66.useState)(() => {
23151 const parsedDate = parseDate(value);
23152 return parsedDate || /* @__PURE__ */ new Date();
23153 });
23154 const [isTouched, setIsTouched] = (0, import_element66.useState)(false);
23155 const validityTargetRef = (0, import_element66.useRef)(null);
23156 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23157 const onChangeCallback = (0, import_element66.useCallback)(
23158 (newValue) => onChange(setValue({ item: data, value: newValue })),
23159 [data, onChange, setValue]
23160 );
23161 const onSelectDate = (0, import_element66.useCallback)(
23162 (newDate) => {
23163 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
23164 onChangeCallback(dateValue);
23165 setSelectedPresetId(null);
23166 setIsTouched(true);
23167 },
23168 [onChangeCallback]
23169 );
23170 const handlePresetClick = (0, import_element66.useCallback)(
23171 (preset) => {
23172 const presetDate = preset.getValue();
23173 const dateValue = formatDate(presetDate);
23174 setCalendarMonth(presetDate);
23175 onChangeCallback(dateValue);
23176 setSelectedPresetId(preset.id);
23177 setIsTouched(true);
23178 },
23179 [onChangeCallback]
23180 );
23181 const handleManualDateChange = (0, import_element66.useCallback)(
23182 (newValue) => {
23183 onChangeCallback(newValue);
23184 if (newValue) {
23185 const parsedDate = parseDate(newValue);
23186 if (parsedDate) {
23187 setCalendarMonth(parsedDate);
23188 }
23189 }
23190 setSelectedPresetId(null);
23191 setIsTouched(true);
23192 },
23193 [onChangeCallback]
23194 );
23195 const {
23196 timezone: { string: timezoneString }
23197 } = (0, import_date4.getSettings)();
23198 let displayLabel = label;
23199 if (isValid2?.required && !markWhenOptional) {
23200 displayLabel = `${label} (${(0, import_i18n34.__)("Required")})`;
23201 } else if (!isValid2?.required && markWhenOptional) {
23202 displayLabel = `${label} (${(0, import_i18n34.__)("Optional")})`;
23203 }
23204 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23205 ValidatedDateControl,
23206 {
23207 field,
23208 validity,
23209 inputRefs: validityTargetRef,
23210 isTouched,
23211 setIsTouched,
23212 children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23213 import_components31.BaseControl,
23214 {
23215 id,
23216 className: "dataviews-controls__date",
23217 label: displayLabel,
23218 help: description,
23219 hideLabelFromVision,
23220 children: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23221 /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(
23222 Stack,
23223 {
23224 direction: "row",
23225 gap: "sm",
23226 wrap: "wrap",
23227 justify: "flex-start",
23228 children: [
23229 DATE_PRESETS.map((preset) => {
23230 const isSelected2 = selectedPresetId === preset.id;
23231 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23232 import_components31.Button,
23233 {
23234 className: "dataviews-controls__date-preset",
23235 variant: "tertiary",
23236 isPressed: isSelected2,
23237 size: "small",
23238 disabled: disabled2,
23239 accessibleWhenDisabled: true,
23240 onClick: () => handlePresetClick(preset),
23241 children: preset.label
23242 },
23243 preset.id
23244 );
23245 }),
23246 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23247 import_components31.Button,
23248 {
23249 className: "dataviews-controls__date-preset",
23250 variant: "tertiary",
23251 isPressed: !selectedPresetId,
23252 size: "small",
23253 disabled: !!selectedPresetId || disabled2,
23254 accessibleWhenDisabled: true,
23255 children: (0, import_i18n34.__)("Custom")
23256 }
23257 )
23258 ]
23259 }
23260 ),
23261 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23262 import_components31.__experimentalInputControl,
23263 {
23264 __next40pxDefaultSize: true,
23265 ref: validityTargetRef,
23266 type: "date",
23267 label: (0, import_i18n34.__)("Date"),
23268 hideLabelFromVision: true,
23269 value,
23270 onChange: handleManualDateChange,
23271 required: !!field.isValid?.required,
23272 disabled: disabled2,
23273 min: minConstraint,
23274 max: maxConstraint
23275 }
23276 ),
23277 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23278 DateCalendar2,
23279 {
23280 style: { width: "100%" },
23281 selected: value ? parseDate(value) || void 0 : void 0,
23282 onSelect: onSelectDate,
23283 month: calendarMonth,
23284 onMonthChange: setCalendarMonth,
23285 timeZone: timezoneString || void 0,
23286 weekStartsOn,
23287 disabled: disabled2 || disabledMatchers,
23288 disableNavigation: disabled2
23289 }
23290 )
23291 ] })
23292 }
23293 )
23294 }
23295 );
23296 }
23297 function CalendarDateRangeControl({
23298 data,
23299 field,
23300 onChange,
23301 hideLabelFromVision,
23302 markWhenOptional,
23303 validity
23304 }) {
23305 const {
23306 id,
23307 label,
23308 description,
23309 getValue,
23310 setValue,
23311 isValid: isValid2,
23312 format: fieldFormat
23313 } = field;
23314 const disabled2 = field.isDisabled({ item: data, field });
23315 let value;
23316 const fieldValue = getValue({ item: data });
23317 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
23318 value = fieldValue;
23319 }
23320 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23321 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23322 const onChangeCallback = (0, import_element66.useCallback)(
23323 (newValue) => {
23324 onChange(
23325 setValue({
23326 item: data,
23327 value: newValue
23328 })
23329 );
23330 },
23331 [data, onChange, setValue]
23332 );
23333 const [selectedPresetId, setSelectedPresetId] = (0, import_element66.useState)(
23334 null
23335 );
23336 const selectedRange = (0, import_element66.useMemo)(() => {
23337 if (!value) {
23338 return { from: void 0, to: void 0 };
23339 }
23340 const [from, to] = value;
23341 return {
23342 from: parseDate(from) || void 0,
23343 to: parseDate(to) || void 0
23344 };
23345 }, [value]);
23346 const [calendarMonth, setCalendarMonth] = (0, import_element66.useState)(() => {
23347 return selectedRange.from || /* @__PURE__ */ new Date();
23348 });
23349 const [isTouched, setIsTouched] = (0, import_element66.useState)(false);
23350 const fromInputRef = (0, import_element66.useRef)(null);
23351 const toInputRef = (0, import_element66.useRef)(null);
23352 const updateDateRange = (0, import_element66.useCallback)(
23353 (fromDate, toDate2) => {
23354 if (fromDate && toDate2) {
23355 onChangeCallback([
23356 formatDate(fromDate),
23357 formatDate(toDate2)
23358 ]);
23359 } else if (!fromDate && !toDate2) {
23360 onChangeCallback(void 0);
23361 }
23362 },
23363 [onChangeCallback]
23364 );
23365 const onSelectCalendarRange = (0, import_element66.useCallback)(
23366 (newRange) => {
23367 updateDateRange(newRange?.from, newRange?.to);
23368 setSelectedPresetId(null);
23369 setIsTouched(true);
23370 },
23371 [updateDateRange]
23372 );
23373 const handlePresetClick = (0, import_element66.useCallback)(
23374 (preset) => {
23375 const [startDate, endDate] = preset.getValue();
23376 setCalendarMonth(startDate);
23377 updateDateRange(startDate, endDate);
23378 setSelectedPresetId(preset.id);
23379 setIsTouched(true);
23380 },
23381 [updateDateRange]
23382 );
23383 const handleManualDateChange = (0, import_element66.useCallback)(
23384 (fromOrTo, newValue) => {
23385 const [currentFrom, currentTo] = value || [
23386 void 0,
23387 void 0
23388 ];
23389 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
23390 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
23391 updateDateRange(updatedFrom, updatedTo);
23392 if (newValue) {
23393 const parsedDate = parseDate(newValue);
23394 if (parsedDate) {
23395 setCalendarMonth(parsedDate);
23396 }
23397 }
23398 setSelectedPresetId(null);
23399 setIsTouched(true);
23400 },
23401 [value, updateDateRange]
23402 );
23403 const { timezone } = (0, import_date4.getSettings)();
23404 let displayLabel = label;
23405 if (field.isValid?.required && !markWhenOptional) {
23406 displayLabel = `${label} (${(0, import_i18n34.__)("Required")})`;
23407 } else if (!field.isValid?.required && markWhenOptional) {
23408 displayLabel = `${label} (${(0, import_i18n34.__)("Optional")})`;
23409 }
23410 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23411 ValidatedDateControl,
23412 {
23413 field,
23414 validity,
23415 inputRefs: [fromInputRef, toInputRef],
23416 isTouched,
23417 setIsTouched,
23418 children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23419 import_components31.BaseControl,
23420 {
23421 id,
23422 className: "dataviews-controls__date",
23423 label: displayLabel,
23424 help: description,
23425 hideLabelFromVision,
23426 children: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23427 /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(
23428 Stack,
23429 {
23430 direction: "row",
23431 gap: "sm",
23432 wrap: "wrap",
23433 justify: "flex-start",
23434 children: [
23435 DATE_RANGE_PRESETS.map((preset) => {
23436 const isSelected2 = selectedPresetId === preset.id;
23437 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23438 import_components31.Button,
23439 {
23440 className: "dataviews-controls__date-preset",
23441 variant: "tertiary",
23442 isPressed: isSelected2,
23443 size: "small",
23444 disabled: disabled2,
23445 accessibleWhenDisabled: true,
23446 onClick: () => handlePresetClick(preset),
23447 children: preset.label
23448 },
23449 preset.id
23450 );
23451 }),
23452 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23453 import_components31.Button,
23454 {
23455 className: "dataviews-controls__date-preset",
23456 variant: "tertiary",
23457 isPressed: !selectedPresetId,
23458 size: "small",
23459 accessibleWhenDisabled: true,
23460 disabled: !!selectedPresetId || disabled2,
23461 children: (0, import_i18n34.__)("Custom")
23462 }
23463 )
23464 ]
23465 }
23466 ),
23467 /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(
23468 Stack,
23469 {
23470 direction: "row",
23471 gap: "sm",
23472 justify: "space-between",
23473 className: "dataviews-controls__date-range-inputs",
23474 children: [
23475 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23476 import_components31.__experimentalInputControl,
23477 {
23478 __next40pxDefaultSize: true,
23479 ref: fromInputRef,
23480 type: "date",
23481 label: (0, import_i18n34.__)("From"),
23482 hideLabelFromVision: true,
23483 value: value?.[0],
23484 onChange: (newValue) => handleManualDateChange("from", newValue),
23485 required: !!field.isValid?.required,
23486 disabled: disabled2,
23487 min: minConstraint,
23488 max: maxConstraint
23489 }
23490 ),
23491 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23492 import_components31.__experimentalInputControl,
23493 {
23494 __next40pxDefaultSize: true,
23495 ref: toInputRef,
23496 type: "date",
23497 label: (0, import_i18n34.__)("To"),
23498 hideLabelFromVision: true,
23499 value: value?.[1],
23500 onChange: (newValue) => handleManualDateChange("to", newValue),
23501 required: !!field.isValid?.required,
23502 disabled: disabled2,
23503 min: minConstraint,
23504 max: maxConstraint
23505 }
23506 )
23507 ]
23508 }
23509 ),
23510 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23511 DateRangeCalendar,
23512 {
23513 style: { width: "100%" },
23514 selected: selectedRange,
23515 onSelect: onSelectCalendarRange,
23516 month: calendarMonth,
23517 onMonthChange: setCalendarMonth,
23518 timeZone: timezone.string || void 0,
23519 weekStartsOn,
23520 disabled: disabled2 || disabledMatchers
23521 }
23522 )
23523 ] })
23524 }
23525 )
23526 }
23527 );
23528 }
23529 function DateControl({
23530 data,
23531 field,
23532 onChange,
23533 hideLabelFromVision,
23534 markWhenOptional,
23535 operator,
23536 validity
23537 }) {
23538 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
23539 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23540 RelativeDateControl,
23541 {
23542 className: "dataviews-controls__date",
23543 data,
23544 field,
23545 onChange,
23546 hideLabelFromVision,
23547 operator
23548 }
23549 );
23550 }
23551 if (operator === OPERATOR_BETWEEN) {
23552 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23553 CalendarDateRangeControl,
23554 {
23555 data,
23556 field,
23557 onChange,
23558 hideLabelFromVision,
23559 markWhenOptional,
23560 validity
23561 }
23562 );
23563 }
23564 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23565 CalendarDateControl,
23566 {
23567 data,
23568 field,
23569 onChange,
23570 hideLabelFromVision,
23571 markWhenOptional,
23572 validity
23573 }
23574 );
23575 }
23576
23577 // packages/dataviews/build-module/components/dataform-controls/select.mjs
23578 var import_components32 = __toESM(require_components(), 1);
23579 var import_element67 = __toESM(require_element(), 1);
23580 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
23581 var { ValidatedSelectControl } = unlock2(import_components32.privateApis);
23582 function Select({
23583 data,
23584 field,
23585 onChange,
23586 hideLabelFromVision,
23587 markWhenOptional,
23588 validity
23589 }) {
23590 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
23591 const disabled2 = field.isDisabled({ item: data, field });
23592 const isMultiple = type === "array";
23593 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
23594 const onChangeControl = (0, import_element67.useCallback)(
23595 (newValue) => onChange(setValue({ item: data, value: newValue })),
23596 [data, onChange, setValue]
23597 );
23598 const { elements, isLoading } = useElements({
23599 elements: field.elements,
23600 getElements: field.getElements
23601 });
23602 if (isLoading) {
23603 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(import_components32.Spinner, {});
23604 }
23605 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23606 ValidatedSelectControl,
23607 {
23608 required: !!field.isValid?.required,
23609 markWhenOptional,
23610 customValidity: getCustomValidity(isValid2, validity),
23611 label,
23612 value,
23613 help: description,
23614 options: elements,
23615 onChange: onChangeControl,
23616 __next40pxDefaultSize: true,
23617 hideLabelFromVision,
23618 multiple: isMultiple,
23619 disabled: disabled2
23620 }
23621 );
23622 }
23623
23624 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
23625 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
23626 var ELEMENTS_THRESHOLD = 10;
23627 function AdaptiveSelect(props) {
23628 const { field } = props;
23629 const { elements } = useElements({
23630 elements: field.elements,
23631 getElements: field.getElements
23632 });
23633 if (elements.length >= ELEMENTS_THRESHOLD) {
23634 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(Combobox3, { ...props });
23635 }
23636 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(Select, { ...props });
23637 }
23638
23639 // packages/dataviews/build-module/components/dataform-controls/email.mjs
23640 var import_components34 = __toESM(require_components(), 1);
23641
23642 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
23643 var import_components33 = __toESM(require_components(), 1);
23644 var import_element68 = __toESM(require_element(), 1);
23645 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
23646 var { ValidatedInputControl: ValidatedInputControl2 } = unlock2(import_components33.privateApis);
23647 function ValidatedText({
23648 data,
23649 field,
23650 onChange,
23651 hideLabelFromVision,
23652 markWhenOptional,
23653 type,
23654 prefix,
23655 suffix,
23656 validity
23657 }) {
23658 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
23659 const value = getValue({ item: data });
23660 const disabled2 = field.isDisabled({ item: data, field });
23661 const onChangeControl = (0, import_element68.useCallback)(
23662 (newValue) => onChange(
23663 setValue({
23664 item: data,
23665 value: newValue
23666 })
23667 ),
23668 [data, setValue, onChange]
23669 );
23670 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
23671 ValidatedInputControl2,
23672 {
23673 required: !!isValid2.required,
23674 markWhenOptional,
23675 customValidity: getCustomValidity(isValid2, validity),
23676 label,
23677 placeholder,
23678 value: value ?? "",
23679 help: description,
23680 onChange: onChangeControl,
23681 hideLabelFromVision,
23682 type,
23683 prefix,
23684 suffix,
23685 disabled: disabled2,
23686 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
23687 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
23688 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
23689 __next40pxDefaultSize: true
23690 }
23691 );
23692 }
23693
23694 // packages/dataviews/build-module/components/dataform-controls/email.mjs
23695 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
23696 function Email({
23697 data,
23698 field,
23699 onChange,
23700 hideLabelFromVision,
23701 markWhenOptional,
23702 validity
23703 }) {
23704 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
23705 ValidatedText,
23706 {
23707 ...{
23708 data,
23709 field,
23710 onChange,
23711 hideLabelFromVision,
23712 markWhenOptional,
23713 validity,
23714 type: "email",
23715 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 }) })
23716 }
23717 }
23718 );
23719 }
23720
23721 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
23722 var import_components35 = __toESM(require_components(), 1);
23723 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
23724 function Telephone({
23725 data,
23726 field,
23727 onChange,
23728 hideLabelFromVision,
23729 markWhenOptional,
23730 validity
23731 }) {
23732 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
23733 ValidatedText,
23734 {
23735 ...{
23736 data,
23737 field,
23738 onChange,
23739 hideLabelFromVision,
23740 markWhenOptional,
23741 validity,
23742 type: "tel",
23743 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 }) })
23744 }
23745 }
23746 );
23747 }
23748
23749 // packages/dataviews/build-module/components/dataform-controls/url.mjs
23750 var import_components36 = __toESM(require_components(), 1);
23751 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
23752 function Url({
23753 data,
23754 field,
23755 onChange,
23756 hideLabelFromVision,
23757 markWhenOptional,
23758 validity
23759 }) {
23760 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
23761 ValidatedText,
23762 {
23763 ...{
23764 data,
23765 field,
23766 onChange,
23767 hideLabelFromVision,
23768 markWhenOptional,
23769 validity,
23770 type: "url",
23771 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 }) })
23772 }
23773 }
23774 );
23775 }
23776
23777 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
23778 var import_components37 = __toESM(require_components(), 1);
23779 var import_element69 = __toESM(require_element(), 1);
23780 var import_i18n35 = __toESM(require_i18n(), 1);
23781 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
23782 var { ValidatedNumberControl } = unlock2(import_components37.privateApis);
23783 function toNumberOrEmpty(value) {
23784 if (value === "" || value === void 0) {
23785 return "";
23786 }
23787 const number = Number(value);
23788 return Number.isFinite(number) ? number : "";
23789 }
23790 function BetweenControls({
23791 value,
23792 onChange,
23793 hideLabelFromVision,
23794 step
23795 }) {
23796 const [min2 = "", max2 = ""] = value;
23797 const onChangeMin = (0, import_element69.useCallback)(
23798 (newValue) => onChange([toNumberOrEmpty(newValue), max2]),
23799 [onChange, max2]
23800 );
23801 const onChangeMax = (0, import_element69.useCallback)(
23802 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]),
23803 [onChange, min2]
23804 );
23805 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
23806 import_components37.BaseControl,
23807 {
23808 help: (0, import_i18n35.__)("The max. value must be greater than the min. value."),
23809 children: /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)(import_components37.Flex, { direction: "row", gap: 4, children: [
23810 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
23811 import_components37.__experimentalNumberControl,
23812 {
23813 label: (0, import_i18n35.__)("Min."),
23814 value: min2,
23815 max: max2 ? Number(max2) - step : void 0,
23816 onChange: onChangeMin,
23817 __next40pxDefaultSize: true,
23818 hideLabelFromVision,
23819 step
23820 }
23821 ),
23822 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
23823 import_components37.__experimentalNumberControl,
23824 {
23825 label: (0, import_i18n35.__)("Max."),
23826 value: max2,
23827 min: min2 ? Number(min2) + step : void 0,
23828 onChange: onChangeMax,
23829 __next40pxDefaultSize: true,
23830 hideLabelFromVision,
23831 step
23832 }
23833 )
23834 ] })
23835 }
23836 );
23837 }
23838 function ValidatedNumber({
23839 data,
23840 field,
23841 onChange,
23842 hideLabelFromVision,
23843 markWhenOptional,
23844 operator,
23845 validity
23846 }) {
23847 const decimals = field.format?.decimals ?? 0;
23848 const step = Math.pow(10, Math.abs(decimals) * -1);
23849 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23850 const value = getValue({ item: data }) ?? "";
23851 const disabled2 = field.isDisabled({ item: data, field });
23852 const onChangeControl = (0, import_element69.useCallback)(
23853 (newValue) => {
23854 onChange(
23855 setValue({
23856 item: data,
23857 // Do not convert an empty string or undefined to a number,
23858 // otherwise there's a mismatch between the UI control (empty)
23859 // and the data relied by onChange (0).
23860 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
23861 })
23862 );
23863 },
23864 [data, onChange, setValue]
23865 );
23866 const onChangeBetweenControls = (0, import_element69.useCallback)(
23867 (newValue) => {
23868 onChange(
23869 setValue({
23870 item: data,
23871 value: newValue
23872 })
23873 );
23874 },
23875 [data, onChange, setValue]
23876 );
23877 if (operator === OPERATOR_BETWEEN) {
23878 let valueBetween = ["", ""];
23879 if (Array.isArray(value) && value.length === 2 && value.every(
23880 (element) => typeof element === "number" || element === ""
23881 )) {
23882 valueBetween = value;
23883 }
23884 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
23885 BetweenControls,
23886 {
23887 value: valueBetween,
23888 onChange: onChangeBetweenControls,
23889 hideLabelFromVision,
23890 step
23891 }
23892 );
23893 }
23894 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
23895 ValidatedNumberControl,
23896 {
23897 required: !!isValid2.required,
23898 markWhenOptional,
23899 customValidity: getCustomValidity(isValid2, validity),
23900 label,
23901 help: description,
23902 value,
23903 onChange: onChangeControl,
23904 __next40pxDefaultSize: true,
23905 hideLabelFromVision,
23906 step,
23907 min: isValid2.min ? isValid2.min.constraint : void 0,
23908 max: isValid2.max ? isValid2.max.constraint : void 0,
23909 disabled: disabled2
23910 }
23911 );
23912 }
23913
23914 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
23915 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
23916 function Integer(props) {
23917 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(ValidatedNumber, { ...props });
23918 }
23919
23920 // packages/dataviews/build-module/components/dataform-controls/number.mjs
23921 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
23922 function Number2(props) {
23923 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(ValidatedNumber, { ...props });
23924 }
23925
23926 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
23927 var import_components38 = __toESM(require_components(), 1);
23928 var import_element70 = __toESM(require_element(), 1);
23929 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
23930 var { ValidatedRadioControl } = unlock2(import_components38.privateApis);
23931 function Radio({
23932 data,
23933 field,
23934 onChange,
23935 hideLabelFromVision,
23936 markWhenOptional,
23937 validity
23938 }) {
23939 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23940 const disabled2 = field.isDisabled({ item: data, field });
23941 const { elements, isLoading } = useElements({
23942 elements: field.elements,
23943 getElements: field.getElements
23944 });
23945 const value = getValue({ item: data });
23946 const onChangeControl = (0, import_element70.useCallback)(
23947 (newValue) => onChange(setValue({ item: data, value: newValue })),
23948 [data, onChange, setValue]
23949 );
23950 if (isLoading) {
23951 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components38.Spinner, {});
23952 }
23953 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
23954 ValidatedRadioControl,
23955 {
23956 required: !!field.isValid?.required,
23957 markWhenOptional,
23958 customValidity: getCustomValidity(isValid2, validity),
23959 label,
23960 help: description,
23961 onChange: onChangeControl,
23962 options: elements,
23963 selected: value,
23964 hideLabelFromVision,
23965 disabled: disabled2
23966 }
23967 );
23968 }
23969
23970 // packages/dataviews/build-module/components/dataform-controls/text.mjs
23971 var import_element71 = __toESM(require_element(), 1);
23972 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
23973 function Text3({
23974 data,
23975 field,
23976 onChange,
23977 hideLabelFromVision,
23978 markWhenOptional,
23979 config,
23980 validity
23981 }) {
23982 const { prefix, suffix } = config || {};
23983 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
23984 ValidatedText,
23985 {
23986 ...{
23987 data,
23988 field,
23989 onChange,
23990 hideLabelFromVision,
23991 markWhenOptional,
23992 validity,
23993 prefix: prefix ? (0, import_element71.createElement)(prefix) : void 0,
23994 suffix: suffix ? (0, import_element71.createElement)(suffix) : void 0
23995 }
23996 }
23997 );
23998 }
23999
24000 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
24001 var import_components39 = __toESM(require_components(), 1);
24002 var import_element72 = __toESM(require_element(), 1);
24003 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
24004 var { ValidatedToggleControl } = unlock2(import_components39.privateApis);
24005 function Toggle({
24006 field,
24007 onChange,
24008 data,
24009 hideLabelFromVision,
24010 markWhenOptional,
24011 validity
24012 }) {
24013 const { label, description, getValue, setValue, isValid: isValid2 } = field;
24014 const disabled2 = field.isDisabled({ item: data, field });
24015 const onChangeControl = (0, import_element72.useCallback)(() => {
24016 onChange(
24017 setValue({ item: data, value: !getValue({ item: data }) })
24018 );
24019 }, [onChange, setValue, data, getValue]);
24020 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
24021 ValidatedToggleControl,
24022 {
24023 required: !!isValid2.required,
24024 markWhenOptional,
24025 customValidity: getCustomValidity(isValid2, validity),
24026 hidden: hideLabelFromVision,
24027 label,
24028 help: description,
24029 checked: getValue({ item: data }),
24030 onChange: onChangeControl,
24031 disabled: disabled2
24032 }
24033 );
24034 }
24035
24036 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
24037 var import_components40 = __toESM(require_components(), 1);
24038 var import_element73 = __toESM(require_element(), 1);
24039 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
24040 var { ValidatedTextareaControl } = unlock2(import_components40.privateApis);
24041 function Textarea({
24042 data,
24043 field,
24044 onChange,
24045 hideLabelFromVision,
24046 markWhenOptional,
24047 config,
24048 validity
24049 }) {
24050 const { rows = 4 } = config || {};
24051 const disabled2 = field.isDisabled({ item: data, field });
24052 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
24053 const value = field.getValue({ item: data });
24054 const onChangeControl = (0, import_element73.useCallback)(
24055 (newValue) => onChange(setValue({ item: data, value: newValue })),
24056 [data, onChange, setValue]
24057 );
24058 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
24059 ValidatedTextareaControl,
24060 {
24061 required: !!isValid2.required,
24062 markWhenOptional,
24063 customValidity: getCustomValidity(isValid2, validity),
24064 label,
24065 placeholder,
24066 value: value ?? "",
24067 help: description,
24068 onChange: onChangeControl,
24069 rows,
24070 disabled: disabled2,
24071 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
24072 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
24073 __next40pxDefaultSize: true,
24074 hideLabelFromVision
24075 }
24076 );
24077 }
24078
24079 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
24080 var import_components41 = __toESM(require_components(), 1);
24081 var import_element74 = __toESM(require_element(), 1);
24082 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
24083 var { ValidatedToggleGroupControl } = unlock2(import_components41.privateApis);
24084 function ToggleGroup({
24085 data,
24086 field,
24087 onChange,
24088 hideLabelFromVision,
24089 markWhenOptional,
24090 validity
24091 }) {
24092 const { getValue, setValue, isValid: isValid2 } = field;
24093 const disabled2 = field.isDisabled({ item: data, field });
24094 const value = getValue({ item: data });
24095 const onChangeControl = (0, import_element74.useCallback)(
24096 (newValue) => onChange(setValue({ item: data, value: newValue })),
24097 [data, onChange, setValue]
24098 );
24099 const { elements, isLoading } = useElements({
24100 elements: field.elements,
24101 getElements: field.getElements
24102 });
24103 if (isLoading) {
24104 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_components41.Spinner, {});
24105 }
24106 if (elements.length === 0) {
24107 return null;
24108 }
24109 const selectedOption = elements.find((el) => el.value === value);
24110 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24111 ValidatedToggleGroupControl,
24112 {
24113 required: !!field.isValid?.required,
24114 markWhenOptional,
24115 customValidity: getCustomValidity(isValid2, validity),
24116 __next40pxDefaultSize: true,
24117 isBlock: true,
24118 label: field.label,
24119 help: selectedOption?.description || field.description,
24120 onChange: onChangeControl,
24121 value,
24122 hideLabelFromVision,
24123 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24124 import_components41.__experimentalToggleGroupControlOption,
24125 {
24126 label: el.label,
24127 value: el.value,
24128 disabled: disabled2
24129 },
24130 el.value
24131 ))
24132 }
24133 );
24134 }
24135
24136 // packages/dataviews/build-module/components/dataform-controls/array.mjs
24137 var import_components42 = __toESM(require_components(), 1);
24138 var import_element75 = __toESM(require_element(), 1);
24139 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
24140 var { ValidatedFormTokenField } = unlock2(import_components42.privateApis);
24141 function ArrayControl({
24142 data,
24143 field,
24144 onChange,
24145 hideLabelFromVision,
24146 markWhenOptional,
24147 validity
24148 }) {
24149 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
24150 const value = getValue({ item: data });
24151 const disabled2 = field.isDisabled({ item: data, field });
24152 const { elements, isLoading } = useElements({
24153 elements: field.elements,
24154 getElements: field.getElements
24155 });
24156 const arrayValueAsElements = (0, import_element75.useMemo)(
24157 () => Array.isArray(value) ? value.map((token) => {
24158 const element = elements?.find(
24159 (suggestion) => suggestion.value === token
24160 );
24161 return element || { value: token, label: token };
24162 }) : [],
24163 [value, elements]
24164 );
24165 const onChangeControl = (0, import_element75.useCallback)(
24166 (tokens) => {
24167 const valueTokens = tokens.map((token) => {
24168 if (typeof token === "object" && "value" in token) {
24169 return token.value;
24170 }
24171 return token;
24172 });
24173 onChange(setValue({ item: data, value: valueTokens }));
24174 },
24175 [onChange, setValue, data]
24176 );
24177 if (isLoading) {
24178 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_components42.Spinner, {});
24179 }
24180 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
24181 ValidatedFormTokenField,
24182 {
24183 required: !!isValid2?.required,
24184 markWhenOptional,
24185 customValidity: getCustomValidity(isValid2, validity),
24186 label: hideLabelFromVision ? void 0 : label,
24187 value: arrayValueAsElements,
24188 onChange: onChangeControl,
24189 placeholder,
24190 suggestions: elements?.map((element) => element.value),
24191 disabled: disabled2,
24192 __experimentalValidateInput: (token) => {
24193 if (field.isValid?.elements && elements) {
24194 return elements.some(
24195 (element) => element.value === token || element.label === token
24196 );
24197 }
24198 return true;
24199 },
24200 __experimentalExpandOnFocus: elements && elements.length > 0,
24201 help: description ?? (field.isValid?.elements ? "" : void 0),
24202 displayTransform: (token) => {
24203 if (typeof token === "object" && "label" in token) {
24204 return token.label;
24205 }
24206 if (typeof token === "string" && elements) {
24207 const element = elements.find(
24208 (el) => el.value === token
24209 );
24210 return element?.label || token;
24211 }
24212 return token;
24213 },
24214 __experimentalRenderItem: ({ item }) => {
24215 if (typeof item === "string" && elements) {
24216 const element = elements.find(
24217 (el) => el.value === item
24218 );
24219 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("span", { children: element?.label || item });
24220 }
24221 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("span", { children: item });
24222 }
24223 }
24224 );
24225 }
24226
24227 // node_modules/colord/index.mjs
24228 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
24229 var t = function(r3) {
24230 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
24231 };
24232 var n = function(r3, t2, n2) {
24233 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
24234 };
24235 var e = function(r3, t2, n2) {
24236 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
24237 };
24238 var u = function(r3) {
24239 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
24240 };
24241 var a = function(r3) {
24242 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
24243 };
24244 var o = function(r3) {
24245 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
24246 };
24247 var i = /^#([0-9a-f]{3,8})$/i;
24248 var s = function(r3) {
24249 var t2 = r3.toString(16);
24250 return t2.length < 2 ? "0" + t2 : t2;
24251 };
24252 var h = function(r3) {
24253 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;
24254 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
24255 };
24256 var b = function(r3) {
24257 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
24258 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
24259 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;
24260 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 };
24261 };
24262 var g = function(r3) {
24263 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
24264 };
24265 var d = function(r3) {
24266 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
24267 };
24268 var f = function(r3) {
24269 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 }));
24270 var t2, n2, e2;
24271 };
24272 var c = function(r3) {
24273 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 };
24274 var t2, n2, e2, u2;
24275 };
24276 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24277 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24278 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24279 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24280 var y = { string: [[function(r3) {
24281 var t2 = i.exec(r3);
24282 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;
24283 }, "hex"], [function(r3) {
24284 var t2 = v.exec(r3) || m.exec(r3);
24285 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;
24286 }, "rgb"], [function(t2) {
24287 var n2 = l.exec(t2) || p.exec(t2);
24288 if (!n2) return null;
24289 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) });
24290 return f(a2);
24291 }, "hsl"]], object: [[function(r3) {
24292 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
24293 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
24294 }, "rgb"], [function(r3) {
24295 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
24296 if (!t(n2) || !t(e2) || !t(u2)) return null;
24297 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
24298 return f(i2);
24299 }, "hsl"], [function(r3) {
24300 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
24301 if (!t(n2) || !t(a2) || !t(o2)) return null;
24302 var h2 = (function(r4) {
24303 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
24304 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
24305 return b(h2);
24306 }, "hsv"]] };
24307 var N = function(r3, t2) {
24308 for (var n2 = 0; n2 < t2.length; n2++) {
24309 var e2 = t2[n2][0](r3);
24310 if (e2) return [e2, t2[n2][1]];
24311 }
24312 return [null, void 0];
24313 };
24314 var x = function(r3) {
24315 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
24316 };
24317 var M = function(r3, t2) {
24318 var n2 = c(r3);
24319 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
24320 };
24321 var H = function(r3) {
24322 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
24323 };
24324 var $ = function(r3, t2) {
24325 var n2 = c(r3);
24326 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
24327 };
24328 var j = (function() {
24329 function r3(r4) {
24330 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
24331 }
24332 return r3.prototype.isValid = function() {
24333 return null !== this.parsed;
24334 }, r3.prototype.brightness = function() {
24335 return n(H(this.rgba), 2);
24336 }, r3.prototype.isDark = function() {
24337 return H(this.rgba) < 0.5;
24338 }, r3.prototype.isLight = function() {
24339 return H(this.rgba) >= 0.5;
24340 }, r3.prototype.toHex = function() {
24341 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;
24342 var r4, t2, e2, u2, a2, i2;
24343 }, r3.prototype.toRgb = function() {
24344 return o(this.rgba);
24345 }, r3.prototype.toRgbString = function() {
24346 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 + ")";
24347 var r4, t2, n2, e2, u2;
24348 }, r3.prototype.toHsl = function() {
24349 return d(c(this.rgba));
24350 }, r3.prototype.toHslString = function() {
24351 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 + "%)";
24352 var r4, t2, n2, e2, u2;
24353 }, r3.prototype.toHsv = function() {
24354 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
24355 var r4;
24356 }, r3.prototype.invert = function() {
24357 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
24358 var r4;
24359 }, r3.prototype.saturate = function(r4) {
24360 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
24361 }, r3.prototype.desaturate = function(r4) {
24362 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
24363 }, r3.prototype.grayscale = function() {
24364 return w(M(this.rgba, -1));
24365 }, r3.prototype.lighten = function(r4) {
24366 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
24367 }, r3.prototype.darken = function(r4) {
24368 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
24369 }, r3.prototype.rotate = function(r4) {
24370 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
24371 }, r3.prototype.alpha = function(r4) {
24372 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
24373 var t2;
24374 }, r3.prototype.hue = function(r4) {
24375 var t2 = c(this.rgba);
24376 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
24377 }, r3.prototype.isEqual = function(r4) {
24378 return this.toHex() === w(r4).toHex();
24379 }, r3;
24380 })();
24381 var w = function(r3) {
24382 return r3 instanceof j ? r3 : new j(r3);
24383 };
24384
24385 // packages/dataviews/build-module/components/dataform-controls/color.mjs
24386 var import_components43 = __toESM(require_components(), 1);
24387 var import_element76 = __toESM(require_element(), 1);
24388 var import_i18n36 = __toESM(require_i18n(), 1);
24389 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
24390 var { ValidatedInputControl: ValidatedInputControl3 } = unlock2(import_components43.privateApis);
24391 var ColorPickerDropdown = ({
24392 color,
24393 onColorChange,
24394 disabled: disabled2
24395 }) => {
24396 const validColor = color && w(color).isValid() ? color : "#ffffff";
24397 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24398 import_components43.Dropdown,
24399 {
24400 className: "dataviews-controls__color-picker-dropdown",
24401 popoverProps: { resize: false },
24402 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24403 import_components43.Button,
24404 {
24405 onClick: onToggle,
24406 "aria-label": (0, import_i18n36.__)("Open color picker"),
24407 size: "small",
24408 disabled: disabled2,
24409 accessibleWhenDisabled: true,
24410 icon: () => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_components43.ColorIndicator, { colorValue: validColor })
24411 }
24412 ),
24413 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_components43.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24414 import_components43.ColorPicker,
24415 {
24416 color: validColor,
24417 onChange: onColorChange,
24418 enableAlpha: true
24419 }
24420 ) })
24421 }
24422 );
24423 };
24424 function Color({
24425 data,
24426 field,
24427 onChange,
24428 hideLabelFromVision,
24429 markWhenOptional,
24430 validity
24431 }) {
24432 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
24433 const disabled2 = field.isDisabled({ item: data, field });
24434 const value = field.getValue({ item: data }) || "";
24435 const handleColorChange = (0, import_element76.useCallback)(
24436 (newColor) => {
24437 onChange(setValue({ item: data, value: newColor }));
24438 },
24439 [data, onChange, setValue]
24440 );
24441 const handleInputChange = (0, import_element76.useCallback)(
24442 (newValue) => {
24443 onChange(setValue({ item: data, value: newValue || "" }));
24444 },
24445 [data, onChange, setValue]
24446 );
24447 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24448 ValidatedInputControl3,
24449 {
24450 required: !!field.isValid?.required,
24451 markWhenOptional,
24452 customValidity: getCustomValidity(isValid2, validity),
24453 label,
24454 placeholder,
24455 value,
24456 help: description,
24457 onChange: handleInputChange,
24458 hideLabelFromVision,
24459 type: "text",
24460 disabled: disabled2,
24461 prefix: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_components43.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24462 ColorPickerDropdown,
24463 {
24464 color: value,
24465 onColorChange: handleColorChange,
24466 disabled: disabled2
24467 }
24468 ) })
24469 }
24470 );
24471 }
24472
24473 // packages/dataviews/build-module/components/dataform-controls/password.mjs
24474 var import_components44 = __toESM(require_components(), 1);
24475 var import_element77 = __toESM(require_element(), 1);
24476 var import_i18n37 = __toESM(require_i18n(), 1);
24477 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
24478 function Password({
24479 data,
24480 field,
24481 onChange,
24482 hideLabelFromVision,
24483 markWhenOptional,
24484 validity
24485 }) {
24486 const [isVisible2, setIsVisible] = (0, import_element77.useState)(false);
24487 const disabled2 = field.isDisabled({ item: data, field });
24488 const toggleVisibility = (0, import_element77.useCallback)(() => {
24489 setIsVisible((prev) => !prev);
24490 }, []);
24491 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24492 ValidatedText,
24493 {
24494 ...{
24495 data,
24496 field,
24497 onChange,
24498 hideLabelFromVision,
24499 markWhenOptional,
24500 validity,
24501 type: isVisible2 ? "text" : "password",
24502 suffix: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_components44.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24503 import_components44.Button,
24504 {
24505 icon: isVisible2 ? unseen_default : seen_default,
24506 onClick: toggleVisibility,
24507 size: "small",
24508 label: isVisible2 ? (0, import_i18n37.__)("Hide password") : (0, import_i18n37.__)("Show password"),
24509 disabled: disabled2,
24510 accessibleWhenDisabled: true
24511 }
24512 ) })
24513 }
24514 }
24515 );
24516 }
24517
24518 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
24519 function hasElements(field) {
24520 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
24521 }
24522
24523 // packages/dataviews/build-module/components/dataform-controls/index.mjs
24524 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
24525 var FORM_CONTROLS = {
24526 adaptiveSelect: AdaptiveSelect,
24527 array: ArrayControl,
24528 checkbox: Checkbox,
24529 color: Color,
24530 combobox: Combobox3,
24531 datetime: DateTime,
24532 date: DateControl,
24533 email: Email,
24534 telephone: Telephone,
24535 url: Url,
24536 integer: Integer,
24537 number: Number2,
24538 password: Password,
24539 radio: Radio,
24540 select: Select,
24541 text: Text3,
24542 toggle: Toggle,
24543 textarea: Textarea,
24544 toggleGroup: ToggleGroup
24545 };
24546 function isEditConfig(value) {
24547 return value && typeof value === "object" && typeof value.control === "string";
24548 }
24549 function createConfiguredControl(config) {
24550 const { control, ...controlConfig } = config;
24551 const BaseControlType = getControlByType(control);
24552 if (BaseControlType === null) {
24553 return null;
24554 }
24555 return function ConfiguredControl(props) {
24556 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(BaseControlType, { ...props, config: controlConfig });
24557 };
24558 }
24559 function getControl(field, fallback) {
24560 if (typeof field.Edit === "function") {
24561 return field.Edit;
24562 }
24563 if (typeof field.Edit === "string") {
24564 return getControlByType(field.Edit);
24565 }
24566 if (isEditConfig(field.Edit)) {
24567 return createConfiguredControl(field.Edit);
24568 }
24569 if (hasElements(field) && field.type !== "array") {
24570 return getControlByType("adaptiveSelect");
24571 }
24572 if (fallback === null) {
24573 return null;
24574 }
24575 return getControlByType(fallback);
24576 }
24577 function getControlByType(type) {
24578 if (Object.keys(FORM_CONTROLS).includes(type)) {
24579 return FORM_CONTROLS[type];
24580 }
24581 return null;
24582 }
24583
24584 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
24585 function getFilterBy(field, defaultOperators, validOperators) {
24586 if (field.filterBy === false) {
24587 return false;
24588 }
24589 const operators = field.filterBy?.operators?.filter(
24590 (op) => validOperators.includes(op)
24591 ) ?? defaultOperators;
24592 if (operators.length === 0) {
24593 return false;
24594 }
24595 return {
24596 isPrimary: !!field.filterBy?.isPrimary,
24597 operators
24598 };
24599 }
24600 var get_filter_by_default = getFilterBy;
24601
24602 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
24603 var getValueFromId = (id) => ({ item }) => {
24604 const path = id.split(".");
24605 let value = item;
24606 for (const segment of path) {
24607 if (value.hasOwnProperty(segment)) {
24608 value = value[segment];
24609 } else {
24610 value = void 0;
24611 }
24612 }
24613 return value;
24614 };
24615 var get_value_from_id_default = getValueFromId;
24616
24617 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
24618 var setValueFromId = (id) => ({ value }) => {
24619 const path = id.split(".");
24620 const result = {};
24621 let current = result;
24622 for (const segment of path.slice(0, -1)) {
24623 current[segment] = {};
24624 current = current[segment];
24625 }
24626 current[path.at(-1)] = value;
24627 return result;
24628 };
24629 var set_value_from_id_default = setValueFromId;
24630
24631 // packages/dataviews/build-module/field-types/email.mjs
24632 var import_i18n38 = __toESM(require_i18n(), 1);
24633
24634 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
24635 function RenderFromElements({
24636 item,
24637 field
24638 }) {
24639 const { elements, isLoading } = useElements({
24640 elements: field.elements,
24641 getElements: field.getElements
24642 });
24643 const value = field.getValue({ item });
24644 if (isLoading) {
24645 return value;
24646 }
24647 if (elements.length === 0) {
24648 return value;
24649 }
24650 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
24651 }
24652
24653 // packages/dataviews/build-module/field-types/utils/render-default.mjs
24654 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
24655 function render({
24656 item,
24657 field
24658 }) {
24659 if (field.hasElements) {
24660 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(RenderFromElements, { item, field });
24661 }
24662 return field.getValueFormatted({ item, field });
24663 }
24664
24665 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
24666 var sort_text_default = (a2, b2, direction) => {
24667 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
24668 };
24669
24670 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
24671 function isValidRequired(item, field) {
24672 const value = field.getValue({ item });
24673 return ![void 0, "", null].includes(value);
24674 }
24675
24676 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
24677 function isValidMinLength(item, field) {
24678 if (typeof field.isValid.minLength?.constraint !== "number") {
24679 return false;
24680 }
24681 const value = field.getValue({ item });
24682 if ([void 0, "", null].includes(value)) {
24683 return true;
24684 }
24685 return String(value).length >= field.isValid.minLength.constraint;
24686 }
24687
24688 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
24689 function isValidMaxLength(item, field) {
24690 if (typeof field.isValid.maxLength?.constraint !== "number") {
24691 return false;
24692 }
24693 const value = field.getValue({ item });
24694 if ([void 0, "", null].includes(value)) {
24695 return true;
24696 }
24697 return String(value).length <= field.isValid.maxLength.constraint;
24698 }
24699
24700 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
24701 function isValidPattern(item, field) {
24702 if (field.isValid.pattern?.constraint === void 0) {
24703 return true;
24704 }
24705 try {
24706 const regexp = new RegExp(field.isValid.pattern.constraint);
24707 const value = field.getValue({ item });
24708 if ([void 0, "", null].includes(value)) {
24709 return true;
24710 }
24711 return regexp.test(String(value));
24712 } catch {
24713 return false;
24714 }
24715 }
24716
24717 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
24718 function isValidElements(item, field) {
24719 const elements = field.elements ?? [];
24720 const validValues = elements.map((el) => el.value);
24721 if (validValues.length === 0) {
24722 return true;
24723 }
24724 const value = field.getValue({ item });
24725 return [].concat(value).every((v2) => validValues.includes(v2));
24726 }
24727
24728 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
24729 function getValueFormatted({
24730 item,
24731 field
24732 }) {
24733 return field.getValue({ item });
24734 }
24735 var get_value_formatted_default_default = getValueFormatted;
24736
24737 // packages/dataviews/build-module/field-types/email.mjs
24738 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])?)*$/;
24739 function isValidCustom(item, field) {
24740 const value = field.getValue({ item });
24741 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
24742 return (0, import_i18n38.__)("Value must be a valid email address.");
24743 }
24744 return null;
24745 }
24746 var email_default = {
24747 type: "email",
24748 render,
24749 Edit: "email",
24750 sort: sort_text_default,
24751 enableSorting: true,
24752 enableGlobalSearch: false,
24753 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24754 validOperators: [
24755 OPERATOR_IS,
24756 OPERATOR_IS_NOT,
24757 OPERATOR_CONTAINS,
24758 OPERATOR_NOT_CONTAINS,
24759 OPERATOR_STARTS_WITH,
24760 // Multiple selection
24761 OPERATOR_IS_ANY,
24762 OPERATOR_IS_NONE,
24763 OPERATOR_IS_ALL,
24764 OPERATOR_IS_NOT_ALL
24765 ],
24766 format: {},
24767 getValueFormatted: get_value_formatted_default_default,
24768 validate: {
24769 required: isValidRequired,
24770 pattern: isValidPattern,
24771 minLength: isValidMinLength,
24772 maxLength: isValidMaxLength,
24773 elements: isValidElements,
24774 custom: isValidCustom
24775 }
24776 };
24777
24778 // packages/dataviews/build-module/field-types/integer.mjs
24779 var import_i18n39 = __toESM(require_i18n(), 1);
24780
24781 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
24782 var sort_number_default = (a2, b2, direction) => {
24783 return direction === "asc" ? a2 - b2 : b2 - a2;
24784 };
24785
24786 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
24787 function isValidMin(item, field) {
24788 if (typeof field.isValid.min?.constraint !== "number") {
24789 return false;
24790 }
24791 const value = field.getValue({ item });
24792 if ([void 0, "", null].includes(value)) {
24793 return true;
24794 }
24795 return Number(value) >= field.isValid.min.constraint;
24796 }
24797
24798 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
24799 function isValidMax(item, field) {
24800 if (typeof field.isValid.max?.constraint !== "number") {
24801 return false;
24802 }
24803 const value = field.getValue({ item });
24804 if ([void 0, "", null].includes(value)) {
24805 return true;
24806 }
24807 return Number(value) <= field.isValid.max.constraint;
24808 }
24809
24810 // packages/dataviews/build-module/field-types/integer.mjs
24811 var format2 = {
24812 separatorThousand: ","
24813 };
24814 function getValueFormatted2({
24815 item,
24816 field
24817 }) {
24818 let value = field.getValue({ item });
24819 if (value === null || value === void 0) {
24820 return "";
24821 }
24822 value = Number(value);
24823 if (!Number.isFinite(value)) {
24824 return String(value);
24825 }
24826 let formatInteger;
24827 if (field.type !== "integer") {
24828 formatInteger = format2;
24829 } else {
24830 formatInteger = field.format;
24831 }
24832 const { separatorThousand } = formatInteger;
24833 const integerValue = Math.trunc(value);
24834 if (!separatorThousand) {
24835 return String(integerValue);
24836 }
24837 return String(integerValue).replace(
24838 /\B(?=(\d{3})+(?!\d))/g,
24839 separatorThousand
24840 );
24841 }
24842 function isValidCustom2(item, field) {
24843 const value = field.getValue({ item });
24844 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
24845 return (0, import_i18n39.__)("Value must be an integer.");
24846 }
24847 return null;
24848 }
24849 var integer_default = {
24850 type: "integer",
24851 render,
24852 Edit: "integer",
24853 sort: sort_number_default,
24854 enableSorting: true,
24855 enableGlobalSearch: false,
24856 defaultOperators: [
24857 OPERATOR_IS,
24858 OPERATOR_IS_NOT,
24859 OPERATOR_LESS_THAN,
24860 OPERATOR_GREATER_THAN,
24861 OPERATOR_LESS_THAN_OR_EQUAL,
24862 OPERATOR_GREATER_THAN_OR_EQUAL,
24863 OPERATOR_BETWEEN
24864 ],
24865 validOperators: [
24866 // Single-selection
24867 OPERATOR_IS,
24868 OPERATOR_IS_NOT,
24869 OPERATOR_LESS_THAN,
24870 OPERATOR_GREATER_THAN,
24871 OPERATOR_LESS_THAN_OR_EQUAL,
24872 OPERATOR_GREATER_THAN_OR_EQUAL,
24873 OPERATOR_BETWEEN,
24874 // Multiple-selection
24875 OPERATOR_IS_ANY,
24876 OPERATOR_IS_NONE,
24877 OPERATOR_IS_ALL,
24878 OPERATOR_IS_NOT_ALL
24879 ],
24880 format: format2,
24881 getValueFormatted: getValueFormatted2,
24882 validate: {
24883 required: isValidRequired,
24884 min: isValidMin,
24885 max: isValidMax,
24886 elements: isValidElements,
24887 custom: isValidCustom2
24888 }
24889 };
24890
24891 // packages/dataviews/build-module/field-types/number.mjs
24892 var import_i18n40 = __toESM(require_i18n(), 1);
24893 var format3 = {
24894 separatorThousand: ",",
24895 separatorDecimal: ".",
24896 decimals: 2
24897 };
24898 function getValueFormatted3({
24899 item,
24900 field
24901 }) {
24902 let value = field.getValue({ item });
24903 if (value === null || value === void 0) {
24904 return "";
24905 }
24906 value = Number(value);
24907 if (!Number.isFinite(value)) {
24908 return String(value);
24909 }
24910 let formatNumber;
24911 if (field.type !== "number") {
24912 formatNumber = format3;
24913 } else {
24914 formatNumber = field.format;
24915 }
24916 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
24917 const fixedValue = value.toFixed(decimals);
24918 const [integerPart, decimalPart] = fixedValue.split(".");
24919 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
24920 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
24921 }
24922 function isEmpty2(value) {
24923 return value === "" || value === void 0 || value === null;
24924 }
24925 function isValidCustom3(item, field) {
24926 const value = field.getValue({ item });
24927 if (!isEmpty2(value) && !Number.isFinite(value)) {
24928 return (0, import_i18n40.__)("Value must be a number.");
24929 }
24930 return null;
24931 }
24932 var number_default = {
24933 type: "number",
24934 render,
24935 Edit: "number",
24936 sort: sort_number_default,
24937 enableSorting: true,
24938 enableGlobalSearch: false,
24939 defaultOperators: [
24940 OPERATOR_IS,
24941 OPERATOR_IS_NOT,
24942 OPERATOR_LESS_THAN,
24943 OPERATOR_GREATER_THAN,
24944 OPERATOR_LESS_THAN_OR_EQUAL,
24945 OPERATOR_GREATER_THAN_OR_EQUAL,
24946 OPERATOR_BETWEEN
24947 ],
24948 validOperators: [
24949 // Single-selection
24950 OPERATOR_IS,
24951 OPERATOR_IS_NOT,
24952 OPERATOR_LESS_THAN,
24953 OPERATOR_GREATER_THAN,
24954 OPERATOR_LESS_THAN_OR_EQUAL,
24955 OPERATOR_GREATER_THAN_OR_EQUAL,
24956 OPERATOR_BETWEEN,
24957 // Multiple-selection
24958 OPERATOR_IS_ANY,
24959 OPERATOR_IS_NONE,
24960 OPERATOR_IS_ALL,
24961 OPERATOR_IS_NOT_ALL
24962 ],
24963 format: format3,
24964 getValueFormatted: getValueFormatted3,
24965 validate: {
24966 required: isValidRequired,
24967 min: isValidMin,
24968 max: isValidMax,
24969 elements: isValidElements,
24970 custom: isValidCustom3
24971 }
24972 };
24973
24974 // packages/dataviews/build-module/field-types/text.mjs
24975 var text_default = {
24976 type: "text",
24977 render,
24978 Edit: "text",
24979 sort: sort_text_default,
24980 enableSorting: true,
24981 enableGlobalSearch: false,
24982 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24983 validOperators: [
24984 // Single selection
24985 OPERATOR_IS,
24986 OPERATOR_IS_NOT,
24987 OPERATOR_CONTAINS,
24988 OPERATOR_NOT_CONTAINS,
24989 OPERATOR_STARTS_WITH,
24990 // Multiple selection
24991 OPERATOR_IS_ANY,
24992 OPERATOR_IS_NONE,
24993 OPERATOR_IS_ALL,
24994 OPERATOR_IS_NOT_ALL
24995 ],
24996 format: {},
24997 getValueFormatted: get_value_formatted_default_default,
24998 validate: {
24999 required: isValidRequired,
25000 pattern: isValidPattern,
25001 minLength: isValidMinLength,
25002 maxLength: isValidMaxLength,
25003 elements: isValidElements
25004 }
25005 };
25006
25007 // packages/dataviews/build-module/field-types/datetime.mjs
25008 var import_date7 = __toESM(require_date(), 1);
25009
25010 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
25011 var import_date6 = __toESM(require_date(), 1);
25012 function parseDateLike(value) {
25013 if (!value) {
25014 return null;
25015 }
25016 if (!isValid(new Date(value))) {
25017 return null;
25018 }
25019 const parsed = (0, import_date6.getDate)(value);
25020 return parsed && isValid(parsed) ? parsed : null;
25021 }
25022 function validateDateLikeBoundary(item, field, boundary) {
25023 const constraint = field.isValid[boundary]?.constraint;
25024 if (typeof constraint !== "string") {
25025 return false;
25026 }
25027 const value = field.getValue({ item });
25028 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
25029 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
25030 return true;
25031 }
25032 const parsedConstraint = parseDateLike(constraint);
25033 const parsedValue = parseDateLike(String(boundaryValue));
25034 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
25035 }
25036 function isValidMinDate(item, field) {
25037 return validateDateLikeBoundary(item, field, "min");
25038 }
25039 function isValidMaxDate(item, field) {
25040 return validateDateLikeBoundary(item, field, "max");
25041 }
25042
25043 // packages/dataviews/build-module/field-types/datetime.mjs
25044 var format4 = {
25045 datetime: (0, import_date7.getSettings)().formats.datetime,
25046 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
25047 };
25048 function getValueFormatted4({
25049 item,
25050 field
25051 }) {
25052 const value = field.getValue({ item });
25053 if (["", void 0, null].includes(value)) {
25054 return "";
25055 }
25056 let formatDatetime;
25057 if (field.type !== "datetime") {
25058 formatDatetime = format4;
25059 } else {
25060 formatDatetime = field.format;
25061 }
25062 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
25063 }
25064 var sort = (a2, b2, direction) => {
25065 const timeA = new Date(a2).getTime();
25066 const timeB = new Date(b2).getTime();
25067 return direction === "asc" ? timeA - timeB : timeB - timeA;
25068 };
25069 var datetime_default = {
25070 type: "datetime",
25071 render,
25072 Edit: "datetime",
25073 sort,
25074 enableSorting: true,
25075 enableGlobalSearch: false,
25076 defaultOperators: [
25077 OPERATOR_ON,
25078 OPERATOR_NOT_ON,
25079 OPERATOR_BEFORE,
25080 OPERATOR_AFTER,
25081 OPERATOR_BEFORE_INC,
25082 OPERATOR_AFTER_INC,
25083 OPERATOR_IN_THE_PAST,
25084 OPERATOR_OVER
25085 ],
25086 validOperators: [
25087 OPERATOR_ON,
25088 OPERATOR_NOT_ON,
25089 OPERATOR_BEFORE,
25090 OPERATOR_AFTER,
25091 OPERATOR_BEFORE_INC,
25092 OPERATOR_AFTER_INC,
25093 OPERATOR_IN_THE_PAST,
25094 OPERATOR_OVER
25095 ],
25096 format: format4,
25097 getValueFormatted: getValueFormatted4,
25098 validate: {
25099 required: isValidRequired,
25100 elements: isValidElements,
25101 min: isValidMinDate,
25102 max: isValidMaxDate
25103 }
25104 };
25105
25106 // packages/dataviews/build-module/field-types/date.mjs
25107 var import_date8 = __toESM(require_date(), 1);
25108 var format5 = {
25109 date: (0, import_date8.getSettings)().formats.date,
25110 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
25111 };
25112 function getValueFormatted5({
25113 item,
25114 field
25115 }) {
25116 const value = field.getValue({ item });
25117 if (["", void 0, null].includes(value)) {
25118 return "";
25119 }
25120 let formatDate2;
25121 if (field.type !== "date") {
25122 formatDate2 = format5;
25123 } else {
25124 formatDate2 = field.format;
25125 }
25126 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
25127 }
25128 var sort2 = (a2, b2, direction) => {
25129 const timeA = new Date(a2).getTime();
25130 const timeB = new Date(b2).getTime();
25131 return direction === "asc" ? timeA - timeB : timeB - timeA;
25132 };
25133 var date_default = {
25134 type: "date",
25135 render,
25136 Edit: "date",
25137 sort: sort2,
25138 enableSorting: true,
25139 enableGlobalSearch: false,
25140 defaultOperators: [
25141 OPERATOR_ON,
25142 OPERATOR_NOT_ON,
25143 OPERATOR_BEFORE,
25144 OPERATOR_AFTER,
25145 OPERATOR_BEFORE_INC,
25146 OPERATOR_AFTER_INC,
25147 OPERATOR_IN_THE_PAST,
25148 OPERATOR_OVER,
25149 OPERATOR_BETWEEN
25150 ],
25151 validOperators: [
25152 OPERATOR_ON,
25153 OPERATOR_NOT_ON,
25154 OPERATOR_BEFORE,
25155 OPERATOR_AFTER,
25156 OPERATOR_BEFORE_INC,
25157 OPERATOR_AFTER_INC,
25158 OPERATOR_IN_THE_PAST,
25159 OPERATOR_OVER,
25160 OPERATOR_BETWEEN
25161 ],
25162 format: format5,
25163 getValueFormatted: getValueFormatted5,
25164 validate: {
25165 required: isValidRequired,
25166 elements: isValidElements,
25167 min: isValidMinDate,
25168 max: isValidMaxDate
25169 }
25170 };
25171
25172 // packages/dataviews/build-module/field-types/boolean.mjs
25173 var import_i18n41 = __toESM(require_i18n(), 1);
25174
25175 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
25176 function isValidRequiredForBool(item, field) {
25177 const value = field.getValue({ item });
25178 return value === true;
25179 }
25180
25181 // packages/dataviews/build-module/field-types/boolean.mjs
25182 function getValueFormatted6({
25183 item,
25184 field
25185 }) {
25186 const value = field.getValue({ item });
25187 if (value === true) {
25188 return (0, import_i18n41.__)("True");
25189 }
25190 if (value === false) {
25191 return (0, import_i18n41.__)("False");
25192 }
25193 return "";
25194 }
25195 function isValidCustom4(item, field) {
25196 const value = field.getValue({ item });
25197 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
25198 return (0, import_i18n41.__)("Value must be true, false, or undefined");
25199 }
25200 return null;
25201 }
25202 var sort3 = (a2, b2, direction) => {
25203 const boolA = Boolean(a2);
25204 const boolB = Boolean(b2);
25205 if (boolA === boolB) {
25206 return 0;
25207 }
25208 if (direction === "asc") {
25209 return boolA ? 1 : -1;
25210 }
25211 return boolA ? -1 : 1;
25212 };
25213 var boolean_default = {
25214 type: "boolean",
25215 render,
25216 Edit: "checkbox",
25217 sort: sort3,
25218 validate: {
25219 required: isValidRequiredForBool,
25220 elements: isValidElements,
25221 custom: isValidCustom4
25222 },
25223 enableSorting: true,
25224 enableGlobalSearch: false,
25225 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25226 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25227 format: {},
25228 getValueFormatted: getValueFormatted6
25229 };
25230
25231 // packages/dataviews/build-module/field-types/media.mjs
25232 var media_default = {
25233 type: "media",
25234 render: () => null,
25235 Edit: null,
25236 sort: () => 0,
25237 enableSorting: false,
25238 enableGlobalSearch: false,
25239 defaultOperators: [],
25240 validOperators: [],
25241 format: {},
25242 getValueFormatted: get_value_formatted_default_default,
25243 // cannot validate any constraint, so
25244 // the only available validation for the field author
25245 // would be providing a custom validator.
25246 validate: {}
25247 };
25248
25249 // packages/dataviews/build-module/field-types/array.mjs
25250 var import_i18n42 = __toESM(require_i18n(), 1);
25251
25252 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
25253 function isValidRequiredForArray(item, field) {
25254 const value = field.getValue({ item });
25255 return Array.isArray(value) && value.length > 0 && value.every(
25256 (element) => ![void 0, "", null].includes(element)
25257 );
25258 }
25259
25260 // packages/dataviews/build-module/field-types/array.mjs
25261 function getValueFormatted7({
25262 item,
25263 field
25264 }) {
25265 const value = field.getValue({ item });
25266 const arr = Array.isArray(value) ? value : [];
25267 return arr.join(", ");
25268 }
25269 function render2({ item, field }) {
25270 return getValueFormatted7({ item, field });
25271 }
25272 function isValidCustom5(item, field) {
25273 const value = field.getValue({ item });
25274 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
25275 return (0, import_i18n42.__)("Value must be an array.");
25276 }
25277 if (!value.every((v2) => typeof v2 === "string")) {
25278 return (0, import_i18n42.__)("Every value must be a string.");
25279 }
25280 return null;
25281 }
25282 var sort4 = (a2, b2, direction) => {
25283 const arrA = Array.isArray(a2) ? a2 : [];
25284 const arrB = Array.isArray(b2) ? b2 : [];
25285 if (arrA.length !== arrB.length) {
25286 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
25287 }
25288 const joinedA = arrA.join(",");
25289 const joinedB = arrB.join(",");
25290 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
25291 };
25292 var array_default = {
25293 type: "array",
25294 render: render2,
25295 Edit: "array",
25296 sort: sort4,
25297 enableSorting: true,
25298 enableGlobalSearch: false,
25299 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25300 validOperators: [
25301 OPERATOR_IS_ANY,
25302 OPERATOR_IS_NONE,
25303 OPERATOR_IS_ALL,
25304 OPERATOR_IS_NOT_ALL
25305 ],
25306 format: {},
25307 getValueFormatted: getValueFormatted7,
25308 validate: {
25309 required: isValidRequiredForArray,
25310 elements: isValidElements,
25311 custom: isValidCustom5
25312 }
25313 };
25314
25315 // packages/dataviews/build-module/field-types/password.mjs
25316 function getValueFormatted8({
25317 item,
25318 field
25319 }) {
25320 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
25321 }
25322 var password_default = {
25323 type: "password",
25324 render,
25325 Edit: "password",
25326 sort: () => 0,
25327 // Passwords should not be sortable for security reasons
25328 enableSorting: false,
25329 enableGlobalSearch: false,
25330 defaultOperators: [],
25331 validOperators: [],
25332 format: {},
25333 getValueFormatted: getValueFormatted8,
25334 validate: {
25335 required: isValidRequired,
25336 pattern: isValidPattern,
25337 minLength: isValidMinLength,
25338 maxLength: isValidMaxLength,
25339 elements: isValidElements
25340 }
25341 };
25342
25343 // packages/dataviews/build-module/field-types/telephone.mjs
25344 var telephone_default = {
25345 type: "telephone",
25346 render,
25347 Edit: "telephone",
25348 sort: sort_text_default,
25349 enableSorting: true,
25350 enableGlobalSearch: false,
25351 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25352 validOperators: [
25353 OPERATOR_IS,
25354 OPERATOR_IS_NOT,
25355 OPERATOR_CONTAINS,
25356 OPERATOR_NOT_CONTAINS,
25357 OPERATOR_STARTS_WITH,
25358 // Multiple selection
25359 OPERATOR_IS_ANY,
25360 OPERATOR_IS_NONE,
25361 OPERATOR_IS_ALL,
25362 OPERATOR_IS_NOT_ALL
25363 ],
25364 format: {},
25365 getValueFormatted: get_value_formatted_default_default,
25366 validate: {
25367 required: isValidRequired,
25368 pattern: isValidPattern,
25369 minLength: isValidMinLength,
25370 maxLength: isValidMaxLength,
25371 elements: isValidElements
25372 }
25373 };
25374
25375 // packages/dataviews/build-module/field-types/color.mjs
25376 var import_i18n43 = __toESM(require_i18n(), 1);
25377 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
25378 function render3({ item, field }) {
25379 if (field.hasElements) {
25380 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(RenderFromElements, { item, field });
25381 }
25382 const value = get_value_formatted_default_default({ item, field });
25383 if (!value || !w(value).isValid()) {
25384 return value;
25385 }
25386 return /* @__PURE__ */ (0, import_jsx_runtime115.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
25387 /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
25388 "div",
25389 {
25390 style: {
25391 width: "16px",
25392 height: "16px",
25393 borderRadius: "50%",
25394 backgroundColor: value,
25395 border: "1px solid #ddd",
25396 flexShrink: 0
25397 }
25398 }
25399 ),
25400 /* @__PURE__ */ (0, import_jsx_runtime115.jsx)("span", { children: value })
25401 ] });
25402 }
25403 function isValidCustom6(item, field) {
25404 const value = field.getValue({ item });
25405 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
25406 return (0, import_i18n43.__)("Value must be a valid color.");
25407 }
25408 return null;
25409 }
25410 var sort5 = (a2, b2, direction) => {
25411 const colorA = w(a2);
25412 const colorB = w(b2);
25413 if (!colorA.isValid() && !colorB.isValid()) {
25414 return 0;
25415 }
25416 if (!colorA.isValid()) {
25417 return direction === "asc" ? 1 : -1;
25418 }
25419 if (!colorB.isValid()) {
25420 return direction === "asc" ? -1 : 1;
25421 }
25422 const hslA = colorA.toHsl();
25423 const hslB = colorB.toHsl();
25424 if (hslA.h !== hslB.h) {
25425 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
25426 }
25427 if (hslA.s !== hslB.s) {
25428 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
25429 }
25430 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
25431 };
25432 var color_default = {
25433 type: "color",
25434 render: render3,
25435 Edit: "color",
25436 sort: sort5,
25437 enableSorting: true,
25438 enableGlobalSearch: false,
25439 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25440 validOperators: [
25441 OPERATOR_IS,
25442 OPERATOR_IS_NOT,
25443 OPERATOR_IS_ANY,
25444 OPERATOR_IS_NONE
25445 ],
25446 format: {},
25447 getValueFormatted: get_value_formatted_default_default,
25448 validate: {
25449 required: isValidRequired,
25450 elements: isValidElements,
25451 custom: isValidCustom6
25452 }
25453 };
25454
25455 // packages/dataviews/build-module/field-types/url.mjs
25456 var url_default = {
25457 type: "url",
25458 render,
25459 Edit: "url",
25460 sort: sort_text_default,
25461 enableSorting: true,
25462 enableGlobalSearch: false,
25463 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25464 validOperators: [
25465 OPERATOR_IS,
25466 OPERATOR_IS_NOT,
25467 OPERATOR_CONTAINS,
25468 OPERATOR_NOT_CONTAINS,
25469 OPERATOR_STARTS_WITH,
25470 // Multiple selection
25471 OPERATOR_IS_ANY,
25472 OPERATOR_IS_NONE,
25473 OPERATOR_IS_ALL,
25474 OPERATOR_IS_NOT_ALL
25475 ],
25476 format: {},
25477 getValueFormatted: get_value_formatted_default_default,
25478 validate: {
25479 required: isValidRequired,
25480 pattern: isValidPattern,
25481 minLength: isValidMinLength,
25482 maxLength: isValidMaxLength,
25483 elements: isValidElements
25484 }
25485 };
25486
25487 // packages/dataviews/build-module/field-types/no-type.mjs
25488 var sort6 = (a2, b2, direction) => {
25489 if (typeof a2 === "number" && typeof b2 === "number") {
25490 return sort_number_default(a2, b2, direction);
25491 }
25492 return sort_text_default(a2, b2, direction);
25493 };
25494 var no_type_default = {
25495 // type: no type for this one
25496 render,
25497 Edit: null,
25498 sort: sort6,
25499 enableSorting: true,
25500 enableGlobalSearch: false,
25501 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25502 validOperators: getAllOperatorNames(),
25503 format: {},
25504 getValueFormatted: get_value_formatted_default_default,
25505 validate: {
25506 required: isValidRequired,
25507 elements: isValidElements
25508 }
25509 };
25510
25511 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
25512 function supportsNumericRangeConstraint(type) {
25513 return type === "integer" || type === "number";
25514 }
25515 function supportsDateRangeConstraint(type) {
25516 return type === "date" || type === "datetime";
25517 }
25518 function normalizeRangeRule(value, fieldType, key) {
25519 const validator = fieldType.validate[key];
25520 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
25521 return { constraint: value, validate: validator };
25522 }
25523 return void 0;
25524 }
25525 function getIsValid(field, fieldType) {
25526 const rules = field.isValid;
25527 let required;
25528 if (rules?.required === true && fieldType.validate.required !== void 0) {
25529 required = {
25530 constraint: true,
25531 validate: fieldType.validate.required
25532 };
25533 }
25534 let elements;
25535 if ((rules?.elements === true || // elements is enabled unless the field opts-out
25536 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
25537 elements = {
25538 constraint: true,
25539 validate: fieldType.validate.elements
25540 };
25541 }
25542 const min2 = normalizeRangeRule(rules?.min, fieldType, "min");
25543 const max2 = normalizeRangeRule(rules?.max, fieldType, "max");
25544 const minLengthValue = rules?.minLength;
25545 let minLength;
25546 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
25547 minLength = {
25548 constraint: minLengthValue,
25549 validate: fieldType.validate.minLength
25550 };
25551 }
25552 const maxLengthValue = rules?.maxLength;
25553 let maxLength;
25554 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
25555 maxLength = {
25556 constraint: maxLengthValue,
25557 validate: fieldType.validate.maxLength
25558 };
25559 }
25560 const patternValue = rules?.pattern;
25561 let pattern;
25562 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
25563 pattern = {
25564 constraint: patternValue,
25565 validate: fieldType.validate.pattern
25566 };
25567 }
25568 const custom = rules?.custom ?? fieldType.validate.custom;
25569 return {
25570 required,
25571 elements,
25572 min: min2,
25573 max: max2,
25574 minLength,
25575 maxLength,
25576 pattern,
25577 custom
25578 };
25579 }
25580
25581 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
25582 function getFilter(fieldType) {
25583 return fieldType.validOperators.reduce((accumulator, operator) => {
25584 const operatorObj = getOperatorByName(operator);
25585 if (operatorObj?.filter) {
25586 accumulator[operator] = operatorObj.filter;
25587 }
25588 return accumulator;
25589 }, {});
25590 }
25591
25592 // packages/dataviews/build-module/field-types/utils/get-format.mjs
25593 function getFormat(field, fieldType) {
25594 return {
25595 ...fieldType.format,
25596 ...field.format
25597 };
25598 }
25599 var get_format_default = getFormat;
25600
25601 // packages/dataviews/build-module/field-types/index.mjs
25602 function getFieldTypeByName(type) {
25603 const found = [
25604 email_default,
25605 integer_default,
25606 number_default,
25607 text_default,
25608 datetime_default,
25609 date_default,
25610 boolean_default,
25611 media_default,
25612 array_default,
25613 password_default,
25614 telephone_default,
25615 color_default,
25616 url_default
25617 ].find((fieldType) => fieldType?.type === type);
25618 if (!!found) {
25619 return found;
25620 }
25621 return no_type_default;
25622 }
25623 function normalizeFields(fields) {
25624 return fields.map((field) => {
25625 const fieldType = getFieldTypeByName(field.type);
25626 const getValue = field.getValue || get_value_from_id_default(field.id);
25627 const sort7 = function(a2, b2, direction) {
25628 const aValue = getValue({ item: a2 });
25629 const bValue = getValue({ item: b2 });
25630 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
25631 };
25632 return {
25633 id: field.id,
25634 label: field.label || field.id,
25635 header: field.header || field.label || field.id,
25636 description: field.description,
25637 placeholder: field.placeholder,
25638 getValue,
25639 setValue: field.setValue || set_value_from_id_default(field.id),
25640 elements: field.elements,
25641 getElements: field.getElements,
25642 hasElements: hasElements(field),
25643 isVisible: field.isVisible,
25644 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
25645 enableHiding: field.enableHiding ?? true,
25646 readOnly: field.readOnly ?? false,
25647 // The type provides defaults for the following props
25648 type: fieldType.type,
25649 render: field.render ?? fieldType.render,
25650 Edit: getControl(field, fieldType.Edit),
25651 sort: sort7,
25652 enableSorting: field.enableSorting ?? fieldType.enableSorting,
25653 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
25654 isValid: getIsValid(field, fieldType),
25655 filterBy: get_filter_by_default(
25656 field,
25657 fieldType.defaultOperators,
25658 fieldType.validOperators
25659 ),
25660 filter: getFilter(fieldType),
25661 format: get_format_default(field, fieldType),
25662 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
25663 };
25664 });
25665 }
25666
25667 // packages/dataviews/build-module/hooks/use-data.mjs
25668 var import_element78 = __toESM(require_element(), 1);
25669 function useData({
25670 view,
25671 data: shownData,
25672 getItemId,
25673 isLoading,
25674 paginationInfo,
25675 selection
25676 }) {
25677 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
25678 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element78.useState)(
25679 !isLoading
25680 );
25681 (0, import_element78.useEffect)(() => {
25682 if (!isLoading) {
25683 setHasInitiallyLoaded(true);
25684 }
25685 }, [isLoading]);
25686 const previousDataRef = (0, import_element78.useRef)(shownData);
25687 const previousPaginationInfoRef = (0, import_element78.useRef)(paginationInfo);
25688 (0, import_element78.useEffect)(() => {
25689 if (!isLoading) {
25690 previousDataRef.current = shownData;
25691 previousPaginationInfoRef.current = paginationInfo;
25692 }
25693 }, [shownData, isLoading, paginationInfo]);
25694 const [visibleEntries, setVisibleEntries] = (0, import_element78.useState)([]);
25695 const positionMapRef = (0, import_element78.useRef)(/* @__PURE__ */ new Map());
25696 const allLoadedRecordsRef = (0, import_element78.useRef)([]);
25697 const prevViewParamsRef = (0, import_element78.useRef)({
25698 search: void 0,
25699 filters: void 0,
25700 perPage: void 0
25701 });
25702 const scrollDirectionRef = (0, import_element78.useRef)(void 0);
25703 const prevStartPositionRef = (0, import_element78.useRef)(void 0);
25704 const hasInitializedRef = (0, import_element78.useRef)(false);
25705 const allLoadedRecords = (0, import_element78.useMemo)(() => {
25706 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
25707 if (view.startPosition < prevStartPositionRef.current) {
25708 scrollDirectionRef.current = "up";
25709 } else if (view.startPosition > prevStartPositionRef.current) {
25710 scrollDirectionRef.current = "down";
25711 }
25712 }
25713 prevStartPositionRef.current = view.startPosition;
25714 const currentFiltersKey = JSON.stringify(view.filters ?? []);
25715 const prevFiltersKey = prevViewParamsRef.current.filters;
25716 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
25717 hasInitializedRef.current = true;
25718 prevViewParamsRef.current = {
25719 search: view.search,
25720 filters: currentFiltersKey,
25721 perPage: view.perPage
25722 };
25723 if (shouldReset) {
25724 positionMapRef.current.clear();
25725 scrollDirectionRef.current = void 0;
25726 const startPosition = view.search ? 1 : view.startPosition ?? 1;
25727 const records = shownData.map((record, index2) => {
25728 const position = startPosition + index2;
25729 positionMapRef.current.set(getItemId(record), position);
25730 return {
25731 ...record,
25732 position
25733 };
25734 });
25735 allLoadedRecordsRef.current = records;
25736 return records;
25737 }
25738 const prev = allLoadedRecordsRef.current;
25739 const shownDataIds = new Set(shownData.map(getItemId));
25740 const scrollDirection = scrollDirectionRef.current;
25741 const basePosition = view.search ? 1 : view.startPosition ?? 1;
25742 const newRecords = shownData.map((record, index2) => {
25743 const itemId = getItemId(record);
25744 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0;
25745 if (position !== void 0) {
25746 positionMapRef.current.set(itemId, position);
25747 }
25748 return {
25749 ...record,
25750 position
25751 };
25752 });
25753 if (newRecords.length === 0) {
25754 return prev;
25755 }
25756 const prevWithoutDuplicates = prev.filter(
25757 (record) => !shownDataIds.has(getItemId(record))
25758 );
25759 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
25760 allRecords.sort((a2, b2) => {
25761 const posA = a2.position;
25762 const posB = b2.position;
25763 return posA - posB;
25764 });
25765 let result = allRecords;
25766 if (visibleEntries.length > 0) {
25767 const visibleMin = Math.min(...visibleEntries);
25768 const visibleMax = Math.max(...visibleEntries);
25769 const buffer = 20;
25770 const recordPositions = allRecords.map(
25771 (r3) => r3.position
25772 );
25773 const minRecordPos = Math.min(...recordPositions);
25774 const maxRecordPos = Math.max(...recordPositions);
25775 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
25776 if (hasOverlap) {
25777 result = allRecords.filter((record) => {
25778 const itemId = getItemId(record);
25779 const isSelected2 = selection?.includes(itemId);
25780 if (isSelected2) {
25781 return true;
25782 }
25783 const itemPosition = record.position;
25784 if (scrollDirection === "up") {
25785 return itemPosition <= visibleMax + buffer;
25786 } else if (scrollDirection === "down") {
25787 return itemPosition >= visibleMin - buffer;
25788 }
25789 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
25790 });
25791 }
25792 }
25793 allLoadedRecordsRef.current = result;
25794 return result;
25795 }, [
25796 shownData,
25797 view.search,
25798 view.filters,
25799 view.perPage,
25800 view.startPosition,
25801 view.infiniteScrollEnabled,
25802 visibleEntries,
25803 selection,
25804 getItemId
25805 ]);
25806 if (!isInfiniteScrollEnabled) {
25807 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
25808 return {
25809 data: dataToReturn.map((item) => ({
25810 ...item,
25811 position: void 0
25812 })),
25813 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
25814 hasInitiallyLoaded,
25815 setVisibleEntries: void 0
25816 };
25817 }
25818 return {
25819 data: allLoadedRecords,
25820 paginationInfo,
25821 hasInitiallyLoaded,
25822 setVisibleEntries
25823 };
25824 }
25825
25826 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
25827 var import_element79 = __toESM(require_element(), 1);
25828 var import_compose11 = __toESM(require_compose(), 1);
25829 function captureAnchorElement(container, anchorElementRef, direction) {
25830 const containerRect = container.getBoundingClientRect();
25831 const centerY = containerRect.top + containerRect.height / 2;
25832 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
25833 if (items.length === 0) {
25834 return false;
25835 }
25836 const bestAnchor = items.reduce((best, item) => {
25837 const itemRect = item.getBoundingClientRect();
25838 const itemCenterY = itemRect.top + itemRect.height / 2;
25839 const distance = Math.abs(itemCenterY - centerY);
25840 const bestRect = best.getBoundingClientRect();
25841 const bestCenterY = bestRect.top + bestRect.height / 2;
25842 const bestDistance = Math.abs(bestCenterY - centerY);
25843 return distance < bestDistance ? item : best;
25844 });
25845 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
25846 const anchorRect = bestAnchor.getBoundingClientRect();
25847 anchorElementRef.current = {
25848 posinset,
25849 viewportOffset: anchorRect.top - containerRect.top,
25850 direction
25851 };
25852 return true;
25853 }
25854 function useInfiniteScroll({
25855 view,
25856 onChangeView,
25857 isLoading,
25858 paginationInfo,
25859 containerRef,
25860 setVisibleEntries
25861 }) {
25862 const anchorElementRef = (0, import_element79.useRef)(null);
25863 const viewRef = (0, import_element79.useRef)(view);
25864 const isLoadingRef = (0, import_element79.useRef)(isLoading);
25865 const onChangeViewRef = (0, import_element79.useRef)(onChangeView);
25866 const totalItemsRef = (0, import_element79.useRef)(paginationInfo.totalItems);
25867 (0, import_element79.useLayoutEffect)(() => {
25868 viewRef.current = view;
25869 isLoadingRef.current = isLoading;
25870 onChangeViewRef.current = onChangeView;
25871 totalItemsRef.current = paginationInfo.totalItems;
25872 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
25873 const intersectionObserverCallback = (0, import_element79.useCallback)(
25874 (entries) => {
25875 if (!setVisibleEntries) {
25876 return;
25877 }
25878 setVisibleEntries((prev) => {
25879 const newVisibleEntries = new Set(prev);
25880 let hasChanged = false;
25881 entries.forEach((entry) => {
25882 const posInSet = Number(
25883 entry.target?.attributes?.getNamedItem(
25884 "aria-posinset"
25885 )?.value
25886 );
25887 if (isNaN(posInSet)) {
25888 return;
25889 }
25890 if (entry.isIntersecting) {
25891 if (!newVisibleEntries.has(posInSet)) {
25892 newVisibleEntries.add(posInSet);
25893 hasChanged = true;
25894 }
25895 } else if (newVisibleEntries.has(posInSet)) {
25896 newVisibleEntries.delete(posInSet);
25897 hasChanged = true;
25898 }
25899 });
25900 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
25901 });
25902 },
25903 [setVisibleEntries]
25904 );
25905 (0, import_element79.useLayoutEffect)(() => {
25906 const container = containerRef.current;
25907 const anchor = anchorElementRef.current;
25908 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
25909 return;
25910 }
25911 const anchorElement = container.querySelector(
25912 `[aria-posinset="${anchor.posinset}"]`
25913 );
25914 if (anchorElement) {
25915 const containerRect = container.getBoundingClientRect();
25916 const anchorRect = anchorElement.getBoundingClientRect();
25917 const currentOffset = anchorRect.top - containerRect.top;
25918 const scrollAdjustment = currentOffset - anchor.viewportOffset;
25919 if (Math.abs(scrollAdjustment) > 1) {
25920 container.scrollTop += scrollAdjustment;
25921 }
25922 }
25923 anchorElementRef.current = null;
25924 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
25925 const intersectionObserverRef = (0, import_element79.useRef)(
25926 null
25927 );
25928 (0, import_element79.useEffect)(() => {
25929 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
25930 if (intersectionObserverRef.current) {
25931 intersectionObserverRef.current.disconnect();
25932 intersectionObserverRef.current = null;
25933 }
25934 return;
25935 }
25936 intersectionObserverRef.current = new IntersectionObserver(
25937 intersectionObserverCallback,
25938 { root: null, rootMargin: "0px", threshold: 0.1 }
25939 );
25940 return () => {
25941 if (intersectionObserverRef.current) {
25942 intersectionObserverRef.current.disconnect();
25943 intersectionObserverRef.current = null;
25944 }
25945 };
25946 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
25947 (0, import_element79.useEffect)(() => {
25948 if (!view.infiniteScrollEnabled || !containerRef.current) {
25949 return;
25950 }
25951 let lastScrollTop = 0;
25952 const BOTTOM_THRESHOLD = 600;
25953 const TOP_THRESHOLD = 800;
25954 const handleScroll = (0, import_compose11.throttle)((event) => {
25955 const currentView = viewRef.current;
25956 const totalItems = totalItemsRef.current;
25957 const target = event.target;
25958 const scrollTop = target.scrollTop;
25959 const scrollHeight = target.scrollHeight;
25960 const clientHeight = target.clientHeight;
25961 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
25962 lastScrollTop = scrollTop;
25963 if (isLoadingRef.current) {
25964 return;
25965 }
25966 const currentStartPosition = currentView.startPosition || 1;
25967 const batchSize = currentView.perPage || 10;
25968 const currentEndPosition = Math.min(
25969 currentStartPosition + batchSize,
25970 totalItems
25971 );
25972 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
25973 if (currentEndPosition < totalItems) {
25974 const newStartPosition = currentEndPosition;
25975 captureAnchorElement(target, anchorElementRef, "down");
25976 onChangeViewRef.current({
25977 ...currentView,
25978 startPosition: newStartPosition
25979 });
25980 }
25981 }
25982 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
25983 if (currentStartPosition > 1) {
25984 const calculatedStartPosition = currentStartPosition - batchSize;
25985 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
25986 captureAnchorElement(target, anchorElementRef, "up");
25987 onChangeViewRef.current({
25988 ...currentView,
25989 startPosition: newStartPosition
25990 });
25991 }
25992 }
25993 }, 50);
25994 const container = containerRef.current;
25995 container.addEventListener("scroll", handleScroll);
25996 return () => {
25997 container.removeEventListener("scroll", handleScroll);
25998 handleScroll.cancel();
25999 };
26000 }, [containerRef, view.infiniteScrollEnabled]);
26001 return {
26002 intersectionObserver: intersectionObserverRef.current
26003 };
26004 }
26005
26006 // packages/dataviews/build-module/dataviews/index.mjs
26007 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
26008 var defaultGetItemId = (item) => item.id;
26009 var defaultIsItemClickable = () => true;
26010 var EMPTY_ARRAY6 = [];
26011 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} };
26012 var dataViewsLayouts = VIEW_LAYOUTS.filter(
26013 (viewLayout) => !viewLayout.isPicker
26014 );
26015 function DefaultUI({
26016 header,
26017 search = true,
26018 searchLabel = void 0
26019 }) {
26020 const { view } = (0, import_element80.useContext)(dataviews_context_default);
26021 const isInfiniteScroll = view.infiniteScrollEnabled;
26022 return /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)(import_jsx_runtime116.Fragment, { children: [
26023 /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)(
26024 Stack,
26025 {
26026 direction: "row",
26027 align: "top",
26028 justify: "space-between",
26029 className: clsx_default("dataviews__view-actions", {
26030 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
26031 }),
26032 gap: "xs",
26033 children: [
26034 /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)(
26035 Stack,
26036 {
26037 direction: "row",
26038 justify: "start",
26039 gap: "sm",
26040 className: "dataviews__search",
26041 children: [
26042 search && /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(dataviews_search_default, { label: searchLabel }),
26043 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(toggle_default, {})
26044 ]
26045 }
26046 ),
26047 /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
26048 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(dataviews_view_config_default, {}),
26049 header
26050 ] })
26051 ]
26052 }
26053 ),
26054 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
26055 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(DataViewsLayout, {}),
26056 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(DataViewsFooter, {})
26057 ] });
26058 }
26059 function DataViews({
26060 view,
26061 onChangeView,
26062 fields,
26063 search = true,
26064 searchLabel = void 0,
26065 actions = EMPTY_ARRAY6,
26066 data,
26067 getItemId = defaultGetItemId,
26068 getItemLevel,
26069 isLoading = false,
26070 paginationInfo,
26071 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS,
26072 selection: selectionProperty,
26073 onChangeSelection,
26074 onClickItem,
26075 renderItemLink,
26076 isItemClickable = defaultIsItemClickable,
26077 header,
26078 children,
26079 config = { perPageSizes: [10, 20, 50, 100] },
26080 empty,
26081 onReset
26082 }) {
26083 const [selectionState, setSelectionState] = (0, import_element80.useState)([]);
26084 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0;
26085 const selection = isUncontrolled ? selectionState : selectionProperty;
26086 const {
26087 data: displayData,
26088 paginationInfo: displayPaginationInfo,
26089 hasInitiallyLoaded,
26090 setVisibleEntries
26091 } = useData({
26092 view,
26093 data,
26094 getItemId,
26095 isLoading,
26096 selection,
26097 paginationInfo
26098 });
26099 const containerRef = (0, import_element80.useRef)(null);
26100 const [containerWidth, setContainerWidth] = (0, import_element80.useState)(0);
26101 const resizeObserverRef = (0, import_compose12.useResizeObserver)(
26102 (resizeObserverEntries) => {
26103 setContainerWidth(
26104 resizeObserverEntries[0].borderBoxSize[0].inlineSize
26105 );
26106 },
26107 { box: "border-box" }
26108 );
26109 const [openedFilter, setOpenedFilter] = (0, import_element80.useState)(null);
26110 function setSelectionWithChange(value) {
26111 const newValue = typeof value === "function" ? value(selection) : value;
26112 if (isUncontrolled) {
26113 setSelectionState(newValue);
26114 }
26115 if (onChangeSelection) {
26116 onChangeSelection(newValue);
26117 }
26118 }
26119 const _fields = (0, import_element80.useMemo)(() => normalizeFields(fields), [fields]);
26120 const _selection = (0, import_element80.useMemo)(() => {
26121 if (view.infiniteScrollEnabled) {
26122 return selection;
26123 }
26124 return selection.filter(
26125 (id) => data.some((item) => getItemId(item) === id)
26126 );
26127 }, [selection, data, getItemId, view.infiniteScrollEnabled]);
26128 const filters = use_filters_default(_fields, view);
26129 const hasPrimaryOrLockedFilters = (0, import_element80.useMemo)(
26130 () => (filters || []).some(
26131 (filter) => filter.isPrimary || filter.isLocked
26132 ),
26133 [filters]
26134 );
26135 const [isShowingFilter, setIsShowingFilter] = (0, import_element80.useState)(
26136 hasPrimaryOrLockedFilters
26137 );
26138 const { intersectionObserver } = useInfiniteScroll({
26139 view,
26140 onChangeView,
26141 isLoading,
26142 paginationInfo,
26143 containerRef,
26144 setVisibleEntries
26145 });
26146 (0, import_element80.useEffect)(() => {
26147 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
26148 setIsShowingFilter(true);
26149 }
26150 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
26151 const defaultLayouts = (0, import_element80.useMemo)(
26152 () => Object.fromEntries(
26153 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
26154 return dataViewsLayouts.some(
26155 (viewLayout) => viewLayout.type === layoutType
26156 );
26157 }).map(([key, value]) => [
26158 key,
26159 value === true ? {} : value
26160 ])
26161 ),
26162 [defaultLayoutsProperty]
26163 );
26164 if (!defaultLayouts[view.type]) {
26165 return null;
26166 }
26167 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
26168 dataviews_context_default.Provider,
26169 {
26170 value: {
26171 view,
26172 onChangeView,
26173 fields: _fields,
26174 actions,
26175 data: displayData,
26176 isLoading,
26177 paginationInfo: displayPaginationInfo,
26178 selection: _selection,
26179 onChangeSelection: setSelectionWithChange,
26180 openedFilter,
26181 setOpenedFilter,
26182 getItemId,
26183 getItemLevel,
26184 isItemClickable,
26185 onClickItem,
26186 renderItemLink,
26187 containerWidth,
26188 containerRef,
26189 resizeObserverRef,
26190 defaultLayouts,
26191 filters,
26192 isShowingFilter,
26193 setIsShowingFilter,
26194 config,
26195 empty,
26196 hasInitiallyLoaded,
26197 onReset,
26198 intersectionObserver
26199 },
26200 children: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
26201 DefaultUI,
26202 {
26203 header,
26204 search,
26205 searchLabel
26206 }
26207 ) })
26208 }
26209 );
26210 }
26211 var DataViewsSubComponents = DataViews;
26212 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
26213 DataViewsSubComponents.Filters = filters_default;
26214 DataViewsSubComponents.FiltersToggled = filters_toggled_default;
26215 DataViewsSubComponents.FiltersToggle = toggle_default;
26216 DataViewsSubComponents.Layout = DataViewsLayout;
26217 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
26218 DataViewsSubComponents.Pagination = DataViewsPagination;
26219 DataViewsSubComponents.Search = dataviews_search_default;
26220 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
26221 DataViewsSubComponents.Footer = DataViewsFooter;
26222 var dataviews_default = DataViewsSubComponents;
26223
26224 // packages/dataviews/build-module/utils/filter-sort-and-paginate.mjs
26225 var import_remove_accents2 = __toESM(require_remove_accents(), 1);
26226 var import_deprecated = __toESM(require_deprecated(), 1);
26227 function normalizeSearchInput2(input = "") {
26228 return (0, import_remove_accents2.default)(input.trim().toLowerCase());
26229 }
26230 var EMPTY_ARRAY7 = [];
26231 function filterSortAndPaginate(data, view, fields) {
26232 if (!data) {
26233 return {
26234 data: EMPTY_ARRAY7,
26235 paginationInfo: { totalItems: 0, totalPages: 0 }
26236 };
26237 }
26238 const _fields = normalizeFields(fields);
26239 let filteredData = [...data];
26240 if (view.search) {
26241 const normalizedSearch = normalizeSearchInput2(view.search);
26242 filteredData = filteredData.filter((item) => {
26243 return _fields.filter((field) => field.enableGlobalSearch).some((field) => {
26244 const fieldValue = field.getValue({ item });
26245 const values = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
26246 return values.some(
26247 (value) => normalizeSearchInput2(String(value)).includes(
26248 normalizedSearch
26249 )
26250 );
26251 });
26252 });
26253 }
26254 if (view.filters && view.filters?.length > 0) {
26255 view.filters.forEach((filter) => {
26256 const field = _fields.find(
26257 (_field) => _field.id === filter.field
26258 );
26259 if (field) {
26260 if (filter.operator === OPERATOR_IS_NOT_ALL) {
26261 (0, import_deprecated.default)("The 'isNotAll' filter operator", {
26262 since: "7.0",
26263 alternative: "'isNone'"
26264 });
26265 }
26266 const handler = field.filter[filter.operator];
26267 if (handler) {
26268 filteredData = filteredData.filter(
26269 (item) => handler(item, field, filter.value)
26270 );
26271 }
26272 }
26273 });
26274 }
26275 const sortByField = view.sort?.field ? _fields.find((field) => {
26276 return field.enableSorting !== false && field.id === view.sort?.field;
26277 }) : null;
26278 const groupByField = view.groupBy?.field ? _fields.find((field) => {
26279 return field.enableSorting !== false && field.id === view.groupBy?.field;
26280 }) : null;
26281 if (sortByField || groupByField) {
26282 filteredData.sort((a2, b2) => {
26283 if (groupByField) {
26284 const groupCompare = groupByField.sort(
26285 a2,
26286 b2,
26287 view.groupBy?.direction ?? "asc"
26288 );
26289 if (groupCompare !== 0) {
26290 return groupCompare;
26291 }
26292 }
26293 if (sortByField) {
26294 return sortByField.sort(a2, b2, view.sort?.direction ?? "desc");
26295 }
26296 return 0;
26297 });
26298 }
26299 let totalItems = filteredData.length;
26300 let totalPages = 1;
26301 if (view.infiniteScrollEnabled && view.startPosition !== void 0 && view.perPage !== void 0) {
26302 const start = view.startPosition - 1;
26303 const end = Math.min(start + view.perPage, totalItems);
26304 filteredData = filteredData?.slice(start, end);
26305 } else if (view.page !== void 0 && view.perPage !== void 0) {
26306 const start = (view.page - 1) * view.perPage;
26307 totalItems = filteredData?.length || 0;
26308 totalPages = Math.ceil(totalItems / view.perPage);
26309 filteredData = filteredData?.slice(start, start + view.perPage);
26310 }
26311 return {
26312 data: filteredData,
26313 paginationInfo: {
26314 totalItems,
26315 totalPages
26316 }
26317 };
26318 }
26319
26320 // packages/style-runtime/src/index.ts
26321 var STYLE_HASH_ATTRIBUTE14 = "data-wp-hash";
26322 function getRuntime14() {
26323 const globalScope = globalThis;
26324 if (globalScope.__wpStyleRuntime) {
26325 return globalScope.__wpStyleRuntime;
26326 }
26327 globalScope.__wpStyleRuntime = {
26328 documents: /* @__PURE__ */ new Map(),
26329 styles: /* @__PURE__ */ new Map(),
26330 injectedStyles: /* @__PURE__ */ new WeakMap()
26331 };
26332 if (typeof document !== "undefined") {
26333 registerDocument14(document);
26334 }
26335 return globalScope.__wpStyleRuntime;
26336 }
26337 function documentContainsStyleHash14(targetDocument, hash) {
26338 if (!targetDocument.head) {
26339 return false;
26340 }
26341 for (const style of targetDocument.head.querySelectorAll(
26342 `style[${STYLE_HASH_ATTRIBUTE14}]`
26343 )) {
26344 if (style.getAttribute(STYLE_HASH_ATTRIBUTE14) === hash) {
26345 return true;
26346 }
26347 }
26348 return false;
26349 }
26350 function injectStyle14(targetDocument, hash, css) {
26351 if (!targetDocument.head) {
26352 return;
26353 }
26354 const runtime = getRuntime14();
26355 let injectedStyles = runtime.injectedStyles.get(targetDocument);
26356 if (!injectedStyles) {
26357 injectedStyles = /* @__PURE__ */ new Set();
26358 runtime.injectedStyles.set(targetDocument, injectedStyles);
26359 }
26360 if (injectedStyles.has(hash)) {
26361 return;
26362 }
26363 if (documentContainsStyleHash14(targetDocument, hash)) {
26364 injectedStyles.add(hash);
26365 return;
26366 }
26367 const style = targetDocument.createElement("style");
26368 style.setAttribute(STYLE_HASH_ATTRIBUTE14, hash);
26369 style.appendChild(targetDocument.createTextNode(css));
26370 targetDocument.head.appendChild(style);
26371 injectedStyles.add(hash);
26372 }
26373 function registerDocument14(targetDocument) {
26374 const runtime = getRuntime14();
26375 runtime.documents.set(
26376 targetDocument,
26377 (runtime.documents.get(targetDocument) ?? 0) + 1
26378 );
26379 for (const [hash, css] of runtime.styles) {
26380 injectStyle14(targetDocument, hash, css);
26381 }
26382 return () => {
26383 const count = runtime.documents.get(targetDocument);
26384 if (count === void 0) {
26385 return;
26386 }
26387 if (count <= 1) {
26388 runtime.documents.delete(targetDocument);
26389 return;
26390 }
26391 runtime.documents.set(targetDocument, count - 1);
26392 };
26393 }
26394 function registerStyle14(hash, css) {
26395 const runtime = getRuntime14();
26396 runtime.styles.set(hash, css);
26397 for (const targetDocument of runtime.documents.keys()) {
26398 injectStyle14(targetDocument, hash, css);
26399 }
26400 }
26401
26402 // widgets/activity/style.module.css
26403 if (typeof process === "undefined" || true) {
26404 registerStyle14("4aa3daa799", "._784d2967c5e53514__loading{height:100%}._21768f83511c9ec9__list{max-height:420px}");
26405 }
26406 var style_default13 = { "loading": "_784d2967c5e53514__loading", "list": "_21768f83511c9ec9__list" };
26407
26408 // widgets/activity/render.tsx
26409 var import_jsx_runtime117 = __toESM(require_jsx_runtime());
26410 function formatGroupDate(dateStr) {
26411 const now = (0, import_date10.getDate)();
26412 const today = (0, import_date10.dateI18n)("Y-m-d", now);
26413 if (dateStr === today) {
26414 return (0, import_i18n44.__)("Today");
26415 }
26416 const yesterday = (0, import_date10.getDate)();
26417 yesterday.setDate(yesterday.getDate() - 1);
26418 const yesterdayStr = (0, import_date10.dateI18n)("Y-m-d", yesterday);
26419 if (dateStr === yesterdayStr) {
26420 return (0, import_i18n44.__)("Yesterday");
26421 }
26422 const currentYear = (0, import_date10.dateI18n)("Y", now);
26423 if (dateStr.slice(0, 4) === currentYear) {
26424 return (0, import_date10.dateI18n)((0, import_i18n44.__)("M jS"), dateStr);
26425 }
26426 return (0, import_date10.dateI18n)((0, import_i18n44.__)("M jS Y"), dateStr);
26427 }
26428 function htmlToPlainText(html) {
26429 const { body } = new window.DOMParser().parseFromString(
26430 html,
26431 "text/html"
26432 );
26433 return (body.textContent ?? "").trim();
26434 }
26435 var FIELDS = [
26436 {
26437 id: "icon",
26438 label: (0, import_i18n44.__)("Icon"),
26439 type: "media",
26440 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(icon_default, { icon: item.kind === "comment" ? comment_default : post_list_default }),
26441 enableSorting: false,
26442 enableHiding: false
26443 },
26444 {
26445 id: "title",
26446 label: (0, import_i18n44.__)("Title"),
26447 type: "text",
26448 getValue: ({ item }) => item.title,
26449 enableSorting: false,
26450 enableGlobalSearch: true
26451 },
26452 {
26453 id: "description",
26454 label: (0, import_i18n44.__)("Description"),
26455 type: "text",
26456 getValue: ({ item }) => item.description,
26457 enableSorting: false,
26458 enableGlobalSearch: true
26459 },
26460 {
26461 id: "datetime",
26462 label: (0, import_i18n44.__)("Time"),
26463 getValue: ({ item }) => item.datetime,
26464 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime117.jsx)("span", { children: (0, import_date10.dateI18n)((0, import_i18n44.__)("g:i a"), item.datetime) }),
26465 enableSorting: true
26466 },
26467 {
26468 id: "date",
26469 label: (0, import_i18n44.__)("Date"),
26470 getValue: ({ item }) => item.datetime.split("T")[0],
26471 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime117.jsx)("span", { children: formatGroupDate(item.datetime.split("T")[0]) }),
26472 enableSorting: true,
26473 enableHiding: false
26474 }
26475 ];
26476 var DEFAULT_PER_PAGE = 5;
26477 var SOURCE_COUNT = 3;
26478 var DEFAULT_VIEW = {
26479 type: "activity",
26480 search: "",
26481 page: 1,
26482 perPage: DEFAULT_PER_PAGE,
26483 filters: [],
26484 fields: ["datetime"],
26485 titleField: "title",
26486 descriptionField: "description",
26487 mediaField: "icon",
26488 showMedia: true,
26489 sort: {
26490 field: "datetime",
26491 direction: "desc"
26492 },
26493 groupBy: {
26494 field: "date",
26495 direction: "desc",
26496 showLabel: false
26497 }
26498 };
26499 function Activity({
26500 attributes
26501 }) {
26502 const perPage = Math.max(1, attributes?.perPage ?? DEFAULT_PER_PAGE);
26503 const [view, setView] = (0, import_element81.useState)(DEFAULT_VIEW);
26504 const queries = (0, import_element81.useMemo)(
26505 () => ({
26506 future: {
26507 status: "future",
26508 orderby: "date",
26509 order: "asc",
26510 per_page: perPage
26511 },
26512 recent: {
26513 status: "publish",
26514 orderby: "date",
26515 order: "desc",
26516 per_page: perPage
26517 },
26518 comments: { per_page: perPage }
26519 }),
26520 [perPage]
26521 );
26522 const { futurePosts, recentPosts, comments, isResolved } = (0, import_data6.useSelect)(
26523 (select) => {
26524 const coreData = select(import_core_data.store);
26525 return {
26526 futurePosts: coreData.getEntityRecords(
26527 "postType",
26528 "post",
26529 queries.future
26530 ),
26531 recentPosts: coreData.getEntityRecords(
26532 "postType",
26533 "post",
26534 queries.recent
26535 ),
26536 comments: coreData.getEntityRecords(
26537 "root",
26538 "comment",
26539 queries.comments
26540 ),
26541 isResolved: coreData.hasFinishedResolution("getEntityRecords", [
26542 "postType",
26543 "post",
26544 queries.future
26545 ]) && coreData.hasFinishedResolution("getEntityRecords", [
26546 "postType",
26547 "post",
26548 queries.recent
26549 ]) && coreData.hasFinishedResolution("getEntityRecords", [
26550 "root",
26551 "comment",
26552 queries.comments
26553 ])
26554 };
26555 },
26556 [queries]
26557 );
26558 const allEvents = (0, import_element81.useMemo)(() => {
26559 const events = [];
26560 for (const post of futurePosts ?? []) {
26561 events.push({
26562 id: `post-future-${post.id}`,
26563 datetime: post.date ?? "",
26564 title: (0, import_html_entities.decodeEntities)(
26565 post.title?.rendered ?? ""
26566 ),
26567 description: "",
26568 link: post.link ?? "",
26569 kind: "post-future"
26570 });
26571 }
26572 for (const post of recentPosts ?? []) {
26573 events.push({
26574 id: `post-published-${post.id}`,
26575 datetime: post.date ?? "",
26576 title: (0, import_html_entities.decodeEntities)(
26577 post.title?.rendered ?? ""
26578 ),
26579 description: "",
26580 link: post.link ?? "",
26581 kind: "post-published"
26582 });
26583 }
26584 for (const c2 of comments ?? []) {
26585 events.push({
26586 id: `comment-${c2.id}`,
26587 datetime: c2.date ?? "",
26588 title: (0, import_html_entities.decodeEntities)(c2.author_name ?? ""),
26589 description: htmlToPlainText(
26590 c2.content?.rendered ?? ""
26591 ),
26592 link: c2.link ?? "",
26593 kind: "comment"
26594 });
26595 }
26596 return events;
26597 }, [futurePosts, recentPosts, comments]);
26598 const resolvedView = (0, import_element81.useMemo)(
26599 () => ({ ...view, perPage: perPage * SOURCE_COUNT }),
26600 [view, perPage]
26601 );
26602 const { data: shownData, paginationInfo } = (0, import_element81.useMemo)(
26603 () => filterSortAndPaginate(allEvents, resolvedView, FIELDS),
26604 [allEvents, resolvedView]
26605 );
26606 if (!isResolved) {
26607 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
26608 Stack,
26609 {
26610 direction: "column",
26611 align: "center",
26612 justify: "center",
26613 className: style_default13.loading,
26614 children: /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(import_components45.Spinner, {})
26615 }
26616 );
26617 }
26618 if (allEvents.length === 0) {
26619 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
26620 Stack,
26621 {
26622 direction: "column",
26623 align: "center",
26624 justify: "center",
26625 className: style_default13.loading,
26626 children: /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(empty_state_exports.Root, { children: [
26627 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(empty_state_exports.Icon, { icon: post_list_default }),
26628 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(empty_state_exports.Title, { children: (0, import_i18n44.__)("No activity yet.") }),
26629 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(empty_state_exports.Description, { children: (0, import_i18n44.__)(
26630 "When you publish posts or receive comments, they will appear here."
26631 ) })
26632 ] })
26633 }
26634 );
26635 }
26636 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(Stack, { direction: "column", className: style_default13.list, children: /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
26637 dataviews_default,
26638 {
26639 data: shownData,
26640 fields: FIELDS,
26641 view: resolvedView,
26642 onChangeView: setView,
26643 paginationInfo,
26644 getItemId: (item) => item.id,
26645 search: false,
26646 isLoading: false,
26647 defaultLayouts: {
26648 activity: {
26649 sort: {
26650 field: "datetime",
26651 direction: "desc"
26652 }
26653 }
26654 },
26655 renderItemLink: ({ item, children, ...aProps }) => /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(Link, { href: item.link, ...aProps, children }),
26656 isItemClickable: (item) => !!item.link,
26657 children: /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(dataviews_default.Layout, {})
26658 }
26659 ) });
26660 }
26661 export {
26662 Activity as default
26663 };
26664 /*! Bundled license information:
26665
26666 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
26667 (**
26668 * @license React
26669 * use-sync-external-store-shim.development.js
26670 *
26671 * Copyright (c) Meta Platforms, Inc. and affiliates.
26672 *
26673 * This source code is licensed under the MIT license found in the
26674 * LICENSE file in the root directory of this source tree.
26675 *)
26676
26677 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
26678 (**
26679 * @license React
26680 * use-sync-external-store-shim/with-selector.development.js
26681 *
26682 * Copyright (c) Meta Platforms, Inc. and affiliates.
26683 *
26684 * This source code is licensed under the MIT license found in the
26685 * LICENSE file in the root directory of this source tree.
26686 *)
26687 */
26688