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 / news / render.js

render.js in Gutenberg 23.3.2, at build/widgets/news/render.js

26,477 lines 915.3 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/i18n
32 var require_i18n = __commonJS({
33 "package-external:@wordpress/i18n"(exports, module) {
34 module.exports = window.wp.i18n;
35 }
36 });
37
38 // package-external:@wordpress/element
39 var require_element = __commonJS({
40 "package-external:@wordpress/element"(exports, module) {
41 module.exports = window.wp.element;
42 }
43 });
44
45 // vendor-external:react
46 var require_react = __commonJS({
47 "vendor-external:react"(exports, module) {
48 module.exports = window.React;
49 }
50 });
51
52 // vendor-external:react/jsx-runtime
53 var require_jsx_runtime = __commonJS({
54 "vendor-external:react/jsx-runtime"(exports, module) {
55 module.exports = window.ReactJSXRuntime;
56 }
57 });
58
59 // vendor-external:react-dom
60 var require_react_dom = __commonJS({
61 "vendor-external:react-dom"(exports, module) {
62 module.exports = window.ReactDOM;
63 }
64 });
65
66 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
67 var require_use_sync_external_store_shim_development = __commonJS({
68 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
69 "use strict";
70 (function() {
71 function is(x2, y2) {
72 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
73 }
74 function useSyncExternalStore$2(subscribe2, getSnapshot) {
75 didWarnOld18Alpha || void 0 === React51.startTransition || (didWarnOld18Alpha = true, console.error(
76 "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."
77 ));
78 var value = getSnapshot();
79 if (!didWarnUncachedGetSnapshot) {
80 var cachedValue = getSnapshot();
81 objectIs(value, cachedValue) || (console.error(
82 "The result of getSnapshot should be cached to avoid an infinite loop"
83 ), didWarnUncachedGetSnapshot = true);
84 }
85 cachedValue = useState36({
86 inst: { value, getSnapshot }
87 });
88 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
89 useLayoutEffect6(
90 function() {
91 inst.value = value;
92 inst.getSnapshot = getSnapshot;
93 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
94 },
95 [subscribe2, value, getSnapshot]
96 );
97 useEffect32(
98 function() {
99 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
100 return subscribe2(function() {
101 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
102 });
103 },
104 [subscribe2]
105 );
106 useDebugValue2(value);
107 return value;
108 }
109 function checkIfSnapshotChanged(inst) {
110 var latestGetSnapshot = inst.getSnapshot;
111 inst = inst.value;
112 try {
113 var nextValue = latestGetSnapshot();
114 return !objectIs(inst, nextValue);
115 } catch (error) {
116 return true;
117 }
118 }
119 function useSyncExternalStore$1(subscribe2, getSnapshot) {
120 return getSnapshot();
121 }
122 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
123 var React51 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState36 = React51.useState, useEffect32 = 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;
124 exports.useSyncExternalStore = void 0 !== React51.useSyncExternalStore ? React51.useSyncExternalStore : shim;
125 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
126 })();
127 }
128 });
129
130 // node_modules/use-sync-external-store/shim/index.js
131 var require_shim = __commonJS({
132 "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
133 "use strict";
134 if (false) {
135 module.exports = null;
136 } else {
137 module.exports = require_use_sync_external_store_shim_development();
138 }
139 }
140 });
141
142 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
143 var require_with_selector_development = __commonJS({
144 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) {
145 "use strict";
146 (function() {
147 function is(x2, y2) {
148 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
149 }
150 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
151 var React51 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore3 = shim.useSyncExternalStore, useRef44 = React51.useRef, useEffect32 = React51.useEffect, useMemo40 = React51.useMemo, useDebugValue2 = React51.useDebugValue;
152 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector2, isEqual) {
153 var instRef = useRef44(null);
154 if (null === instRef.current) {
155 var inst = { hasValue: false, value: null };
156 instRef.current = inst;
157 } else inst = instRef.current;
158 instRef = useMemo40(
159 function() {
160 function memoizedSelector(nextSnapshot) {
161 if (!hasMemo) {
162 hasMemo = true;
163 memoizedSnapshot = nextSnapshot;
164 nextSnapshot = selector2(nextSnapshot);
165 if (void 0 !== isEqual && inst.hasValue) {
166 var currentSelection = inst.value;
167 if (isEqual(currentSelection, nextSnapshot))
168 return memoizedSelection = currentSelection;
169 }
170 return memoizedSelection = nextSnapshot;
171 }
172 currentSelection = memoizedSelection;
173 if (objectIs(memoizedSnapshot, nextSnapshot))
174 return currentSelection;
175 var nextSelection = selector2(nextSnapshot);
176 if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
177 return memoizedSnapshot = nextSnapshot, currentSelection;
178 memoizedSnapshot = nextSnapshot;
179 return memoizedSelection = nextSelection;
180 }
181 var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
182 return [
183 function() {
184 return memoizedSelector(getSnapshot());
185 },
186 null === maybeGetServerSnapshot ? void 0 : function() {
187 return memoizedSelector(maybeGetServerSnapshot());
188 }
189 ];
190 },
191 [getSnapshot, getServerSnapshot, selector2, isEqual]
192 );
193 var value = useSyncExternalStore3(subscribe2, instRef[0], instRef[1]);
194 useEffect32(
195 function() {
196 inst.hasValue = true;
197 inst.value = value;
198 },
199 [value]
200 );
201 useDebugValue2(value);
202 return value;
203 };
204 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
205 })();
206 }
207 });
208
209 // node_modules/use-sync-external-store/shim/with-selector.js
210 var require_with_selector = __commonJS({
211 "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) {
212 "use strict";
213 if (false) {
214 module.exports = null;
215 } else {
216 module.exports = require_with_selector_development();
217 }
218 }
219 });
220
221 // package-external:@wordpress/primitives
222 var require_primitives = __commonJS({
223 "package-external:@wordpress/primitives"(exports, module) {
224 module.exports = window.wp.primitives;
225 }
226 });
227
228 // package-external:@wordpress/compose
229 var require_compose = __commonJS({
230 "package-external:@wordpress/compose"(exports, module) {
231 module.exports = window.wp.compose;
232 }
233 });
234
235 // package-external:@wordpress/theme
236 var require_theme = __commonJS({
237 "package-external:@wordpress/theme"(exports, module) {
238 module.exports = window.wp.theme;
239 }
240 });
241
242 // package-external:@wordpress/private-apis
243 var require_private_apis = __commonJS({
244 "package-external:@wordpress/private-apis"(exports, module) {
245 module.exports = window.wp.privateApis;
246 }
247 });
248
249 // package-external:@wordpress/components
250 var require_components = __commonJS({
251 "package-external:@wordpress/components"(exports, module) {
252 module.exports = window.wp.components;
253 }
254 });
255
256 // package-external:@wordpress/keycodes
257 var require_keycodes = __commonJS({
258 "package-external:@wordpress/keycodes"(exports, module) {
259 module.exports = window.wp.keycodes;
260 }
261 });
262
263 // package-external:@wordpress/data
264 var require_data = __commonJS({
265 "package-external:@wordpress/data"(exports, module) {
266 module.exports = window.wp.data;
267 }
268 });
269
270 // node_modules/remove-accents/index.js
271 var require_remove_accents = __commonJS({
272 "node_modules/remove-accents/index.js"(exports, module) {
273 var characterMap = {
274 "\xC0": "A",
275 "\xC1": "A",
276 "\xC2": "A",
277 "\xC3": "A",
278 "\xC4": "A",
279 "\xC5": "A",
280 "\u1EA4": "A",
281 "\u1EAE": "A",
282 "\u1EB2": "A",
283 "\u1EB4": "A",
284 "\u1EB6": "A",
285 "\xC6": "AE",
286 "\u1EA6": "A",
287 "\u1EB0": "A",
288 "\u0202": "A",
289 "\u1EA2": "A",
290 "\u1EA0": "A",
291 "\u1EA8": "A",
292 "\u1EAA": "A",
293 "\u1EAC": "A",
294 "\xC7": "C",
295 "\u1E08": "C",
296 "\xC8": "E",
297 "\xC9": "E",
298 "\xCA": "E",
299 "\xCB": "E",
300 "\u1EBE": "E",
301 "\u1E16": "E",
302 "\u1EC0": "E",
303 "\u1E14": "E",
304 "\u1E1C": "E",
305 "\u0206": "E",
306 "\u1EBA": "E",
307 "\u1EBC": "E",
308 "\u1EB8": "E",
309 "\u1EC2": "E",
310 "\u1EC4": "E",
311 "\u1EC6": "E",
312 "\xCC": "I",
313 "\xCD": "I",
314 "\xCE": "I",
315 "\xCF": "I",
316 "\u1E2E": "I",
317 "\u020A": "I",
318 "\u1EC8": "I",
319 "\u1ECA": "I",
320 "\xD0": "D",
321 "\xD1": "N",
322 "\xD2": "O",
323 "\xD3": "O",
324 "\xD4": "O",
325 "\xD5": "O",
326 "\xD6": "O",
327 "\xD8": "O",
328 "\u1ED0": "O",
329 "\u1E4C": "O",
330 "\u1E52": "O",
331 "\u020E": "O",
332 "\u1ECE": "O",
333 "\u1ECC": "O",
334 "\u1ED4": "O",
335 "\u1ED6": "O",
336 "\u1ED8": "O",
337 "\u1EDC": "O",
338 "\u1EDE": "O",
339 "\u1EE0": "O",
340 "\u1EDA": "O",
341 "\u1EE2": "O",
342 "\xD9": "U",
343 "\xDA": "U",
344 "\xDB": "U",
345 "\xDC": "U",
346 "\u1EE6": "U",
347 "\u1EE4": "U",
348 "\u1EEC": "U",
349 "\u1EEE": "U",
350 "\u1EF0": "U",
351 "\xDD": "Y",
352 "\xE0": "a",
353 "\xE1": "a",
354 "\xE2": "a",
355 "\xE3": "a",
356 "\xE4": "a",
357 "\xE5": "a",
358 "\u1EA5": "a",
359 "\u1EAF": "a",
360 "\u1EB3": "a",
361 "\u1EB5": "a",
362 "\u1EB7": "a",
363 "\xE6": "ae",
364 "\u1EA7": "a",
365 "\u1EB1": "a",
366 "\u0203": "a",
367 "\u1EA3": "a",
368 "\u1EA1": "a",
369 "\u1EA9": "a",
370 "\u1EAB": "a",
371 "\u1EAD": "a",
372 "\xE7": "c",
373 "\u1E09": "c",
374 "\xE8": "e",
375 "\xE9": "e",
376 "\xEA": "e",
377 "\xEB": "e",
378 "\u1EBF": "e",
379 "\u1E17": "e",
380 "\u1EC1": "e",
381 "\u1E15": "e",
382 "\u1E1D": "e",
383 "\u0207": "e",
384 "\u1EBB": "e",
385 "\u1EBD": "e",
386 "\u1EB9": "e",
387 "\u1EC3": "e",
388 "\u1EC5": "e",
389 "\u1EC7": "e",
390 "\xEC": "i",
391 "\xED": "i",
392 "\xEE": "i",
393 "\xEF": "i",
394 "\u1E2F": "i",
395 "\u020B": "i",
396 "\u1EC9": "i",
397 "\u1ECB": "i",
398 "\xF0": "d",
399 "\xF1": "n",
400 "\xF2": "o",
401 "\xF3": "o",
402 "\xF4": "o",
403 "\xF5": "o",
404 "\xF6": "o",
405 "\xF8": "o",
406 "\u1ED1": "o",
407 "\u1E4D": "o",
408 "\u1E53": "o",
409 "\u020F": "o",
410 "\u1ECF": "o",
411 "\u1ECD": "o",
412 "\u1ED5": "o",
413 "\u1ED7": "o",
414 "\u1ED9": "o",
415 "\u1EDD": "o",
416 "\u1EDF": "o",
417 "\u1EE1": "o",
418 "\u1EDB": "o",
419 "\u1EE3": "o",
420 "\xF9": "u",
421 "\xFA": "u",
422 "\xFB": "u",
423 "\xFC": "u",
424 "\u1EE7": "u",
425 "\u1EE5": "u",
426 "\u1EED": "u",
427 "\u1EEF": "u",
428 "\u1EF1": "u",
429 "\xFD": "y",
430 "\xFF": "y",
431 "\u0100": "A",
432 "\u0101": "a",
433 "\u0102": "A",
434 "\u0103": "a",
435 "\u0104": "A",
436 "\u0105": "a",
437 "\u0106": "C",
438 "\u0107": "c",
439 "\u0108": "C",
440 "\u0109": "c",
441 "\u010A": "C",
442 "\u010B": "c",
443 "\u010C": "C",
444 "\u010D": "c",
445 "C\u0306": "C",
446 "c\u0306": "c",
447 "\u010E": "D",
448 "\u010F": "d",
449 "\u0110": "D",
450 "\u0111": "d",
451 "\u0112": "E",
452 "\u0113": "e",
453 "\u0114": "E",
454 "\u0115": "e",
455 "\u0116": "E",
456 "\u0117": "e",
457 "\u0118": "E",
458 "\u0119": "e",
459 "\u011A": "E",
460 "\u011B": "e",
461 "\u011C": "G",
462 "\u01F4": "G",
463 "\u011D": "g",
464 "\u01F5": "g",
465 "\u011E": "G",
466 "\u011F": "g",
467 "\u0120": "G",
468 "\u0121": "g",
469 "\u0122": "G",
470 "\u0123": "g",
471 "\u0124": "H",
472 "\u0125": "h",
473 "\u0126": "H",
474 "\u0127": "h",
475 "\u1E2A": "H",
476 "\u1E2B": "h",
477 "\u0128": "I",
478 "\u0129": "i",
479 "\u012A": "I",
480 "\u012B": "i",
481 "\u012C": "I",
482 "\u012D": "i",
483 "\u012E": "I",
484 "\u012F": "i",
485 "\u0130": "I",
486 "\u0131": "i",
487 "\u0132": "IJ",
488 "\u0133": "ij",
489 "\u0134": "J",
490 "\u0135": "j",
491 "\u0136": "K",
492 "\u0137": "k",
493 "\u1E30": "K",
494 "\u1E31": "k",
495 "K\u0306": "K",
496 "k\u0306": "k",
497 "\u0139": "L",
498 "\u013A": "l",
499 "\u013B": "L",
500 "\u013C": "l",
501 "\u013D": "L",
502 "\u013E": "l",
503 "\u013F": "L",
504 "\u0140": "l",
505 "\u0141": "l",
506 "\u0142": "l",
507 "\u1E3E": "M",
508 "\u1E3F": "m",
509 "M\u0306": "M",
510 "m\u0306": "m",
511 "\u0143": "N",
512 "\u0144": "n",
513 "\u0145": "N",
514 "\u0146": "n",
515 "\u0147": "N",
516 "\u0148": "n",
517 "\u0149": "n",
518 "N\u0306": "N",
519 "n\u0306": "n",
520 "\u014C": "O",
521 "\u014D": "o",
522 "\u014E": "O",
523 "\u014F": "o",
524 "\u0150": "O",
525 "\u0151": "o",
526 "\u0152": "OE",
527 "\u0153": "oe",
528 "P\u0306": "P",
529 "p\u0306": "p",
530 "\u0154": "R",
531 "\u0155": "r",
532 "\u0156": "R",
533 "\u0157": "r",
534 "\u0158": "R",
535 "\u0159": "r",
536 "R\u0306": "R",
537 "r\u0306": "r",
538 "\u0212": "R",
539 "\u0213": "r",
540 "\u015A": "S",
541 "\u015B": "s",
542 "\u015C": "S",
543 "\u015D": "s",
544 "\u015E": "S",
545 "\u0218": "S",
546 "\u0219": "s",
547 "\u015F": "s",
548 "\u0160": "S",
549 "\u0161": "s",
550 "\u0162": "T",
551 "\u0163": "t",
552 "\u021B": "t",
553 "\u021A": "T",
554 "\u0164": "T",
555 "\u0165": "t",
556 "\u0166": "T",
557 "\u0167": "t",
558 "T\u0306": "T",
559 "t\u0306": "t",
560 "\u0168": "U",
561 "\u0169": "u",
562 "\u016A": "U",
563 "\u016B": "u",
564 "\u016C": "U",
565 "\u016D": "u",
566 "\u016E": "U",
567 "\u016F": "u",
568 "\u0170": "U",
569 "\u0171": "u",
570 "\u0172": "U",
571 "\u0173": "u",
572 "\u0216": "U",
573 "\u0217": "u",
574 "V\u0306": "V",
575 "v\u0306": "v",
576 "\u0174": "W",
577 "\u0175": "w",
578 "\u1E82": "W",
579 "\u1E83": "w",
580 "X\u0306": "X",
581 "x\u0306": "x",
582 "\u0176": "Y",
583 "\u0177": "y",
584 "\u0178": "Y",
585 "Y\u0306": "Y",
586 "y\u0306": "y",
587 "\u0179": "Z",
588 "\u017A": "z",
589 "\u017B": "Z",
590 "\u017C": "z",
591 "\u017D": "Z",
592 "\u017E": "z",
593 "\u017F": "s",
594 "\u0192": "f",
595 "\u01A0": "O",
596 "\u01A1": "o",
597 "\u01AF": "U",
598 "\u01B0": "u",
599 "\u01CD": "A",
600 "\u01CE": "a",
601 "\u01CF": "I",
602 "\u01D0": "i",
603 "\u01D1": "O",
604 "\u01D2": "o",
605 "\u01D3": "U",
606 "\u01D4": "u",
607 "\u01D5": "U",
608 "\u01D6": "u",
609 "\u01D7": "U",
610 "\u01D8": "u",
611 "\u01D9": "U",
612 "\u01DA": "u",
613 "\u01DB": "U",
614 "\u01DC": "u",
615 "\u1EE8": "U",
616 "\u1EE9": "u",
617 "\u1E78": "U",
618 "\u1E79": "u",
619 "\u01FA": "A",
620 "\u01FB": "a",
621 "\u01FC": "AE",
622 "\u01FD": "ae",
623 "\u01FE": "O",
624 "\u01FF": "o",
625 "\xDE": "TH",
626 "\xFE": "th",
627 "\u1E54": "P",
628 "\u1E55": "p",
629 "\u1E64": "S",
630 "\u1E65": "s",
631 "X\u0301": "X",
632 "x\u0301": "x",
633 "\u0403": "\u0413",
634 "\u0453": "\u0433",
635 "\u040C": "\u041A",
636 "\u045C": "\u043A",
637 "A\u030B": "A",
638 "a\u030B": "a",
639 "E\u030B": "E",
640 "e\u030B": "e",
641 "I\u030B": "I",
642 "i\u030B": "i",
643 "\u01F8": "N",
644 "\u01F9": "n",
645 "\u1ED2": "O",
646 "\u1ED3": "o",
647 "\u1E50": "O",
648 "\u1E51": "o",
649 "\u1EEA": "U",
650 "\u1EEB": "u",
651 "\u1E80": "W",
652 "\u1E81": "w",
653 "\u1EF2": "Y",
654 "\u1EF3": "y",
655 "\u0200": "A",
656 "\u0201": "a",
657 "\u0204": "E",
658 "\u0205": "e",
659 "\u0208": "I",
660 "\u0209": "i",
661 "\u020C": "O",
662 "\u020D": "o",
663 "\u0210": "R",
664 "\u0211": "r",
665 "\u0214": "U",
666 "\u0215": "u",
667 "B\u030C": "B",
668 "b\u030C": "b",
669 "\u010C\u0323": "C",
670 "\u010D\u0323": "c",
671 "\xCA\u030C": "E",
672 "\xEA\u030C": "e",
673 "F\u030C": "F",
674 "f\u030C": "f",
675 "\u01E6": "G",
676 "\u01E7": "g",
677 "\u021E": "H",
678 "\u021F": "h",
679 "J\u030C": "J",
680 "\u01F0": "j",
681 "\u01E8": "K",
682 "\u01E9": "k",
683 "M\u030C": "M",
684 "m\u030C": "m",
685 "P\u030C": "P",
686 "p\u030C": "p",
687 "Q\u030C": "Q",
688 "q\u030C": "q",
689 "\u0158\u0329": "R",
690 "\u0159\u0329": "r",
691 "\u1E66": "S",
692 "\u1E67": "s",
693 "V\u030C": "V",
694 "v\u030C": "v",
695 "W\u030C": "W",
696 "w\u030C": "w",
697 "X\u030C": "X",
698 "x\u030C": "x",
699 "Y\u030C": "Y",
700 "y\u030C": "y",
701 "A\u0327": "A",
702 "a\u0327": "a",
703 "B\u0327": "B",
704 "b\u0327": "b",
705 "\u1E10": "D",
706 "\u1E11": "d",
707 "\u0228": "E",
708 "\u0229": "e",
709 "\u0190\u0327": "E",
710 "\u025B\u0327": "e",
711 "\u1E28": "H",
712 "\u1E29": "h",
713 "I\u0327": "I",
714 "i\u0327": "i",
715 "\u0197\u0327": "I",
716 "\u0268\u0327": "i",
717 "M\u0327": "M",
718 "m\u0327": "m",
719 "O\u0327": "O",
720 "o\u0327": "o",
721 "Q\u0327": "Q",
722 "q\u0327": "q",
723 "U\u0327": "U",
724 "u\u0327": "u",
725 "X\u0327": "X",
726 "x\u0327": "x",
727 "Z\u0327": "Z",
728 "z\u0327": "z",
729 "\u0439": "\u0438",
730 "\u0419": "\u0418",
731 "\u0451": "\u0435",
732 "\u0401": "\u0415"
733 };
734 var chars = Object.keys(characterMap).join("|");
735 var allAccents = new RegExp(chars, "g");
736 var firstAccent = new RegExp(chars, "");
737 function matcher(match2) {
738 return characterMap[match2];
739 }
740 var removeAccents2 = function(string) {
741 return string.replace(allAccents, matcher);
742 };
743 var hasAccents = function(string) {
744 return !!string.match(firstAccent);
745 };
746 module.exports = removeAccents2;
747 module.exports.has = hasAccents;
748 module.exports.remove = removeAccents2;
749 }
750 });
751
752 // node_modules/fast-deep-equal/es6/index.js
753 var require_es6 = __commonJS({
754 "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
755 "use strict";
756 module.exports = function equal(a2, b2) {
757 if (a2 === b2) return true;
758 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
759 if (a2.constructor !== b2.constructor) return false;
760 var length, i2, keys;
761 if (Array.isArray(a2)) {
762 length = a2.length;
763 if (length != b2.length) return false;
764 for (i2 = length; i2-- !== 0; )
765 if (!equal(a2[i2], b2[i2])) return false;
766 return true;
767 }
768 if (a2 instanceof Map && b2 instanceof Map) {
769 if (a2.size !== b2.size) return false;
770 for (i2 of a2.entries())
771 if (!b2.has(i2[0])) return false;
772 for (i2 of a2.entries())
773 if (!equal(i2[1], b2.get(i2[0]))) return false;
774 return true;
775 }
776 if (a2 instanceof Set && b2 instanceof Set) {
777 if (a2.size !== b2.size) return false;
778 for (i2 of a2.entries())
779 if (!b2.has(i2[0])) return false;
780 return true;
781 }
782 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
783 length = a2.length;
784 if (length != b2.length) return false;
785 for (i2 = length; i2-- !== 0; )
786 if (a2[i2] !== b2[i2]) return false;
787 return true;
788 }
789 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
790 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
791 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
792 keys = Object.keys(a2);
793 length = keys.length;
794 if (length !== Object.keys(b2).length) return false;
795 for (i2 = length; i2-- !== 0; )
796 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
797 for (i2 = length; i2-- !== 0; ) {
798 var key = keys[i2];
799 if (!equal(a2[key], b2[key])) return false;
800 }
801 return true;
802 }
803 return a2 !== a2 && b2 !== b2;
804 };
805 }
806 });
807
808 // package-external:@wordpress/date
809 var require_date = __commonJS({
810 "package-external:@wordpress/date"(exports, module) {
811 module.exports = window.wp.date;
812 }
813 });
814
815 // package-external:@wordpress/warning
816 var require_warning = __commonJS({
817 "package-external:@wordpress/warning"(exports, module) {
818 module.exports = window.wp.warning;
819 }
820 });
821
822 // package-external:@wordpress/html-entities
823 var require_html_entities = __commonJS({
824 "package-external:@wordpress/html-entities"(exports, module) {
825 module.exports = window.wp.htmlEntities;
826 }
827 });
828
829 // widgets/news/render.tsx
830 var import_i18n45 = __toESM(require_i18n());
831
832 // node_modules/clsx/dist/clsx.mjs
833 function r(e2) {
834 var t2, f2, n2 = "";
835 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
836 else if ("object" == typeof e2) if (Array.isArray(e2)) {
837 var o2 = e2.length;
838 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
839 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
840 return n2;
841 }
842 function clsx() {
843 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
844 return n2;
845 }
846 var clsx_default = clsx;
847
848 // node_modules/@base-ui/utils/esm/useStableCallback.js
849 var React2 = __toESM(require_react(), 1);
850
851 // node_modules/@base-ui/utils/esm/useRefWithInit.js
852 var React = __toESM(require_react(), 1);
853 var UNINITIALIZED = {};
854 function useRefWithInit(init2, initArg) {
855 const ref = React.useRef(UNINITIALIZED);
856 if (ref.current === UNINITIALIZED) {
857 ref.current = init2(initArg);
858 }
859 return ref;
860 }
861
862 // node_modules/@base-ui/utils/esm/useStableCallback.js
863 var useInsertionEffect = React2[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0, -3)];
864 var useSafeInsertionEffect = (
865 // React 17 doesn't have useInsertionEffect.
866 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
867 useInsertionEffect !== React2.useLayoutEffect ? useInsertionEffect : (fn) => fn()
868 );
869 function useStableCallback(callback) {
870 const stable = useRefWithInit(createStableCallback).current;
871 stable.next = callback;
872 useSafeInsertionEffect(stable.effect);
873 return stable.trampoline;
874 }
875 function createStableCallback() {
876 const stable = {
877 next: void 0,
878 callback: assertNotCalled,
879 trampoline: (...args) => stable.callback?.(...args),
880 effect: () => {
881 stable.callback = stable.next;
882 }
883 };
884 return stable;
885 }
886 function assertNotCalled() {
887 if (true) {
888 throw (
889 /* minify-error-disabled */
890 new Error("Base UI: Cannot call an event handler while rendering.")
891 );
892 }
893 }
894
895 // node_modules/@base-ui/utils/esm/useIsoLayoutEffect.js
896 var React3 = __toESM(require_react(), 1);
897 var noop = () => {
898 };
899 var useIsoLayoutEffect = typeof document !== "undefined" ? React3.useLayoutEffect : noop;
900
901 // node_modules/@base-ui/utils/esm/warn.js
902 var set;
903 if (true) {
904 set = /* @__PURE__ */ new Set();
905 }
906 function warn(...messages) {
907 if (true) {
908 const messageKey = messages.join(" ");
909 if (!set.has(messageKey)) {
910 set.add(messageKey);
911 console.warn(`Base UI: ${messageKey}`);
912 }
913 }
914 }
915
916 // node_modules/@base-ui/react/esm/internals/direction-context/DirectionContext.js
917 var React4 = __toESM(require_react(), 1);
918 var DirectionContext = /* @__PURE__ */ React4.createContext(void 0);
919 if (true) DirectionContext.displayName = "DirectionContext";
920 function useDirection() {
921 const context = React4.useContext(DirectionContext);
922 return context?.direction ?? "ltr";
923 }
924
925 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
926 var React7 = __toESM(require_react(), 1);
927
928 // node_modules/@base-ui/utils/esm/useMergedRefs.js
929 function useMergedRefs(a2, b2, c2, d2) {
930 const forkRef = useRefWithInit(createForkRef).current;
931 if (didChange(forkRef, a2, b2, c2, d2)) {
932 update(forkRef, [a2, b2, c2, d2]);
933 }
934 return forkRef.callback;
935 }
936 function useMergedRefsN(refs) {
937 const forkRef = useRefWithInit(createForkRef).current;
938 if (didChangeN(forkRef, refs)) {
939 update(forkRef, refs);
940 }
941 return forkRef.callback;
942 }
943 function createForkRef() {
944 return {
945 callback: null,
946 cleanup: null,
947 refs: []
948 };
949 }
950 function didChange(forkRef, a2, b2, c2, d2) {
951 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
952 }
953 function didChangeN(forkRef, newRefs) {
954 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
955 }
956 function update(forkRef, refs) {
957 forkRef.refs = refs;
958 if (refs.every((ref) => ref == null)) {
959 forkRef.callback = null;
960 return;
961 }
962 forkRef.callback = (instance) => {
963 if (forkRef.cleanup) {
964 forkRef.cleanup();
965 forkRef.cleanup = null;
966 }
967 if (instance != null) {
968 const cleanupCallbacks = Array(refs.length).fill(null);
969 for (let i2 = 0; i2 < refs.length; i2 += 1) {
970 const ref = refs[i2];
971 if (ref == null) {
972 continue;
973 }
974 switch (typeof ref) {
975 case "function": {
976 const refCleanup = ref(instance);
977 if (typeof refCleanup === "function") {
978 cleanupCallbacks[i2] = refCleanup;
979 }
980 break;
981 }
982 case "object": {
983 ref.current = instance;
984 break;
985 }
986 default:
987 }
988 }
989 forkRef.cleanup = () => {
990 for (let i2 = 0; i2 < refs.length; i2 += 1) {
991 const ref = refs[i2];
992 if (ref == null) {
993 continue;
994 }
995 switch (typeof ref) {
996 case "function": {
997 const cleanupCallback = cleanupCallbacks[i2];
998 if (typeof cleanupCallback === "function") {
999 cleanupCallback();
1000 } else {
1001 ref(null);
1002 }
1003 break;
1004 }
1005 case "object": {
1006 ref.current = null;
1007 break;
1008 }
1009 default:
1010 }
1011 }
1012 };
1013 }
1014 };
1015 }
1016
1017 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1018 var React6 = __toESM(require_react(), 1);
1019
1020 // node_modules/@base-ui/utils/esm/reactVersion.js
1021 var React5 = __toESM(require_react(), 1);
1022 var majorVersion = parseInt(React5.version, 10);
1023 function isReactVersionAtLeast(reactVersionToCheck) {
1024 return majorVersion >= reactVersionToCheck;
1025 }
1026
1027 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1028 function getReactElementRef(element) {
1029 if (!/* @__PURE__ */ React6.isValidElement(element)) {
1030 return null;
1031 }
1032 const reactElement = element;
1033 const propsWithRef = reactElement.props;
1034 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1035 }
1036
1037 // node_modules/@base-ui/utils/esm/mergeObjects.js
1038 function mergeObjects(a2, b2) {
1039 if (a2 && !b2) {
1040 return a2;
1041 }
1042 if (!a2 && b2) {
1043 return b2;
1044 }
1045 if (a2 || b2) {
1046 return {
1047 ...a2,
1048 ...b2
1049 };
1050 }
1051 return void 0;
1052 }
1053
1054 // node_modules/@base-ui/utils/esm/empty.js
1055 function NOOP() {
1056 }
1057 var EMPTY_ARRAY = Object.freeze([]);
1058 var EMPTY_OBJECT = Object.freeze({});
1059
1060 // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js
1061 function getStateAttributesProps(state, customMapping) {
1062 const props = {};
1063 for (const key in state) {
1064 const value = state[key];
1065 if (customMapping?.hasOwnProperty(key)) {
1066 const customProps = customMapping[key](value);
1067 if (customProps != null) {
1068 Object.assign(props, customProps);
1069 }
1070 continue;
1071 }
1072 if (value === true) {
1073 props[`data-${key.toLowerCase()}`] = "";
1074 } else if (value) {
1075 props[`data-${key.toLowerCase()}`] = value.toString();
1076 }
1077 }
1078 return props;
1079 }
1080
1081 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
1082 function resolveClassName(className, state) {
1083 return typeof className === "function" ? className(state) : className;
1084 }
1085
1086 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
1087 function resolveStyle(style, state) {
1088 return typeof style === "function" ? style(state) : style;
1089 }
1090
1091 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
1092 var EMPTY_PROPS = {};
1093 function mergeProps(a2, b2, c2, d2, e2) {
1094 if (!c2 && !d2 && !e2 && !a2) {
1095 return createInitialMergedProps(b2);
1096 }
1097 let merged = createInitialMergedProps(a2);
1098 if (b2) {
1099 merged = mergeInto(merged, b2);
1100 }
1101 if (c2) {
1102 merged = mergeInto(merged, c2);
1103 }
1104 if (d2) {
1105 merged = mergeInto(merged, d2);
1106 }
1107 if (e2) {
1108 merged = mergeInto(merged, e2);
1109 }
1110 return merged;
1111 }
1112 function mergePropsN(props) {
1113 if (props.length === 0) {
1114 return EMPTY_PROPS;
1115 }
1116 if (props.length === 1) {
1117 return createInitialMergedProps(props[0]);
1118 }
1119 let merged = createInitialMergedProps(props[0]);
1120 for (let i2 = 1; i2 < props.length; i2 += 1) {
1121 merged = mergeInto(merged, props[i2]);
1122 }
1123 return merged;
1124 }
1125 function createInitialMergedProps(inputProps) {
1126 if (isPropsGetter(inputProps)) {
1127 return {
1128 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1129 };
1130 }
1131 return copyInitialProps(inputProps);
1132 }
1133 function mergeInto(merged, inputProps) {
1134 if (isPropsGetter(inputProps)) {
1135 return resolvePropsGetter(inputProps, merged);
1136 }
1137 return mutablyMergeInto(merged, inputProps);
1138 }
1139 function copyInitialProps(inputProps) {
1140 const copiedProps = {
1141 ...inputProps
1142 };
1143 for (const propName in copiedProps) {
1144 const propValue = copiedProps[propName];
1145 if (isEventHandler(propName, propValue)) {
1146 copiedProps[propName] = wrapEventHandler(propValue);
1147 }
1148 }
1149 return copiedProps;
1150 }
1151 function mutablyMergeInto(mergedProps, externalProps) {
1152 if (!externalProps) {
1153 return mergedProps;
1154 }
1155 for (const propName in externalProps) {
1156 const externalPropValue = externalProps[propName];
1157 switch (propName) {
1158 case "style": {
1159 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1160 break;
1161 }
1162 case "className": {
1163 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1164 break;
1165 }
1166 default: {
1167 if (isEventHandler(propName, externalPropValue)) {
1168 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1169 } else {
1170 mergedProps[propName] = externalPropValue;
1171 }
1172 }
1173 }
1174 }
1175 return mergedProps;
1176 }
1177 function isEventHandler(key, value) {
1178 const code0 = key.charCodeAt(0);
1179 const code1 = key.charCodeAt(1);
1180 const code2 = key.charCodeAt(2);
1181 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1182 }
1183 function isPropsGetter(inputProps) {
1184 return typeof inputProps === "function";
1185 }
1186 function resolvePropsGetter(inputProps, previousProps) {
1187 if (isPropsGetter(inputProps)) {
1188 return inputProps(previousProps);
1189 }
1190 return inputProps ?? EMPTY_PROPS;
1191 }
1192 function mergeEventHandlers(ourHandler, theirHandler) {
1193 if (!theirHandler) {
1194 return ourHandler;
1195 }
1196 if (!ourHandler) {
1197 return wrapEventHandler(theirHandler);
1198 }
1199 return (...args) => {
1200 const event = args[0];
1201 if (isSyntheticEvent(event)) {
1202 const baseUIEvent = event;
1203 makeEventPreventable(baseUIEvent);
1204 const result2 = theirHandler(...args);
1205 if (!baseUIEvent.baseUIHandlerPrevented) {
1206 ourHandler?.(...args);
1207 }
1208 return result2;
1209 }
1210 const result = theirHandler(...args);
1211 ourHandler?.(...args);
1212 return result;
1213 };
1214 }
1215 function wrapEventHandler(handler) {
1216 if (!handler) {
1217 return handler;
1218 }
1219 return (...args) => {
1220 const event = args[0];
1221 if (isSyntheticEvent(event)) {
1222 makeEventPreventable(event);
1223 }
1224 return handler(...args);
1225 };
1226 }
1227 function makeEventPreventable(event) {
1228 event.preventBaseUIHandler = () => {
1229 event.baseUIHandlerPrevented = true;
1230 };
1231 return event;
1232 }
1233 function mergeClassNames(ourClassName, theirClassName) {
1234 if (theirClassName) {
1235 if (ourClassName) {
1236 return theirClassName + " " + ourClassName;
1237 }
1238 return theirClassName;
1239 }
1240 return ourClassName;
1241 }
1242 function isSyntheticEvent(event) {
1243 return event != null && typeof event === "object" && "nativeEvent" in event;
1244 }
1245
1246 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1247 var import_react = __toESM(require_react(), 1);
1248 function useRenderElement(element, componentProps, params = {}) {
1249 const renderProp = componentProps.render;
1250 const outProps = useRenderElementProps(componentProps, params);
1251 if (params.enabled === false) {
1252 return null;
1253 }
1254 const state = params.state ?? EMPTY_OBJECT;
1255 return evaluateRenderProp(element, renderProp, outProps, state);
1256 }
1257 function useRenderElementProps(componentProps, params = {}) {
1258 const {
1259 className: classNameProp,
1260 style: styleProp,
1261 render: renderProp
1262 } = componentProps;
1263 const {
1264 state = EMPTY_OBJECT,
1265 ref,
1266 props,
1267 stateAttributesMapping: stateAttributesMapping3,
1268 enabled = true
1269 } = params;
1270 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1271 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1272 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping3) : EMPTY_OBJECT;
1273 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1274 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1275 if (typeof document !== "undefined") {
1276 if (!enabled) {
1277 useMergedRefs(null, null);
1278 } else if (Array.isArray(ref)) {
1279 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1280 } else {
1281 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1282 }
1283 }
1284 if (!enabled) {
1285 return EMPTY_OBJECT;
1286 }
1287 if (className !== void 0) {
1288 outProps.className = mergeClassNames(outProps.className, className);
1289 }
1290 if (style !== void 0) {
1291 outProps.style = mergeObjects(outProps.style, style);
1292 }
1293 return outProps;
1294 }
1295 function resolveRenderFunctionProps(props) {
1296 if (Array.isArray(props)) {
1297 return mergePropsN(props);
1298 }
1299 return mergeProps(void 0, props);
1300 }
1301 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1302 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1303 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1304 function evaluateRenderProp(element, render4, props, state) {
1305 if (render4) {
1306 if (typeof render4 === "function") {
1307 if (true) {
1308 warnIfRenderPropLooksLikeComponent(render4);
1309 }
1310 return render4(props, state);
1311 }
1312 const mergedProps = mergeProps(props, render4.props);
1313 mergedProps.ref = props.ref;
1314 let newElement = render4;
1315 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1316 const children = React7.Children.toArray(render4);
1317 newElement = children[0];
1318 }
1319 if (true) {
1320 if (!/* @__PURE__ */ React7.isValidElement(newElement)) {
1321 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"));
1322 }
1323 }
1324 return /* @__PURE__ */ React7.cloneElement(newElement, mergedProps);
1325 }
1326 if (element) {
1327 if (typeof element === "string") {
1328 return renderTag(element, props);
1329 }
1330 }
1331 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1332 }
1333 function warnIfRenderPropLooksLikeComponent(renderFn) {
1334 const functionName = renderFn.name;
1335 if (functionName.length === 0) {
1336 return;
1337 }
1338 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1339 return;
1340 }
1341 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1342 return;
1343 }
1344 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");
1345 }
1346 function renderTag(Tag, props) {
1347 if (Tag === "button") {
1348 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1349 type: "button",
1350 ...props,
1351 key: props.key
1352 });
1353 }
1354 if (Tag === "img") {
1355 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1356 alt: "",
1357 ...props,
1358 key: props.key
1359 });
1360 }
1361 return /* @__PURE__ */ React7.createElement(Tag, props);
1362 }
1363
1364 // node_modules/@base-ui/react/esm/internals/reason-parts.js
1365 var reason_parts_exports = {};
1366 __export(reason_parts_exports, {
1367 cancelOpen: () => cancelOpen,
1368 chipRemovePress: () => chipRemovePress,
1369 clearPress: () => clearPress,
1370 closePress: () => closePress,
1371 closeWatcher: () => closeWatcher,
1372 decrementPress: () => decrementPress,
1373 disabled: () => disabled,
1374 drag: () => drag,
1375 escapeKey: () => escapeKey,
1376 focusOut: () => focusOut,
1377 imperativeAction: () => imperativeAction,
1378 incrementPress: () => incrementPress,
1379 inputBlur: () => inputBlur,
1380 inputChange: () => inputChange,
1381 inputClear: () => inputClear,
1382 inputPaste: () => inputPaste,
1383 inputPress: () => inputPress,
1384 itemPress: () => itemPress,
1385 keyboard: () => keyboard,
1386 linkPress: () => linkPress,
1387 listNavigation: () => listNavigation,
1388 none: () => none,
1389 outsidePress: () => outsidePress,
1390 pointer: () => pointer,
1391 scrub: () => scrub,
1392 siblingOpen: () => siblingOpen,
1393 swipe: () => swipe,
1394 trackPress: () => trackPress,
1395 triggerFocus: () => triggerFocus,
1396 triggerHover: () => triggerHover,
1397 triggerPress: () => triggerPress,
1398 wheel: () => wheel,
1399 windowResize: () => windowResize
1400 });
1401 var none = "none";
1402 var triggerPress = "trigger-press";
1403 var triggerHover = "trigger-hover";
1404 var triggerFocus = "trigger-focus";
1405 var outsidePress = "outside-press";
1406 var itemPress = "item-press";
1407 var closePress = "close-press";
1408 var linkPress = "link-press";
1409 var clearPress = "clear-press";
1410 var chipRemovePress = "chip-remove-press";
1411 var trackPress = "track-press";
1412 var incrementPress = "increment-press";
1413 var decrementPress = "decrement-press";
1414 var inputChange = "input-change";
1415 var inputClear = "input-clear";
1416 var inputBlur = "input-blur";
1417 var inputPaste = "input-paste";
1418 var inputPress = "input-press";
1419 var focusOut = "focus-out";
1420 var escapeKey = "escape-key";
1421 var closeWatcher = "close-watcher";
1422 var listNavigation = "list-navigation";
1423 var keyboard = "keyboard";
1424 var pointer = "pointer";
1425 var drag = "drag";
1426 var wheel = "wheel";
1427 var scrub = "scrub";
1428 var cancelOpen = "cancel-open";
1429 var siblingOpen = "sibling-open";
1430 var disabled = "disabled";
1431 var imperativeAction = "imperative-action";
1432 var swipe = "swipe";
1433 var windowResize = "window-resize";
1434
1435 // node_modules/@base-ui/react/esm/internals/createBaseUIEventDetails.js
1436 function createChangeEventDetails(reason, event, trigger, customProperties) {
1437 let canceled = false;
1438 let allowPropagation = false;
1439 const custom = customProperties ?? EMPTY_OBJECT;
1440 const details = {
1441 reason,
1442 event: event ?? new Event("base-ui"),
1443 cancel() {
1444 canceled = true;
1445 },
1446 allowPropagation() {
1447 allowPropagation = true;
1448 },
1449 get isCanceled() {
1450 return canceled;
1451 },
1452 get isPropagationAllowed() {
1453 return allowPropagation;
1454 },
1455 trigger,
1456 ...custom
1457 };
1458 return details;
1459 }
1460
1461 // node_modules/@base-ui/utils/esm/useId.js
1462 var React9 = __toESM(require_react(), 1);
1463
1464 // node_modules/@base-ui/utils/esm/safeReact.js
1465 var React8 = __toESM(require_react(), 1);
1466 var SafeReact = {
1467 ...React8
1468 };
1469
1470 // node_modules/@base-ui/utils/esm/useId.js
1471 var globalId = 0;
1472 function useGlobalId(idOverride, prefix = "mui") {
1473 const [defaultId, setDefaultId] = React9.useState(idOverride);
1474 const id = idOverride || defaultId;
1475 React9.useEffect(() => {
1476 if (defaultId == null) {
1477 globalId += 1;
1478 setDefaultId(`${prefix}-${globalId}`);
1479 }
1480 }, [defaultId, prefix]);
1481 return id;
1482 }
1483 var maybeReactUseId = SafeReact.useId;
1484 function useId(idOverride, prefix) {
1485 if (maybeReactUseId !== void 0) {
1486 const reactId = maybeReactUseId();
1487 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
1488 }
1489 return useGlobalId(idOverride, prefix);
1490 }
1491
1492 // node_modules/@base-ui/react/esm/internals/useBaseUiId.js
1493 function useBaseUiId(idOverride) {
1494 return useId(idOverride, "base-ui");
1495 }
1496
1497 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
1498 var ReactDOM = __toESM(require_react_dom(), 1);
1499
1500 // node_modules/@base-ui/utils/esm/useOnMount.js
1501 var React10 = __toESM(require_react(), 1);
1502 var EMPTY = [];
1503 function useOnMount(fn) {
1504 React10.useEffect(fn, EMPTY);
1505 }
1506
1507 // node_modules/@base-ui/utils/esm/useAnimationFrame.js
1508 var EMPTY2 = null;
1509 var LAST_RAF = globalThis.requestAnimationFrame;
1510 var Scheduler = class {
1511 /* This implementation uses an array as a backing data-structure for frame callbacks.
1512 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
1513 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
1514 * be much more efficient if there is a call pattern that alterns as
1515 * "request-cancel-request-cancel-…".
1516 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
1517 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
1518 callbacks = [];
1519 callbacksCount = 0;
1520 nextId = 1;
1521 startId = 1;
1522 isScheduled = false;
1523 tick = (timestamp) => {
1524 this.isScheduled = false;
1525 const currentCallbacks = this.callbacks;
1526 const currentCallbacksCount = this.callbacksCount;
1527 this.callbacks = [];
1528 this.callbacksCount = 0;
1529 this.startId = this.nextId;
1530 if (currentCallbacksCount > 0) {
1531 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
1532 currentCallbacks[i2]?.(timestamp);
1533 }
1534 }
1535 };
1536 request(fn) {
1537 const id = this.nextId;
1538 this.nextId += 1;
1539 this.callbacks.push(fn);
1540 this.callbacksCount += 1;
1541 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
1542 if (!this.isScheduled || didRAFChange) {
1543 requestAnimationFrame(this.tick);
1544 this.isScheduled = true;
1545 }
1546 return id;
1547 }
1548 cancel(id) {
1549 const index2 = id - this.startId;
1550 if (index2 < 0 || index2 >= this.callbacks.length) {
1551 return;
1552 }
1553 this.callbacks[index2] = null;
1554 this.callbacksCount -= 1;
1555 }
1556 };
1557 var scheduler = new Scheduler();
1558 var AnimationFrame = class _AnimationFrame {
1559 static create() {
1560 return new _AnimationFrame();
1561 }
1562 static request(fn) {
1563 return scheduler.request(fn);
1564 }
1565 static cancel(id) {
1566 return scheduler.cancel(id);
1567 }
1568 currentId = EMPTY2;
1569 /**
1570 * Executes `fn` after `delay`, clearing any previously scheduled call.
1571 */
1572 request(fn) {
1573 this.cancel();
1574 this.currentId = scheduler.request(() => {
1575 this.currentId = EMPTY2;
1576 fn();
1577 });
1578 }
1579 cancel = () => {
1580 if (this.currentId !== EMPTY2) {
1581 scheduler.cancel(this.currentId);
1582 this.currentId = EMPTY2;
1583 }
1584 };
1585 disposeEffect = () => {
1586 return this.cancel;
1587 };
1588 };
1589 function useAnimationFrame() {
1590 const timeout = useRefWithInit(AnimationFrame.create).current;
1591 useOnMount(timeout.disposeEffect);
1592 return timeout;
1593 }
1594
1595 // node_modules/@base-ui/react/esm/utils/resolveRef.js
1596 function resolveRef(maybeRef) {
1597 if (maybeRef == null) {
1598 return maybeRef;
1599 }
1600 return "current" in maybeRef ? maybeRef.current : maybeRef;
1601 }
1602
1603 // node_modules/@base-ui/react/esm/internals/stateAttributesMapping.js
1604 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
1605 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
1606 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
1607 return TransitionStatusDataAttributes2;
1608 })({});
1609 var STARTING_HOOK = {
1610 [TransitionStatusDataAttributes.startingStyle]: ""
1611 };
1612 var ENDING_HOOK = {
1613 [TransitionStatusDataAttributes.endingStyle]: ""
1614 };
1615 var transitionStatusMapping = {
1616 transitionStatus(value) {
1617 if (value === "starting") {
1618 return STARTING_HOOK;
1619 }
1620 if (value === "ending") {
1621 return ENDING_HOOK;
1622 }
1623 return null;
1624 }
1625 };
1626
1627 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
1628 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
1629 const frame = useAnimationFrame();
1630 return useStableCallback((fnToExecute, signal = null) => {
1631 frame.cancel();
1632 const element = resolveRef(elementOrRef);
1633 if (element == null) {
1634 return;
1635 }
1636 const resolvedElement = element;
1637 const done = () => {
1638 ReactDOM.flushSync(fnToExecute);
1639 };
1640 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
1641 fnToExecute();
1642 return;
1643 }
1644 function exec() {
1645 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
1646 if (!signal?.aborted) {
1647 done();
1648 }
1649 }).catch(() => {
1650 if (treatAbortedAsFinished) {
1651 if (!signal?.aborted) {
1652 done();
1653 }
1654 return;
1655 }
1656 const currentAnimations = resolvedElement.getAnimations();
1657 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
1658 exec();
1659 }
1660 });
1661 }
1662 if (waitForStartingStyleRemoved) {
1663 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
1664 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
1665 frame.request(exec);
1666 return;
1667 }
1668 const attributeObserver = new MutationObserver(() => {
1669 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
1670 attributeObserver.disconnect();
1671 exec();
1672 }
1673 });
1674 attributeObserver.observe(resolvedElement, {
1675 attributes: true,
1676 attributeFilter: [startingStyleAttribute]
1677 });
1678 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
1679 once: true
1680 });
1681 return;
1682 }
1683 frame.request(exec);
1684 });
1685 }
1686
1687 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1688 var React11 = __toESM(require_react(), 1);
1689 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
1690 const [transitionStatus, setTransitionStatus] = React11.useState(open && enableIdleState ? "idle" : void 0);
1691 const [mounted, setMounted] = React11.useState(open);
1692 if (open && !mounted) {
1693 setMounted(true);
1694 setTransitionStatus("starting");
1695 }
1696 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
1697 setTransitionStatus("ending");
1698 }
1699 if (!open && !mounted && transitionStatus === "ending") {
1700 setTransitionStatus(void 0);
1701 }
1702 useIsoLayoutEffect(() => {
1703 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
1704 const frame = AnimationFrame.request(() => {
1705 setTransitionStatus("ending");
1706 });
1707 return () => {
1708 AnimationFrame.cancel(frame);
1709 };
1710 }
1711 return void 0;
1712 }, [open, mounted, transitionStatus, deferEndingState]);
1713 useIsoLayoutEffect(() => {
1714 if (!open || enableIdleState) {
1715 return void 0;
1716 }
1717 const frame = AnimationFrame.request(() => {
1718 setTransitionStatus(void 0);
1719 });
1720 return () => {
1721 AnimationFrame.cancel(frame);
1722 };
1723 }, [enableIdleState, open]);
1724 useIsoLayoutEffect(() => {
1725 if (!open || !enableIdleState) {
1726 return void 0;
1727 }
1728 if (open && mounted && transitionStatus !== "idle") {
1729 setTransitionStatus("starting");
1730 }
1731 const frame = AnimationFrame.request(() => {
1732 setTransitionStatus("idle");
1733 });
1734 return () => {
1735 AnimationFrame.cancel(frame);
1736 };
1737 }, [enableIdleState, open, mounted, transitionStatus]);
1738 return {
1739 mounted,
1740 setMounted,
1741 transitionStatus
1742 };
1743 }
1744
1745 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
1746 function hasWindow() {
1747 return typeof window !== "undefined";
1748 }
1749 function getNodeName(node) {
1750 if (isNode(node)) {
1751 return (node.nodeName || "").toLowerCase();
1752 }
1753 return "#document";
1754 }
1755 function getWindow(node) {
1756 var _node$ownerDocument;
1757 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1758 }
1759 function getDocumentElement(node) {
1760 var _ref;
1761 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1762 }
1763 function isNode(value) {
1764 if (!hasWindow()) {
1765 return false;
1766 }
1767 return value instanceof Node || value instanceof getWindow(value).Node;
1768 }
1769 function isElement(value) {
1770 if (!hasWindow()) {
1771 return false;
1772 }
1773 return value instanceof Element || value instanceof getWindow(value).Element;
1774 }
1775 function isHTMLElement(value) {
1776 if (!hasWindow()) {
1777 return false;
1778 }
1779 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1780 }
1781 function isShadowRoot(value) {
1782 if (!hasWindow() || typeof ShadowRoot === "undefined") {
1783 return false;
1784 }
1785 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1786 }
1787 function isOverflowElement(element) {
1788 const {
1789 overflow,
1790 overflowX,
1791 overflowY,
1792 display
1793 } = getComputedStyle2(element);
1794 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
1795 }
1796 function isTableElement(element) {
1797 return /^(table|td|th)$/.test(getNodeName(element));
1798 }
1799 function isTopLayer(element) {
1800 try {
1801 if (element.matches(":popover-open")) {
1802 return true;
1803 }
1804 } catch (_e) {
1805 }
1806 try {
1807 return element.matches(":modal");
1808 } catch (_e) {
1809 return false;
1810 }
1811 }
1812 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
1813 var containRe = /paint|layout|strict|content/;
1814 var isNotNone = (value) => !!value && value !== "none";
1815 var isWebKitValue;
1816 function isContainingBlock(elementOrCss) {
1817 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
1818 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 || "");
1819 }
1820 function getContainingBlock(element) {
1821 let currentNode = getParentNode(element);
1822 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1823 if (isContainingBlock(currentNode)) {
1824 return currentNode;
1825 } else if (isTopLayer(currentNode)) {
1826 return null;
1827 }
1828 currentNode = getParentNode(currentNode);
1829 }
1830 return null;
1831 }
1832 function isWebKit() {
1833 if (isWebKitValue == null) {
1834 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
1835 }
1836 return isWebKitValue;
1837 }
1838 function isLastTraversableNode(node) {
1839 return /^(html|body|#document)$/.test(getNodeName(node));
1840 }
1841 function getComputedStyle2(element) {
1842 return getWindow(element).getComputedStyle(element);
1843 }
1844 function getNodeScroll(element) {
1845 if (isElement(element)) {
1846 return {
1847 scrollLeft: element.scrollLeft,
1848 scrollTop: element.scrollTop
1849 };
1850 }
1851 return {
1852 scrollLeft: element.scrollX,
1853 scrollTop: element.scrollY
1854 };
1855 }
1856 function getParentNode(node) {
1857 if (getNodeName(node) === "html") {
1858 return node;
1859 }
1860 const result = (
1861 // Step into the shadow DOM of the parent of a slotted node.
1862 node.assignedSlot || // DOM Element detected.
1863 node.parentNode || // ShadowRoot detected.
1864 isShadowRoot(node) && node.host || // Fallback.
1865 getDocumentElement(node)
1866 );
1867 return isShadowRoot(result) ? result.host : result;
1868 }
1869 function getNearestOverflowAncestor(node) {
1870 const parentNode = getParentNode(node);
1871 if (isLastTraversableNode(parentNode)) {
1872 return node.ownerDocument ? node.ownerDocument.body : node.body;
1873 }
1874 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1875 return parentNode;
1876 }
1877 return getNearestOverflowAncestor(parentNode);
1878 }
1879 function getOverflowAncestors(node, list, traverseIframes) {
1880 var _node$ownerDocument2;
1881 if (list === void 0) {
1882 list = [];
1883 }
1884 if (traverseIframes === void 0) {
1885 traverseIframes = true;
1886 }
1887 const scrollableAncestor = getNearestOverflowAncestor(node);
1888 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1889 const win = getWindow(scrollableAncestor);
1890 if (isBody) {
1891 const frameElement = getFrameElement(win);
1892 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
1893 } else {
1894 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1895 }
1896 }
1897 function getFrameElement(win) {
1898 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
1899 }
1900
1901 // node_modules/@base-ui/utils/esm/detectBrowser.js
1902 var hasNavigator = typeof navigator !== "undefined";
1903 var nav = getNavigatorData();
1904 var platform = getPlatform();
1905 var userAgent = getUserAgent();
1906 var isWebKit2 = typeof CSS === "undefined" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter:none");
1907 var isIOS = (
1908 // iPads can claim to be MacIntel
1909 nav.platform === "MacIntel" && nav.maxTouchPoints > 1 ? true : /iP(hone|ad|od)|iOS/.test(nav.platform)
1910 );
1911 var isFirefox = hasNavigator && /firefox/i.test(userAgent);
1912 var isSafari = hasNavigator && /apple/i.test(navigator.vendor);
1913 var isEdge = hasNavigator && /Edg/i.test(userAgent);
1914 var isAndroid = hasNavigator && /android/i.test(platform) || /android/i.test(userAgent);
1915 var isMac = hasNavigator && platform.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
1916 var isJSDOM = userAgent.includes("jsdom/");
1917 function getNavigatorData() {
1918 if (!hasNavigator) {
1919 return {
1920 platform: "",
1921 maxTouchPoints: -1
1922 };
1923 }
1924 const uaData = navigator.userAgentData;
1925 if (uaData?.platform) {
1926 return {
1927 platform: uaData.platform,
1928 maxTouchPoints: navigator.maxTouchPoints
1929 };
1930 }
1931 return {
1932 platform: navigator.platform ?? "",
1933 maxTouchPoints: navigator.maxTouchPoints ?? -1
1934 };
1935 }
1936 function getUserAgent() {
1937 if (!hasNavigator) {
1938 return "";
1939 }
1940 const uaData = navigator.userAgentData;
1941 if (uaData && Array.isArray(uaData.brands)) {
1942 return uaData.brands.map(({
1943 brand,
1944 version: version2
1945 }) => `${brand}/${version2}`).join(" ");
1946 }
1947 return navigator.userAgent;
1948 }
1949 function getPlatform() {
1950 if (!hasNavigator) {
1951 return "";
1952 }
1953 const uaData = navigator.userAgentData;
1954 if (uaData?.platform) {
1955 return uaData.platform;
1956 }
1957 return navigator.platform ?? "";
1958 }
1959
1960 // node_modules/@base-ui/react/esm/floating-ui-react/utils/constants.js
1961 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
1962 var ACTIVE_KEY = "active";
1963 var SELECTED_KEY = "selected";
1964 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
1965
1966 // node_modules/@base-ui/react/esm/internals/shadowDom.js
1967 function activeElement(doc) {
1968 let element = doc.activeElement;
1969 while (element?.shadowRoot?.activeElement != null) {
1970 element = element.shadowRoot.activeElement;
1971 }
1972 return element;
1973 }
1974 function contains(parent, child) {
1975 if (!parent || !child) {
1976 return false;
1977 }
1978 const rootNode = child.getRootNode?.();
1979 if (parent.contains(child)) {
1980 return true;
1981 }
1982 if (rootNode && isShadowRoot(rootNode)) {
1983 let next = child;
1984 while (next) {
1985 if (parent === next) {
1986 return true;
1987 }
1988 next = next.parentNode || next.host;
1989 }
1990 }
1991 return false;
1992 }
1993 function getTarget(event) {
1994 if ("composedPath" in event) {
1995 return event.composedPath()[0];
1996 }
1997 return event.target;
1998 }
1999
2000 // node_modules/@base-ui/react/esm/floating-ui-react/utils/element.js
2001 function isTargetInsideEnabledTrigger(target, triggerElements) {
2002 if (!isElement(target)) {
2003 return false;
2004 }
2005 const targetElement = target;
2006 if (triggerElements.hasElement(targetElement)) {
2007 return !targetElement.hasAttribute("data-trigger-disabled");
2008 }
2009 for (const [, trigger] of triggerElements.entries()) {
2010 if (contains(trigger, targetElement)) {
2011 return !trigger.hasAttribute("data-trigger-disabled");
2012 }
2013 }
2014 return false;
2015 }
2016 function isEventTargetWithin(event, node) {
2017 if (node == null) {
2018 return false;
2019 }
2020 if ("composedPath" in event) {
2021 return event.composedPath().includes(node);
2022 }
2023 const eventAgain = event;
2024 return eventAgain.target != null && node.contains(eventAgain.target);
2025 }
2026 function isRootElement(element) {
2027 return element.matches("html,body");
2028 }
2029 function isTypeableElement(element) {
2030 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
2031 }
2032 function isInteractiveElement(element) {
2033 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
2034 }
2035 function matchesFocusVisible(element) {
2036 if (!element || isJSDOM) {
2037 return true;
2038 }
2039 try {
2040 return element.matches(":focus-visible");
2041 } catch (_e) {
2042 return true;
2043 }
2044 }
2045
2046 // node_modules/@base-ui/react/esm/floating-ui-react/utils/nodes.js
2047 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
2048 const directChildren = nodes.filter((node) => node.parentId === id);
2049 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
2050 }
2051
2052 // node_modules/@base-ui/react/esm/floating-ui-react/utils/event.js
2053 function isReactEvent(event) {
2054 return "nativeEvent" in event;
2055 }
2056 function isMouseLikePointerType(pointerType, strict) {
2057 const values = ["mouse", "pen"];
2058 if (!strict) {
2059 values.push("", void 0);
2060 }
2061 return values.includes(pointerType);
2062 }
2063 function isClickLikeEvent(event) {
2064 const type = event.type;
2065 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
2066 }
2067
2068 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
2069 var sides = ["top", "right", "bottom", "left"];
2070 var min = Math.min;
2071 var max = Math.max;
2072 var round = Math.round;
2073 var floor = Math.floor;
2074 var createCoords = (v2) => ({
2075 x: v2,
2076 y: v2
2077 });
2078 var oppositeSideMap = {
2079 left: "right",
2080 right: "left",
2081 bottom: "top",
2082 top: "bottom"
2083 };
2084 function clamp(start, value, end) {
2085 return max(start, min(value, end));
2086 }
2087 function evaluate(value, param) {
2088 return typeof value === "function" ? value(param) : value;
2089 }
2090 function getSide(placement) {
2091 return placement.split("-")[0];
2092 }
2093 function getAlignment(placement) {
2094 return placement.split("-")[1];
2095 }
2096 function getOppositeAxis(axis) {
2097 return axis === "x" ? "y" : "x";
2098 }
2099 function getAxisLength(axis) {
2100 return axis === "y" ? "height" : "width";
2101 }
2102 function getSideAxis(placement) {
2103 const firstChar = placement[0];
2104 return firstChar === "t" || firstChar === "b" ? "y" : "x";
2105 }
2106 function getAlignmentAxis(placement) {
2107 return getOppositeAxis(getSideAxis(placement));
2108 }
2109 function getAlignmentSides(placement, rects, rtl) {
2110 if (rtl === void 0) {
2111 rtl = false;
2112 }
2113 const alignment = getAlignment(placement);
2114 const alignmentAxis = getAlignmentAxis(placement);
2115 const length = getAxisLength(alignmentAxis);
2116 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
2117 if (rects.reference[length] > rects.floating[length]) {
2118 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
2119 }
2120 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
2121 }
2122 function getExpandedPlacements(placement) {
2123 const oppositePlacement = getOppositePlacement(placement);
2124 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
2125 }
2126 function getOppositeAlignmentPlacement(placement) {
2127 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
2128 }
2129 var lrPlacement = ["left", "right"];
2130 var rlPlacement = ["right", "left"];
2131 var tbPlacement = ["top", "bottom"];
2132 var btPlacement = ["bottom", "top"];
2133 function getSideList(side, isStart, rtl) {
2134 switch (side) {
2135 case "top":
2136 case "bottom":
2137 if (rtl) return isStart ? rlPlacement : lrPlacement;
2138 return isStart ? lrPlacement : rlPlacement;
2139 case "left":
2140 case "right":
2141 return isStart ? tbPlacement : btPlacement;
2142 default:
2143 return [];
2144 }
2145 }
2146 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
2147 const alignment = getAlignment(placement);
2148 let list = getSideList(getSide(placement), direction === "start", rtl);
2149 if (alignment) {
2150 list = list.map((side) => side + "-" + alignment);
2151 if (flipAlignment) {
2152 list = list.concat(list.map(getOppositeAlignmentPlacement));
2153 }
2154 }
2155 return list;
2156 }
2157 function getOppositePlacement(placement) {
2158 const side = getSide(placement);
2159 return oppositeSideMap[side] + placement.slice(side.length);
2160 }
2161 function expandPaddingObject(padding) {
2162 return {
2163 top: 0,
2164 right: 0,
2165 bottom: 0,
2166 left: 0,
2167 ...padding
2168 };
2169 }
2170 function getPaddingObject(padding) {
2171 return typeof padding !== "number" ? expandPaddingObject(padding) : {
2172 top: padding,
2173 right: padding,
2174 bottom: padding,
2175 left: padding
2176 };
2177 }
2178 function rectToClientRect(rect) {
2179 const {
2180 x: x2,
2181 y: y2,
2182 width,
2183 height
2184 } = rect;
2185 return {
2186 width,
2187 height,
2188 top: y2,
2189 left: x2,
2190 right: x2 + width,
2191 bottom: y2 + height,
2192 x: x2,
2193 y: y2
2194 };
2195 }
2196
2197 // node_modules/@base-ui/react/esm/floating-ui-react/utils/composite.js
2198 function isHiddenByStyles(styles) {
2199 return styles.visibility === "hidden" || styles.visibility === "collapse";
2200 }
2201 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
2202 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
2203 return false;
2204 }
2205 if (typeof element.checkVisibility === "function") {
2206 return element.checkVisibility();
2207 }
2208 return styles.display !== "none" && styles.display !== "contents";
2209 }
2210
2211 // node_modules/@base-ui/utils/esm/owner.js
2212 function ownerDocument(node) {
2213 return node?.ownerDocument || document;
2214 }
2215
2216 // node_modules/@base-ui/react/esm/floating-ui-react/utils/tabbable.js
2217 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
2218 function getParentElement(element) {
2219 const assignedSlot = element.assignedSlot;
2220 if (assignedSlot) {
2221 return assignedSlot;
2222 }
2223 if (element.parentElement) {
2224 return element.parentElement;
2225 }
2226 const rootNode = element.getRootNode();
2227 return isShadowRoot(rootNode) ? rootNode.host : null;
2228 }
2229 function getDetailsSummary(details) {
2230 for (const child of Array.from(details.children)) {
2231 if (getNodeName(child) === "summary") {
2232 return child;
2233 }
2234 }
2235 return null;
2236 }
2237 function isWithinOpenDetailsSummary(element, details) {
2238 const summary = getDetailsSummary(details);
2239 return !!summary && (element === summary || contains(summary, element));
2240 }
2241 function isFocusableCandidate(element) {
2242 const nodeName = element ? getNodeName(element) : "";
2243 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");
2244 }
2245 function isFocusableElement(element) {
2246 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
2247 return false;
2248 }
2249 for (let current = element; current; current = getParentElement(current)) {
2250 const isAncestor = current !== element;
2251 const isSlot = getNodeName(current) === "slot";
2252 if (current.hasAttribute("inert")) {
2253 return false;
2254 }
2255 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
2256 return false;
2257 }
2258 }
2259 return true;
2260 }
2261 function isVisibleInTabbableTree(element, isAncestor) {
2262 const styles = getComputedStyle2(element);
2263 if (!isAncestor) {
2264 return isElementVisible(element, styles);
2265 }
2266 return styles.display !== "none";
2267 }
2268 function getTabIndex(element) {
2269 const tabIndex = element.tabIndex;
2270 if (tabIndex < 0) {
2271 const nodeName = getNodeName(element);
2272 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
2273 return 0;
2274 }
2275 }
2276 return tabIndex;
2277 }
2278 function getNamedRadioInput(element) {
2279 if (getNodeName(element) !== "input") {
2280 return null;
2281 }
2282 const input = element;
2283 return input.type === "radio" && input.name !== "" ? input : null;
2284 }
2285 function isTabbableRadio(element, candidates) {
2286 const input = getNamedRadioInput(element);
2287 if (!input) {
2288 return true;
2289 }
2290 const checkedRadio = candidates.find((candidate) => {
2291 const radio = getNamedRadioInput(candidate);
2292 return radio?.name === input.name && radio.form === input.form && radio.checked;
2293 });
2294 if (checkedRadio) {
2295 return checkedRadio === input;
2296 }
2297 return candidates.find((candidate) => {
2298 const radio = getNamedRadioInput(candidate);
2299 return radio?.name === input.name && radio.form === input.form;
2300 }) === input;
2301 }
2302 function getComposedChildren(container) {
2303 if (isHTMLElement(container) && getNodeName(container) === "slot") {
2304 const assignedElements = container.assignedElements({
2305 flatten: true
2306 });
2307 if (assignedElements.length > 0) {
2308 return assignedElements;
2309 }
2310 }
2311 if (isHTMLElement(container) && container.shadowRoot) {
2312 return Array.from(container.shadowRoot.children);
2313 }
2314 return Array.from(container.children);
2315 }
2316 function appendCandidates(container, list) {
2317 getComposedChildren(container).forEach((child) => {
2318 if (isFocusableCandidate(child)) {
2319 list.push(child);
2320 }
2321 appendCandidates(child, list);
2322 });
2323 }
2324 function appendMatchingElements(container, selector2, list) {
2325 getComposedChildren(container).forEach((child) => {
2326 if (isHTMLElement(child) && child.matches(selector2)) {
2327 list.push(child);
2328 }
2329 appendMatchingElements(child, selector2, list);
2330 });
2331 }
2332 function focusable(container) {
2333 const candidates = [];
2334 appendCandidates(container, candidates);
2335 return candidates.filter(isFocusableElement);
2336 }
2337 function tabbable(container) {
2338 const candidates = focusable(container);
2339 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
2340 }
2341 function getTabbableIn(container, dir) {
2342 const list = tabbable(container);
2343 const len = list.length;
2344 if (len === 0) {
2345 return void 0;
2346 }
2347 const active = activeElement(ownerDocument(container));
2348 const index2 = list.indexOf(active);
2349 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
2350 return list[nextIndex];
2351 }
2352 function getNextTabbable(referenceElement) {
2353 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
2354 }
2355 function getPreviousTabbable(referenceElement) {
2356 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
2357 }
2358 function isOutsideEvent(event, container) {
2359 const containerElement = container || event.currentTarget;
2360 const relatedTarget = event.relatedTarget;
2361 return !relatedTarget || !contains(containerElement, relatedTarget);
2362 }
2363 function disableFocusInside(container) {
2364 const tabbableElements = tabbable(container);
2365 tabbableElements.forEach((element) => {
2366 element.dataset.tabindex = element.getAttribute("tabindex") || "";
2367 element.setAttribute("tabindex", "-1");
2368 });
2369 }
2370 function enableFocusInside(container) {
2371 const elements = [];
2372 appendMatchingElements(container, "[data-tabindex]", elements);
2373 elements.forEach((element) => {
2374 const tabindex = element.dataset.tabindex;
2375 delete element.dataset.tabindex;
2376 if (tabindex) {
2377 element.setAttribute("tabindex", tabindex);
2378 } else {
2379 element.removeAttribute("tabindex");
2380 }
2381 });
2382 }
2383
2384 // node_modules/@base-ui/utils/esm/addEventListener.js
2385 function addEventListener(target, type, listener, options) {
2386 target.addEventListener(type, listener, options);
2387 return () => {
2388 target.removeEventListener(type, listener, options);
2389 };
2390 }
2391
2392 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
2393 var React12 = __toESM(require_react(), 1);
2394 function useOpenChangeComplete(parameters) {
2395 const {
2396 enabled = true,
2397 open,
2398 ref,
2399 onComplete: onCompleteParam
2400 } = parameters;
2401 const onComplete = useStableCallback(onCompleteParam);
2402 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
2403 React12.useEffect(() => {
2404 if (!enabled) {
2405 return void 0;
2406 }
2407 const abortController = new AbortController();
2408 runOnceAnimationsFinish(onComplete, abortController.signal);
2409 return () => {
2410 abortController.abort();
2411 };
2412 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
2413 }
2414
2415 // node_modules/@base-ui/utils/esm/useOnFirstRender.js
2416 var React13 = __toESM(require_react(), 1);
2417 function useOnFirstRender(fn) {
2418 const ref = React13.useRef(true);
2419 if (ref.current) {
2420 ref.current = false;
2421 fn();
2422 }
2423 }
2424
2425 // node_modules/@base-ui/utils/esm/useTimeout.js
2426 var EMPTY3 = 0;
2427 var Timeout = class _Timeout {
2428 static create() {
2429 return new _Timeout();
2430 }
2431 currentId = EMPTY3;
2432 /**
2433 * Executes `fn` after `delay`, clearing any previously scheduled call.
2434 */
2435 start(delay, fn) {
2436 this.clear();
2437 this.currentId = setTimeout(() => {
2438 this.currentId = EMPTY3;
2439 fn();
2440 }, delay);
2441 }
2442 isStarted() {
2443 return this.currentId !== EMPTY3;
2444 }
2445 clear = () => {
2446 if (this.currentId !== EMPTY3) {
2447 clearTimeout(this.currentId);
2448 this.currentId = EMPTY3;
2449 }
2450 };
2451 disposeEffect = () => {
2452 return this.clear;
2453 };
2454 };
2455 function useTimeout() {
2456 const timeout = useRefWithInit(Timeout.create).current;
2457 useOnMount(timeout.disposeEffect);
2458 return timeout;
2459 }
2460
2461 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2462 var React14 = __toESM(require_react(), 1);
2463
2464 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverShared.js
2465 function resolveValue(value, pointerType) {
2466 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
2467 return 0;
2468 }
2469 if (typeof value === "function") {
2470 return value();
2471 }
2472 return value;
2473 }
2474 function getDelay(value, prop, pointerType) {
2475 const result = resolveValue(value, pointerType);
2476 if (typeof result === "number") {
2477 return result;
2478 }
2479 return result?.[prop];
2480 }
2481 function getRestMs(value) {
2482 if (typeof value === "function") {
2483 return value();
2484 }
2485 return value;
2486 }
2487 function isClickLikeOpenEvent(openEventType, interactedInside) {
2488 return interactedInside || openEventType === "click" || openEventType === "mousedown";
2489 }
2490
2491 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2492 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
2493 var FloatingDelayGroupContext = /* @__PURE__ */ React14.createContext({
2494 hasProvider: false,
2495 timeoutMs: 0,
2496 delayRef: {
2497 current: 0
2498 },
2499 initialDelayRef: {
2500 current: 0
2501 },
2502 timeout: new Timeout(),
2503 currentIdRef: {
2504 current: null
2505 },
2506 currentContextRef: {
2507 current: null
2508 }
2509 });
2510 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
2511 function FloatingDelayGroup(props) {
2512 const {
2513 children,
2514 delay,
2515 timeoutMs = 0
2516 } = props;
2517 const delayRef = React14.useRef(delay);
2518 const initialDelayRef = React14.useRef(delay);
2519 const currentIdRef = React14.useRef(null);
2520 const currentContextRef = React14.useRef(null);
2521 const timeout = useTimeout();
2522 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, {
2523 value: React14.useMemo(() => ({
2524 hasProvider: true,
2525 delayRef,
2526 initialDelayRef,
2527 currentIdRef,
2528 timeoutMs,
2529 currentContextRef,
2530 timeout
2531 }), [timeoutMs, timeout]),
2532 children
2533 });
2534 }
2535 function useDelayGroup(context, options = {
2536 open: false
2537 }) {
2538 const store = "rootStore" in context ? context.rootStore : context;
2539 const floatingId = store.useState("floatingId");
2540 const {
2541 open
2542 } = options;
2543 const groupContext = React14.useContext(FloatingDelayGroupContext);
2544 const {
2545 currentIdRef,
2546 delayRef,
2547 timeoutMs,
2548 initialDelayRef,
2549 currentContextRef,
2550 hasProvider,
2551 timeout
2552 } = groupContext;
2553 const [isInstantPhase, setIsInstantPhase] = React14.useState(false);
2554 useIsoLayoutEffect(() => {
2555 function unset() {
2556 setIsInstantPhase(false);
2557 currentContextRef.current?.setIsInstantPhase(false);
2558 currentIdRef.current = null;
2559 currentContextRef.current = null;
2560 delayRef.current = initialDelayRef.current;
2561 }
2562 if (!currentIdRef.current) {
2563 return void 0;
2564 }
2565 if (!open && currentIdRef.current === floatingId) {
2566 setIsInstantPhase(false);
2567 if (timeoutMs) {
2568 const closingId = floatingId;
2569 timeout.start(timeoutMs, () => {
2570 if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
2571 return;
2572 }
2573 unset();
2574 });
2575 return () => {
2576 timeout.clear();
2577 };
2578 }
2579 unset();
2580 }
2581 return void 0;
2582 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]);
2583 useIsoLayoutEffect(() => {
2584 if (!open) {
2585 return;
2586 }
2587 const prevContext = currentContextRef.current;
2588 const prevId = currentIdRef.current;
2589 timeout.clear();
2590 currentContextRef.current = {
2591 onOpenChange: store.setOpen,
2592 setIsInstantPhase
2593 };
2594 currentIdRef.current = floatingId;
2595 delayRef.current = {
2596 open: 0,
2597 close: getDelay(initialDelayRef.current, "close")
2598 };
2599 if (prevId !== null && prevId !== floatingId) {
2600 setIsInstantPhase(true);
2601 prevContext?.setIsInstantPhase(true);
2602 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
2603 } else {
2604 setIsInstantPhase(false);
2605 prevContext?.setIsInstantPhase(false);
2606 }
2607 }, [open, floatingId, store, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout]);
2608 useIsoLayoutEffect(() => {
2609 return () => {
2610 currentContextRef.current = null;
2611 };
2612 }, [currentContextRef]);
2613 return React14.useMemo(() => ({
2614 hasProvider,
2615 delayRef,
2616 isInstantPhase
2617 }), [hasProvider, delayRef, isInstantPhase]);
2618 }
2619
2620 // node_modules/@base-ui/utils/esm/mergeCleanups.js
2621 function mergeCleanups(...cleanups) {
2622 return () => {
2623 for (let i2 = 0; i2 < cleanups.length; i2 += 1) {
2624 const cleanup = cleanups[i2];
2625 if (cleanup) {
2626 cleanup();
2627 }
2628 }
2629 };
2630 }
2631
2632 // node_modules/@base-ui/utils/esm/useValueAsRef.js
2633 function useValueAsRef(value) {
2634 const latest = useRefWithInit(createLatestRef, value).current;
2635 latest.next = value;
2636 useIsoLayoutEffect(latest.effect);
2637 return latest;
2638 }
2639 function createLatestRef(value) {
2640 const latest = {
2641 current: value,
2642 next: value,
2643 effect: () => {
2644 latest.current = latest.next;
2645 }
2646 };
2647 return latest;
2648 }
2649
2650 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
2651 var React15 = __toESM(require_react(), 1);
2652
2653 // node_modules/@base-ui/utils/esm/visuallyHidden.js
2654 var visuallyHiddenBase = {
2655 clipPath: "inset(50%)",
2656 overflow: "hidden",
2657 whiteSpace: "nowrap",
2658 border: 0,
2659 padding: 0,
2660 width: 1,
2661 height: 1,
2662 margin: -1
2663 };
2664 var visuallyHidden = {
2665 ...visuallyHiddenBase,
2666 position: "fixed",
2667 top: 0,
2668 left: 0
2669 };
2670 var visuallyHiddenInput = {
2671 ...visuallyHiddenBase,
2672 position: "absolute"
2673 };
2674
2675 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
2676 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
2677 var FocusGuard = /* @__PURE__ */ React15.forwardRef(function FocusGuard2(props, ref) {
2678 const [role, setRole] = React15.useState();
2679 useIsoLayoutEffect(() => {
2680 if (isSafari) {
2681 setRole("button");
2682 }
2683 }, []);
2684 const restProps = {
2685 tabIndex: 0,
2686 // Role is only for VoiceOver
2687 role
2688 };
2689 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {
2690 ...props,
2691 ref,
2692 style: visuallyHidden,
2693 "aria-hidden": role ? void 0 : true,
2694 ...restProps,
2695 "data-base-ui-focus-guard": ""
2696 });
2697 });
2698 if (true) FocusGuard.displayName = "FocusGuard";
2699
2700 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createAttribute.js
2701 function createAttribute(name) {
2702 return `data-base-ui-${name}`;
2703 }
2704
2705 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
2706 var React16 = __toESM(require_react(), 1);
2707 var ReactDOM2 = __toESM(require_react_dom(), 1);
2708
2709 // node_modules/@base-ui/react/esm/internals/constants.js
2710 var DISABLED_TRANSITIONS_STYLE = {
2711 style: {
2712 transition: "none"
2713 }
2714 };
2715 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
2716 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
2717 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
2718 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
2719 var POPUP_COLLISION_AVOIDANCE = {
2720 fallbackAxisSide: "end"
2721 };
2722 var ownerVisuallyHidden = {
2723 clipPath: "inset(50%)",
2724 position: "fixed",
2725 top: 0,
2726 left: 0
2727 };
2728
2729 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
2730 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
2731 var PortalContext = /* @__PURE__ */ React16.createContext(null);
2732 if (true) PortalContext.displayName = "PortalContext";
2733 var usePortalContext = () => React16.useContext(PortalContext);
2734 var attr = createAttribute("portal");
2735 function useFloatingPortalNode(props = {}) {
2736 const {
2737 ref,
2738 container: containerProp,
2739 componentProps = EMPTY_OBJECT,
2740 elementProps
2741 } = props;
2742 const uniqueId = useId();
2743 const portalContext = usePortalContext();
2744 const parentPortalNode = portalContext?.portalNode;
2745 const [containerElement, setContainerElement] = React16.useState(null);
2746 const [portalNode, setPortalNode] = React16.useState(null);
2747 const setPortalNodeRef = useStableCallback((node) => {
2748 if (node !== null) {
2749 setPortalNode(node);
2750 }
2751 });
2752 const containerRef = React16.useRef(null);
2753 useIsoLayoutEffect(() => {
2754 if (containerProp === null) {
2755 if (containerRef.current) {
2756 containerRef.current = null;
2757 setPortalNode(null);
2758 setContainerElement(null);
2759 }
2760 return;
2761 }
2762 if (uniqueId == null) {
2763 return;
2764 }
2765 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
2766 if (resolvedContainer == null) {
2767 if (containerRef.current) {
2768 containerRef.current = null;
2769 setPortalNode(null);
2770 setContainerElement(null);
2771 }
2772 return;
2773 }
2774 if (containerRef.current !== resolvedContainer) {
2775 containerRef.current = resolvedContainer;
2776 setPortalNode(null);
2777 setContainerElement(resolvedContainer);
2778 }
2779 }, [containerProp, parentPortalNode, uniqueId]);
2780 const portalElement = useRenderElement("div", componentProps, {
2781 ref: [ref, setPortalNodeRef],
2782 props: [{
2783 id: uniqueId,
2784 [attr]: ""
2785 }, elementProps]
2786 });
2787 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
2788 return {
2789 portalNode,
2790 portalSubtree
2791 };
2792 }
2793 var FloatingPortal = /* @__PURE__ */ React16.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
2794 const {
2795 children,
2796 container,
2797 className,
2798 render: render4,
2799 renderGuards,
2800 style,
2801 ...elementProps
2802 } = componentProps;
2803 const {
2804 portalNode,
2805 portalSubtree
2806 } = useFloatingPortalNode({
2807 container,
2808 ref: forwardedRef,
2809 componentProps,
2810 elementProps
2811 });
2812 const beforeOutsideRef = React16.useRef(null);
2813 const afterOutsideRef = React16.useRef(null);
2814 const beforeInsideRef = React16.useRef(null);
2815 const afterInsideRef = React16.useRef(null);
2816 const [focusManagerState, setFocusManagerState] = React16.useState(null);
2817 const focusInsideDisabledRef = React16.useRef(false);
2818 const modal = focusManagerState?.modal;
2819 const open = focusManagerState?.open;
2820 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
2821 React16.useEffect(() => {
2822 if (!portalNode || modal) {
2823 return void 0;
2824 }
2825 function onFocus(event) {
2826 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
2827 if (event.type === "focusin") {
2828 if (focusInsideDisabledRef.current) {
2829 enableFocusInside(portalNode);
2830 focusInsideDisabledRef.current = false;
2831 }
2832 } else {
2833 disableFocusInside(portalNode);
2834 focusInsideDisabledRef.current = true;
2835 }
2836 }
2837 }
2838 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
2839 }, [portalNode, modal]);
2840 React16.useEffect(() => {
2841 if (!portalNode || open !== false) {
2842 return;
2843 }
2844 enableFocusInside(portalNode);
2845 focusInsideDisabledRef.current = false;
2846 }, [open, portalNode]);
2847 const portalContextValue = React16.useMemo(() => ({
2848 beforeOutsideRef,
2849 afterOutsideRef,
2850 beforeInsideRef,
2851 afterInsideRef,
2852 portalNode,
2853 setFocusManagerState
2854 }), [portalNode]);
2855 return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React16.Fragment, {
2856 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PortalContext.Provider, {
2857 value: portalContextValue,
2858 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
2859 "data-type": "outside",
2860 ref: beforeOutsideRef,
2861 onFocus: (event) => {
2862 if (isOutsideEvent(event, portalNode)) {
2863 beforeInsideRef.current?.focus();
2864 } else {
2865 const domReference = focusManagerState ? focusManagerState.domReference : null;
2866 const prevTabbable = getPreviousTabbable(domReference);
2867 prevTabbable?.focus();
2868 }
2869 }
2870 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", {
2871 "aria-owns": portalNode.id,
2872 style: ownerVisuallyHidden
2873 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
2874 "data-type": "outside",
2875 ref: afterOutsideRef,
2876 onFocus: (event) => {
2877 if (isOutsideEvent(event, portalNode)) {
2878 afterInsideRef.current?.focus();
2879 } else {
2880 const domReference = focusManagerState ? focusManagerState.domReference : null;
2881 const nextTabbable = getNextTabbable(domReference);
2882 nextTabbable?.focus();
2883 if (focusManagerState?.closeOnFocusOut) {
2884 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
2885 }
2886 }
2887 }
2888 })]
2889 })]
2890 });
2891 });
2892 if (true) FloatingPortal.displayName = "FloatingPortal";
2893
2894 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
2895 var React17 = __toESM(require_react(), 1);
2896
2897 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createEventEmitter.js
2898 function createEventEmitter() {
2899 const map = /* @__PURE__ */ new Map();
2900 return {
2901 emit(event, data) {
2902 map.get(event)?.forEach((listener) => listener(data));
2903 },
2904 on(event, listener) {
2905 if (!map.has(event)) {
2906 map.set(event, /* @__PURE__ */ new Set());
2907 }
2908 map.get(event).add(listener);
2909 },
2910 off(event, listener) {
2911 map.get(event)?.delete(listener);
2912 }
2913 };
2914 }
2915
2916 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
2917 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
2918 var FloatingNodeContext = /* @__PURE__ */ React17.createContext(null);
2919 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
2920 var FloatingTreeContext = /* @__PURE__ */ React17.createContext(null);
2921 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
2922 var useFloatingParentNodeId = () => React17.useContext(FloatingNodeContext)?.id || null;
2923 var useFloatingTree = (externalTree) => {
2924 const contextTree = React17.useContext(FloatingTreeContext);
2925 return externalTree ?? contextTree;
2926 };
2927
2928 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useClientPoint.js
2929 var React18 = __toESM(require_react(), 1);
2930 function createVirtualElement(domElement, data) {
2931 let offsetX = null;
2932 let offsetY = null;
2933 let isAutoUpdateEvent = false;
2934 return {
2935 contextElement: domElement || void 0,
2936 getBoundingClientRect() {
2937 const domRect = domElement?.getBoundingClientRect() || {
2938 width: 0,
2939 height: 0,
2940 x: 0,
2941 y: 0
2942 };
2943 const isXAxis = data.axis === "x" || data.axis === "both";
2944 const isYAxis = data.axis === "y" || data.axis === "both";
2945 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
2946 let width = domRect.width;
2947 let height = domRect.height;
2948 let x2 = domRect.x;
2949 let y2 = domRect.y;
2950 if (offsetX == null && data.x && isXAxis) {
2951 offsetX = domRect.x - data.x;
2952 }
2953 if (offsetY == null && data.y && isYAxis) {
2954 offsetY = domRect.y - data.y;
2955 }
2956 x2 -= offsetX || 0;
2957 y2 -= offsetY || 0;
2958 width = 0;
2959 height = 0;
2960 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
2961 width = data.axis === "y" ? domRect.width : 0;
2962 height = data.axis === "x" ? domRect.height : 0;
2963 x2 = isXAxis && data.x != null ? data.x : x2;
2964 y2 = isYAxis && data.y != null ? data.y : y2;
2965 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
2966 height = data.axis === "x" ? domRect.height : height;
2967 width = data.axis === "y" ? domRect.width : width;
2968 }
2969 isAutoUpdateEvent = true;
2970 return {
2971 width,
2972 height,
2973 x: x2,
2974 y: y2,
2975 top: y2,
2976 right: x2 + width,
2977 bottom: y2 + height,
2978 left: x2
2979 };
2980 }
2981 };
2982 }
2983 function isMouseBasedEvent(event) {
2984 return event != null && event.clientX != null;
2985 }
2986 function useClientPoint(context, props = {}) {
2987 const store = "rootStore" in context ? context.rootStore : context;
2988 const open = store.useState("open");
2989 const floating = store.useState("floatingElement");
2990 const domReference = store.useState("domReferenceElement");
2991 const dataRef = store.context.dataRef;
2992 const {
2993 enabled = true,
2994 axis = "both"
2995 } = props;
2996 const initialRef = React18.useRef(false);
2997 const cleanupListenerRef = React18.useRef(null);
2998 const [pointerType, setPointerType] = React18.useState();
2999 const [reactive, setReactive] = React18.useState([]);
3000 const setReference = useStableCallback((newX, newY, referenceElement) => {
3001 if (initialRef.current) {
3002 return;
3003 }
3004 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
3005 return;
3006 }
3007 store.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
3008 x: newX,
3009 y: newY,
3010 axis,
3011 dataRef,
3012 pointerType
3013 }));
3014 });
3015 const handleReferenceEnterOrMove = useStableCallback((event) => {
3016 if (!open) {
3017 setReference(event.clientX, event.clientY, event.currentTarget);
3018 } else if (!cleanupListenerRef.current) {
3019 setReactive([]);
3020 }
3021 });
3022 const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
3023 const addListener = React18.useCallback(() => {
3024 if (!openCheck || !enabled) {
3025 return void 0;
3026 }
3027 const win = getWindow(floating);
3028 function handleMouseMove(event) {
3029 const target = getTarget(event);
3030 if (!contains(floating, target)) {
3031 setReference(event.clientX, event.clientY);
3032 } else {
3033 cleanupListenerRef.current?.();
3034 cleanupListenerRef.current = null;
3035 }
3036 }
3037 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
3038 const cleanup = () => {
3039 cleanupListenerRef.current?.();
3040 cleanupListenerRef.current = null;
3041 };
3042 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
3043 return cleanup;
3044 }
3045 store.set("positionReference", domReference);
3046 return void 0;
3047 }, [openCheck, enabled, floating, dataRef, domReference, store, setReference]);
3048 React18.useEffect(() => {
3049 return addListener();
3050 }, [addListener, reactive]);
3051 React18.useEffect(() => {
3052 if (enabled && !floating) {
3053 initialRef.current = false;
3054 }
3055 }, [enabled, floating]);
3056 React18.useEffect(() => {
3057 if (!enabled && open) {
3058 initialRef.current = true;
3059 }
3060 }, [enabled, open]);
3061 const reference = React18.useMemo(() => {
3062 function setPointerTypeRef(event) {
3063 setPointerType(event.pointerType);
3064 }
3065 return {
3066 onPointerDown: setPointerTypeRef,
3067 onPointerEnter: setPointerTypeRef,
3068 onMouseMove: handleReferenceEnterOrMove,
3069 onMouseEnter: handleReferenceEnterOrMove
3070 };
3071 }, [handleReferenceEnterOrMove]);
3072 return React18.useMemo(() => enabled ? {
3073 reference,
3074 trigger: reference
3075 } : {}, [enabled, reference]);
3076 }
3077
3078 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useDismiss.js
3079 var React19 = __toESM(require_react(), 1);
3080 var bubbleHandlerKeys = {
3081 intentional: "onClick",
3082 sloppy: "onPointerDown"
3083 };
3084 function alwaysFalse() {
3085 return false;
3086 }
3087 function normalizeProp(normalizable) {
3088 return {
3089 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
3090 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
3091 };
3092 }
3093 function useDismiss(context, props = {}) {
3094 const store = "rootStore" in context ? context.rootStore : context;
3095 const open = store.useState("open");
3096 const floatingElement = store.useState("floatingElement");
3097 const {
3098 dataRef
3099 } = store.context;
3100 const {
3101 enabled = true,
3102 escapeKey: escapeKey2 = true,
3103 outsidePress: outsidePressProp = true,
3104 outsidePressEvent = "sloppy",
3105 referencePress = alwaysFalse,
3106 referencePressEvent = "sloppy",
3107 bubbles,
3108 externalTree
3109 } = props;
3110 const tree = useFloatingTree(externalTree);
3111 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
3112 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
3113 const outsidePressEnabled = outsidePress2 !== false;
3114 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
3115 const pressStartedInsideRef = React19.useRef(false);
3116 const pressStartPreventedRef = React19.useRef(false);
3117 const suppressNextOutsideClickRef = React19.useRef(false);
3118 const {
3119 escapeKey: escapeKeyBubbles,
3120 outsidePress: outsidePressBubbles
3121 } = normalizeProp(bubbles);
3122 const touchStateRef = React19.useRef(null);
3123 const cancelDismissOnEndTimeout = useTimeout();
3124 const clearInsideReactTreeTimeout = useTimeout();
3125 const clearInsideReactTree = useStableCallback(() => {
3126 clearInsideReactTreeTimeout.clear();
3127 dataRef.current.insideReactTree = false;
3128 });
3129 const isComposingRef = React19.useRef(false);
3130 const currentPointerTypeRef = React19.useRef("");
3131 const isReferencePressEnabled = useStableCallback(referencePress);
3132 const closeOnEscapeKeyDown = useStableCallback((event) => {
3133 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
3134 return;
3135 }
3136 if (isComposingRef.current) {
3137 return;
3138 }
3139 const nodeId = dataRef.current.floatingContext?.nodeId;
3140 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
3141 if (!escapeKeyBubbles) {
3142 if (children.length > 0) {
3143 let shouldDismiss = true;
3144 children.forEach((child) => {
3145 if (child.context?.open && !child.context.dataRef.current.__escapeKeyBubbles) {
3146 shouldDismiss = false;
3147 }
3148 });
3149 if (!shouldDismiss) {
3150 return;
3151 }
3152 }
3153 }
3154 const native = isReactEvent(event) ? event.nativeEvent : event;
3155 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
3156 store.setOpen(false, eventDetails);
3157 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
3158 event.stopPropagation();
3159 }
3160 });
3161 const markInsideReactTree = useStableCallback(() => {
3162 dataRef.current.insideReactTree = true;
3163 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
3164 });
3165 React19.useEffect(() => {
3166 if (!open || !enabled) {
3167 return void 0;
3168 }
3169 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
3170 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
3171 const compositionTimeout = new Timeout();
3172 const preventedPressSuppressionTimeout = new Timeout();
3173 function handleCompositionStart() {
3174 compositionTimeout.clear();
3175 isComposingRef.current = true;
3176 }
3177 function handleCompositionEnd() {
3178 compositionTimeout.start(
3179 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
3180 // Only apply to WebKit for the test to remain 0ms.
3181 isWebKit() ? 5 : 0,
3182 () => {
3183 isComposingRef.current = false;
3184 }
3185 );
3186 }
3187 function suppressImmediateOutsideClickAfterPreventedStart() {
3188 suppressNextOutsideClickRef.current = true;
3189 preventedPressSuppressionTimeout.start(0, () => {
3190 suppressNextOutsideClickRef.current = false;
3191 });
3192 }
3193 function resetPressStartState() {
3194 pressStartedInsideRef.current = false;
3195 pressStartPreventedRef.current = false;
3196 }
3197 function getOutsidePressEvent() {
3198 const type = currentPointerTypeRef.current;
3199 const computedType = type === "pen" || !type ? "mouse" : type;
3200 const outsidePressEventValue = getOutsidePressEventProp();
3201 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
3202 if (typeof resolved === "string") {
3203 return resolved;
3204 }
3205 return resolved[computedType];
3206 }
3207 function shouldIgnoreEvent(event) {
3208 const computedOutsidePressEvent = getOutsidePressEvent();
3209 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
3210 }
3211 function isEventWithinFloatingTree(event) {
3212 const nodeId = dataRef.current.floatingContext?.nodeId;
3213 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
3214 return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement")) || targetIsInsideChildren;
3215 }
3216 function closeOnPressOutside(event) {
3217 if (shouldIgnoreEvent(event)) {
3218 clearInsideReactTree();
3219 return;
3220 }
3221 if (dataRef.current.insideReactTree) {
3222 clearInsideReactTree();
3223 return;
3224 }
3225 const target = getTarget(event);
3226 const inertSelector = `[${createAttribute("inert")}]`;
3227 const targetRoot = isElement(target) ? target.getRootNode() : null;
3228 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
3229 const triggers = store.context.triggerElements;
3230 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
3231 return;
3232 }
3233 let targetRootAncestor = isElement(target) ? target : null;
3234 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
3235 const nextParent = getParentNode(targetRootAncestor);
3236 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
3237 break;
3238 }
3239 targetRootAncestor = nextParent;
3240 }
3241 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
3242 !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
3243 // element was injected after the floating element rendered.
3244 markers.every((marker) => !contains(targetRootAncestor, marker))) {
3245 return;
3246 }
3247 if (isHTMLElement(target) && !("touches" in event)) {
3248 const lastTraversableNode = isLastTraversableNode(target);
3249 const style = getComputedStyle2(target);
3250 const scrollRe = /auto|scroll/;
3251 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
3252 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
3253 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
3254 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
3255 const isRTL7 = style.direction === "rtl";
3256 const pressedVerticalScrollbar = canScrollY && (isRTL7 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
3257 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
3258 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
3259 return;
3260 }
3261 }
3262 if (isEventWithinFloatingTree(event)) {
3263 return;
3264 }
3265 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
3266 preventedPressSuppressionTimeout.clear();
3267 suppressNextOutsideClickRef.current = false;
3268 return;
3269 }
3270 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3271 return;
3272 }
3273 const nodeId = dataRef.current.floatingContext?.nodeId;
3274 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
3275 if (children.length > 0) {
3276 let shouldDismiss = true;
3277 children.forEach((child) => {
3278 if (child.context?.open && !child.context.dataRef.current.__outsidePressBubbles) {
3279 shouldDismiss = false;
3280 }
3281 });
3282 if (!shouldDismiss) {
3283 return;
3284 }
3285 }
3286 store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
3287 clearInsideReactTree();
3288 }
3289 function handlePointerDown(event) {
3290 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
3291 return;
3292 }
3293 closeOnPressOutside(event);
3294 }
3295 function handleTouchStart(event) {
3296 if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
3297 return;
3298 }
3299 const touch = event.touches[0];
3300 if (touch) {
3301 touchStateRef.current = {
3302 startTime: Date.now(),
3303 startX: touch.clientX,
3304 startY: touch.clientY,
3305 dismissOnTouchEnd: false,
3306 dismissOnMouseDown: true
3307 };
3308 cancelDismissOnEndTimeout.start(1e3, () => {
3309 if (touchStateRef.current) {
3310 touchStateRef.current.dismissOnTouchEnd = false;
3311 touchStateRef.current.dismissOnMouseDown = false;
3312 }
3313 });
3314 }
3315 }
3316 function addTargetEventListenerOnce(event, listener) {
3317 const target = getTarget(event);
3318 if (!target) {
3319 return;
3320 }
3321 const unsubscribe2 = addEventListener(target, event.type, () => {
3322 listener(event);
3323 unsubscribe2();
3324 });
3325 }
3326 function handleTouchStartCapture(event) {
3327 currentPointerTypeRef.current = "touch";
3328 addTargetEventListenerOnce(event, handleTouchStart);
3329 }
3330 function closeOnPressOutsideCapture(event) {
3331 cancelDismissOnEndTimeout.clear();
3332 if (event.type === "pointerdown") {
3333 currentPointerTypeRef.current = event.pointerType;
3334 }
3335 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
3336 return;
3337 }
3338 addTargetEventListenerOnce(event, (targetEvent) => {
3339 if (targetEvent.type === "pointerdown") {
3340 handlePointerDown(targetEvent);
3341 } else {
3342 closeOnPressOutside(targetEvent);
3343 }
3344 });
3345 }
3346 function handlePressEndCapture(event) {
3347 if (!pressStartedInsideRef.current) {
3348 return;
3349 }
3350 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
3351 resetPressStartState();
3352 if (getOutsidePressEvent() !== "intentional") {
3353 return;
3354 }
3355 if (event.type === "pointercancel") {
3356 if (pressStartedInsideDefaultPrevented) {
3357 suppressImmediateOutsideClickAfterPreventedStart();
3358 }
3359 return;
3360 }
3361 if (isEventWithinFloatingTree(event)) {
3362 return;
3363 }
3364 if (pressStartedInsideDefaultPrevented) {
3365 suppressImmediateOutsideClickAfterPreventedStart();
3366 return;
3367 }
3368 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3369 return;
3370 }
3371 preventedPressSuppressionTimeout.clear();
3372 suppressNextOutsideClickRef.current = true;
3373 clearInsideReactTree();
3374 }
3375 function handleTouchMove(event) {
3376 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
3377 return;
3378 }
3379 const touch = event.touches[0];
3380 if (!touch) {
3381 return;
3382 }
3383 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
3384 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
3385 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
3386 if (distance > 5) {
3387 touchStateRef.current.dismissOnTouchEnd = true;
3388 }
3389 if (distance > 10) {
3390 closeOnPressOutside(event);
3391 cancelDismissOnEndTimeout.clear();
3392 touchStateRef.current = null;
3393 }
3394 }
3395 function handleTouchMoveCapture(event) {
3396 addTargetEventListenerOnce(event, handleTouchMove);
3397 }
3398 function handleTouchEnd(event) {
3399 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
3400 return;
3401 }
3402 if (touchStateRef.current.dismissOnTouchEnd) {
3403 closeOnPressOutside(event);
3404 }
3405 cancelDismissOnEndTimeout.clear();
3406 touchStateRef.current = null;
3407 }
3408 function handleTouchEndCapture(event) {
3409 addTargetEventListenerOnce(event, handleTouchEnd);
3410 }
3411 const doc = ownerDocument(floatingElement);
3412 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)));
3413 return () => {
3414 unsubscribe();
3415 compositionTimeout.clear();
3416 preventedPressSuppressionTimeout.clear();
3417 resetPressStartState();
3418 suppressNextOutsideClickRef.current = false;
3419 };
3420 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, tree, store, cancelDismissOnEndTimeout]);
3421 React19.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
3422 const reference = React19.useMemo(() => ({
3423 onKeyDown: closeOnEscapeKeyDown,
3424 [bubbleHandlerKeys[referencePressEvent]]: (event) => {
3425 if (!isReferencePressEnabled()) {
3426 return;
3427 }
3428 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
3429 },
3430 ...referencePressEvent !== "intentional" && {
3431 onClick(event) {
3432 if (!isReferencePressEnabled()) {
3433 return;
3434 }
3435 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
3436 }
3437 }
3438 }), [closeOnEscapeKeyDown, store, referencePressEvent, isReferencePressEnabled]);
3439 const markPressStartedInsideReactTree = useStableCallback((event) => {
3440 if (!open || !enabled || event.button !== 0) {
3441 return;
3442 }
3443 const target = getTarget(event.nativeEvent);
3444 if (!contains(store.select("floatingElement"), target)) {
3445 return;
3446 }
3447 if (!pressStartedInsideRef.current) {
3448 pressStartedInsideRef.current = true;
3449 pressStartPreventedRef.current = false;
3450 }
3451 });
3452 const markInsidePressStartPrevented = useStableCallback((event) => {
3453 if (!open || !enabled) {
3454 return;
3455 }
3456 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
3457 return;
3458 }
3459 if (pressStartedInsideRef.current) {
3460 pressStartPreventedRef.current = true;
3461 }
3462 });
3463 const floating = React19.useMemo(() => ({
3464 onKeyDown: closeOnEscapeKeyDown,
3465 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
3466 // `onPointerDown`, such as with <NumberField.ScrubArea>.
3467 // See https://github.com/mui/base-ui/pull/3379
3468 onPointerDown: markInsidePressStartPrevented,
3469 onMouseDown: markInsidePressStartPrevented,
3470 onClickCapture: markInsideReactTree,
3471 onMouseDownCapture(event) {
3472 markInsideReactTree();
3473 markPressStartedInsideReactTree(event);
3474 },
3475 onPointerDownCapture(event) {
3476 markInsideReactTree();
3477 markPressStartedInsideReactTree(event);
3478 },
3479 onMouseUpCapture: markInsideReactTree,
3480 onTouchEndCapture: markInsideReactTree,
3481 onTouchMoveCapture: markInsideReactTree
3482 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
3483 return React19.useMemo(() => enabled ? {
3484 reference,
3485 floating,
3486 trigger: reference
3487 } : {}, [enabled, reference, floating]);
3488 }
3489
3490 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
3491 var React25 = __toESM(require_react(), 1);
3492
3493 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
3494 function computeCoordsFromPlacement(_ref, placement, rtl) {
3495 let {
3496 reference,
3497 floating
3498 } = _ref;
3499 const sideAxis = getSideAxis(placement);
3500 const alignmentAxis = getAlignmentAxis(placement);
3501 const alignLength = getAxisLength(alignmentAxis);
3502 const side = getSide(placement);
3503 const isVertical = sideAxis === "y";
3504 const commonX = reference.x + reference.width / 2 - floating.width / 2;
3505 const commonY = reference.y + reference.height / 2 - floating.height / 2;
3506 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
3507 let coords;
3508 switch (side) {
3509 case "top":
3510 coords = {
3511 x: commonX,
3512 y: reference.y - floating.height
3513 };
3514 break;
3515 case "bottom":
3516 coords = {
3517 x: commonX,
3518 y: reference.y + reference.height
3519 };
3520 break;
3521 case "right":
3522 coords = {
3523 x: reference.x + reference.width,
3524 y: commonY
3525 };
3526 break;
3527 case "left":
3528 coords = {
3529 x: reference.x - floating.width,
3530 y: commonY
3531 };
3532 break;
3533 default:
3534 coords = {
3535 x: reference.x,
3536 y: reference.y
3537 };
3538 }
3539 switch (getAlignment(placement)) {
3540 case "start":
3541 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
3542 break;
3543 case "end":
3544 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
3545 break;
3546 }
3547 return coords;
3548 }
3549 async function detectOverflow(state, options) {
3550 var _await$platform$isEle;
3551 if (options === void 0) {
3552 options = {};
3553 }
3554 const {
3555 x: x2,
3556 y: y2,
3557 platform: platform3,
3558 rects,
3559 elements,
3560 strategy
3561 } = state;
3562 const {
3563 boundary = "clippingAncestors",
3564 rootBoundary = "viewport",
3565 elementContext = "floating",
3566 altBoundary = false,
3567 padding = 0
3568 } = evaluate(options, state);
3569 const paddingObject = getPaddingObject(padding);
3570 const altContext = elementContext === "floating" ? "reference" : "floating";
3571 const element = elements[altBoundary ? altContext : elementContext];
3572 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
3573 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)),
3574 boundary,
3575 rootBoundary,
3576 strategy
3577 }));
3578 const rect = elementContext === "floating" ? {
3579 x: x2,
3580 y: y2,
3581 width: rects.floating.width,
3582 height: rects.floating.height
3583 } : rects.reference;
3584 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
3585 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
3586 x: 1,
3587 y: 1
3588 } : {
3589 x: 1,
3590 y: 1
3591 };
3592 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
3593 elements,
3594 rect,
3595 offsetParent,
3596 strategy
3597 }) : rect);
3598 return {
3599 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
3600 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
3601 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
3602 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
3603 };
3604 }
3605 var MAX_RESET_COUNT = 50;
3606 var computePosition = async (reference, floating, config) => {
3607 const {
3608 placement = "bottom",
3609 strategy = "absolute",
3610 middleware = [],
3611 platform: platform3
3612 } = config;
3613 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
3614 ...platform3,
3615 detectOverflow
3616 };
3617 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
3618 let rects = await platform3.getElementRects({
3619 reference,
3620 floating,
3621 strategy
3622 });
3623 let {
3624 x: x2,
3625 y: y2
3626 } = computeCoordsFromPlacement(rects, placement, rtl);
3627 let statefulPlacement = placement;
3628 let resetCount = 0;
3629 const middlewareData = {};
3630 for (let i2 = 0; i2 < middleware.length; i2++) {
3631 const currentMiddleware = middleware[i2];
3632 if (!currentMiddleware) {
3633 continue;
3634 }
3635 const {
3636 name,
3637 fn
3638 } = currentMiddleware;
3639 const {
3640 x: nextX,
3641 y: nextY,
3642 data,
3643 reset
3644 } = await fn({
3645 x: x2,
3646 y: y2,
3647 initialPlacement: placement,
3648 placement: statefulPlacement,
3649 strategy,
3650 middlewareData,
3651 rects,
3652 platform: platformWithDetectOverflow,
3653 elements: {
3654 reference,
3655 floating
3656 }
3657 });
3658 x2 = nextX != null ? nextX : x2;
3659 y2 = nextY != null ? nextY : y2;
3660 middlewareData[name] = {
3661 ...middlewareData[name],
3662 ...data
3663 };
3664 if (reset && resetCount < MAX_RESET_COUNT) {
3665 resetCount++;
3666 if (typeof reset === "object") {
3667 if (reset.placement) {
3668 statefulPlacement = reset.placement;
3669 }
3670 if (reset.rects) {
3671 rects = reset.rects === true ? await platform3.getElementRects({
3672 reference,
3673 floating,
3674 strategy
3675 }) : reset.rects;
3676 }
3677 ({
3678 x: x2,
3679 y: y2
3680 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
3681 }
3682 i2 = -1;
3683 }
3684 }
3685 return {
3686 x: x2,
3687 y: y2,
3688 placement: statefulPlacement,
3689 strategy,
3690 middlewareData
3691 };
3692 };
3693 var flip = function(options) {
3694 if (options === void 0) {
3695 options = {};
3696 }
3697 return {
3698 name: "flip",
3699 options,
3700 async fn(state) {
3701 var _middlewareData$arrow, _middlewareData$flip;
3702 const {
3703 placement,
3704 middlewareData,
3705 rects,
3706 initialPlacement,
3707 platform: platform3,
3708 elements
3709 } = state;
3710 const {
3711 mainAxis: checkMainAxis = true,
3712 crossAxis: checkCrossAxis = true,
3713 fallbackPlacements: specifiedFallbackPlacements,
3714 fallbackStrategy = "bestFit",
3715 fallbackAxisSideDirection = "none",
3716 flipAlignment = true,
3717 ...detectOverflowOptions
3718 } = evaluate(options, state);
3719 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
3720 return {};
3721 }
3722 const side = getSide(placement);
3723 const initialSideAxis = getSideAxis(initialPlacement);
3724 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
3725 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
3726 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
3727 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
3728 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
3729 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
3730 }
3731 const placements2 = [initialPlacement, ...fallbackPlacements];
3732 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
3733 const overflows = [];
3734 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
3735 if (checkMainAxis) {
3736 overflows.push(overflow[side]);
3737 }
3738 if (checkCrossAxis) {
3739 const sides2 = getAlignmentSides(placement, rects, rtl);
3740 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
3741 }
3742 overflowsData = [...overflowsData, {
3743 placement,
3744 overflows
3745 }];
3746 if (!overflows.every((side2) => side2 <= 0)) {
3747 var _middlewareData$flip2, _overflowsData$filter;
3748 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
3749 const nextPlacement = placements2[nextIndex];
3750 if (nextPlacement) {
3751 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
3752 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
3753 // overflows the main axis.
3754 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) {
3755 return {
3756 data: {
3757 index: nextIndex,
3758 overflows: overflowsData
3759 },
3760 reset: {
3761 placement: nextPlacement
3762 }
3763 };
3764 }
3765 }
3766 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;
3767 if (!resetPlacement) {
3768 switch (fallbackStrategy) {
3769 case "bestFit": {
3770 var _overflowsData$filter2;
3771 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
3772 if (hasFallbackAxisSideDirection) {
3773 const currentSideAxis = getSideAxis(d2.placement);
3774 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
3775 // reading directions favoring greater width.
3776 currentSideAxis === "y";
3777 }
3778 return true;
3779 }).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];
3780 if (placement2) {
3781 resetPlacement = placement2;
3782 }
3783 break;
3784 }
3785 case "initialPlacement":
3786 resetPlacement = initialPlacement;
3787 break;
3788 }
3789 }
3790 if (placement !== resetPlacement) {
3791 return {
3792 reset: {
3793 placement: resetPlacement
3794 }
3795 };
3796 }
3797 }
3798 return {};
3799 }
3800 };
3801 };
3802 function getSideOffsets(overflow, rect) {
3803 return {
3804 top: overflow.top - rect.height,
3805 right: overflow.right - rect.width,
3806 bottom: overflow.bottom - rect.height,
3807 left: overflow.left - rect.width
3808 };
3809 }
3810 function isAnySideFullyClipped(overflow) {
3811 return sides.some((side) => overflow[side] >= 0);
3812 }
3813 var hide = function(options) {
3814 if (options === void 0) {
3815 options = {};
3816 }
3817 return {
3818 name: "hide",
3819 options,
3820 async fn(state) {
3821 const {
3822 rects,
3823 platform: platform3
3824 } = state;
3825 const {
3826 strategy = "referenceHidden",
3827 ...detectOverflowOptions
3828 } = evaluate(options, state);
3829 switch (strategy) {
3830 case "referenceHidden": {
3831 const overflow = await platform3.detectOverflow(state, {
3832 ...detectOverflowOptions,
3833 elementContext: "reference"
3834 });
3835 const offsets = getSideOffsets(overflow, rects.reference);
3836 return {
3837 data: {
3838 referenceHiddenOffsets: offsets,
3839 referenceHidden: isAnySideFullyClipped(offsets)
3840 }
3841 };
3842 }
3843 case "escaped": {
3844 const overflow = await platform3.detectOverflow(state, {
3845 ...detectOverflowOptions,
3846 altBoundary: true
3847 });
3848 const offsets = getSideOffsets(overflow, rects.floating);
3849 return {
3850 data: {
3851 escapedOffsets: offsets,
3852 escaped: isAnySideFullyClipped(offsets)
3853 }
3854 };
3855 }
3856 default: {
3857 return {};
3858 }
3859 }
3860 }
3861 };
3862 };
3863 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
3864 async function convertValueToCoords(state, options) {
3865 const {
3866 placement,
3867 platform: platform3,
3868 elements
3869 } = state;
3870 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
3871 const side = getSide(placement);
3872 const alignment = getAlignment(placement);
3873 const isVertical = getSideAxis(placement) === "y";
3874 const mainAxisMulti = originSides.has(side) ? -1 : 1;
3875 const crossAxisMulti = rtl && isVertical ? -1 : 1;
3876 const rawValue = evaluate(options, state);
3877 let {
3878 mainAxis,
3879 crossAxis,
3880 alignmentAxis
3881 } = typeof rawValue === "number" ? {
3882 mainAxis: rawValue,
3883 crossAxis: 0,
3884 alignmentAxis: null
3885 } : {
3886 mainAxis: rawValue.mainAxis || 0,
3887 crossAxis: rawValue.crossAxis || 0,
3888 alignmentAxis: rawValue.alignmentAxis
3889 };
3890 if (alignment && typeof alignmentAxis === "number") {
3891 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
3892 }
3893 return isVertical ? {
3894 x: crossAxis * crossAxisMulti,
3895 y: mainAxis * mainAxisMulti
3896 } : {
3897 x: mainAxis * mainAxisMulti,
3898 y: crossAxis * crossAxisMulti
3899 };
3900 }
3901 var offset = function(options) {
3902 if (options === void 0) {
3903 options = 0;
3904 }
3905 return {
3906 name: "offset",
3907 options,
3908 async fn(state) {
3909 var _middlewareData$offse, _middlewareData$arrow;
3910 const {
3911 x: x2,
3912 y: y2,
3913 placement,
3914 middlewareData
3915 } = state;
3916 const diffCoords = await convertValueToCoords(state, options);
3917 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
3918 return {};
3919 }
3920 return {
3921 x: x2 + diffCoords.x,
3922 y: y2 + diffCoords.y,
3923 data: {
3924 ...diffCoords,
3925 placement
3926 }
3927 };
3928 }
3929 };
3930 };
3931 var shift = function(options) {
3932 if (options === void 0) {
3933 options = {};
3934 }
3935 return {
3936 name: "shift",
3937 options,
3938 async fn(state) {
3939 const {
3940 x: x2,
3941 y: y2,
3942 placement,
3943 platform: platform3
3944 } = state;
3945 const {
3946 mainAxis: checkMainAxis = true,
3947 crossAxis: checkCrossAxis = false,
3948 limiter = {
3949 fn: (_ref) => {
3950 let {
3951 x: x3,
3952 y: y3
3953 } = _ref;
3954 return {
3955 x: x3,
3956 y: y3
3957 };
3958 }
3959 },
3960 ...detectOverflowOptions
3961 } = evaluate(options, state);
3962 const coords = {
3963 x: x2,
3964 y: y2
3965 };
3966 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
3967 const crossAxis = getSideAxis(getSide(placement));
3968 const mainAxis = getOppositeAxis(crossAxis);
3969 let mainAxisCoord = coords[mainAxis];
3970 let crossAxisCoord = coords[crossAxis];
3971 if (checkMainAxis) {
3972 const minSide = mainAxis === "y" ? "top" : "left";
3973 const maxSide = mainAxis === "y" ? "bottom" : "right";
3974 const min2 = mainAxisCoord + overflow[minSide];
3975 const max2 = mainAxisCoord - overflow[maxSide];
3976 mainAxisCoord = clamp(min2, mainAxisCoord, max2);
3977 }
3978 if (checkCrossAxis) {
3979 const minSide = crossAxis === "y" ? "top" : "left";
3980 const maxSide = crossAxis === "y" ? "bottom" : "right";
3981 const min2 = crossAxisCoord + overflow[minSide];
3982 const max2 = crossAxisCoord - overflow[maxSide];
3983 crossAxisCoord = clamp(min2, crossAxisCoord, max2);
3984 }
3985 const limitedCoords = limiter.fn({
3986 ...state,
3987 [mainAxis]: mainAxisCoord,
3988 [crossAxis]: crossAxisCoord
3989 });
3990 return {
3991 ...limitedCoords,
3992 data: {
3993 x: limitedCoords.x - x2,
3994 y: limitedCoords.y - y2,
3995 enabled: {
3996 [mainAxis]: checkMainAxis,
3997 [crossAxis]: checkCrossAxis
3998 }
3999 }
4000 };
4001 }
4002 };
4003 };
4004 var limitShift = function(options) {
4005 if (options === void 0) {
4006 options = {};
4007 }
4008 return {
4009 options,
4010 fn(state) {
4011 const {
4012 x: x2,
4013 y: y2,
4014 placement,
4015 rects,
4016 middlewareData
4017 } = state;
4018 const {
4019 offset: offset4 = 0,
4020 mainAxis: checkMainAxis = true,
4021 crossAxis: checkCrossAxis = true
4022 } = evaluate(options, state);
4023 const coords = {
4024 x: x2,
4025 y: y2
4026 };
4027 const crossAxis = getSideAxis(placement);
4028 const mainAxis = getOppositeAxis(crossAxis);
4029 let mainAxisCoord = coords[mainAxis];
4030 let crossAxisCoord = coords[crossAxis];
4031 const rawOffset = evaluate(offset4, state);
4032 const computedOffset = typeof rawOffset === "number" ? {
4033 mainAxis: rawOffset,
4034 crossAxis: 0
4035 } : {
4036 mainAxis: 0,
4037 crossAxis: 0,
4038 ...rawOffset
4039 };
4040 if (checkMainAxis) {
4041 const len = mainAxis === "y" ? "height" : "width";
4042 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
4043 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
4044 if (mainAxisCoord < limitMin) {
4045 mainAxisCoord = limitMin;
4046 } else if (mainAxisCoord > limitMax) {
4047 mainAxisCoord = limitMax;
4048 }
4049 }
4050 if (checkCrossAxis) {
4051 var _middlewareData$offse, _middlewareData$offse2;
4052 const len = mainAxis === "y" ? "width" : "height";
4053 const isOriginSide = originSides.has(getSide(placement));
4054 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);
4055 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);
4056 if (crossAxisCoord < limitMin) {
4057 crossAxisCoord = limitMin;
4058 } else if (crossAxisCoord > limitMax) {
4059 crossAxisCoord = limitMax;
4060 }
4061 }
4062 return {
4063 [mainAxis]: mainAxisCoord,
4064 [crossAxis]: crossAxisCoord
4065 };
4066 }
4067 };
4068 };
4069 var size = function(options) {
4070 if (options === void 0) {
4071 options = {};
4072 }
4073 return {
4074 name: "size",
4075 options,
4076 async fn(state) {
4077 var _state$middlewareData, _state$middlewareData2;
4078 const {
4079 placement,
4080 rects,
4081 platform: platform3,
4082 elements
4083 } = state;
4084 const {
4085 apply = () => {
4086 },
4087 ...detectOverflowOptions
4088 } = evaluate(options, state);
4089 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4090 const side = getSide(placement);
4091 const alignment = getAlignment(placement);
4092 const isYAxis = getSideAxis(placement) === "y";
4093 const {
4094 width,
4095 height
4096 } = rects.floating;
4097 let heightSide;
4098 let widthSide;
4099 if (side === "top" || side === "bottom") {
4100 heightSide = side;
4101 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
4102 } else {
4103 widthSide = side;
4104 heightSide = alignment === "end" ? "top" : "bottom";
4105 }
4106 const maximumClippingHeight = height - overflow.top - overflow.bottom;
4107 const maximumClippingWidth = width - overflow.left - overflow.right;
4108 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
4109 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
4110 const noShift = !state.middlewareData.shift;
4111 let availableHeight = overflowAvailableHeight;
4112 let availableWidth = overflowAvailableWidth;
4113 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
4114 availableWidth = maximumClippingWidth;
4115 }
4116 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
4117 availableHeight = maximumClippingHeight;
4118 }
4119 if (noShift && !alignment) {
4120 const xMin = max(overflow.left, 0);
4121 const xMax = max(overflow.right, 0);
4122 const yMin = max(overflow.top, 0);
4123 const yMax = max(overflow.bottom, 0);
4124 if (isYAxis) {
4125 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
4126 } else {
4127 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
4128 }
4129 }
4130 await apply({
4131 ...state,
4132 availableWidth,
4133 availableHeight
4134 });
4135 const nextDimensions = await platform3.getDimensions(elements.floating);
4136 if (width !== nextDimensions.width || height !== nextDimensions.height) {
4137 return {
4138 reset: {
4139 rects: true
4140 }
4141 };
4142 }
4143 return {};
4144 }
4145 };
4146 };
4147
4148 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
4149 function getCssDimensions(element) {
4150 const css = getComputedStyle2(element);
4151 let width = parseFloat(css.width) || 0;
4152 let height = parseFloat(css.height) || 0;
4153 const hasOffset = isHTMLElement(element);
4154 const offsetWidth = hasOffset ? element.offsetWidth : width;
4155 const offsetHeight = hasOffset ? element.offsetHeight : height;
4156 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
4157 if (shouldFallback) {
4158 width = offsetWidth;
4159 height = offsetHeight;
4160 }
4161 return {
4162 width,
4163 height,
4164 $: shouldFallback
4165 };
4166 }
4167 function unwrapElement(element) {
4168 return !isElement(element) ? element.contextElement : element;
4169 }
4170 function getScale(element) {
4171 const domElement = unwrapElement(element);
4172 if (!isHTMLElement(domElement)) {
4173 return createCoords(1);
4174 }
4175 const rect = domElement.getBoundingClientRect();
4176 const {
4177 width,
4178 height,
4179 $: $2
4180 } = getCssDimensions(domElement);
4181 let x2 = ($2 ? round(rect.width) : rect.width) / width;
4182 let y2 = ($2 ? round(rect.height) : rect.height) / height;
4183 if (!x2 || !Number.isFinite(x2)) {
4184 x2 = 1;
4185 }
4186 if (!y2 || !Number.isFinite(y2)) {
4187 y2 = 1;
4188 }
4189 return {
4190 x: x2,
4191 y: y2
4192 };
4193 }
4194 var noOffsets = /* @__PURE__ */ createCoords(0);
4195 function getVisualOffsets(element) {
4196 const win = getWindow(element);
4197 if (!isWebKit() || !win.visualViewport) {
4198 return noOffsets;
4199 }
4200 return {
4201 x: win.visualViewport.offsetLeft,
4202 y: win.visualViewport.offsetTop
4203 };
4204 }
4205 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
4206 if (isFixed === void 0) {
4207 isFixed = false;
4208 }
4209 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
4210 return false;
4211 }
4212 return isFixed;
4213 }
4214 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
4215 if (includeScale === void 0) {
4216 includeScale = false;
4217 }
4218 if (isFixedStrategy === void 0) {
4219 isFixedStrategy = false;
4220 }
4221 const clientRect = element.getBoundingClientRect();
4222 const domElement = unwrapElement(element);
4223 let scale = createCoords(1);
4224 if (includeScale) {
4225 if (offsetParent) {
4226 if (isElement(offsetParent)) {
4227 scale = getScale(offsetParent);
4228 }
4229 } else {
4230 scale = getScale(element);
4231 }
4232 }
4233 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
4234 let x2 = (clientRect.left + visualOffsets.x) / scale.x;
4235 let y2 = (clientRect.top + visualOffsets.y) / scale.y;
4236 let width = clientRect.width / scale.x;
4237 let height = clientRect.height / scale.y;
4238 if (domElement) {
4239 const win = getWindow(domElement);
4240 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
4241 let currentWin = win;
4242 let currentIFrame = getFrameElement(currentWin);
4243 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
4244 const iframeScale = getScale(currentIFrame);
4245 const iframeRect = currentIFrame.getBoundingClientRect();
4246 const css = getComputedStyle2(currentIFrame);
4247 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
4248 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
4249 x2 *= iframeScale.x;
4250 y2 *= iframeScale.y;
4251 width *= iframeScale.x;
4252 height *= iframeScale.y;
4253 x2 += left;
4254 y2 += top;
4255 currentWin = getWindow(currentIFrame);
4256 currentIFrame = getFrameElement(currentWin);
4257 }
4258 }
4259 return rectToClientRect({
4260 width,
4261 height,
4262 x: x2,
4263 y: y2
4264 });
4265 }
4266 function getWindowScrollBarX(element, rect) {
4267 const leftScroll = getNodeScroll(element).scrollLeft;
4268 if (!rect) {
4269 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
4270 }
4271 return rect.left + leftScroll;
4272 }
4273 function getHTMLOffset(documentElement, scroll) {
4274 const htmlRect = documentElement.getBoundingClientRect();
4275 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
4276 const y2 = htmlRect.top + scroll.scrollTop;
4277 return {
4278 x: x2,
4279 y: y2
4280 };
4281 }
4282 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
4283 let {
4284 elements,
4285 rect,
4286 offsetParent,
4287 strategy
4288 } = _ref;
4289 const isFixed = strategy === "fixed";
4290 const documentElement = getDocumentElement(offsetParent);
4291 const topLayer = elements ? isTopLayer(elements.floating) : false;
4292 if (offsetParent === documentElement || topLayer && isFixed) {
4293 return rect;
4294 }
4295 let scroll = {
4296 scrollLeft: 0,
4297 scrollTop: 0
4298 };
4299 let scale = createCoords(1);
4300 const offsets = createCoords(0);
4301 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4302 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4303 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4304 scroll = getNodeScroll(offsetParent);
4305 }
4306 if (isOffsetParentAnElement) {
4307 const offsetRect = getBoundingClientRect(offsetParent);
4308 scale = getScale(offsetParent);
4309 offsets.x = offsetRect.x + offsetParent.clientLeft;
4310 offsets.y = offsetRect.y + offsetParent.clientTop;
4311 }
4312 }
4313 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4314 return {
4315 width: rect.width * scale.x,
4316 height: rect.height * scale.y,
4317 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
4318 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
4319 };
4320 }
4321 function getClientRects(element) {
4322 return Array.from(element.getClientRects());
4323 }
4324 function getDocumentRect(element) {
4325 const html = getDocumentElement(element);
4326 const scroll = getNodeScroll(element);
4327 const body = element.ownerDocument.body;
4328 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
4329 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
4330 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
4331 const y2 = -scroll.scrollTop;
4332 if (getComputedStyle2(body).direction === "rtl") {
4333 x2 += max(html.clientWidth, body.clientWidth) - width;
4334 }
4335 return {
4336 width,
4337 height,
4338 x: x2,
4339 y: y2
4340 };
4341 }
4342 var SCROLLBAR_MAX = 25;
4343 function getViewportRect(element, strategy) {
4344 const win = getWindow(element);
4345 const html = getDocumentElement(element);
4346 const visualViewport = win.visualViewport;
4347 let width = html.clientWidth;
4348 let height = html.clientHeight;
4349 let x2 = 0;
4350 let y2 = 0;
4351 if (visualViewport) {
4352 width = visualViewport.width;
4353 height = visualViewport.height;
4354 const visualViewportBased = isWebKit();
4355 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
4356 x2 = visualViewport.offsetLeft;
4357 y2 = visualViewport.offsetTop;
4358 }
4359 }
4360 const windowScrollbarX = getWindowScrollBarX(html);
4361 if (windowScrollbarX <= 0) {
4362 const doc = html.ownerDocument;
4363 const body = doc.body;
4364 const bodyStyles = getComputedStyle(body);
4365 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
4366 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
4367 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
4368 width -= clippingStableScrollbarWidth;
4369 }
4370 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
4371 width += windowScrollbarX;
4372 }
4373 return {
4374 width,
4375 height,
4376 x: x2,
4377 y: y2
4378 };
4379 }
4380 function getInnerBoundingClientRect(element, strategy) {
4381 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
4382 const top = clientRect.top + element.clientTop;
4383 const left = clientRect.left + element.clientLeft;
4384 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
4385 const width = element.clientWidth * scale.x;
4386 const height = element.clientHeight * scale.y;
4387 const x2 = left * scale.x;
4388 const y2 = top * scale.y;
4389 return {
4390 width,
4391 height,
4392 x: x2,
4393 y: y2
4394 };
4395 }
4396 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
4397 let rect;
4398 if (clippingAncestor === "viewport") {
4399 rect = getViewportRect(element, strategy);
4400 } else if (clippingAncestor === "document") {
4401 rect = getDocumentRect(getDocumentElement(element));
4402 } else if (isElement(clippingAncestor)) {
4403 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
4404 } else {
4405 const visualOffsets = getVisualOffsets(element);
4406 rect = {
4407 x: clippingAncestor.x - visualOffsets.x,
4408 y: clippingAncestor.y - visualOffsets.y,
4409 width: clippingAncestor.width,
4410 height: clippingAncestor.height
4411 };
4412 }
4413 return rectToClientRect(rect);
4414 }
4415 function hasFixedPositionAncestor(element, stopNode) {
4416 const parentNode = getParentNode(element);
4417 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
4418 return false;
4419 }
4420 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
4421 }
4422 function getClippingElementAncestors(element, cache) {
4423 const cachedResult = cache.get(element);
4424 if (cachedResult) {
4425 return cachedResult;
4426 }
4427 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
4428 let currentContainingBlockComputedStyle = null;
4429 const elementIsFixed = getComputedStyle2(element).position === "fixed";
4430 let currentNode = elementIsFixed ? getParentNode(element) : element;
4431 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
4432 const computedStyle = getComputedStyle2(currentNode);
4433 const currentNodeIsContaining = isContainingBlock(currentNode);
4434 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
4435 currentContainingBlockComputedStyle = null;
4436 }
4437 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
4438 if (shouldDropCurrentNode) {
4439 result = result.filter((ancestor) => ancestor !== currentNode);
4440 } else {
4441 currentContainingBlockComputedStyle = computedStyle;
4442 }
4443 currentNode = getParentNode(currentNode);
4444 }
4445 cache.set(element, result);
4446 return result;
4447 }
4448 function getClippingRect(_ref) {
4449 let {
4450 element,
4451 boundary,
4452 rootBoundary,
4453 strategy
4454 } = _ref;
4455 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
4456 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
4457 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
4458 let top = firstRect.top;
4459 let right = firstRect.right;
4460 let bottom = firstRect.bottom;
4461 let left = firstRect.left;
4462 for (let i2 = 1; i2 < clippingAncestors.length; i2++) {
4463 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy);
4464 top = max(rect.top, top);
4465 right = min(rect.right, right);
4466 bottom = min(rect.bottom, bottom);
4467 left = max(rect.left, left);
4468 }
4469 return {
4470 width: right - left,
4471 height: bottom - top,
4472 x: left,
4473 y: top
4474 };
4475 }
4476 function getDimensions(element) {
4477 const {
4478 width,
4479 height
4480 } = getCssDimensions(element);
4481 return {
4482 width,
4483 height
4484 };
4485 }
4486 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
4487 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4488 const documentElement = getDocumentElement(offsetParent);
4489 const isFixed = strategy === "fixed";
4490 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
4491 let scroll = {
4492 scrollLeft: 0,
4493 scrollTop: 0
4494 };
4495 const offsets = createCoords(0);
4496 function setLeftRTLScrollbarOffset() {
4497 offsets.x = getWindowScrollBarX(documentElement);
4498 }
4499 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4500 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4501 scroll = getNodeScroll(offsetParent);
4502 }
4503 if (isOffsetParentAnElement) {
4504 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
4505 offsets.x = offsetRect.x + offsetParent.clientLeft;
4506 offsets.y = offsetRect.y + offsetParent.clientTop;
4507 } else if (documentElement) {
4508 setLeftRTLScrollbarOffset();
4509 }
4510 }
4511 if (isFixed && !isOffsetParentAnElement && documentElement) {
4512 setLeftRTLScrollbarOffset();
4513 }
4514 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4515 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
4516 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
4517 return {
4518 x: x2,
4519 y: y2,
4520 width: rect.width,
4521 height: rect.height
4522 };
4523 }
4524 function isStaticPositioned(element) {
4525 return getComputedStyle2(element).position === "static";
4526 }
4527 function getTrueOffsetParent(element, polyfill) {
4528 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
4529 return null;
4530 }
4531 if (polyfill) {
4532 return polyfill(element);
4533 }
4534 let rawOffsetParent = element.offsetParent;
4535 if (getDocumentElement(element) === rawOffsetParent) {
4536 rawOffsetParent = rawOffsetParent.ownerDocument.body;
4537 }
4538 return rawOffsetParent;
4539 }
4540 function getOffsetParent(element, polyfill) {
4541 const win = getWindow(element);
4542 if (isTopLayer(element)) {
4543 return win;
4544 }
4545 if (!isHTMLElement(element)) {
4546 let svgOffsetParent = getParentNode(element);
4547 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
4548 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
4549 return svgOffsetParent;
4550 }
4551 svgOffsetParent = getParentNode(svgOffsetParent);
4552 }
4553 return win;
4554 }
4555 let offsetParent = getTrueOffsetParent(element, polyfill);
4556 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
4557 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
4558 }
4559 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
4560 return win;
4561 }
4562 return offsetParent || getContainingBlock(element) || win;
4563 }
4564 var getElementRects = async function(data) {
4565 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
4566 const getDimensionsFn = this.getDimensions;
4567 const floatingDimensions = await getDimensionsFn(data.floating);
4568 return {
4569 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
4570 floating: {
4571 x: 0,
4572 y: 0,
4573 width: floatingDimensions.width,
4574 height: floatingDimensions.height
4575 }
4576 };
4577 };
4578 function isRTL(element) {
4579 return getComputedStyle2(element).direction === "rtl";
4580 }
4581 var platform2 = {
4582 convertOffsetParentRelativeRectToViewportRelativeRect,
4583 getDocumentElement,
4584 getClippingRect,
4585 getOffsetParent,
4586 getElementRects,
4587 getClientRects,
4588 getDimensions,
4589 getScale,
4590 isElement,
4591 isRTL
4592 };
4593 function rectsAreEqual(a2, b2) {
4594 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
4595 }
4596 function observeMove(element, onMove) {
4597 let io = null;
4598 let timeoutId;
4599 const root = getDocumentElement(element);
4600 function cleanup() {
4601 var _io;
4602 clearTimeout(timeoutId);
4603 (_io = io) == null || _io.disconnect();
4604 io = null;
4605 }
4606 function refresh(skip, threshold) {
4607 if (skip === void 0) {
4608 skip = false;
4609 }
4610 if (threshold === void 0) {
4611 threshold = 1;
4612 }
4613 cleanup();
4614 const elementRectForRootMargin = element.getBoundingClientRect();
4615 const {
4616 left,
4617 top,
4618 width,
4619 height
4620 } = elementRectForRootMargin;
4621 if (!skip) {
4622 onMove();
4623 }
4624 if (!width || !height) {
4625 return;
4626 }
4627 const insetTop = floor(top);
4628 const insetRight = floor(root.clientWidth - (left + width));
4629 const insetBottom = floor(root.clientHeight - (top + height));
4630 const insetLeft = floor(left);
4631 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
4632 const options = {
4633 rootMargin,
4634 threshold: max(0, min(1, threshold)) || 1
4635 };
4636 let isFirstUpdate = true;
4637 function handleObserve(entries) {
4638 const ratio = entries[0].intersectionRatio;
4639 if (ratio !== threshold) {
4640 if (!isFirstUpdate) {
4641 return refresh();
4642 }
4643 if (!ratio) {
4644 timeoutId = setTimeout(() => {
4645 refresh(false, 1e-7);
4646 }, 1e3);
4647 } else {
4648 refresh(false, ratio);
4649 }
4650 }
4651 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
4652 refresh();
4653 }
4654 isFirstUpdate = false;
4655 }
4656 try {
4657 io = new IntersectionObserver(handleObserve, {
4658 ...options,
4659 // Handle <iframe>s
4660 root: root.ownerDocument
4661 });
4662 } catch (_e) {
4663 io = new IntersectionObserver(handleObserve, options);
4664 }
4665 io.observe(element);
4666 }
4667 refresh(true);
4668 return cleanup;
4669 }
4670 function autoUpdate(reference, floating, update2, options) {
4671 if (options === void 0) {
4672 options = {};
4673 }
4674 const {
4675 ancestorScroll = true,
4676 ancestorResize = true,
4677 elementResize = typeof ResizeObserver === "function",
4678 layoutShift = typeof IntersectionObserver === "function",
4679 animationFrame = false
4680 } = options;
4681 const referenceEl = unwrapElement(reference);
4682 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
4683 ancestors.forEach((ancestor) => {
4684 ancestorScroll && ancestor.addEventListener("scroll", update2, {
4685 passive: true
4686 });
4687 ancestorResize && ancestor.addEventListener("resize", update2);
4688 });
4689 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
4690 let reobserveFrame = -1;
4691 let resizeObserver = null;
4692 if (elementResize) {
4693 resizeObserver = new ResizeObserver((_ref) => {
4694 let [firstEntry] = _ref;
4695 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
4696 resizeObserver.unobserve(floating);
4697 cancelAnimationFrame(reobserveFrame);
4698 reobserveFrame = requestAnimationFrame(() => {
4699 var _resizeObserver;
4700 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
4701 });
4702 }
4703 update2();
4704 });
4705 if (referenceEl && !animationFrame) {
4706 resizeObserver.observe(referenceEl);
4707 }
4708 if (floating) {
4709 resizeObserver.observe(floating);
4710 }
4711 }
4712 let frameId;
4713 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
4714 if (animationFrame) {
4715 frameLoop();
4716 }
4717 function frameLoop() {
4718 const nextRefRect = getBoundingClientRect(reference);
4719 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
4720 update2();
4721 }
4722 prevRefRect = nextRefRect;
4723 frameId = requestAnimationFrame(frameLoop);
4724 }
4725 update2();
4726 return () => {
4727 var _resizeObserver2;
4728 ancestors.forEach((ancestor) => {
4729 ancestorScroll && ancestor.removeEventListener("scroll", update2);
4730 ancestorResize && ancestor.removeEventListener("resize", update2);
4731 });
4732 cleanupIo == null || cleanupIo();
4733 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
4734 resizeObserver = null;
4735 if (animationFrame) {
4736 cancelAnimationFrame(frameId);
4737 }
4738 };
4739 }
4740 var offset2 = offset;
4741 var shift2 = shift;
4742 var flip2 = flip;
4743 var size2 = size;
4744 var hide2 = hide;
4745 var limitShift2 = limitShift;
4746 var computePosition2 = (reference, floating, options) => {
4747 const cache = /* @__PURE__ */ new Map();
4748 const mergedOptions = {
4749 platform: platform2,
4750 ...options
4751 };
4752 const platformWithCache = {
4753 ...mergedOptions.platform,
4754 _c: cache
4755 };
4756 return computePosition(reference, floating, {
4757 ...mergedOptions,
4758 platform: platformWithCache
4759 });
4760 };
4761
4762 // node_modules/@base-ui/react/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
4763 var React20 = __toESM(require_react(), 1);
4764 var import_react2 = __toESM(require_react(), 1);
4765 var ReactDOM3 = __toESM(require_react_dom(), 1);
4766 var isClient = typeof document !== "undefined";
4767 var noop2 = function noop3() {
4768 };
4769 var index = isClient ? import_react2.useLayoutEffect : noop2;
4770 function deepEqual(a2, b2) {
4771 if (a2 === b2) {
4772 return true;
4773 }
4774 if (typeof a2 !== typeof b2) {
4775 return false;
4776 }
4777 if (typeof a2 === "function" && a2.toString() === b2.toString()) {
4778 return true;
4779 }
4780 let length;
4781 let i2;
4782 let keys;
4783 if (a2 && b2 && typeof a2 === "object") {
4784 if (Array.isArray(a2)) {
4785 length = a2.length;
4786 if (length !== b2.length) return false;
4787 for (i2 = length; i2-- !== 0; ) {
4788 if (!deepEqual(a2[i2], b2[i2])) {
4789 return false;
4790 }
4791 }
4792 return true;
4793 }
4794 keys = Object.keys(a2);
4795 length = keys.length;
4796 if (length !== Object.keys(b2).length) {
4797 return false;
4798 }
4799 for (i2 = length; i2-- !== 0; ) {
4800 if (!{}.hasOwnProperty.call(b2, keys[i2])) {
4801 return false;
4802 }
4803 }
4804 for (i2 = length; i2-- !== 0; ) {
4805 const key = keys[i2];
4806 if (key === "_owner" && a2.$$typeof) {
4807 continue;
4808 }
4809 if (!deepEqual(a2[key], b2[key])) {
4810 return false;
4811 }
4812 }
4813 return true;
4814 }
4815 return a2 !== a2 && b2 !== b2;
4816 }
4817 function getDPR(element) {
4818 if (typeof window === "undefined") {
4819 return 1;
4820 }
4821 const win = element.ownerDocument.defaultView || window;
4822 return win.devicePixelRatio || 1;
4823 }
4824 function roundByDPR(element, value) {
4825 const dpr = getDPR(element);
4826 return Math.round(value * dpr) / dpr;
4827 }
4828 function useLatestRef(value) {
4829 const ref = React20.useRef(value);
4830 index(() => {
4831 ref.current = value;
4832 });
4833 return ref;
4834 }
4835 function useFloating(options) {
4836 if (options === void 0) {
4837 options = {};
4838 }
4839 const {
4840 placement = "bottom",
4841 strategy = "absolute",
4842 middleware = [],
4843 platform: platform3,
4844 elements: {
4845 reference: externalReference,
4846 floating: externalFloating
4847 } = {},
4848 transform = true,
4849 whileElementsMounted,
4850 open
4851 } = options;
4852 const [data, setData] = React20.useState({
4853 x: 0,
4854 y: 0,
4855 strategy,
4856 placement,
4857 middlewareData: {},
4858 isPositioned: false
4859 });
4860 const [latestMiddleware, setLatestMiddleware] = React20.useState(middleware);
4861 if (!deepEqual(latestMiddleware, middleware)) {
4862 setLatestMiddleware(middleware);
4863 }
4864 const [_reference, _setReference] = React20.useState(null);
4865 const [_floating, _setFloating] = React20.useState(null);
4866 const setReference = React20.useCallback((node) => {
4867 if (node !== referenceRef.current) {
4868 referenceRef.current = node;
4869 _setReference(node);
4870 }
4871 }, []);
4872 const setFloating = React20.useCallback((node) => {
4873 if (node !== floatingRef.current) {
4874 floatingRef.current = node;
4875 _setFloating(node);
4876 }
4877 }, []);
4878 const referenceEl = externalReference || _reference;
4879 const floatingEl = externalFloating || _floating;
4880 const referenceRef = React20.useRef(null);
4881 const floatingRef = React20.useRef(null);
4882 const dataRef = React20.useRef(data);
4883 const hasWhileElementsMounted = whileElementsMounted != null;
4884 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
4885 const platformRef = useLatestRef(platform3);
4886 const openRef = useLatestRef(open);
4887 const update2 = React20.useCallback(() => {
4888 if (!referenceRef.current || !floatingRef.current) {
4889 return;
4890 }
4891 const config = {
4892 placement,
4893 strategy,
4894 middleware: latestMiddleware
4895 };
4896 if (platformRef.current) {
4897 config.platform = platformRef.current;
4898 }
4899 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
4900 const fullData = {
4901 ...data2,
4902 // The floating element's position may be recomputed while it's closed
4903 // but still mounted (such as when transitioning out). To ensure
4904 // `isPositioned` will be `false` initially on the next open, avoid
4905 // setting it to `true` when `open === false` (must be specified).
4906 isPositioned: openRef.current !== false
4907 };
4908 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
4909 dataRef.current = fullData;
4910 ReactDOM3.flushSync(() => {
4911 setData(fullData);
4912 });
4913 }
4914 });
4915 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
4916 index(() => {
4917 if (open === false && dataRef.current.isPositioned) {
4918 dataRef.current.isPositioned = false;
4919 setData((data2) => ({
4920 ...data2,
4921 isPositioned: false
4922 }));
4923 }
4924 }, [open]);
4925 const isMountedRef = React20.useRef(false);
4926 index(() => {
4927 isMountedRef.current = true;
4928 return () => {
4929 isMountedRef.current = false;
4930 };
4931 }, []);
4932 index(() => {
4933 if (referenceEl) referenceRef.current = referenceEl;
4934 if (floatingEl) floatingRef.current = floatingEl;
4935 if (referenceEl && floatingEl) {
4936 if (whileElementsMountedRef.current) {
4937 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
4938 }
4939 update2();
4940 }
4941 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
4942 const refs = React20.useMemo(() => ({
4943 reference: referenceRef,
4944 floating: floatingRef,
4945 setReference,
4946 setFloating
4947 }), [setReference, setFloating]);
4948 const elements = React20.useMemo(() => ({
4949 reference: referenceEl,
4950 floating: floatingEl
4951 }), [referenceEl, floatingEl]);
4952 const floatingStyles = React20.useMemo(() => {
4953 const initialStyles = {
4954 position: strategy,
4955 left: 0,
4956 top: 0
4957 };
4958 if (!elements.floating) {
4959 return initialStyles;
4960 }
4961 const x2 = roundByDPR(elements.floating, data.x);
4962 const y2 = roundByDPR(elements.floating, data.y);
4963 if (transform) {
4964 return {
4965 ...initialStyles,
4966 transform: "translate(" + x2 + "px, " + y2 + "px)",
4967 ...getDPR(elements.floating) >= 1.5 && {
4968 willChange: "transform"
4969 }
4970 };
4971 }
4972 return {
4973 position: strategy,
4974 left: x2,
4975 top: y2
4976 };
4977 }, [strategy, transform, elements.floating, data.x, data.y]);
4978 return React20.useMemo(() => ({
4979 ...data,
4980 update: update2,
4981 refs,
4982 elements,
4983 floatingStyles
4984 }), [data, update2, refs, elements, floatingStyles]);
4985 }
4986 var offset3 = (options, deps) => {
4987 const result = offset2(options);
4988 return {
4989 name: result.name,
4990 fn: result.fn,
4991 options: [options, deps]
4992 };
4993 };
4994 var shift3 = (options, deps) => {
4995 const result = shift2(options);
4996 return {
4997 name: result.name,
4998 fn: result.fn,
4999 options: [options, deps]
5000 };
5001 };
5002 var limitShift3 = (options, deps) => {
5003 const result = limitShift2(options);
5004 return {
5005 fn: result.fn,
5006 options: [options, deps]
5007 };
5008 };
5009 var flip3 = (options, deps) => {
5010 const result = flip2(options);
5011 return {
5012 name: result.name,
5013 fn: result.fn,
5014 options: [options, deps]
5015 };
5016 };
5017 var size3 = (options, deps) => {
5018 const result = size2(options);
5019 return {
5020 name: result.name,
5021 fn: result.fn,
5022 options: [options, deps]
5023 };
5024 };
5025 var hide3 = (options, deps) => {
5026 const result = hide2(options);
5027 return {
5028 name: result.name,
5029 fn: result.fn,
5030 options: [options, deps]
5031 };
5032 };
5033
5034 // node_modules/@base-ui/utils/esm/store/createSelector.js
5035 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => {
5036 if (other.length > 0) {
5037 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
5038 }
5039 let selector2;
5040 if (a2 && b2 && c2 && d2 && e2 && f2) {
5041 selector2 = (state, a1, a22, a3) => {
5042 const va = a2(state, a1, a22, a3);
5043 const vb = b2(state, a1, a22, a3);
5044 const vc = c2(state, a1, a22, a3);
5045 const vd = d2(state, a1, a22, a3);
5046 const ve = e2(state, a1, a22, a3);
5047 return f2(va, vb, vc, vd, ve, a1, a22, a3);
5048 };
5049 } else if (a2 && b2 && c2 && d2 && e2) {
5050 selector2 = (state, a1, a22, a3) => {
5051 const va = a2(state, a1, a22, a3);
5052 const vb = b2(state, a1, a22, a3);
5053 const vc = c2(state, a1, a22, a3);
5054 const vd = d2(state, a1, a22, a3);
5055 return e2(va, vb, vc, vd, a1, a22, a3);
5056 };
5057 } else if (a2 && b2 && c2 && d2) {
5058 selector2 = (state, a1, a22, a3) => {
5059 const va = a2(state, a1, a22, a3);
5060 const vb = b2(state, a1, a22, a3);
5061 const vc = c2(state, a1, a22, a3);
5062 return d2(va, vb, vc, a1, a22, a3);
5063 };
5064 } else if (a2 && b2 && c2) {
5065 selector2 = (state, a1, a22, a3) => {
5066 const va = a2(state, a1, a22, a3);
5067 const vb = b2(state, a1, a22, a3);
5068 return c2(va, vb, a1, a22, a3);
5069 };
5070 } else if (a2 && b2) {
5071 selector2 = (state, a1, a22, a3) => {
5072 const va = a2(state, a1, a22, a3);
5073 return b2(va, a1, a22, a3);
5074 };
5075 } else if (a2) {
5076 selector2 = a2;
5077 } else {
5078 throw (
5079 /* minify-error-disabled */
5080 new Error("Missing arguments")
5081 );
5082 }
5083 return selector2;
5084 };
5085
5086 // node_modules/@base-ui/utils/esm/store/useStore.js
5087 var React22 = __toESM(require_react(), 1);
5088 var import_shim = __toESM(require_shim(), 1);
5089 var import_with_selector = __toESM(require_with_selector(), 1);
5090
5091 // node_modules/@base-ui/utils/esm/fastHooks.js
5092 var React21 = __toESM(require_react(), 1);
5093 var hooks = [];
5094 var currentInstance = void 0;
5095 function getInstance() {
5096 return currentInstance;
5097 }
5098 function register(hook) {
5099 hooks.push(hook);
5100 }
5101 function fastComponent(fn) {
5102 const FastComponent = (props, forwardedRef) => {
5103 const instance = useRefWithInit(createInstance).current;
5104 let result;
5105 try {
5106 currentInstance = instance;
5107 for (const hook of hooks) {
5108 hook.before(instance);
5109 }
5110 result = fn(props, forwardedRef);
5111 for (const hook of hooks) {
5112 hook.after(instance);
5113 }
5114 instance.didInitialize = true;
5115 } finally {
5116 currentInstance = void 0;
5117 }
5118 return result;
5119 };
5120 FastComponent.displayName = fn.displayName || fn.name;
5121 return FastComponent;
5122 }
5123 function fastComponentRef(fn) {
5124 return /* @__PURE__ */ React21.forwardRef(fastComponent(fn));
5125 }
5126 function createInstance() {
5127 return {
5128 didInitialize: false
5129 };
5130 }
5131
5132 // node_modules/@base-ui/utils/esm/store/useStore.js
5133 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
5134 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
5135 function useStore(store, selector2, a1, a2, a3) {
5136 return useStoreImplementation(store, selector2, a1, a2, a3);
5137 }
5138 function useStoreR19(store, selector2, a1, a2, a3) {
5139 const getSelection = React22.useCallback(() => selector2(store.getSnapshot(), a1, a2, a3), [store, selector2, a1, a2, a3]);
5140 return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection);
5141 }
5142 register({
5143 before(instance) {
5144 instance.syncIndex = 0;
5145 if (!instance.didInitialize) {
5146 instance.syncTick = 1;
5147 instance.syncHooks = [];
5148 instance.didChangeStore = true;
5149 instance.getSnapshot = () => {
5150 let didChange2 = false;
5151 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) {
5152 const hook = instance.syncHooks[i2];
5153 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
5154 if (hook.didChange || !Object.is(hook.value, value)) {
5155 didChange2 = true;
5156 hook.value = value;
5157 hook.didChange = false;
5158 }
5159 }
5160 if (didChange2) {
5161 instance.syncTick += 1;
5162 }
5163 return instance.syncTick;
5164 };
5165 }
5166 },
5167 after(instance) {
5168 if (instance.syncHooks.length > 0) {
5169 if (instance.didChangeStore) {
5170 instance.didChangeStore = false;
5171 instance.subscribe = (onStoreChange) => {
5172 const stores = /* @__PURE__ */ new Set();
5173 for (const hook of instance.syncHooks) {
5174 stores.add(hook.store);
5175 }
5176 const unsubscribes = [];
5177 for (const store of stores) {
5178 unsubscribes.push(store.subscribe(onStoreChange));
5179 }
5180 return () => {
5181 for (const unsubscribe of unsubscribes) {
5182 unsubscribe();
5183 }
5184 };
5185 };
5186 }
5187 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
5188 }
5189 }
5190 });
5191 function useStoreFast(store, selector2, a1, a2, a3) {
5192 const instance = getInstance();
5193 if (!instance) {
5194 return useStoreR19(store, selector2, a1, a2, a3);
5195 }
5196 const index2 = instance.syncIndex;
5197 instance.syncIndex += 1;
5198 let hook;
5199 if (!instance.didInitialize) {
5200 hook = {
5201 store,
5202 selector: selector2,
5203 a1,
5204 a2,
5205 a3,
5206 value: selector2(store.getSnapshot(), a1, a2, a3),
5207 didChange: false
5208 };
5209 instance.syncHooks.push(hook);
5210 } else {
5211 hook = instance.syncHooks[index2];
5212 if (hook.store !== store || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
5213 if (hook.store !== store) {
5214 instance.didChangeStore = true;
5215 }
5216 hook.store = store;
5217 hook.selector = selector2;
5218 hook.a1 = a1;
5219 hook.a2 = a2;
5220 hook.a3 = a3;
5221 hook.didChange = true;
5222 }
5223 }
5224 return hook.value;
5225 }
5226 function useStoreLegacy(store, selector2, a1, a2, a3) {
5227 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector2(state, a1, a2, a3));
5228 }
5229
5230 // node_modules/@base-ui/utils/esm/store/Store.js
5231 var Store = class {
5232 /**
5233 * The current state of the store.
5234 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
5235 * 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).
5236 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
5237 *
5238 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
5239 */
5240 // Internal state to handle recursive `setState()` calls
5241 constructor(state) {
5242 this.state = state;
5243 this.listeners = /* @__PURE__ */ new Set();
5244 this.updateTick = 0;
5245 }
5246 /**
5247 * Registers a listener that will be called whenever the store's state changes.
5248 *
5249 * @param fn The listener function to be called on state changes.
5250 * @returns A function to unsubscribe the listener.
5251 */
5252 subscribe = (fn) => {
5253 this.listeners.add(fn);
5254 return () => {
5255 this.listeners.delete(fn);
5256 };
5257 };
5258 /**
5259 * Returns the current state of the store.
5260 */
5261 getSnapshot = () => {
5262 return this.state;
5263 };
5264 /**
5265 * Updates the entire store's state and notifies all registered listeners.
5266 *
5267 * @param newState The new state to set for the store.
5268 */
5269 setState(newState) {
5270 if (this.state === newState) {
5271 return;
5272 }
5273 this.state = newState;
5274 this.updateTick += 1;
5275 const currentTick = this.updateTick;
5276 for (const listener of this.listeners) {
5277 if (currentTick !== this.updateTick) {
5278 return;
5279 }
5280 listener(newState);
5281 }
5282 }
5283 /**
5284 * Merges the provided changes into the current state and notifies listeners if there are changes.
5285 *
5286 * @param changes An object containing the changes to apply to the current state.
5287 */
5288 update(changes) {
5289 for (const key in changes) {
5290 if (!Object.is(this.state[key], changes[key])) {
5291 this.setState({
5292 ...this.state,
5293 ...changes
5294 });
5295 return;
5296 }
5297 }
5298 }
5299 /**
5300 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
5301 *
5302 * @param key The key in the store's state to update.
5303 * @param value The new value to set for the specified key.
5304 */
5305 set(key, value) {
5306 if (!Object.is(this.state[key], value)) {
5307 this.setState({
5308 ...this.state,
5309 [key]: value
5310 });
5311 }
5312 }
5313 /**
5314 * Gives the state a new reference and updates all registered listeners.
5315 */
5316 notifyAll() {
5317 const newState = {
5318 ...this.state
5319 };
5320 this.setState(newState);
5321 }
5322 use(selector2, a1, a2, a3) {
5323 return useStore(this, selector2, a1, a2, a3);
5324 }
5325 };
5326
5327 // node_modules/@base-ui/utils/esm/store/ReactStore.js
5328 var React23 = __toESM(require_react(), 1);
5329 var ReactStore = class extends Store {
5330 /**
5331 * Creates a new ReactStore instance.
5332 *
5333 * @param state Initial state of the store.
5334 * @param context Non-reactive context values.
5335 * @param selectors Optional selectors for use with `useState`.
5336 */
5337 constructor(state, context = {}, selectors3) {
5338 super(state);
5339 this.context = context;
5340 this.selectors = selectors3;
5341 }
5342 /**
5343 * Non-reactive values such as refs, callbacks, etc.
5344 */
5345 /**
5346 * Synchronizes a single external value into the store.
5347 *
5348 * Note that the while the value in `state` is updated immediately, the value returned
5349 * by `useState` is updated before the next render (similarly to React's `useState`).
5350 */
5351 useSyncedValue(key, value) {
5352 React23.useDebugValue(key);
5353 useIsoLayoutEffect(() => {
5354 if (this.state[key] !== value) {
5355 this.set(key, value);
5356 }
5357 }, [key, value]);
5358 }
5359 /**
5360 * Synchronizes a single external value into the store and
5361 * cleans it up (sets to `undefined`) on unmount.
5362 *
5363 * Note that the while the value in `state` is updated immediately, the value returned
5364 * by `useState` is updated before the next render (similarly to React's `useState`).
5365 */
5366 useSyncedValueWithCleanup(key, value) {
5367 const store = this;
5368 useIsoLayoutEffect(() => {
5369 if (store.state[key] !== value) {
5370 store.set(key, value);
5371 }
5372 return () => {
5373 store.set(key, void 0);
5374 };
5375 }, [store, key, value]);
5376 }
5377 /**
5378 * Synchronizes multiple external values into the store.
5379 *
5380 * Note that the while the values in `state` are updated immediately, the values returned
5381 * by `useState` are updated before the next render (similarly to React's `useState`).
5382 */
5383 useSyncedValues(statePart) {
5384 const store = this;
5385 if (true) {
5386 React23.useDebugValue(statePart, (p2) => Object.keys(p2));
5387 const keys = React23.useRef(Object.keys(statePart)).current;
5388 const nextKeys = Object.keys(statePart);
5389 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
5390 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
5391 }
5392 }
5393 const dependencies = Object.values(statePart);
5394 useIsoLayoutEffect(() => {
5395 store.update(statePart);
5396 }, [store, ...dependencies]);
5397 }
5398 /**
5399 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
5400 * is non-undefined, the store's state at `key` is updated to match `controlled`.
5401 */
5402 useControlledProp(key, controlled) {
5403 React23.useDebugValue(key);
5404 const isControlled = controlled !== void 0;
5405 useIsoLayoutEffect(() => {
5406 if (isControlled && !Object.is(this.state[key], controlled)) {
5407 super.setState({
5408 ...this.state,
5409 [key]: controlled
5410 });
5411 }
5412 }, [key, controlled, isControlled]);
5413 if (true) {
5414 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
5415 if (!cache.has(key)) {
5416 cache.set(key, isControlled);
5417 }
5418 const previouslyControlled = cache.get(key);
5419 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
5420 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).`);
5421 }
5422 }
5423 }
5424 /** Gets the current value from the store using a selector with the provided key.
5425 *
5426 * @param key Key of the selector to use.
5427 */
5428 select(key, a1, a2, a3) {
5429 const selector2 = this.selectors[key];
5430 return selector2(this.state, a1, a2, a3);
5431 }
5432 /**
5433 * Returns a value from the store's state using a selector function.
5434 * Used to subscribe to specific parts of the state.
5435 * This methods causes a rerender whenever the selected state changes.
5436 *
5437 * @param key Key of the selector to use.
5438 */
5439 useState(key, a1, a2, a3) {
5440 React23.useDebugValue(key);
5441 return useStore(this, this.selectors[key], a1, a2, a3);
5442 }
5443 /**
5444 * Wraps a function with `useStableCallback` to ensure it has a stable reference
5445 * and assigns it to the context.
5446 *
5447 * @param key Key of the event callback. Must be a function in the context.
5448 * @param fn Function to assign.
5449 */
5450 useContextCallback(key, fn) {
5451 React23.useDebugValue(key);
5452 const stableFunction = useStableCallback(fn ?? NOOP);
5453 this.context[key] = stableFunction;
5454 }
5455 /**
5456 * Returns a stable setter function for a specific key in the store's state.
5457 * It's commonly used to pass as a ref callback to React elements.
5458 *
5459 * @param key Key of the state to set.
5460 */
5461 useStateSetter(key) {
5462 const ref = React23.useRef(void 0);
5463 if (ref.current === void 0) {
5464 ref.current = (value) => {
5465 this.set(key, value);
5466 };
5467 }
5468 return ref.current;
5469 }
5470 /**
5471 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
5472 *
5473 * @param key Key of the selector to observe.
5474 * @param listener Listener function called when the selector result changes.
5475 */
5476 observe(selector2, listener) {
5477 let selectFn;
5478 if (typeof selector2 === "function") {
5479 selectFn = selector2;
5480 } else {
5481 selectFn = this.selectors[selector2];
5482 }
5483 let prevValue = selectFn(this.state);
5484 listener(prevValue, prevValue, this);
5485 return this.subscribe((nextState) => {
5486 const nextValue = selectFn(nextState);
5487 if (!Object.is(prevValue, nextValue)) {
5488 const oldValue = prevValue;
5489 prevValue = nextValue;
5490 listener(nextValue, oldValue, this);
5491 }
5492 });
5493 }
5494 };
5495
5496 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingRootStore.js
5497 var selectors = {
5498 open: createSelector((state) => state.open),
5499 transitionStatus: createSelector((state) => state.transitionStatus),
5500 domReferenceElement: createSelector((state) => state.domReferenceElement),
5501 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
5502 floatingElement: createSelector((state) => state.floatingElement),
5503 floatingId: createSelector((state) => state.floatingId)
5504 };
5505 var FloatingRootStore = class extends ReactStore {
5506 constructor(options) {
5507 const {
5508 syncOnly,
5509 nested,
5510 onOpenChange,
5511 triggerElements,
5512 ...initialState
5513 } = options;
5514 super({
5515 ...initialState,
5516 positionReference: initialState.referenceElement,
5517 domReferenceElement: initialState.referenceElement
5518 }, {
5519 onOpenChange,
5520 dataRef: {
5521 current: {}
5522 },
5523 events: createEventEmitter(),
5524 nested,
5525 triggerElements
5526 }, selectors);
5527 this.syncOnly = syncOnly;
5528 }
5529 /**
5530 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
5531 */
5532 syncOpenEvent = (newOpen, event) => {
5533 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
5534 // click events to upgrade a hover-open.
5535 event != null && isClickLikeEvent(event)) {
5536 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
5537 }
5538 };
5539 /**
5540 * Runs the root-owned side effects for an open state change.
5541 */
5542 dispatchOpenChange = (newOpen, eventDetails) => {
5543 this.syncOpenEvent(newOpen, eventDetails.event);
5544 const details = {
5545 open: newOpen,
5546 reason: eventDetails.reason,
5547 nativeEvent: eventDetails.event,
5548 nested: this.context.nested,
5549 triggerElement: eventDetails.trigger
5550 };
5551 this.context.events.emit("openchange", details);
5552 };
5553 /**
5554 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
5555 *
5556 * @param newOpen The new open state.
5557 * @param eventDetails Details about the event that triggered the open state change.
5558 */
5559 setOpen = (newOpen, eventDetails) => {
5560 if (this.syncOnly) {
5561 this.context.onOpenChange?.(newOpen, eventDetails);
5562 return;
5563 }
5564 this.dispatchOpenChange(newOpen, eventDetails);
5565 this.context.onOpenChange?.(newOpen, eventDetails);
5566 };
5567 };
5568
5569 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
5570 var React24 = __toESM(require_react(), 1);
5571 function useTriggerRegistration(id, store) {
5572 const registeredElementIdRef = React24.useRef(null);
5573 const registeredElementRef = React24.useRef(null);
5574 return React24.useCallback((element) => {
5575 if (id === void 0) {
5576 return;
5577 }
5578 if (registeredElementIdRef.current !== null) {
5579 const registeredId = registeredElementIdRef.current;
5580 const registeredElement = registeredElementRef.current;
5581 const currentElement = store.context.triggerElements.getById(registeredId);
5582 if (registeredElement && currentElement === registeredElement) {
5583 store.context.triggerElements.delete(registeredId);
5584 }
5585 registeredElementIdRef.current = null;
5586 registeredElementRef.current = null;
5587 }
5588 if (element !== null) {
5589 registeredElementIdRef.current = id;
5590 registeredElementRef.current = element;
5591 store.context.triggerElements.add(id, element);
5592 }
5593 }, [store, id]);
5594 }
5595 function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
5596 const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
5597 const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
5598 const registerTrigger = useStableCallback((element) => {
5599 baseRegisterTrigger(element);
5600 if (!element || !store.select("open")) {
5601 return;
5602 }
5603 const activeTriggerId = store.select("activeTriggerId");
5604 if (activeTriggerId === triggerId) {
5605 store.update({
5606 activeTriggerElement: element,
5607 ...stateUpdates
5608 });
5609 return;
5610 }
5611 if (activeTriggerId == null) {
5612 store.update({
5613 activeTriggerId: triggerId,
5614 activeTriggerElement: element,
5615 ...stateUpdates
5616 });
5617 }
5618 });
5619 useIsoLayoutEffect(() => {
5620 if (isMountedByThisTrigger) {
5621 store.update({
5622 activeTriggerElement: triggerElementRef.current,
5623 ...stateUpdates
5624 });
5625 }
5626 }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]);
5627 return {
5628 registerTrigger,
5629 isMountedByThisTrigger
5630 };
5631 }
5632 function useImplicitActiveTrigger(store) {
5633 const open = store.useState("open");
5634 useIsoLayoutEffect(() => {
5635 if (open && !store.select("activeTriggerId") && store.context.triggerElements.size === 1) {
5636 const iteratorResult = store.context.triggerElements.entries().next();
5637 if (!iteratorResult.done) {
5638 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
5639 store.update({
5640 activeTriggerId: implicitTriggerId,
5641 activeTriggerElement: implicitTriggerElement
5642 });
5643 }
5644 }
5645 }, [open, store]);
5646 }
5647 function useOpenStateTransitions(open, store, onUnmount) {
5648 const {
5649 mounted,
5650 setMounted,
5651 transitionStatus
5652 } = useTransitionStatus(open);
5653 store.useSyncedValues({
5654 mounted,
5655 transitionStatus
5656 });
5657 const forceUnmount = useStableCallback(() => {
5658 setMounted(false);
5659 store.update({
5660 activeTriggerId: null,
5661 activeTriggerElement: null,
5662 mounted: false
5663 });
5664 onUnmount?.();
5665 store.context.onOpenChangeComplete?.(false);
5666 });
5667 const preventUnmountingOnClose = store.useState("preventUnmountingOnClose");
5668 useOpenChangeComplete({
5669 enabled: !preventUnmountingOnClose,
5670 open,
5671 ref: store.context.popupRef,
5672 onComplete() {
5673 if (!open) {
5674 forceUnmount();
5675 }
5676 }
5677 });
5678 return {
5679 forceUnmount,
5680 transitionStatus
5681 };
5682 }
5683
5684 // node_modules/@base-ui/react/esm/utils/popups/popupTriggerMap.js
5685 var PopupTriggerMap = class {
5686 constructor() {
5687 this.elementsSet = /* @__PURE__ */ new Set();
5688 this.idMap = /* @__PURE__ */ new Map();
5689 }
5690 /**
5691 * Adds a trigger element with the given ID.
5692 *
5693 * Note: The provided element is assumed to not be registered under multiple IDs.
5694 */
5695 add(id, element) {
5696 const existingElement = this.idMap.get(id);
5697 if (existingElement === element) {
5698 return;
5699 }
5700 if (existingElement !== void 0) {
5701 this.elementsSet.delete(existingElement);
5702 }
5703 this.elementsSet.add(element);
5704 this.idMap.set(id, element);
5705 if (true) {
5706 if (this.elementsSet.size !== this.idMap.size) {
5707 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
5708 }
5709 }
5710 }
5711 /**
5712 * Removes the trigger element with the given ID.
5713 */
5714 delete(id) {
5715 const element = this.idMap.get(id);
5716 if (element) {
5717 this.elementsSet.delete(element);
5718 this.idMap.delete(id);
5719 }
5720 }
5721 /**
5722 * Whether the given element is registered as a trigger.
5723 */
5724 hasElement(element) {
5725 return this.elementsSet.has(element);
5726 }
5727 /**
5728 * Whether there is a registered trigger element matching the given predicate.
5729 */
5730 hasMatchingElement(predicate) {
5731 for (const element of this.elementsSet) {
5732 if (predicate(element)) {
5733 return true;
5734 }
5735 }
5736 return false;
5737 }
5738 /**
5739 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
5740 */
5741 getById(id) {
5742 return this.idMap.get(id);
5743 }
5744 /**
5745 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
5746 */
5747 entries() {
5748 return this.idMap.entries();
5749 }
5750 /**
5751 * Returns an iterable of all registered trigger elements.
5752 */
5753 elements() {
5754 return this.elementsSet.values();
5755 }
5756 /**
5757 * Returns the number of registered trigger elements.
5758 */
5759 get size() {
5760 return this.idMap.size;
5761 }
5762 };
5763
5764 // node_modules/@base-ui/react/esm/floating-ui-react/utils/getEmptyRootContext.js
5765 function getEmptyRootContext() {
5766 return new FloatingRootStore({
5767 open: false,
5768 transitionStatus: void 0,
5769 floatingElement: null,
5770 referenceElement: null,
5771 triggerElements: new PopupTriggerMap(),
5772 floatingId: "",
5773 syncOnly: false,
5774 nested: false,
5775 onOpenChange: void 0
5776 });
5777 }
5778
5779 // node_modules/@base-ui/react/esm/utils/popups/store.js
5780 function createInitialPopupStoreState() {
5781 return {
5782 open: false,
5783 openProp: void 0,
5784 mounted: false,
5785 transitionStatus: void 0,
5786 floatingRootContext: getEmptyRootContext(),
5787 preventUnmountingOnClose: false,
5788 payload: void 0,
5789 activeTriggerId: null,
5790 activeTriggerElement: null,
5791 triggerIdProp: void 0,
5792 popupElement: null,
5793 positionerElement: null,
5794 activeTriggerProps: EMPTY_OBJECT,
5795 inactiveTriggerProps: EMPTY_OBJECT,
5796 popupProps: EMPTY_OBJECT
5797 };
5798 }
5799 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
5800 var popupStoreSelectors = {
5801 open: createSelector((state) => state.openProp ?? state.open),
5802 mounted: createSelector((state) => state.mounted),
5803 transitionStatus: createSelector((state) => state.transitionStatus),
5804 floatingRootContext: createSelector((state) => state.floatingRootContext),
5805 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
5806 payload: createSelector((state) => state.payload),
5807 activeTriggerId: activeTriggerIdSelector,
5808 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
5809 /**
5810 * Whether the trigger with the given ID was used to open the popup.
5811 */
5812 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
5813 /**
5814 * Whether the popup is open and was activated by a trigger with the given ID.
5815 */
5816 isOpenedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.open),
5817 /**
5818 * Whether the popup is mounted and was activated by a trigger with the given ID.
5819 */
5820 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
5821 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
5822 popupProps: createSelector((state) => state.popupProps),
5823 popupElement: createSelector((state) => state.popupElement),
5824 positionerElement: createSelector((state) => state.positionerElement)
5825 };
5826
5827 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloatingRootContext.js
5828 function useFloatingRootContext(options) {
5829 const {
5830 open = false,
5831 onOpenChange,
5832 elements = {}
5833 } = options;
5834 const floatingId = useId();
5835 const nested = useFloatingParentNodeId() != null;
5836 if (true) {
5837 const optionDomReference = elements.reference;
5838 if (optionDomReference && !isElement(optionDomReference)) {
5839 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
5840 }
5841 }
5842 const store = useRefWithInit(() => new FloatingRootStore({
5843 open,
5844 transitionStatus: void 0,
5845 onOpenChange,
5846 referenceElement: elements.reference ?? null,
5847 floatingElement: elements.floating ?? null,
5848 triggerElements: new PopupTriggerMap(),
5849 floatingId,
5850 syncOnly: false,
5851 nested
5852 })).current;
5853 useIsoLayoutEffect(() => {
5854 const valuesToSync = {
5855 open,
5856 floatingId
5857 };
5858 if (elements.reference !== void 0) {
5859 valuesToSync.referenceElement = elements.reference;
5860 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
5861 }
5862 if (elements.floating !== void 0) {
5863 valuesToSync.floatingElement = elements.floating;
5864 }
5865 store.update(valuesToSync);
5866 }, [open, floatingId, elements.reference, elements.floating, store]);
5867 store.context.onOpenChange = onOpenChange;
5868 store.context.nested = nested;
5869 return store;
5870 }
5871
5872 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
5873 function useFloating2(options = {}) {
5874 const {
5875 nodeId,
5876 externalTree
5877 } = options;
5878 const internalRootStore = useFloatingRootContext(options);
5879 const rootContext = options.rootContext || internalRootStore;
5880 const rootContextElements = {
5881 reference: rootContext.useState("referenceElement"),
5882 floating: rootContext.useState("floatingElement"),
5883 domReference: rootContext.useState("domReferenceElement")
5884 };
5885 const [positionReference, setPositionReferenceRaw] = React25.useState(null);
5886 const domReferenceRef = React25.useRef(null);
5887 const tree = useFloatingTree(externalTree);
5888 useIsoLayoutEffect(() => {
5889 if (rootContextElements.domReference) {
5890 domReferenceRef.current = rootContextElements.domReference;
5891 }
5892 }, [rootContextElements.domReference]);
5893 const position = useFloating({
5894 ...options,
5895 elements: {
5896 ...rootContextElements,
5897 ...positionReference && {
5898 reference: positionReference
5899 }
5900 }
5901 });
5902 const setPositionReference = React25.useCallback((node) => {
5903 const computedPositionReference = isElement(node) ? {
5904 getBoundingClientRect: () => node.getBoundingClientRect(),
5905 getClientRects: () => node.getClientRects(),
5906 contextElement: node
5907 } : node;
5908 setPositionReferenceRaw(computedPositionReference);
5909 position.refs.setReference(computedPositionReference);
5910 }, [position.refs]);
5911 const [localDomReference, setLocalDomReference] = React25.useState(void 0);
5912 const [localFloatingElement, setLocalFloatingElement] = React25.useState(null);
5913 rootContext.useSyncedValue("referenceElement", localDomReference ?? null);
5914 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
5915 rootContext.useSyncedValue("domReferenceElement", localDomReference === void 0 ? rootContextElements.domReference : localDomReferenceElement);
5916 rootContext.useSyncedValue("floatingElement", localFloatingElement);
5917 const setReference = React25.useCallback((node) => {
5918 if (isElement(node) || node === null) {
5919 domReferenceRef.current = node;
5920 setLocalDomReference(node);
5921 }
5922 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
5923 // `null` to support `positionReference` + an unstable `reference`
5924 // callback ref.
5925 node !== null && !isElement(node)) {
5926 position.refs.setReference(node);
5927 }
5928 }, [position.refs, setLocalDomReference]);
5929 const setFloating = React25.useCallback((node) => {
5930 setLocalFloatingElement(node);
5931 position.refs.setFloating(node);
5932 }, [position.refs]);
5933 const refs = React25.useMemo(() => ({
5934 ...position.refs,
5935 setReference,
5936 setFloating,
5937 setPositionReference,
5938 domReference: domReferenceRef
5939 }), [position.refs, setReference, setFloating, setPositionReference]);
5940 const elements = React25.useMemo(() => ({
5941 ...position.elements,
5942 domReference: rootContextElements.domReference
5943 }), [position.elements, rootContextElements.domReference]);
5944 const open = rootContext.useState("open");
5945 const floatingId = rootContext.useState("floatingId");
5946 const context = React25.useMemo(() => ({
5947 ...position,
5948 dataRef: rootContext.context.dataRef,
5949 open,
5950 onOpenChange: rootContext.setOpen,
5951 events: rootContext.context.events,
5952 floatingId,
5953 refs,
5954 elements,
5955 nodeId,
5956 rootStore: rootContext
5957 }), [position, refs, elements, nodeId, rootContext, open, floatingId]);
5958 useIsoLayoutEffect(() => {
5959 rootContext.context.dataRef.current.floatingContext = context;
5960 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId);
5961 if (node) {
5962 node.context = context;
5963 }
5964 });
5965 return React25.useMemo(() => ({
5966 ...position,
5967 context,
5968 refs,
5969 elements,
5970 rootStore: rootContext
5971 }), [position, refs, elements, context, rootContext]);
5972 }
5973
5974 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
5975 function useSyncedFloatingRootContext(options) {
5976 const {
5977 popupStore,
5978 treatPopupAsFloatingElement = false,
5979 onOpenChange
5980 } = options;
5981 const floatingId = useId();
5982 const nested = useFloatingParentNodeId() != null;
5983 const open = popupStore.useState("open");
5984 const referenceElement = popupStore.useState("activeTriggerElement");
5985 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
5986 const triggerElements = popupStore.context.triggerElements;
5987 const store = useRefWithInit(() => new FloatingRootStore({
5988 open,
5989 transitionStatus: void 0,
5990 referenceElement,
5991 floatingElement,
5992 triggerElements,
5993 onOpenChange,
5994 floatingId,
5995 syncOnly: true,
5996 nested
5997 })).current;
5998 useIsoLayoutEffect(() => {
5999 const valuesToSync = {
6000 open,
6001 floatingId,
6002 referenceElement,
6003 floatingElement
6004 };
6005 if (isElement(referenceElement)) {
6006 valuesToSync.domReferenceElement = referenceElement;
6007 }
6008 if (store.state.positionReference === store.state.referenceElement) {
6009 valuesToSync.positionReference = referenceElement;
6010 }
6011 store.update(valuesToSync);
6012 }, [open, floatingId, referenceElement, floatingElement, store]);
6013 store.context.onOpenChange = onOpenChange;
6014 store.context.nested = nested;
6015 return store;
6016 }
6017
6018 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFocus.js
6019 var React26 = __toESM(require_react(), 1);
6020 var isMacSafari = isMac && isSafari;
6021 function useFocus(context, props = {}) {
6022 const store = "rootStore" in context ? context.rootStore : context;
6023 const {
6024 events,
6025 dataRef
6026 } = store.context;
6027 const {
6028 enabled = true,
6029 delay
6030 } = props;
6031 const blockFocusRef = React26.useRef(false);
6032 const blockedReferenceRef = React26.useRef(null);
6033 const timeout = useTimeout();
6034 const keyboardModalityRef = React26.useRef(true);
6035 React26.useEffect(() => {
6036 const domReference = store.select("domReferenceElement");
6037 if (!enabled) {
6038 return void 0;
6039 }
6040 const win = getWindow(domReference);
6041 function onBlur() {
6042 const currentDomReference = store.select("domReferenceElement");
6043 if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
6044 blockFocusRef.current = true;
6045 }
6046 }
6047 function onKeyDown() {
6048 keyboardModalityRef.current = true;
6049 }
6050 function onPointerDown() {
6051 keyboardModalityRef.current = false;
6052 }
6053 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
6054 }, [store, enabled]);
6055 React26.useEffect(() => {
6056 if (!enabled) {
6057 return void 0;
6058 }
6059 function onOpenChangeLocal(details) {
6060 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
6061 const referenceElement = store.select("domReferenceElement");
6062 if (isElement(referenceElement)) {
6063 blockedReferenceRef.current = referenceElement;
6064 blockFocusRef.current = true;
6065 }
6066 }
6067 }
6068 events.on("openchange", onOpenChangeLocal);
6069 return () => {
6070 events.off("openchange", onOpenChangeLocal);
6071 };
6072 }, [events, enabled, store]);
6073 const reference = React26.useMemo(() => ({
6074 onMouseLeave() {
6075 blockFocusRef.current = false;
6076 blockedReferenceRef.current = null;
6077 },
6078 onFocus(event) {
6079 const focusTarget = event.currentTarget;
6080 if (blockFocusRef.current) {
6081 if (blockedReferenceRef.current === focusTarget) {
6082 return;
6083 }
6084 blockFocusRef.current = false;
6085 blockedReferenceRef.current = null;
6086 }
6087 const target = getTarget(event.nativeEvent);
6088 if (isElement(target)) {
6089 if (isMacSafari && !event.relatedTarget) {
6090 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
6091 return;
6092 }
6093 } else if (!matchesFocusVisible(target)) {
6094 return;
6095 }
6096 }
6097 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);
6098 const {
6099 nativeEvent,
6100 currentTarget
6101 } = event;
6102 const delayValue = typeof delay === "function" ? delay() : delay;
6103 if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
6104 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6105 return;
6106 }
6107 timeout.start(delayValue, () => {
6108 if (blockFocusRef.current) {
6109 return;
6110 }
6111 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6112 });
6113 },
6114 onBlur(event) {
6115 blockFocusRef.current = false;
6116 blockedReferenceRef.current = null;
6117 const relatedTarget = event.relatedTarget;
6118 const nativeEvent = event.nativeEvent;
6119 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
6120 timeout.start(0, () => {
6121 const domReference = store.select("domReferenceElement");
6122 const activeEl = activeElement(ownerDocument(domReference));
6123 if (!relatedTarget && activeEl === domReference) {
6124 return;
6125 }
6126 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
6127 return;
6128 }
6129 const nextFocusedElement = relatedTarget ?? activeEl;
6130 if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {
6131 return;
6132 }
6133 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
6134 });
6135 }
6136 }), [dataRef, store, timeout, delay]);
6137 return React26.useMemo(() => enabled ? {
6138 reference,
6139 trigger: reference
6140 } : {}, [enabled, reference]);
6141 }
6142
6143 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
6144 var React27 = __toESM(require_react(), 1);
6145
6146 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverInteractionSharedState.js
6147 var HoverInteraction = class _HoverInteraction {
6148 constructor() {
6149 this.pointerType = void 0;
6150 this.interactedInside = false;
6151 this.handler = void 0;
6152 this.blockMouseMove = true;
6153 this.performedPointerEventsMutation = false;
6154 this.pointerEventsScopeElement = null;
6155 this.pointerEventsReferenceElement = null;
6156 this.pointerEventsFloatingElement = null;
6157 this.restTimeoutPending = false;
6158 this.openChangeTimeout = new Timeout();
6159 this.restTimeout = new Timeout();
6160 this.handleCloseOptions = void 0;
6161 }
6162 static create() {
6163 return new _HoverInteraction();
6164 }
6165 dispose = () => {
6166 this.openChangeTimeout.clear();
6167 this.restTimeout.clear();
6168 };
6169 disposeEffect = () => {
6170 return this.dispose;
6171 };
6172 };
6173 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
6174 function clearSafePolygonPointerEventsMutation(instance) {
6175 if (!instance.performedPointerEventsMutation) {
6176 return;
6177 }
6178 const scopeElement = instance.pointerEventsScopeElement;
6179 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
6180 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
6181 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
6182 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
6183 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
6184 }
6185 instance.performedPointerEventsMutation = false;
6186 instance.pointerEventsScopeElement = null;
6187 instance.pointerEventsReferenceElement = null;
6188 instance.pointerEventsFloatingElement = null;
6189 }
6190 function applySafePolygonPointerEventsMutation(instance, options) {
6191 const {
6192 scopeElement,
6193 referenceElement,
6194 floatingElement
6195 } = options;
6196 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
6197 if (existingOwner && existingOwner !== instance) {
6198 clearSafePolygonPointerEventsMutation(existingOwner);
6199 }
6200 clearSafePolygonPointerEventsMutation(instance);
6201 instance.performedPointerEventsMutation = true;
6202 instance.pointerEventsScopeElement = scopeElement;
6203 instance.pointerEventsReferenceElement = referenceElement;
6204 instance.pointerEventsFloatingElement = floatingElement;
6205 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
6206 scopeElement.style.pointerEvents = "none";
6207 referenceElement.style.pointerEvents = "auto";
6208 floatingElement.style.pointerEvents = "auto";
6209 }
6210 function useHoverInteractionSharedState(store) {
6211 const instance = useRefWithInit(HoverInteraction.create).current;
6212 const data = store.context.dataRef.current;
6213 if (!data.hoverInteractionState) {
6214 data.hoverInteractionState = instance;
6215 }
6216 useOnMount(data.hoverInteractionState.disposeEffect);
6217 return data.hoverInteractionState;
6218 }
6219
6220 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
6221 function useHoverFloatingInteraction(context, parameters = {}) {
6222 const store = "rootStore" in context ? context.rootStore : context;
6223 const open = store.useState("open");
6224 const floatingElement = store.useState("floatingElement");
6225 const domReferenceElement = store.useState("domReferenceElement");
6226 const {
6227 dataRef
6228 } = store.context;
6229 const {
6230 enabled = true,
6231 closeDelay: closeDelayProp = 0,
6232 nodeId: nodeIdProp
6233 } = parameters;
6234 const instance = useHoverInteractionSharedState(store);
6235 const tree = useFloatingTree();
6236 const parentId = useFloatingParentNodeId();
6237 const isClickLikeOpenEvent2 = useStableCallback(() => {
6238 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6239 });
6240 const isHoverOpen = useStableCallback(() => {
6241 const type = dataRef.current.openEvent?.type;
6242 return type?.includes("mouse") && type !== "mousedown";
6243 });
6244 const isRelatedTargetInsideEnabledTrigger = useStableCallback((target) => {
6245 return isTargetInsideEnabledTrigger(target, store.context.triggerElements);
6246 });
6247 const closeWithDelay = React27.useCallback((event) => {
6248 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
6249 const close = () => {
6250 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6251 tree?.events.emit("floating.closed", event);
6252 };
6253 if (closeDelay) {
6254 instance.openChangeTimeout.start(closeDelay, close);
6255 } else {
6256 instance.openChangeTimeout.clear();
6257 close();
6258 }
6259 }, [closeDelayProp, store, instance, tree]);
6260 const clearPointerEvents = useStableCallback(() => {
6261 clearSafePolygonPointerEventsMutation(instance);
6262 });
6263 const handleInteractInside = useStableCallback((event) => {
6264 const target = getTarget(event);
6265 if (!isInteractiveElement(target)) {
6266 instance.interactedInside = false;
6267 return;
6268 }
6269 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
6270 });
6271 useIsoLayoutEffect(() => {
6272 if (!open) {
6273 instance.pointerType = void 0;
6274 instance.restTimeoutPending = false;
6275 instance.interactedInside = false;
6276 clearPointerEvents();
6277 }
6278 }, [open, instance, clearPointerEvents]);
6279 React27.useEffect(() => {
6280 return clearPointerEvents;
6281 }, [clearPointerEvents]);
6282 useIsoLayoutEffect(() => {
6283 if (!enabled) {
6284 return void 0;
6285 }
6286 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
6287 const ref = domReferenceElement;
6288 const floatingEl = floatingElement;
6289 const doc = ownerDocument(floatingElement);
6290 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
6291 if (parentFloating) {
6292 parentFloating.style.pointerEvents = "";
6293 }
6294 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? instance.pointerEventsScopeElement ?? parentFloating ?? ref.closest("[data-rootownerid]") ?? doc.body;
6295 applySafePolygonPointerEventsMutation(instance, {
6296 scopeElement,
6297 referenceElement: ref,
6298 floatingElement: floatingEl
6299 });
6300 return () => {
6301 clearPointerEvents();
6302 };
6303 }
6304 return void 0;
6305 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
6306 const childClosedTimeout = useTimeout();
6307 React27.useEffect(() => {
6308 if (!enabled) {
6309 return void 0;
6310 }
6311 function onFloatingMouseEnter() {
6312 instance.openChangeTimeout.clear();
6313 childClosedTimeout.clear();
6314 tree?.events.off("floating.closed", onNodeClosed);
6315 clearPointerEvents();
6316 }
6317 function onFloatingMouseLeave(event) {
6318 if (tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0) {
6319 tree.events.on("floating.closed", onNodeClosed);
6320 return;
6321 }
6322 if (isRelatedTargetInsideEnabledTrigger(event.relatedTarget)) {
6323 return;
6324 }
6325 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
6326 const relatedTarget = event.relatedTarget;
6327 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
6328 if (isMovingIntoDescendantFloating) {
6329 return;
6330 }
6331 if (instance.handler) {
6332 instance.handler(event);
6333 return;
6334 }
6335 clearPointerEvents();
6336 if (!isClickLikeOpenEvent2()) {
6337 closeWithDelay(event);
6338 }
6339 }
6340 function onNodeClosed(event) {
6341 if (!tree || !parentId || getNodeChildren(tree.nodesRef.current, parentId).length > 0) {
6342 return;
6343 }
6344 childClosedTimeout.start(0, () => {
6345 tree.events.off("floating.closed", onNodeClosed);
6346 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6347 tree.events.emit("floating.closed", event);
6348 });
6349 }
6350 const floating = floatingElement;
6351 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
6352 tree?.events.off("floating.closed", onNodeClosed);
6353 });
6354 }, [enabled, floatingElement, store, dataRef, nodeIdProp, isClickLikeOpenEvent2, isRelatedTargetInsideEnabledTrigger, closeWithDelay, clearPointerEvents, handleInteractInside, instance, tree, parentId, childClosedTimeout]);
6355 }
6356
6357 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverReferenceInteraction.js
6358 var React28 = __toESM(require_react(), 1);
6359 var ReactDOM4 = __toESM(require_react_dom(), 1);
6360 var EMPTY_REF = {
6361 current: null
6362 };
6363 function useHoverReferenceInteraction(context, props = {}) {
6364 const store = "rootStore" in context ? context.rootStore : context;
6365 const {
6366 dataRef,
6367 events
6368 } = store.context;
6369 const {
6370 enabled = true,
6371 delay = 0,
6372 handleClose = null,
6373 mouseOnly = false,
6374 restMs = 0,
6375 move = true,
6376 triggerElementRef = EMPTY_REF,
6377 externalTree,
6378 isActiveTrigger = true,
6379 getHandleCloseContext,
6380 isClosing
6381 } = props;
6382 const tree = useFloatingTree(externalTree);
6383 const instance = useHoverInteractionSharedState(store);
6384 const isHoverCloseActiveRef = React28.useRef(false);
6385 const handleCloseRef = useValueAsRef(handleClose);
6386 const delayRef = useValueAsRef(delay);
6387 const restMsRef = useValueAsRef(restMs);
6388 const enabledRef = useValueAsRef(enabled);
6389 const isClosingRef = useValueAsRef(isClosing);
6390 if (isActiveTrigger) {
6391 instance.handleCloseOptions = handleCloseRef.current?.__options;
6392 }
6393 const isClickLikeOpenEvent2 = useStableCallback(() => {
6394 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6395 });
6396 const isRelatedTargetInsideEnabledTrigger = useStableCallback((target) => {
6397 return isTargetInsideEnabledTrigger(target, store.context.triggerElements);
6398 });
6399 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
6400 const allTriggers = store.context.triggerElements;
6401 if (allTriggers.hasElement(currentTarget)) {
6402 return !currentDomReference || !contains(currentDomReference, currentTarget);
6403 }
6404 if (!isElement(target)) {
6405 return false;
6406 }
6407 const targetElement = target;
6408 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
6409 });
6410 const closeWithDelay = useStableCallback((event, runElseBranch = true) => {
6411 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
6412 if (closeDelay) {
6413 instance.openChangeTimeout.start(closeDelay, () => {
6414 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6415 tree?.events.emit("floating.closed", event);
6416 });
6417 } else if (runElseBranch) {
6418 instance.openChangeTimeout.clear();
6419 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6420 tree?.events.emit("floating.closed", event);
6421 }
6422 });
6423 const cleanupMouseMoveHandler = useStableCallback(() => {
6424 if (!instance.handler) {
6425 return;
6426 }
6427 const doc = ownerDocument(store.select("domReferenceElement"));
6428 doc.removeEventListener("mousemove", instance.handler);
6429 instance.handler = void 0;
6430 });
6431 const clearPointerEvents = useStableCallback(() => {
6432 clearSafePolygonPointerEventsMutation(instance);
6433 });
6434 React28.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
6435 React28.useEffect(() => {
6436 if (!enabled) {
6437 return void 0;
6438 }
6439 function onOpenChangeLocal(details) {
6440 if (!details.open) {
6441 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
6442 cleanupMouseMoveHandler();
6443 instance.openChangeTimeout.clear();
6444 instance.restTimeout.clear();
6445 instance.blockMouseMove = true;
6446 instance.restTimeoutPending = false;
6447 } else {
6448 isHoverCloseActiveRef.current = false;
6449 }
6450 }
6451 events.on("openchange", onOpenChangeLocal);
6452 return () => {
6453 events.off("openchange", onOpenChangeLocal);
6454 };
6455 }, [enabled, events, instance, cleanupMouseMoveHandler]);
6456 React28.useEffect(() => {
6457 if (!enabled) {
6458 return void 0;
6459 }
6460 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null);
6461 if (!isElement(trigger)) {
6462 return void 0;
6463 }
6464 function onMouseEnter(event) {
6465 instance.openChangeTimeout.clear();
6466 instance.blockMouseMove = false;
6467 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6468 return;
6469 }
6470 const restMsValue = getRestMs(restMsRef.current);
6471 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
6472 const eventTarget = getTarget(event);
6473 const currentTarget = event.currentTarget ?? null;
6474 const currentDomReference = store.select("domReferenceElement");
6475 let triggerNode = currentTarget;
6476 if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) {
6477 for (const triggerElement of store.context.triggerElements.elements()) {
6478 if (contains(triggerElement, eventTarget)) {
6479 triggerNode = triggerElement;
6480 break;
6481 }
6482 }
6483 }
6484 if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
6485 triggerNode = currentDomReference;
6486 }
6487 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
6488 const isOpen = store.select("open");
6489 const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending";
6490 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
6491 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
6492 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
6493 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
6494 const shouldOpen = !isOpen || isOverInactive;
6495 if (shouldOpenImmediately) {
6496 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6497 return;
6498 }
6499 if (isRestOnlyDelay) {
6500 return;
6501 }
6502 if (openDelay) {
6503 instance.openChangeTimeout.start(openDelay, () => {
6504 if (shouldOpen) {
6505 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6506 }
6507 });
6508 } else if (shouldOpen) {
6509 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6510 }
6511 }
6512 function onMouseLeave(event) {
6513 if (isClickLikeOpenEvent2()) {
6514 clearPointerEvents();
6515 return;
6516 }
6517 cleanupMouseMoveHandler();
6518 const domReferenceElement = store.select("domReferenceElement");
6519 const doc = ownerDocument(domReferenceElement);
6520 instance.restTimeout.clear();
6521 instance.restTimeoutPending = false;
6522 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
6523 const ignoreRelatedTargetTrigger = isRelatedTargetInsideEnabledTrigger(event.relatedTarget);
6524 if (ignoreRelatedTargetTrigger) {
6525 return;
6526 }
6527 if (handleCloseRef.current && handleCloseContextBase) {
6528 if (!store.select("open")) {
6529 instance.openChangeTimeout.clear();
6530 }
6531 const currentTrigger = triggerElementRef.current;
6532 instance.handler = handleCloseRef.current({
6533 ...handleCloseContextBase,
6534 tree,
6535 x: event.clientX,
6536 y: event.clientY,
6537 onClose() {
6538 clearPointerEvents();
6539 cleanupMouseMoveHandler();
6540 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) {
6541 closeWithDelay(event, true);
6542 }
6543 }
6544 });
6545 doc.addEventListener("mousemove", instance.handler);
6546 instance.handler(event);
6547 return;
6548 }
6549 const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true;
6550 if (shouldClose) {
6551 closeWithDelay(event);
6552 }
6553 }
6554 if (move) {
6555 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
6556 once: true
6557 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
6558 }
6559 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
6560 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, closeWithDelay, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, isRelatedTargetInsideEnabledTrigger, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef]);
6561 return React28.useMemo(() => {
6562 if (!enabled) {
6563 return void 0;
6564 }
6565 function setPointerRef(event) {
6566 instance.pointerType = event.pointerType;
6567 }
6568 return {
6569 onPointerDown: setPointerRef,
6570 onPointerEnter: setPointerRef,
6571 onMouseMove(event) {
6572 const {
6573 nativeEvent
6574 } = event;
6575 const trigger = event.currentTarget;
6576 const currentDomReference = store.select("domReferenceElement");
6577 const currentOpen = store.select("open");
6578 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
6579 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6580 return;
6581 }
6582 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
6583 const floatingElement = store.select("floatingElement");
6584 if (floatingElement) {
6585 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
6586 applySafePolygonPointerEventsMutation(instance, {
6587 scopeElement,
6588 referenceElement: trigger,
6589 floatingElement
6590 });
6591 }
6592 }
6593 const restMsValue = getRestMs(restMsRef.current);
6594 if (currentOpen && !isOverInactive || restMsValue === 0) {
6595 return;
6596 }
6597 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
6598 return;
6599 }
6600 instance.restTimeout.clear();
6601 function handleMouseMove() {
6602 instance.restTimeoutPending = false;
6603 if (isClickLikeOpenEvent2()) {
6604 return;
6605 }
6606 const latestOpen = store.select("open");
6607 if (!instance.blockMouseMove && (!latestOpen || isOverInactive)) {
6608 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
6609 }
6610 }
6611 if (instance.pointerType === "touch") {
6612 ReactDOM4.flushSync(() => {
6613 handleMouseMove();
6614 });
6615 } else if (isOverInactive && currentOpen) {
6616 handleMouseMove();
6617 } else {
6618 instance.restTimeoutPending = true;
6619 instance.restTimeout.start(restMsValue, handleMouseMove);
6620 }
6621 }
6622 };
6623 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef]);
6624 }
6625
6626 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useInteractions.js
6627 var React29 = __toESM(require_react(), 1);
6628 function useInteractions(propsList = []) {
6629 const referenceDeps = propsList.map((key) => key?.reference);
6630 const floatingDeps = propsList.map((key) => key?.floating);
6631 const itemDeps = propsList.map((key) => key?.item);
6632 const triggerDeps = propsList.map((key) => key?.trigger);
6633 const getReferenceProps = React29.useCallback(
6634 (userProps) => mergeProps2(userProps, propsList, "reference"),
6635 // eslint-disable-next-line react-hooks/exhaustive-deps
6636 referenceDeps
6637 );
6638 const getFloatingProps = React29.useCallback(
6639 (userProps) => mergeProps2(userProps, propsList, "floating"),
6640 // eslint-disable-next-line react-hooks/exhaustive-deps
6641 floatingDeps
6642 );
6643 const getItemProps = React29.useCallback(
6644 (userProps) => mergeProps2(userProps, propsList, "item"),
6645 // eslint-disable-next-line react-hooks/exhaustive-deps
6646 itemDeps
6647 );
6648 const getTriggerProps = React29.useCallback(
6649 (userProps) => mergeProps2(userProps, propsList, "trigger"),
6650 // eslint-disable-next-line react-hooks/exhaustive-deps
6651 triggerDeps
6652 );
6653 return React29.useMemo(() => ({
6654 getReferenceProps,
6655 getFloatingProps,
6656 getItemProps,
6657 getTriggerProps
6658 }), [getReferenceProps, getFloatingProps, getItemProps, getTriggerProps]);
6659 }
6660 function mergeProps2(userProps, propsList, elementKey) {
6661 const eventHandlers = /* @__PURE__ */ new Map();
6662 const isItem2 = elementKey === "item";
6663 const outputProps = {};
6664 if (elementKey === "floating") {
6665 outputProps.tabIndex = -1;
6666 outputProps[FOCUSABLE_ATTRIBUTE] = "";
6667 }
6668 for (const key in userProps) {
6669 if (isItem2 && userProps) {
6670 if (key === ACTIVE_KEY || key === SELECTED_KEY) {
6671 continue;
6672 }
6673 }
6674 outputProps[key] = userProps[key];
6675 }
6676 for (let i2 = 0; i2 < propsList.length; i2 += 1) {
6677 let props;
6678 const propsOrGetProps = propsList[i2]?.[elementKey];
6679 if (typeof propsOrGetProps === "function") {
6680 props = userProps ? propsOrGetProps(userProps) : null;
6681 } else {
6682 props = propsOrGetProps;
6683 }
6684 if (!props) {
6685 continue;
6686 }
6687 mutablyMergeProps(outputProps, props, isItem2, eventHandlers);
6688 }
6689 mutablyMergeProps(outputProps, userProps, isItem2, eventHandlers);
6690 return outputProps;
6691 }
6692 function mutablyMergeProps(outputProps, props, isItem2, eventHandlers) {
6693 for (const key in props) {
6694 const value = props[key];
6695 if (isItem2 && (key === ACTIVE_KEY || key === SELECTED_KEY)) {
6696 continue;
6697 }
6698 if (!key.startsWith("on")) {
6699 outputProps[key] = value;
6700 } else {
6701 if (!eventHandlers.has(key)) {
6702 eventHandlers.set(key, []);
6703 }
6704 if (typeof value === "function") {
6705 eventHandlers.get(key)?.push(value);
6706 outputProps[key] = (...args) => {
6707 return eventHandlers.get(key)?.map((fn) => fn(...args)).find((val) => val !== void 0);
6708 };
6709 }
6710 }
6711 }
6712 }
6713
6714 // node_modules/@base-ui/react/esm/floating-ui-react/safePolygon.js
6715 var CURSOR_SPEED_THRESHOLD = 0.1;
6716 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
6717 var POLYGON_BUFFER = 0.5;
6718 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
6719 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
6720 }
6721 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
6722 let isInsideValue = false;
6723 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
6724 isInsideValue = !isInsideValue;
6725 }
6726 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
6727 isInsideValue = !isInsideValue;
6728 }
6729 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
6730 isInsideValue = !isInsideValue;
6731 }
6732 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
6733 isInsideValue = !isInsideValue;
6734 }
6735 return isInsideValue;
6736 }
6737 function isInsideRect(pointX, pointY, rect) {
6738 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
6739 }
6740 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
6741 const minX = Math.min(x1, x2);
6742 const maxX = Math.max(x1, x2);
6743 const minY = Math.min(y1, y2);
6744 const maxY = Math.max(y1, y2);
6745 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
6746 }
6747 function safePolygon(options = {}) {
6748 const {
6749 blockPointerEvents = false
6750 } = options;
6751 const timeout = new Timeout();
6752 const fn = ({
6753 x: x2,
6754 y: y2,
6755 placement,
6756 elements,
6757 onClose,
6758 nodeId,
6759 tree
6760 }) => {
6761 const side = placement?.split("-")[0];
6762 let hasLanded = false;
6763 let lastX = null;
6764 let lastY = null;
6765 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
6766 function isCursorMovingSlowly(nextX, nextY) {
6767 const currentTime = performance.now();
6768 const elapsedTime = currentTime - lastCursorTime;
6769 if (lastX === null || lastY === null || elapsedTime === 0) {
6770 lastX = nextX;
6771 lastY = nextY;
6772 lastCursorTime = currentTime;
6773 return false;
6774 }
6775 const deltaX = nextX - lastX;
6776 const deltaY = nextY - lastY;
6777 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
6778 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
6779 lastX = nextX;
6780 lastY = nextY;
6781 lastCursorTime = currentTime;
6782 return distanceSquared < thresholdSquared;
6783 }
6784 function close() {
6785 timeout.clear();
6786 onClose();
6787 }
6788 return function onMouseMove(event) {
6789 timeout.clear();
6790 const domReference = elements.domReference;
6791 const floating = elements.floating;
6792 if (!domReference || !floating || side == null || x2 == null || y2 == null) {
6793 return void 0;
6794 }
6795 const {
6796 clientX,
6797 clientY
6798 } = event;
6799 const target = getTarget(event);
6800 const isLeave = event.type === "mouseleave";
6801 const isOverFloatingEl = contains(floating, target);
6802 const isOverReferenceEl = contains(domReference, target);
6803 if (isOverFloatingEl) {
6804 hasLanded = true;
6805 if (!isLeave) {
6806 return void 0;
6807 }
6808 }
6809 if (isOverReferenceEl) {
6810 hasLanded = false;
6811 if (!isLeave) {
6812 hasLanded = true;
6813 return void 0;
6814 }
6815 }
6816 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
6817 return void 0;
6818 }
6819 function hasOpenChildNode() {
6820 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
6821 }
6822 function closeIfNoOpenChild() {
6823 if (!hasOpenChildNode()) {
6824 close();
6825 }
6826 }
6827 if (hasOpenChildNode()) {
6828 return void 0;
6829 }
6830 const refRect = domReference.getBoundingClientRect();
6831 const rect = floating.getBoundingClientRect();
6832 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2;
6833 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2;
6834 const isFloatingWider = rect.width > refRect.width;
6835 const isFloatingTaller = rect.height > refRect.height;
6836 const left = (isFloatingWider ? refRect : rect).left;
6837 const right = (isFloatingWider ? refRect : rect).right;
6838 const top = (isFloatingTaller ? refRect : rect).top;
6839 const bottom = (isFloatingTaller ? refRect : rect).bottom;
6840 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) {
6841 closeIfNoOpenChild();
6842 return void 0;
6843 }
6844 let isInsideTroughRect = false;
6845 switch (side) {
6846 case "top":
6847 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
6848 break;
6849 case "bottom":
6850 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
6851 break;
6852 case "left":
6853 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
6854 break;
6855 case "right":
6856 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
6857 break;
6858 default:
6859 }
6860 if (isInsideTroughRect) {
6861 return void 0;
6862 }
6863 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
6864 closeIfNoOpenChild();
6865 return void 0;
6866 }
6867 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
6868 closeIfNoOpenChild();
6869 return void 0;
6870 }
6871 let isInsidePolygon = false;
6872 switch (side) {
6873 case "top": {
6874 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
6875 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
6876 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
6877 const cursorPointY = y2 + POLYGON_BUFFER + 1;
6878 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
6879 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
6880 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
6881 break;
6882 }
6883 case "bottom": {
6884 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
6885 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
6886 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
6887 const cursorPointY = y2 - POLYGON_BUFFER;
6888 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
6889 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
6890 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
6891 break;
6892 }
6893 case "left": {
6894 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
6895 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
6896 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
6897 const cursorPointX = x2 + POLYGON_BUFFER + 1;
6898 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
6899 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
6900 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
6901 break;
6902 }
6903 case "right": {
6904 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
6905 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
6906 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
6907 const cursorPointX = x2 - POLYGON_BUFFER;
6908 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
6909 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
6910 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
6911 break;
6912 }
6913 default:
6914 }
6915 if (!isInsidePolygon) {
6916 closeIfNoOpenChild();
6917 } else if (!hasLanded) {
6918 timeout.start(40, closeIfNoOpenChild);
6919 }
6920 return void 0;
6921 };
6922 };
6923 fn.__options = {
6924 ...options,
6925 blockPointerEvents
6926 };
6927 return fn;
6928 }
6929
6930 // node_modules/@base-ui/react/esm/utils/popupStateMapping.js
6931 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
6932 CommonPopupDataAttributes2["open"] = "data-open";
6933 CommonPopupDataAttributes2["closed"] = "data-closed";
6934 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
6935 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
6936 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
6937 CommonPopupDataAttributes2["side"] = "data-side";
6938 CommonPopupDataAttributes2["align"] = "data-align";
6939 return CommonPopupDataAttributes2;
6940 })({});
6941 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
6942 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
6943 CommonTriggerDataAttributes2["pressed"] = "data-pressed";
6944 return CommonTriggerDataAttributes2;
6945 })({});
6946 var TRIGGER_HOOK = {
6947 [CommonTriggerDataAttributes.popupOpen]: ""
6948 };
6949 var PRESSABLE_TRIGGER_HOOK = {
6950 [CommonTriggerDataAttributes.popupOpen]: "",
6951 [CommonTriggerDataAttributes.pressed]: ""
6952 };
6953 var POPUP_OPEN_HOOK = {
6954 [CommonPopupDataAttributes.open]: ""
6955 };
6956 var POPUP_CLOSED_HOOK = {
6957 [CommonPopupDataAttributes.closed]: ""
6958 };
6959 var ANCHOR_HIDDEN_HOOK = {
6960 [CommonPopupDataAttributes.anchorHidden]: ""
6961 };
6962 var triggerOpenStateMapping = {
6963 open(value) {
6964 if (value) {
6965 return TRIGGER_HOOK;
6966 }
6967 return null;
6968 }
6969 };
6970 var popupStateMapping = {
6971 open(value) {
6972 if (value) {
6973 return POPUP_OPEN_HOOK;
6974 }
6975 return POPUP_CLOSED_HOOK;
6976 },
6977 anchorHidden(value) {
6978 if (value) {
6979 return ANCHOR_HIDDEN_HOOK;
6980 }
6981 return null;
6982 }
6983 };
6984
6985 // node_modules/@base-ui/utils/esm/inertValue.js
6986 function inertValue(value) {
6987 if (isReactVersionAtLeast(19)) {
6988 return value;
6989 }
6990 return value ? "true" : void 0;
6991 }
6992
6993 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
6994 var React30 = __toESM(require_react(), 1);
6995
6996 // node_modules/@base-ui/react/esm/floating-ui-react/middleware/arrow.js
6997 var baseArrow = (options) => ({
6998 name: "arrow",
6999 options,
7000 async fn(state) {
7001 const {
7002 x: x2,
7003 y: y2,
7004 placement,
7005 rects,
7006 platform: platform3,
7007 elements,
7008 middlewareData
7009 } = state;
7010 const {
7011 element,
7012 padding = 0,
7013 offsetParent = "real"
7014 } = evaluate(options, state) || {};
7015 if (element == null) {
7016 return {};
7017 }
7018 const paddingObject = getPaddingObject(padding);
7019 const coords = {
7020 x: x2,
7021 y: y2
7022 };
7023 const axis = getAlignmentAxis(placement);
7024 const length = getAxisLength(axis);
7025 const arrowDimensions = await platform3.getDimensions(element);
7026 const isYAxis = axis === "y";
7027 const minProp = isYAxis ? "top" : "left";
7028 const maxProp = isYAxis ? "bottom" : "right";
7029 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
7030 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
7031 const startDiff = coords[axis] - rects.reference[axis];
7032 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
7033 let clientSize = elements.floating[clientProp] || rects.floating[length];
7034 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
7035 clientSize = elements.floating[clientProp] || rects.floating[length];
7036 }
7037 const centerToReference = endDiff / 2 - startDiff / 2;
7038 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
7039 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
7040 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
7041 const min2 = minPadding;
7042 const max2 = clientSize - arrowDimensions[length] - maxPadding;
7043 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
7044 const offset4 = clamp(min2, center, max2);
7045 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
7046 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
7047 return {
7048 [axis]: coords[axis] + alignmentOffset,
7049 data: {
7050 [axis]: offset4,
7051 centerOffset: center - offset4 - alignmentOffset,
7052 ...shouldAddOffset && {
7053 alignmentOffset
7054 }
7055 },
7056 reset: shouldAddOffset
7057 };
7058 }
7059 });
7060 var arrow4 = (options, deps) => ({
7061 ...baseArrow(options),
7062 options: [options, deps]
7063 });
7064
7065 // node_modules/@base-ui/react/esm/utils/hideMiddleware.js
7066 var hide4 = {
7067 name: "hide",
7068 async fn(state) {
7069 const {
7070 width,
7071 height,
7072 x: x2,
7073 y: y2
7074 } = state.rects.reference;
7075 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0;
7076 const nativeHideResult = await hide3().fn(state);
7077 return {
7078 data: {
7079 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
7080 }
7081 };
7082 }
7083 };
7084
7085 // node_modules/@base-ui/react/esm/utils/adaptiveOriginMiddleware.js
7086 var DEFAULT_SIDES = {
7087 sideX: "left",
7088 sideY: "top"
7089 };
7090 var adaptiveOrigin = {
7091 name: "adaptiveOrigin",
7092 async fn(state) {
7093 const {
7094 x: rawX,
7095 y: rawY,
7096 rects: {
7097 floating: floatRect
7098 },
7099 elements: {
7100 floating
7101 },
7102 platform: platform3,
7103 strategy,
7104 placement
7105 } = state;
7106 const win = getWindow(floating);
7107 const styles = win.getComputedStyle(floating);
7108 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
7109 if (!hasTransition) {
7110 return {
7111 x: rawX,
7112 y: rawY,
7113 data: DEFAULT_SIDES
7114 };
7115 }
7116 const offsetParent = await platform3.getOffsetParent?.(floating);
7117 let offsetDimensions = {
7118 width: 0,
7119 height: 0
7120 };
7121 if (strategy === "fixed" && win?.visualViewport) {
7122 offsetDimensions = {
7123 width: win.visualViewport.width,
7124 height: win.visualViewport.height
7125 };
7126 } else if (offsetParent === win) {
7127 const doc = ownerDocument(floating);
7128 offsetDimensions = {
7129 width: doc.documentElement.clientWidth,
7130 height: doc.documentElement.clientHeight
7131 };
7132 } else if (await platform3.isElement?.(offsetParent)) {
7133 offsetDimensions = await platform3.getDimensions(offsetParent);
7134 }
7135 const currentSide = getSide(placement);
7136 let x2 = rawX;
7137 let y2 = rawY;
7138 if (currentSide === "left") {
7139 x2 = offsetDimensions.width - (rawX + floatRect.width);
7140 }
7141 if (currentSide === "top") {
7142 y2 = offsetDimensions.height - (rawY + floatRect.height);
7143 }
7144 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
7145 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
7146 return {
7147 x: x2,
7148 y: y2,
7149 data: {
7150 sideX,
7151 sideY
7152 }
7153 };
7154 }
7155 };
7156
7157 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
7158 function getLogicalSide(sideParam, renderedSide, isRtl) {
7159 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
7160 const logicalRight = isRtl ? "inline-start" : "inline-end";
7161 const logicalLeft = isRtl ? "inline-end" : "inline-start";
7162 return {
7163 top: "top",
7164 right: isLogicalSideParam ? logicalRight : "right",
7165 bottom: "bottom",
7166 left: isLogicalSideParam ? logicalLeft : "left"
7167 }[renderedSide];
7168 }
7169 function getOffsetData(state, sideParam, isRtl) {
7170 const {
7171 rects,
7172 placement
7173 } = state;
7174 const data = {
7175 side: getLogicalSide(sideParam, getSide(placement), isRtl),
7176 align: getAlignment(placement) || "center",
7177 anchor: {
7178 width: rects.reference.width,
7179 height: rects.reference.height
7180 },
7181 positioner: {
7182 width: rects.floating.width,
7183 height: rects.floating.height
7184 }
7185 };
7186 return data;
7187 }
7188 function useAnchorPositioning(params) {
7189 const {
7190 // Public parameters
7191 anchor,
7192 positionMethod = "absolute",
7193 side: sideParam = "bottom",
7194 sideOffset = 0,
7195 align = "center",
7196 alignOffset = 0,
7197 collisionBoundary,
7198 collisionPadding: collisionPaddingParam = 5,
7199 sticky = false,
7200 arrowPadding = 5,
7201 disableAnchorTracking = false,
7202 // Private parameters
7203 keepMounted = false,
7204 floatingRootContext,
7205 mounted,
7206 collisionAvoidance,
7207 shiftCrossAxis = false,
7208 nodeId,
7209 adaptiveOrigin: adaptiveOrigin2,
7210 lazyFlip = false,
7211 externalTree
7212 } = params;
7213 const [mountSide, setMountSide] = React30.useState(null);
7214 if (!mounted && mountSide !== null) {
7215 setMountSide(null);
7216 }
7217 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
7218 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
7219 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
7220 const anchorFn = typeof anchor === "function" ? anchor : void 0;
7221 const anchorFnCallback = useStableCallback(anchorFn);
7222 const anchorDep = anchorFn ? anchorFnCallback : anchor;
7223 const anchorValueRef = useValueAsRef(anchor);
7224 const mountedRef = useValueAsRef(mounted);
7225 const direction = useDirection();
7226 const isRtl = direction === "rtl";
7227 const side = mountSide || {
7228 top: "top",
7229 right: "right",
7230 bottom: "bottom",
7231 left: "left",
7232 "inline-end": isRtl ? "left" : "right",
7233 "inline-start": isRtl ? "right" : "left"
7234 }[sideParam];
7235 const placement = align === "center" ? side : `${side}-${align}`;
7236 let collisionPadding = collisionPaddingParam;
7237 const bias = 1;
7238 const biasTop = sideParam === "bottom" ? bias : 0;
7239 const biasBottom = sideParam === "top" ? bias : 0;
7240 const biasLeft = sideParam === "right" ? bias : 0;
7241 const biasRight = sideParam === "left" ? bias : 0;
7242 if (typeof collisionPadding === "number") {
7243 collisionPadding = {
7244 top: collisionPadding + biasTop,
7245 right: collisionPadding + biasRight,
7246 bottom: collisionPadding + biasBottom,
7247 left: collisionPadding + biasLeft
7248 };
7249 } else if (collisionPadding) {
7250 collisionPadding = {
7251 top: (collisionPadding.top || 0) + biasTop,
7252 right: (collisionPadding.right || 0) + biasRight,
7253 bottom: (collisionPadding.bottom || 0) + biasBottom,
7254 left: (collisionPadding.left || 0) + biasLeft
7255 };
7256 }
7257 const commonCollisionProps = {
7258 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
7259 padding: collisionPadding
7260 };
7261 const arrowRef = React30.useRef(null);
7262 const sideOffsetRef = useValueAsRef(sideOffset);
7263 const alignOffsetRef = useValueAsRef(alignOffset);
7264 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
7265 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
7266 const middleware = [offset3((state) => {
7267 const data = getOffsetData(state, sideParam, isRtl);
7268 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
7269 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
7270 return {
7271 mainAxis: sideAxis,
7272 crossAxis: alignAxis,
7273 alignmentAxis: alignAxis
7274 };
7275 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam])];
7276 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
7277 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
7278 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
7279 ...commonCollisionProps,
7280 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
7281 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
7282 padding: {
7283 top: collisionPadding.top + bias,
7284 right: collisionPadding.right + bias,
7285 bottom: collisionPadding.bottom + bias,
7286 left: collisionPadding.left + bias
7287 },
7288 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
7289 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
7290 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
7291 });
7292 const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
7293 const html = ownerDocument(data.elements.floating).documentElement;
7294 return {
7295 ...commonCollisionProps,
7296 // Use the Layout Viewport to avoid shifting around when pinch-zooming
7297 // for context menus.
7298 rootBoundary: shiftCrossAxis ? {
7299 x: 0,
7300 y: 0,
7301 width: html.clientWidth,
7302 height: html.clientHeight
7303 } : void 0,
7304 mainAxis: collisionAvoidanceAlign !== "none",
7305 crossAxis: crossAxisShiftEnabled,
7306 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
7307 if (!arrowRef.current) {
7308 return {};
7309 }
7310 const {
7311 width,
7312 height
7313 } = arrowRef.current.getBoundingClientRect();
7314 const sideAxis = getSideAxis(getSide(limitData.placement));
7315 const arrowSize = sideAxis === "y" ? width : height;
7316 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
7317 return {
7318 offset: arrowSize / 2 + offsetAmount / 2
7319 };
7320 })
7321 };
7322 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
7323 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
7324 middleware.push(shiftMiddleware, flipMiddleware);
7325 } else {
7326 middleware.push(flipMiddleware, shiftMiddleware);
7327 }
7328 middleware.push(size3({
7329 ...commonCollisionProps,
7330 apply({
7331 elements: {
7332 floating
7333 },
7334 availableWidth,
7335 availableHeight,
7336 rects
7337 }) {
7338 if (!mountedRef.current) {
7339 return;
7340 }
7341 const floatingStyle = floating.style;
7342 floatingStyle.setProperty("--available-width", `${availableWidth}px`);
7343 floatingStyle.setProperty("--available-height", `${availableHeight}px`);
7344 const dpr = getWindow(floating).devicePixelRatio || 1;
7345 const {
7346 x: x3,
7347 y: y3,
7348 width,
7349 height
7350 } = rects.reference;
7351 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr;
7352 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr;
7353 floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
7354 floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
7355 }
7356 }), arrow4(() => ({
7357 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
7358 // we'll create a fake element.
7359 element: arrowRef.current || ownerDocument(arrowRef.current).createElement("div"),
7360 padding: arrowPadding,
7361 offsetParent: "floating"
7362 }), [arrowPadding]), {
7363 name: "transformOrigin",
7364 fn(state) {
7365 const {
7366 elements: elements2,
7367 middlewareData: middlewareData2,
7368 placement: renderedPlacement2,
7369 rects,
7370 y: y3
7371 } = state;
7372 const currentRenderedSide = getSide(renderedPlacement2);
7373 const currentRenderedAxis = getSideAxis(currentRenderedSide);
7374 const arrowEl = arrowRef.current;
7375 const arrowX = middlewareData2.arrow?.x || 0;
7376 const arrowY = middlewareData2.arrow?.y || 0;
7377 const arrowWidth = arrowEl?.clientWidth || 0;
7378 const arrowHeight = arrowEl?.clientHeight || 0;
7379 const transformX = arrowX + arrowWidth / 2;
7380 const transformY = arrowY + arrowHeight / 2;
7381 const shiftY = Math.abs(middlewareData2.shift?.y || 0);
7382 const halfAnchorHeight = rects.reference.height / 2;
7383 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
7384 const isOverlappingAnchor = shiftY > sideOffsetValue;
7385 const adjacentTransformOrigin = {
7386 top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
7387 bottom: `${transformX}px ${-sideOffsetValue}px`,
7388 left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
7389 right: `${-sideOffsetValue}px ${transformY}px`
7390 }[currentRenderedSide];
7391 const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y3}px`;
7392 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
7393 return {};
7394 }
7395 }, hide4, adaptiveOrigin2);
7396 useIsoLayoutEffect(() => {
7397 if (!mounted && floatingRootContext) {
7398 floatingRootContext.update({
7399 referenceElement: null,
7400 floatingElement: null,
7401 domReferenceElement: null,
7402 positionReference: null
7403 });
7404 }
7405 }, [mounted, floatingRootContext]);
7406 const autoUpdateOptions = React30.useMemo(() => ({
7407 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
7408 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
7409 }), [disableAnchorTracking]);
7410 const {
7411 refs,
7412 elements,
7413 x: x2,
7414 y: y2,
7415 middlewareData,
7416 update: update2,
7417 placement: renderedPlacement,
7418 context,
7419 isPositioned,
7420 floatingStyles: originalFloatingStyles
7421 } = useFloating2({
7422 rootContext: floatingRootContext,
7423 open: keepMounted ? mounted : void 0,
7424 placement,
7425 middleware,
7426 strategy: positionMethod,
7427 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
7428 nodeId,
7429 externalTree
7430 });
7431 const {
7432 sideX,
7433 sideY
7434 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
7435 const resolvedPosition = isPositioned ? positionMethod : "fixed";
7436 const floatingStyles = React30.useMemo(() => {
7437 const base = adaptiveOrigin2 ? {
7438 position: resolvedPosition,
7439 [sideX]: x2,
7440 [sideY]: y2
7441 } : {
7442 position: resolvedPosition,
7443 ...originalFloatingStyles
7444 };
7445 if (!isPositioned) {
7446 base.opacity = 0;
7447 }
7448 return base;
7449 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]);
7450 const registeredPositionReferenceRef = React30.useRef(null);
7451 useIsoLayoutEffect(() => {
7452 if (!mounted) {
7453 return;
7454 }
7455 const anchorValue = anchorValueRef.current;
7456 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
7457 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
7458 const finalAnchor = unwrappedElement || null;
7459 if (finalAnchor !== registeredPositionReferenceRef.current) {
7460 refs.setPositionReference(finalAnchor);
7461 registeredPositionReferenceRef.current = finalAnchor;
7462 }
7463 }, [mounted, refs, anchorDep, anchorValueRef]);
7464 React30.useEffect(() => {
7465 if (!mounted) {
7466 return;
7467 }
7468 const anchorValue = anchorValueRef.current;
7469 if (typeof anchorValue === "function") {
7470 return;
7471 }
7472 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
7473 refs.setPositionReference(anchorValue.current);
7474 registeredPositionReferenceRef.current = anchorValue.current;
7475 }
7476 }, [mounted, refs, anchorDep, anchorValueRef]);
7477 React30.useEffect(() => {
7478 if (keepMounted && mounted && elements.domReference && elements.floating) {
7479 return autoUpdate(elements.domReference, elements.floating, update2, autoUpdateOptions);
7480 }
7481 return void 0;
7482 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
7483 const renderedSide = getSide(renderedPlacement);
7484 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
7485 const renderedAlign = getAlignment(renderedPlacement) || "center";
7486 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
7487 useIsoLayoutEffect(() => {
7488 if (lazyFlip && mounted && isPositioned) {
7489 setMountSide(renderedSide);
7490 }
7491 }, [lazyFlip, mounted, isPositioned, renderedSide]);
7492 const arrowStyles = React30.useMemo(() => ({
7493 position: "absolute",
7494 top: middlewareData.arrow?.y,
7495 left: middlewareData.arrow?.x
7496 }), [middlewareData.arrow]);
7497 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
7498 return React30.useMemo(() => ({
7499 positionerStyles: floatingStyles,
7500 arrowStyles,
7501 arrowRef,
7502 arrowUncentered,
7503 side: logicalRenderedSide,
7504 align: renderedAlign,
7505 physicalSide: renderedSide,
7506 anchorHidden,
7507 refs,
7508 context,
7509 isPositioned,
7510 update: update2
7511 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
7512 }
7513 function isRef(param) {
7514 return param != null && "current" in param;
7515 }
7516
7517 // node_modules/@base-ui/react/esm/utils/getDisabledMountTransitionStyles.js
7518 function getDisabledMountTransitionStyles(transitionStatus) {
7519 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
7520 }
7521
7522 // node_modules/@base-ui/react/esm/utils/usePositioner.js
7523 function usePositioner(componentProps, state, {
7524 styles,
7525 transitionStatus,
7526 props,
7527 refs,
7528 hidden,
7529 inert = false
7530 }) {
7531 const style = {
7532 ...styles
7533 };
7534 if (inert) {
7535 style.pointerEvents = "none";
7536 }
7537 return useRenderElement("div", componentProps, {
7538 state,
7539 ref: refs,
7540 props: [{
7541 role: "presentation",
7542 hidden,
7543 style
7544 }, getDisabledMountTransitionStyles(transitionStatus), props],
7545 stateAttributesMapping: popupStateMapping
7546 });
7547 }
7548
7549 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
7550 var React33 = __toESM(require_react(), 1);
7551 var ReactDOM5 = __toESM(require_react_dom(), 1);
7552
7553 // node_modules/@base-ui/utils/esm/usePreviousValue.js
7554 var React31 = __toESM(require_react(), 1);
7555 function usePreviousValue(value) {
7556 const [state, setState] = React31.useState({
7557 current: value,
7558 previous: null
7559 });
7560 if (value !== state.current) {
7561 setState({
7562 current: value,
7563 previous: state.current
7564 });
7565 }
7566 return state.previous;
7567 }
7568
7569 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7570 var React32 = __toESM(require_react(), 1);
7571
7572 // node_modules/@base-ui/react/esm/utils/getCssDimensions.js
7573 function getCssDimensions2(element) {
7574 const css = getComputedStyle2(element);
7575 let width = parseFloat(css.width) || 0;
7576 let height = parseFloat(css.height) || 0;
7577 const hasOffset = isHTMLElement(element);
7578 const offsetWidth = hasOffset ? element.offsetWidth : width;
7579 const offsetHeight = hasOffset ? element.offsetHeight : height;
7580 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
7581 if (shouldFallback) {
7582 width = offsetWidth;
7583 height = offsetHeight;
7584 }
7585 return {
7586 width,
7587 height
7588 };
7589 }
7590
7591 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7592 var DEFAULT_ENABLED = () => true;
7593 function usePopupAutoResize(parameters) {
7594 const {
7595 popupElement,
7596 positionerElement,
7597 content,
7598 mounted,
7599 enabled = DEFAULT_ENABLED,
7600 onMeasureLayout: onMeasureLayoutParam,
7601 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
7602 side,
7603 direction
7604 } = parameters;
7605 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
7606 const animationFrame = useAnimationFrame();
7607 const committedDimensionsRef = React32.useRef(null);
7608 const liveDimensionsRef = React32.useRef(null);
7609 const isInitialRenderRef = React32.useRef(true);
7610 const restoreAnchoringStylesRef = React32.useRef(NOOP);
7611 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
7612 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
7613 const anchoringStyles = React32.useMemo(() => {
7614 let isOriginSide = side === "top";
7615 let isPhysicalLeft = side === "left";
7616 if (direction === "rtl") {
7617 isOriginSide = isOriginSide || side === "inline-end";
7618 isPhysicalLeft = isPhysicalLeft || side === "inline-end";
7619 } else {
7620 isOriginSide = isOriginSide || side === "inline-start";
7621 isPhysicalLeft = isPhysicalLeft || side === "inline-start";
7622 }
7623 return isOriginSide ? {
7624 position: "absolute",
7625 [side === "top" ? "bottom" : "top"]: "0",
7626 [isPhysicalLeft ? "right" : "left"]: "0"
7627 } : EMPTY_OBJECT;
7628 }, [side, direction]);
7629 useIsoLayoutEffect(() => {
7630 if (!mounted || !enabled() || typeof ResizeObserver !== "function") {
7631 restoreAnchoringStylesRef.current = NOOP;
7632 isInitialRenderRef.current = true;
7633 committedDimensionsRef.current = null;
7634 liveDimensionsRef.current = null;
7635 return void 0;
7636 }
7637 if (!popupElement || !positionerElement) {
7638 return void 0;
7639 }
7640 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
7641 const observer = new ResizeObserver((entries) => {
7642 const entry = entries[0];
7643 if (entry) {
7644 liveDimensionsRef.current = {
7645 width: Math.ceil(entry.borderBoxSize[0].inlineSize),
7646 height: Math.ceil(entry.borderBoxSize[0].blockSize)
7647 };
7648 }
7649 });
7650 observer.observe(popupElement);
7651 setPopupCssSize(popupElement, "auto");
7652 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
7653 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
7654 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
7655 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
7656 "--available-width": "max-content",
7657 "--available-height": "max-content"
7658 });
7659 function restoreMeasurementOverrides() {
7660 restorePopupPosition();
7661 restorePopupTransform();
7662 restorePositionerAvailableSize();
7663 }
7664 function restoreMeasurementOverridesIncludingScale() {
7665 restoreMeasurementOverrides();
7666 restorePopupScale();
7667 }
7668 onMeasureLayout?.();
7669 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
7670 setPositionerCssSize(positionerElement, "max-content");
7671 const dimensions = getCssDimensions2(popupElement);
7672 committedDimensionsRef.current = dimensions;
7673 setPositionerCssSize(positionerElement, dimensions);
7674 restoreMeasurementOverridesIncludingScale();
7675 onMeasureLayoutComplete?.(null, dimensions);
7676 isInitialRenderRef.current = false;
7677 return () => {
7678 observer.disconnect();
7679 restoreAnchoringStylesRef.current();
7680 restoreAnchoringStylesRef.current = NOOP;
7681 };
7682 }
7683 setPopupCssSize(popupElement, "auto");
7684 setPositionerCssSize(positionerElement, "max-content");
7685 const previousDimensions = committedDimensionsRef.current ?? liveDimensionsRef.current;
7686 const newDimensions = getCssDimensions2(popupElement);
7687 committedDimensionsRef.current = newDimensions;
7688 if (!previousDimensions) {
7689 setPositionerCssSize(positionerElement, newDimensions);
7690 restoreMeasurementOverridesIncludingScale();
7691 onMeasureLayoutComplete?.(null, newDimensions);
7692 return () => {
7693 observer.disconnect();
7694 animationFrame.cancel();
7695 restoreAnchoringStylesRef.current();
7696 restoreAnchoringStylesRef.current = NOOP;
7697 };
7698 }
7699 setPopupCssSize(popupElement, previousDimensions);
7700 restoreMeasurementOverridesIncludingScale();
7701 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
7702 setPositionerCssSize(positionerElement, newDimensions);
7703 const abortController = new AbortController();
7704 animationFrame.request(() => {
7705 setPopupCssSize(popupElement, newDimensions);
7706 runOnceAnimationsFinish(() => {
7707 popupElement.style.setProperty("--popup-width", "auto");
7708 popupElement.style.setProperty("--popup-height", "auto");
7709 }, abortController.signal);
7710 });
7711 return () => {
7712 observer.disconnect();
7713 abortController.abort();
7714 animationFrame.cancel();
7715 restoreAnchoringStylesRef.current();
7716 restoreAnchoringStylesRef.current = NOOP;
7717 };
7718 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, enabled, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
7719 }
7720 function overrideElementStyle(element, property, value) {
7721 const originalValue = element.style.getPropertyValue(property);
7722 element.style.setProperty(property, value);
7723 return () => {
7724 element.style.setProperty(property, originalValue);
7725 };
7726 }
7727 function applyElementStyles(element, styles) {
7728 const restorers = [];
7729 for (const [key, value] of Object.entries(styles)) {
7730 restorers.push(overrideElementStyle(element, key, value));
7731 }
7732 return restorers.length ? () => {
7733 restorers.forEach((restore) => restore());
7734 } : NOOP;
7735 }
7736 function setPopupCssSize(popupElement, size4) {
7737 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
7738 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
7739 popupElement.style.setProperty("--popup-width", width);
7740 popupElement.style.setProperty("--popup-height", height);
7741 }
7742 function setPositionerCssSize(positionerElement, size4) {
7743 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
7744 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
7745 positionerElement.style.setProperty("--positioner-width", width);
7746 positionerElement.style.setProperty("--positioner-height", height);
7747 }
7748
7749 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
7750 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
7751 function usePopupViewport(parameters) {
7752 const {
7753 store,
7754 side,
7755 cssVars,
7756 children
7757 } = parameters;
7758 const direction = useDirection();
7759 const activeTrigger = store.useState("activeTriggerElement");
7760 const activeTriggerId = store.useState("activeTriggerId");
7761 const open = store.useState("open");
7762 const payload = store.useState("payload");
7763 const mounted = store.useState("mounted");
7764 const popupElement = store.useState("popupElement");
7765 const positionerElement = store.useState("positionerElement");
7766 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
7767 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
7768 const capturedNodeRef = React33.useRef(null);
7769 const [previousContentNode, setPreviousContentNode] = React33.useState(null);
7770 const [newTriggerOffset, setNewTriggerOffset] = React33.useState(null);
7771 const currentContainerRef = React33.useRef(null);
7772 const previousContainerRef = React33.useRef(null);
7773 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
7774 const cleanupFrame = useAnimationFrame();
7775 const [previousContentDimensions, setPreviousContentDimensions] = React33.useState(null);
7776 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React33.useState(false);
7777 useIsoLayoutEffect(() => {
7778 store.set("hasViewport", true);
7779 return () => {
7780 store.set("hasViewport", false);
7781 };
7782 }, [store]);
7783 const handleMeasureLayout = useStableCallback(() => {
7784 currentContainerRef.current?.style.setProperty("animation", "none");
7785 currentContainerRef.current?.style.setProperty("transition", "none");
7786 previousContainerRef.current?.style.setProperty("display", "none");
7787 });
7788 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
7789 currentContainerRef.current?.style.removeProperty("animation");
7790 currentContainerRef.current?.style.removeProperty("transition");
7791 previousContainerRef.current?.style.removeProperty("display");
7792 if (previousDimensions) {
7793 setPreviousContentDimensions(previousDimensions);
7794 }
7795 });
7796 const lastHandledTriggerRef = React33.useRef(null);
7797 useIsoLayoutEffect(() => {
7798 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
7799 setPreviousContentNode(capturedNodeRef.current);
7800 setShowStartingStyleAttribute(true);
7801 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
7802 setNewTriggerOffset(offset4);
7803 cleanupFrame.request(() => {
7804 ReactDOM5.flushSync(() => {
7805 setShowStartingStyleAttribute(false);
7806 });
7807 onAnimationsFinished(() => {
7808 setPreviousContentNode(null);
7809 setPreviousContentDimensions(null);
7810 capturedNodeRef.current = null;
7811 });
7812 });
7813 lastHandledTriggerRef.current = activeTrigger;
7814 }
7815 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
7816 useIsoLayoutEffect(() => {
7817 const source = currentContainerRef.current;
7818 if (!source) {
7819 return;
7820 }
7821 const wrapper = ownerDocument(source).createElement("div");
7822 for (const child of Array.from(source.childNodes)) {
7823 wrapper.appendChild(child.cloneNode(true));
7824 }
7825 capturedNodeRef.current = wrapper;
7826 });
7827 const isTransitioning = previousContentNode != null;
7828 let childrenToRender;
7829 if (!isTransitioning) {
7830 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
7831 "data-current": true,
7832 ref: currentContainerRef,
7833 children
7834 }, currentContentKey);
7835 } else {
7836 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(React33.Fragment, {
7837 children: [/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
7838 "data-previous": true,
7839 inert: inertValue(true),
7840 ref: previousContainerRef,
7841 style: {
7842 ...previousContentDimensions ? {
7843 [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
7844 [cssVars.popupHeight]: `${previousContentDimensions.height}px`
7845 } : null,
7846 position: "absolute"
7847 },
7848 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
7849 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
7850 "data-current": true,
7851 ref: currentContainerRef,
7852 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
7853 children
7854 }, currentContentKey)]
7855 });
7856 }
7857 useIsoLayoutEffect(() => {
7858 const container = previousContainerRef.current;
7859 if (!container || !previousContentNode) {
7860 return;
7861 }
7862 container.replaceChildren(...Array.from(previousContentNode.childNodes));
7863 }, [previousContentNode]);
7864 usePopupAutoResize({
7865 popupElement,
7866 positionerElement,
7867 mounted,
7868 content: payload,
7869 onMeasureLayout: handleMeasureLayout,
7870 onMeasureLayoutComplete: handleMeasureLayoutComplete,
7871 side,
7872 direction
7873 });
7874 const state = {
7875 activationDirection: getActivationDirection(newTriggerOffset),
7876 transitioning: isTransitioning
7877 };
7878 return {
7879 children: childrenToRender,
7880 state
7881 };
7882 }
7883 function getActivationDirection(offset4) {
7884 if (!offset4) {
7885 return void 0;
7886 }
7887 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
7888 }
7889 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
7890 if (value > tolerance) {
7891 return positiveLabel;
7892 }
7893 if (value < -tolerance) {
7894 return negativeLabel;
7895 }
7896 return "";
7897 }
7898 function calculateRelativePosition(from, to) {
7899 const fromRect = from.getBoundingClientRect();
7900 const toRect = to.getBoundingClientRect();
7901 const fromCenter = {
7902 x: fromRect.left + fromRect.width / 2,
7903 y: fromRect.top + fromRect.height / 2
7904 };
7905 const toCenter = {
7906 x: toRect.left + toRect.width / 2,
7907 y: toRect.top + toRect.height / 2
7908 };
7909 return {
7910 horizontal: toCenter.x - fromCenter.x,
7911 vertical: toCenter.y - fromCenter.y
7912 };
7913 }
7914 function usePopupContentKey(activeTriggerId, payload) {
7915 const [contentKey, setContentKey] = React33.useState(0);
7916 const previousActiveTriggerIdRef = React33.useRef(activeTriggerId);
7917 const previousPayloadRef = React33.useRef(payload);
7918 const pendingPayloadUpdateRef = React33.useRef(false);
7919 useIsoLayoutEffect(() => {
7920 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
7921 const previousPayload = previousPayloadRef.current;
7922 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
7923 const payloadChanged = payload !== previousPayload;
7924 if (triggerIdChanged) {
7925 setContentKey((value) => value + 1);
7926 pendingPayloadUpdateRef.current = !payloadChanged;
7927 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
7928 setContentKey((value) => value + 1);
7929 pendingPayloadUpdateRef.current = false;
7930 }
7931 previousActiveTriggerIdRef.current = activeTriggerId;
7932 previousPayloadRef.current = payload;
7933 }, [activeTriggerId, payload]);
7934 return `${activeTriggerId ?? "current"}-${contentKey}`;
7935 }
7936
7937 // node_modules/@base-ui/react/esm/utils/FloatingPortalLite.js
7938 var React34 = __toESM(require_react(), 1);
7939 var ReactDOM6 = __toESM(require_react_dom(), 1);
7940 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
7941 var FloatingPortalLite = /* @__PURE__ */ React34.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
7942 const {
7943 children,
7944 container,
7945 className,
7946 render: render4,
7947 style,
7948 ...elementProps
7949 } = componentProps;
7950 const {
7951 portalNode,
7952 portalSubtree
7953 } = useFloatingPortalNode({
7954 container,
7955 ref: forwardedRef,
7956 componentProps,
7957 elementProps
7958 });
7959 if (!portalSubtree && !portalNode) {
7960 return null;
7961 }
7962 return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(React34.Fragment, {
7963 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM6.createPortal(children, portalNode)]
7964 });
7965 });
7966 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
7967
7968 // node_modules/@base-ui/react/esm/tooltip/index.parts.js
7969 var index_parts_exports = {};
7970 __export(index_parts_exports, {
7971 Arrow: () => TooltipArrow,
7972 Handle: () => TooltipHandle,
7973 Popup: () => TooltipPopup,
7974 Portal: () => TooltipPortal,
7975 Positioner: () => TooltipPositioner,
7976 Provider: () => TooltipProvider,
7977 Root: () => TooltipRoot,
7978 Trigger: () => TooltipTrigger,
7979 Viewport: () => TooltipViewport,
7980 createHandle: () => createTooltipHandle
7981 });
7982
7983 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
7984 var React37 = __toESM(require_react(), 1);
7985
7986 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRootContext.js
7987 var React35 = __toESM(require_react(), 1);
7988 var TooltipRootContext = /* @__PURE__ */ React35.createContext(void 0);
7989 if (true) TooltipRootContext.displayName = "TooltipRootContext";
7990 function useTooltipRootContext(optional) {
7991 const context = React35.useContext(TooltipRootContext);
7992 if (context === void 0 && !optional) {
7993 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
7994 }
7995 return context;
7996 }
7997
7998 // node_modules/@base-ui/react/esm/tooltip/store/TooltipStore.js
7999 var React36 = __toESM(require_react(), 1);
8000 var ReactDOM7 = __toESM(require_react_dom(), 1);
8001 var selectors2 = {
8002 ...popupStoreSelectors,
8003 disabled: createSelector((state) => state.disabled),
8004 instantType: createSelector((state) => state.instantType),
8005 isInstantPhase: createSelector((state) => state.isInstantPhase),
8006 trackCursorAxis: createSelector((state) => state.trackCursorAxis),
8007 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
8008 lastOpenChangeReason: createSelector((state) => state.openChangeReason),
8009 closeOnClick: createSelector((state) => state.closeOnClick),
8010 closeDelay: createSelector((state) => state.closeDelay),
8011 hasViewport: createSelector((state) => state.hasViewport)
8012 };
8013 var TooltipStore = class _TooltipStore extends ReactStore {
8014 constructor(initialState) {
8015 super({
8016 ...createInitialState(),
8017 ...initialState
8018 }, {
8019 popupRef: /* @__PURE__ */ React36.createRef(),
8020 onOpenChange: void 0,
8021 onOpenChangeComplete: void 0,
8022 triggerElements: new PopupTriggerMap()
8023 }, selectors2);
8024 }
8025 setOpen = (nextOpen, eventDetails) => {
8026 const reason = eventDetails.reason;
8027 const isHover = reason === reason_parts_exports.triggerHover;
8028 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
8029 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
8030 eventDetails.preventUnmountOnClose = () => {
8031 this.set("preventUnmountingOnClose", true);
8032 };
8033 this.context.onOpenChange?.(nextOpen, eventDetails);
8034 if (eventDetails.isCanceled) {
8035 return;
8036 }
8037 this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
8038 const changeState = () => {
8039 const updatedState = {
8040 open: nextOpen,
8041 openChangeReason: reason
8042 };
8043 if (isFocusOpen) {
8044 updatedState.instantType = "focus";
8045 } else if (isDismissClose) {
8046 updatedState.instantType = "dismiss";
8047 } else if (reason === reason_parts_exports.triggerHover) {
8048 updatedState.instantType = void 0;
8049 }
8050 const newTriggerId = eventDetails.trigger?.id ?? null;
8051 if (newTriggerId || nextOpen) {
8052 updatedState.activeTriggerId = newTriggerId;
8053 updatedState.activeTriggerElement = eventDetails.trigger ?? null;
8054 }
8055 this.update(updatedState);
8056 };
8057 if (isHover) {
8058 ReactDOM7.flushSync(changeState);
8059 } else {
8060 changeState();
8061 }
8062 };
8063 static useStore(externalStore, initialState) {
8064 const internalStore = useRefWithInit(() => {
8065 return new _TooltipStore(initialState);
8066 }).current;
8067 const store = externalStore ?? internalStore;
8068 const floatingRootContext = useSyncedFloatingRootContext({
8069 popupStore: store,
8070 onOpenChange: store.setOpen
8071 });
8072 store.state.floatingRootContext = floatingRootContext;
8073 return store;
8074 }
8075 };
8076 function createInitialState() {
8077 return {
8078 ...createInitialPopupStoreState(),
8079 disabled: false,
8080 instantType: void 0,
8081 isInstantPhase: false,
8082 trackCursorAxis: "none",
8083 disableHoverablePopup: false,
8084 openChangeReason: null,
8085 closeOnClick: true,
8086 closeDelay: 0,
8087 hasViewport: false
8088 };
8089 }
8090
8091 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
8092 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
8093 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
8094 const {
8095 disabled: disabled2 = false,
8096 defaultOpen = false,
8097 open: openProp,
8098 disableHoverablePopup = false,
8099 trackCursorAxis = "none",
8100 actionsRef,
8101 onOpenChange,
8102 onOpenChangeComplete,
8103 handle,
8104 triggerId: triggerIdProp,
8105 defaultTriggerId: defaultTriggerIdProp = null,
8106 children
8107 } = props;
8108 const store = TooltipStore.useStore(handle?.store, {
8109 open: defaultOpen,
8110 openProp,
8111 activeTriggerId: defaultTriggerIdProp,
8112 triggerIdProp
8113 });
8114 useOnFirstRender(() => {
8115 if (openProp === void 0 && store.state.open === false && defaultOpen === true) {
8116 store.update({
8117 open: true,
8118 activeTriggerId: defaultTriggerIdProp
8119 });
8120 }
8121 });
8122 store.useControlledProp("openProp", openProp);
8123 store.useControlledProp("triggerIdProp", triggerIdProp);
8124 store.useContextCallback("onOpenChange", onOpenChange);
8125 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
8126 const openState = store.useState("open");
8127 const open = !disabled2 && openState;
8128 const activeTriggerId = store.useState("activeTriggerId");
8129 const payload = store.useState("payload");
8130 store.useSyncedValues({
8131 trackCursorAxis,
8132 disableHoverablePopup
8133 });
8134 useIsoLayoutEffect(() => {
8135 if (openState && disabled2) {
8136 store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
8137 }
8138 }, [openState, disabled2, store]);
8139 store.useSyncedValue("disabled", disabled2);
8140 useImplicitActiveTrigger(store);
8141 const {
8142 forceUnmount,
8143 transitionStatus
8144 } = useOpenStateTransitions(open, store);
8145 const floatingRootContext = store.select("floatingRootContext");
8146 const isInstantPhase = store.useState("isInstantPhase");
8147 const instantType = store.useState("instantType");
8148 const lastOpenChangeReason = store.useState("lastOpenChangeReason");
8149 const previousInstantTypeRef = React37.useRef(null);
8150 useIsoLayoutEffect(() => {
8151 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
8152 if (instantType !== "delay") {
8153 previousInstantTypeRef.current = instantType;
8154 }
8155 store.set("instantType", "delay");
8156 } else if (previousInstantTypeRef.current !== null) {
8157 store.set("instantType", previousInstantTypeRef.current);
8158 previousInstantTypeRef.current = null;
8159 }
8160 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]);
8161 useIsoLayoutEffect(() => {
8162 if (open) {
8163 if (activeTriggerId == null) {
8164 store.set("payload", void 0);
8165 }
8166 }
8167 }, [store, activeTriggerId, open]);
8168 const handleImperativeClose = React37.useCallback(() => {
8169 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
8170 }, [store]);
8171 React37.useImperativeHandle(actionsRef, () => ({
8172 unmount: forceUnmount,
8173 close: handleImperativeClose
8174 }), [forceUnmount, handleImperativeClose]);
8175 const dismiss = useDismiss(floatingRootContext, {
8176 enabled: !disabled2,
8177 referencePress: () => store.select("closeOnClick")
8178 });
8179 const clientPoint = useClientPoint(floatingRootContext, {
8180 enabled: !disabled2 && trackCursorAxis !== "none",
8181 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
8182 });
8183 const {
8184 getReferenceProps,
8185 getFloatingProps,
8186 getTriggerProps
8187 } = useInteractions([dismiss, clientPoint]);
8188 const activeTriggerProps = React37.useMemo(() => getReferenceProps(), [getReferenceProps]);
8189 const inactiveTriggerProps = React37.useMemo(() => getTriggerProps(), [getTriggerProps]);
8190 const popupProps = React37.useMemo(() => getFloatingProps(), [getFloatingProps]);
8191 store.useSyncedValues({
8192 activeTriggerProps,
8193 inactiveTriggerProps,
8194 popupProps
8195 });
8196 return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TooltipRootContext.Provider, {
8197 value: store,
8198 children: typeof children === "function" ? children({
8199 payload
8200 }) : children
8201 });
8202 });
8203 if (true) TooltipRoot.displayName = "TooltipRoot";
8204
8205 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
8206 var React39 = __toESM(require_react(), 1);
8207
8208 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProviderContext.js
8209 var React38 = __toESM(require_react(), 1);
8210 var TooltipProviderContext = /* @__PURE__ */ React38.createContext(void 0);
8211 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
8212 function useTooltipProviderContext() {
8213 return React38.useContext(TooltipProviderContext);
8214 }
8215
8216 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTriggerDataAttributes.js
8217 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
8218 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
8219 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
8220 return TooltipTriggerDataAttributes2;
8221 })({});
8222
8223 // node_modules/@base-ui/react/esm/tooltip/utils/constants.js
8224 var OPEN_DELAY = 600;
8225
8226 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
8227 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
8228 const {
8229 className,
8230 render: render4,
8231 handle,
8232 payload,
8233 disabled: disabledProp,
8234 delay,
8235 closeOnClick = true,
8236 closeDelay,
8237 id: idProp,
8238 style,
8239 ...elementProps
8240 } = componentProps;
8241 const rootContext = useTooltipRootContext(true);
8242 const store = handle?.store ?? rootContext;
8243 if (!store) {
8244 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));
8245 }
8246 const thisTriggerId = useBaseUiId(idProp);
8247 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
8248 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
8249 const floatingRootContext = store.useState("floatingRootContext");
8250 const triggerElementRef = React39.useRef(null);
8251 const delayWithDefault = delay ?? OPEN_DELAY;
8252 const closeDelayWithDefault = closeDelay ?? 0;
8253 const {
8254 registerTrigger,
8255 isMountedByThisTrigger
8256 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
8257 payload,
8258 closeOnClick,
8259 closeDelay: closeDelayWithDefault
8260 });
8261 const providerContext = useTooltipProviderContext();
8262 const {
8263 delayRef,
8264 isInstantPhase,
8265 hasProvider
8266 } = useDelayGroup(floatingRootContext, {
8267 open: isOpenedByThisTrigger
8268 });
8269 store.useSyncedValue("isInstantPhase", isInstantPhase);
8270 const rootDisabled = store.useState("disabled");
8271 const disabled2 = disabledProp ?? rootDisabled;
8272 const trackCursorAxis = store.useState("trackCursorAxis");
8273 const disableHoverablePopup = store.useState("disableHoverablePopup");
8274 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
8275 enabled: !disabled2,
8276 mouseOnly: true,
8277 move: false,
8278 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
8279 restMs() {
8280 const providerDelay = providerContext?.delay;
8281 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
8282 let computedRestMs = delayWithDefault;
8283 if (hasProvider) {
8284 if (groupOpenValue !== 0) {
8285 computedRestMs = delay ?? providerDelay ?? delayWithDefault;
8286 } else {
8287 computedRestMs = 0;
8288 }
8289 }
8290 return computedRestMs;
8291 },
8292 delay() {
8293 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
8294 let computedCloseDelay = closeDelayWithDefault;
8295 if (closeDelay == null && hasProvider) {
8296 computedCloseDelay = closeValue;
8297 }
8298 return {
8299 close: computedCloseDelay
8300 };
8301 },
8302 triggerElementRef,
8303 isActiveTrigger: isTriggerActive,
8304 isClosing: () => store.select("transitionStatus") === "ending"
8305 });
8306 const focusProps = useFocus(floatingRootContext, {
8307 enabled: !disabled2
8308 }).reference;
8309 const state = {
8310 open: isOpenedByThisTrigger
8311 };
8312 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
8313 const element = useRenderElement("button", componentProps, {
8314 state,
8315 ref: [forwardedRef, registerTrigger, triggerElementRef],
8316 props: [hoverProps, focusProps, rootTriggerProps, {
8317 onPointerDown() {
8318 store.set("closeOnClick", closeOnClick);
8319 },
8320 id: thisTriggerId,
8321 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0
8322 }, elementProps],
8323 stateAttributesMapping: triggerOpenStateMapping
8324 });
8325 return element;
8326 });
8327 if (true) TooltipTrigger.displayName = "TooltipTrigger";
8328
8329 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
8330 var React41 = __toESM(require_react(), 1);
8331
8332 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortalContext.js
8333 var React40 = __toESM(require_react(), 1);
8334 var TooltipPortalContext = /* @__PURE__ */ React40.createContext(void 0);
8335 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
8336 function useTooltipPortalContext() {
8337 const value = React40.useContext(TooltipPortalContext);
8338 if (value === void 0) {
8339 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
8340 }
8341 return value;
8342 }
8343
8344 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
8345 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
8346 var TooltipPortal = /* @__PURE__ */ React41.forwardRef(function TooltipPortal2(props, forwardedRef) {
8347 const {
8348 keepMounted = false,
8349 ...portalProps
8350 } = props;
8351 const store = useTooltipRootContext();
8352 const mounted = store.useState("mounted");
8353 const shouldRender = mounted || keepMounted;
8354 if (!shouldRender) {
8355 return null;
8356 }
8357 return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TooltipPortalContext.Provider, {
8358 value: keepMounted,
8359 children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FloatingPortalLite, {
8360 ref: forwardedRef,
8361 ...portalProps
8362 })
8363 });
8364 });
8365 if (true) TooltipPortal.displayName = "TooltipPortal";
8366
8367 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
8368 var React43 = __toESM(require_react(), 1);
8369
8370 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositionerContext.js
8371 var React42 = __toESM(require_react(), 1);
8372 var TooltipPositionerContext = /* @__PURE__ */ React42.createContext(void 0);
8373 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
8374 function useTooltipPositionerContext() {
8375 const context = React42.useContext(TooltipPositionerContext);
8376 if (context === void 0) {
8377 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
8378 }
8379 return context;
8380 }
8381
8382 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
8383 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
8384 var TooltipPositioner = /* @__PURE__ */ React43.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
8385 const {
8386 render: render4,
8387 className,
8388 anchor,
8389 positionMethod = "absolute",
8390 side = "top",
8391 align = "center",
8392 sideOffset = 0,
8393 alignOffset = 0,
8394 collisionBoundary = "clipping-ancestors",
8395 collisionPadding = 5,
8396 arrowPadding = 5,
8397 sticky = false,
8398 disableAnchorTracking = false,
8399 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
8400 style,
8401 ...elementProps
8402 } = componentProps;
8403 const store = useTooltipRootContext();
8404 const keepMounted = useTooltipPortalContext();
8405 const open = store.useState("open");
8406 const mounted = store.useState("mounted");
8407 const trackCursorAxis = store.useState("trackCursorAxis");
8408 const disableHoverablePopup = store.useState("disableHoverablePopup");
8409 const floatingRootContext = store.useState("floatingRootContext");
8410 const instantType = store.useState("instantType");
8411 const transitionStatus = store.useState("transitionStatus");
8412 const hasViewport = store.useState("hasViewport");
8413 const positioning = useAnchorPositioning({
8414 anchor,
8415 positionMethod,
8416 floatingRootContext,
8417 mounted,
8418 side,
8419 sideOffset,
8420 align,
8421 alignOffset,
8422 collisionBoundary,
8423 collisionPadding,
8424 sticky,
8425 arrowPadding,
8426 disableAnchorTracking,
8427 keepMounted,
8428 collisionAvoidance,
8429 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
8430 });
8431 const state = React43.useMemo(() => ({
8432 open,
8433 side: positioning.side,
8434 align: positioning.align,
8435 anchorHidden: positioning.anchorHidden,
8436 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
8437 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
8438 const element = usePositioner(componentProps, state, {
8439 styles: positioning.positionerStyles,
8440 transitionStatus,
8441 props: elementProps,
8442 refs: [forwardedRef, store.useStateSetter("positionerElement")],
8443 hidden: !mounted,
8444 inert: !open || trackCursorAxis === "both" || disableHoverablePopup
8445 });
8446 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TooltipPositionerContext.Provider, {
8447 value: positioning,
8448 children: element
8449 });
8450 });
8451 if (true) TooltipPositioner.displayName = "TooltipPositioner";
8452
8453 // node_modules/@base-ui/react/esm/tooltip/popup/TooltipPopup.js
8454 var React44 = __toESM(require_react(), 1);
8455 var stateAttributesMapping = {
8456 ...popupStateMapping,
8457 ...transitionStatusMapping
8458 };
8459 var TooltipPopup = /* @__PURE__ */ React44.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
8460 const {
8461 className,
8462 render: render4,
8463 style,
8464 ...elementProps
8465 } = componentProps;
8466 const store = useTooltipRootContext();
8467 const {
8468 side,
8469 align
8470 } = useTooltipPositionerContext();
8471 const open = store.useState("open");
8472 const instantType = store.useState("instantType");
8473 const transitionStatus = store.useState("transitionStatus");
8474 const popupProps = store.useState("popupProps");
8475 const floatingContext = store.useState("floatingRootContext");
8476 useOpenChangeComplete({
8477 open,
8478 ref: store.context.popupRef,
8479 onComplete() {
8480 if (open) {
8481 store.context.onOpenChangeComplete?.(true);
8482 }
8483 }
8484 });
8485 const disabled2 = store.useState("disabled");
8486 const closeDelay = store.useState("closeDelay");
8487 useHoverFloatingInteraction(floatingContext, {
8488 enabled: !disabled2,
8489 closeDelay
8490 });
8491 const state = {
8492 open,
8493 side,
8494 align,
8495 instant: instantType,
8496 transitionStatus
8497 };
8498 const element = useRenderElement("div", componentProps, {
8499 state,
8500 ref: [forwardedRef, store.context.popupRef, store.useStateSetter("popupElement")],
8501 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
8502 stateAttributesMapping
8503 });
8504 return element;
8505 });
8506 if (true) TooltipPopup.displayName = "TooltipPopup";
8507
8508 // node_modules/@base-ui/react/esm/tooltip/arrow/TooltipArrow.js
8509 var React45 = __toESM(require_react(), 1);
8510 var TooltipArrow = /* @__PURE__ */ React45.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
8511 const {
8512 className,
8513 render: render4,
8514 style,
8515 ...elementProps
8516 } = componentProps;
8517 const store = useTooltipRootContext();
8518 const open = store.useState("open");
8519 const instantType = store.useState("instantType");
8520 const {
8521 arrowRef,
8522 side,
8523 align,
8524 arrowUncentered,
8525 arrowStyles
8526 } = useTooltipPositionerContext();
8527 const state = {
8528 open,
8529 side,
8530 align,
8531 uncentered: arrowUncentered,
8532 instant: instantType
8533 };
8534 const element = useRenderElement("div", componentProps, {
8535 state,
8536 ref: [forwardedRef, arrowRef],
8537 props: [{
8538 style: arrowStyles,
8539 "aria-hidden": true
8540 }, elementProps],
8541 stateAttributesMapping: popupStateMapping
8542 });
8543 return element;
8544 });
8545 if (true) TooltipArrow.displayName = "TooltipArrow";
8546
8547 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProvider.js
8548 var React46 = __toESM(require_react(), 1);
8549 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
8550 var TooltipProvider = function TooltipProvider2(props) {
8551 const {
8552 delay,
8553 closeDelay,
8554 timeout = 400
8555 } = props;
8556 const contextValue = React46.useMemo(() => ({
8557 delay,
8558 closeDelay
8559 }), [delay, closeDelay]);
8560 const delayValue = React46.useMemo(() => ({
8561 open: delay,
8562 close: closeDelay
8563 }), [delay, closeDelay]);
8564 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipProviderContext.Provider, {
8565 value: contextValue,
8566 children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FloatingDelayGroup, {
8567 delay: delayValue,
8568 timeoutMs: timeout,
8569 children: props.children
8570 })
8571 });
8572 };
8573 if (true) TooltipProvider.displayName = "TooltipProvider";
8574
8575 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
8576 var React47 = __toESM(require_react(), 1);
8577
8578 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewportCssVars.js
8579 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
8580 TooltipViewportCssVars2["popupWidth"] = "--popup-width";
8581 TooltipViewportCssVars2["popupHeight"] = "--popup-height";
8582 return TooltipViewportCssVars2;
8583 })({});
8584
8585 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
8586 var stateAttributesMapping2 = {
8587 activationDirection: (value) => value ? {
8588 "data-activation-direction": value
8589 } : null
8590 };
8591 var TooltipViewport = /* @__PURE__ */ React47.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
8592 const {
8593 render: render4,
8594 className,
8595 style,
8596 children,
8597 ...elementProps
8598 } = componentProps;
8599 const store = useTooltipRootContext();
8600 const positioner = useTooltipPositionerContext();
8601 const instantType = store.useState("instantType");
8602 const {
8603 children: childrenToRender,
8604 state: viewportState
8605 } = usePopupViewport({
8606 store,
8607 side: positioner.side,
8608 cssVars: TooltipViewportCssVars,
8609 children
8610 });
8611 const state = {
8612 activationDirection: viewportState.activationDirection,
8613 transitioning: viewportState.transitioning,
8614 instant: instantType
8615 };
8616 return useRenderElement("div", componentProps, {
8617 state,
8618 ref: forwardedRef,
8619 props: [elementProps, {
8620 children: childrenToRender
8621 }],
8622 stateAttributesMapping: stateAttributesMapping2
8623 });
8624 });
8625 if (true) TooltipViewport.displayName = "TooltipViewport";
8626
8627 // node_modules/@base-ui/react/esm/tooltip/store/TooltipHandle.js
8628 var TooltipHandle = class {
8629 /**
8630 * Internal store holding the tooltip state.
8631 * @internal
8632 */
8633 constructor() {
8634 this.store = new TooltipStore();
8635 }
8636 /**
8637 * Opens the tooltip and associates it with the trigger with the given ID.
8638 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
8639 *
8640 * This method should only be called in an event handler or an effect (not during rendering).
8641 *
8642 * @param triggerId ID of the trigger to associate with the tooltip.
8643 */
8644 open(triggerId) {
8645 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
8646 if (triggerId && !triggerElement) {
8647 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
8648 }
8649 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
8650 }
8651 /**
8652 * Closes the tooltip.
8653 */
8654 close() {
8655 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
8656 }
8657 /**
8658 * Indicates whether the tooltip is currently open.
8659 */
8660 get isOpen() {
8661 return this.store.state.open;
8662 }
8663 };
8664 function createTooltipHandle() {
8665 return new TooltipHandle();
8666 }
8667
8668 // node_modules/@base-ui/react/esm/use-render/useRender.js
8669 function useRender(params) {
8670 return useRenderElement(params.defaultTagName ?? "div", params, params);
8671 }
8672
8673 // packages/ui/build-module/text/text.mjs
8674 var import_element8 = __toESM(require_element(), 1);
8675 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
8676 function getRuntime() {
8677 const globalScope = globalThis;
8678 if (globalScope.__wpStyleRuntime) {
8679 return globalScope.__wpStyleRuntime;
8680 }
8681 globalScope.__wpStyleRuntime = {
8682 documents: /* @__PURE__ */ new Map(),
8683 styles: /* @__PURE__ */ new Map(),
8684 injectedStyles: /* @__PURE__ */ new WeakMap()
8685 };
8686 if (typeof document !== "undefined") {
8687 registerDocument(document);
8688 }
8689 return globalScope.__wpStyleRuntime;
8690 }
8691 function documentContainsStyleHash(targetDocument, hash) {
8692 if (!targetDocument.head) {
8693 return false;
8694 }
8695 for (const style of targetDocument.head.querySelectorAll(
8696 `style[${STYLE_HASH_ATTRIBUTE}]`
8697 )) {
8698 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
8699 return true;
8700 }
8701 }
8702 return false;
8703 }
8704 function injectStyle(targetDocument, hash, css) {
8705 if (!targetDocument.head) {
8706 return;
8707 }
8708 const runtime = getRuntime();
8709 let injectedStyles = runtime.injectedStyles.get(targetDocument);
8710 if (!injectedStyles) {
8711 injectedStyles = /* @__PURE__ */ new Set();
8712 runtime.injectedStyles.set(targetDocument, injectedStyles);
8713 }
8714 if (injectedStyles.has(hash)) {
8715 return;
8716 }
8717 if (documentContainsStyleHash(targetDocument, hash)) {
8718 injectedStyles.add(hash);
8719 return;
8720 }
8721 const style = targetDocument.createElement("style");
8722 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
8723 style.appendChild(targetDocument.createTextNode(css));
8724 targetDocument.head.appendChild(style);
8725 injectedStyles.add(hash);
8726 }
8727 function registerDocument(targetDocument) {
8728 const runtime = getRuntime();
8729 runtime.documents.set(
8730 targetDocument,
8731 (runtime.documents.get(targetDocument) ?? 0) + 1
8732 );
8733 for (const [hash, css] of runtime.styles) {
8734 injectStyle(targetDocument, hash, css);
8735 }
8736 return () => {
8737 const count = runtime.documents.get(targetDocument);
8738 if (count === void 0) {
8739 return;
8740 }
8741 if (count <= 1) {
8742 runtime.documents.delete(targetDocument);
8743 return;
8744 }
8745 runtime.documents.set(targetDocument, count - 1);
8746 };
8747 }
8748 function registerStyle(hash, css) {
8749 const runtime = getRuntime();
8750 runtime.styles.set(hash, css);
8751 for (const targetDocument of runtime.documents.keys()) {
8752 injectStyle(targetDocument, hash, css);
8753 }
8754 }
8755 if (typeof process === "undefined" || true) {
8756 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)}}');
8757 }
8758 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" };
8759 if (typeof process === "undefined" || true) {
8760 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)}");
8761 }
8762 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" };
8763 var Text = (0, import_element8.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
8764 const element = useRender({
8765 render: render4,
8766 defaultTagName: "span",
8767 ref,
8768 props: mergeProps(props, {
8769 className: clsx_default(
8770 style_default.text,
8771 global_css_defense_default.heading,
8772 global_css_defense_default.p,
8773 style_default[variant],
8774 className
8775 )
8776 })
8777 });
8778 return element;
8779 });
8780
8781 // packages/ui/build-module/icon/icon.mjs
8782 var import_element9 = __toESM(require_element(), 1);
8783 var import_primitives = __toESM(require_primitives(), 1);
8784 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
8785 var Icon = (0, import_element9.forwardRef)(function Icon2({ icon, size: size4 = 24, ...restProps }, ref) {
8786 return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
8787 import_primitives.SVG,
8788 {
8789 ref,
8790 fill: "currentColor",
8791 ...icon.props,
8792 ...restProps,
8793 width: size4,
8794 height: size4
8795 }
8796 );
8797 });
8798
8799 // packages/icons/build-module/library/arrow-down.mjs
8800 var import_primitives2 = __toESM(require_primitives(), 1);
8801 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
8802 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives2.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" }) });
8803
8804 // packages/icons/build-module/library/arrow-left.mjs
8805 var import_primitives3 = __toESM(require_primitives(), 1);
8806 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
8807 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives3.Path, { d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" }) });
8808
8809 // packages/icons/build-module/library/arrow-right.mjs
8810 var import_primitives4 = __toESM(require_primitives(), 1);
8811 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
8812 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives4.Path, { d: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) });
8813
8814 // packages/icons/build-module/library/arrow-up.mjs
8815 var import_primitives5 = __toESM(require_primitives(), 1);
8816 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
8817 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives5.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) });
8818
8819 // packages/icons/build-module/library/block-table.mjs
8820 var import_primitives6 = __toESM(require_primitives(), 1);
8821 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
8822 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives6.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" }) });
8823
8824 // packages/icons/build-module/library/category.mjs
8825 var import_primitives7 = __toESM(require_primitives(), 1);
8826 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
8827 var category_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives7.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" }) });
8828
8829 // packages/icons/build-module/library/check.mjs
8830 var import_primitives8 = __toESM(require_primitives(), 1);
8831 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
8832 var check_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives8.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });
8833
8834 // packages/icons/build-module/library/close-small.mjs
8835 var import_primitives9 = __toESM(require_primitives(), 1);
8836 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
8837 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives9.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" }) });
8838
8839 // packages/icons/build-module/library/cog.mjs
8840 var import_primitives10 = __toESM(require_primitives(), 1);
8841 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
8842 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives10.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" }) });
8843
8844 // packages/icons/build-module/library/envelope.mjs
8845 var import_primitives11 = __toESM(require_primitives(), 1);
8846 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
8847 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime21.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" }) });
8848
8849 // packages/icons/build-module/library/error.mjs
8850 var import_primitives12 = __toESM(require_primitives(), 1);
8851 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
8852 var error_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime22.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" }) });
8853
8854 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
8855 var import_primitives13 = __toESM(require_primitives(), 1);
8856 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
8857 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime23.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" }) });
8858
8859 // packages/icons/build-module/library/format-list-bullets.mjs
8860 var import_primitives14 = __toESM(require_primitives(), 1);
8861 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
8862 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime24.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" }) });
8863
8864 // packages/icons/build-module/library/funnel.mjs
8865 var import_primitives15 = __toESM(require_primitives(), 1);
8866 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
8867 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives15.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) });
8868
8869 // packages/icons/build-module/library/globe.mjs
8870 var import_primitives16 = __toESM(require_primitives(), 1);
8871 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
8872 var globe_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives16.Path, { d: "M12 4c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8Zm6.5 8c0 .6 0 1.2-.2 1.8h-2.7c0-.6.2-1.1.2-1.8s0-1.2-.2-1.8h2.7c.2.6.2 1.1.2 1.8Zm-.9-3.2h-2.4c-.3-.9-.7-1.8-1.1-2.4-.1-.2-.2-.4-.3-.5 1.6.5 3 1.6 3.8 3ZM12.8 17c-.3.5-.6 1-.8 1.3-.2-.3-.5-.8-.8-1.3-.3-.5-.6-1.1-.8-1.7h3.3c-.2.6-.5 1.2-.8 1.7Zm-2.9-3.2c-.1-.6-.2-1.1-.2-1.8s0-1.2.2-1.8H14c.1.6.2 1.1.2 1.8s0 1.2-.2 1.8H9.9ZM11.2 7c.3-.5.6-1 .8-1.3.2.3.5.8.8 1.3.3.5.6 1.1.8 1.7h-3.3c.2-.6.5-1.2.8-1.7Zm-1-1.2c-.1.2-.2.3-.3.5-.4.7-.8 1.5-1.1 2.4H6.4c.8-1.4 2.2-2.5 3.8-3Zm-1.8 8H5.7c-.2-.6-.2-1.1-.2-1.8s0-1.2.2-1.8h2.7c0 .6-.2 1.1-.2 1.8s0 1.2.2 1.8Zm-2 1.4h2.4c.3.9.7 1.8 1.1 2.4.1.2.2.4.3.5-1.6-.5-3-1.6-3.8-3Zm7.4 3c.1-.2.2-.3.3-.5.4-.7.8-1.5 1.1-2.4h2.4c-.8 1.4-2.2 2.5-3.8 3Z" }) });
8873
8874 // packages/icons/build-module/library/link.mjs
8875 var import_primitives17 = __toESM(require_primitives(), 1);
8876 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
8877 var link_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives17.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" }) });
8878
8879 // packages/icons/build-module/library/mobile.mjs
8880 var import_primitives18 = __toESM(require_primitives(), 1);
8881 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
8882 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives18.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" }) });
8883
8884 // packages/icons/build-module/library/more-vertical.mjs
8885 var import_primitives19 = __toESM(require_primitives(), 1);
8886 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
8887 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives19.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
8888
8889 // packages/icons/build-module/library/next.mjs
8890 var import_primitives20 = __toESM(require_primitives(), 1);
8891 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
8892 var next_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives20.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" }) });
8893
8894 // packages/icons/build-module/library/post-list.mjs
8895 var import_primitives21 = __toESM(require_primitives(), 1);
8896 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
8897 var post_list_default = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives21.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" }) });
8898
8899 // packages/icons/build-module/library/previous.mjs
8900 var import_primitives22 = __toESM(require_primitives(), 1);
8901 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
8902 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives22.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" }) });
8903
8904 // packages/icons/build-module/library/scheduled.mjs
8905 var import_primitives23 = __toESM(require_primitives(), 1);
8906 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
8907 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives23.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" }) });
8908
8909 // packages/icons/build-module/library/search.mjs
8910 var import_primitives24 = __toESM(require_primitives(), 1);
8911 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
8912 var search_default = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives24.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" }) });
8913
8914 // packages/icons/build-module/library/seen.mjs
8915 var import_primitives25 = __toESM(require_primitives(), 1);
8916 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
8917 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives25.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" }) });
8918
8919 // packages/icons/build-module/library/unseen.mjs
8920 var import_primitives26 = __toESM(require_primitives(), 1);
8921 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
8922 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives26.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives26.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" }) });
8923
8924 // packages/icons/build-module/library/wordpress.mjs
8925 var import_primitives27 = __toESM(require_primitives(), 1);
8926 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
8927 var wordpress_default = /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives27.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "-2 -2 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives27.Path, { d: "M20 10c0-5.51-4.49-10-10-10C4.48 0 0 4.49 0 10c0 5.52 4.48 10 10 10 5.51 0 10-4.48 10-10zM7.78 15.37L4.37 6.22c.55-.02 1.17-.08 1.17-.08.5-.06.44-1.13-.06-1.11 0 0-1.45.11-2.37.11-.18 0-.37 0-.58-.01C4.12 2.69 6.87 1.11 10 1.11c2.33 0 4.45.87 6.05 2.34-.68-.11-1.65.39-1.65 1.58 0 .74.45 1.36.9 2.1.35.61.55 1.36.55 2.46 0 1.49-1.4 5-1.4 5l-3.03-8.37c.54-.02.82-.17.82-.17.5-.05.44-1.25-.06-1.22 0 0-1.44.12-2.38.12-.87 0-2.33-.12-2.33-.12-.5-.03-.56 1.2-.06 1.22l.92.08 1.26 3.41zM17.41 10c.24-.64.74-1.87.43-4.25.7 1.29 1.05 2.71 1.05 4.25 0 3.29-1.73 6.24-4.4 7.78.97-2.59 1.94-5.2 2.92-7.78zM6.1 18.09C3.12 16.65 1.11 13.53 1.11 10c0-1.3.23-2.48.72-3.59C3.25 10.3 4.67 14.2 6.1 18.09zm4.03-6.63l2.58 6.98c-.86.29-1.76.45-2.71.45-.79 0-1.57-.11-2.29-.33.81-2.38 1.62-4.74 2.42-7.1z" }) });
8928
8929 // packages/ui/build-module/utils/render-slot-with-children.mjs
8930 var import_element10 = __toESM(require_element(), 1);
8931 function renderSlotWithChildren(slot, defaultSlot, children) {
8932 return (0, import_element10.cloneElement)(slot ?? defaultSlot, { children });
8933 }
8934
8935 // packages/ui/build-module/lock-unlock.mjs
8936 var import_private_apis = __toESM(require_private_apis(), 1);
8937 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
8938 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
8939 "@wordpress/ui"
8940 );
8941
8942 // packages/ui/build-module/stack/stack.mjs
8943 var import_element11 = __toESM(require_element(), 1);
8944 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
8945 function getRuntime2() {
8946 const globalScope = globalThis;
8947 if (globalScope.__wpStyleRuntime) {
8948 return globalScope.__wpStyleRuntime;
8949 }
8950 globalScope.__wpStyleRuntime = {
8951 documents: /* @__PURE__ */ new Map(),
8952 styles: /* @__PURE__ */ new Map(),
8953 injectedStyles: /* @__PURE__ */ new WeakMap()
8954 };
8955 if (typeof document !== "undefined") {
8956 registerDocument2(document);
8957 }
8958 return globalScope.__wpStyleRuntime;
8959 }
8960 function documentContainsStyleHash2(targetDocument, hash) {
8961 if (!targetDocument.head) {
8962 return false;
8963 }
8964 for (const style of targetDocument.head.querySelectorAll(
8965 `style[${STYLE_HASH_ATTRIBUTE2}]`
8966 )) {
8967 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
8968 return true;
8969 }
8970 }
8971 return false;
8972 }
8973 function injectStyle2(targetDocument, hash, css) {
8974 if (!targetDocument.head) {
8975 return;
8976 }
8977 const runtime = getRuntime2();
8978 let injectedStyles = runtime.injectedStyles.get(targetDocument);
8979 if (!injectedStyles) {
8980 injectedStyles = /* @__PURE__ */ new Set();
8981 runtime.injectedStyles.set(targetDocument, injectedStyles);
8982 }
8983 if (injectedStyles.has(hash)) {
8984 return;
8985 }
8986 if (documentContainsStyleHash2(targetDocument, hash)) {
8987 injectedStyles.add(hash);
8988 return;
8989 }
8990 const style = targetDocument.createElement("style");
8991 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
8992 style.appendChild(targetDocument.createTextNode(css));
8993 targetDocument.head.appendChild(style);
8994 injectedStyles.add(hash);
8995 }
8996 function registerDocument2(targetDocument) {
8997 const runtime = getRuntime2();
8998 runtime.documents.set(
8999 targetDocument,
9000 (runtime.documents.get(targetDocument) ?? 0) + 1
9001 );
9002 for (const [hash, css] of runtime.styles) {
9003 injectStyle2(targetDocument, hash, css);
9004 }
9005 return () => {
9006 const count = runtime.documents.get(targetDocument);
9007 if (count === void 0) {
9008 return;
9009 }
9010 if (count <= 1) {
9011 runtime.documents.delete(targetDocument);
9012 return;
9013 }
9014 runtime.documents.set(targetDocument, count - 1);
9015 };
9016 }
9017 function registerStyle2(hash, css) {
9018 const runtime = getRuntime2();
9019 runtime.styles.set(hash, css);
9020 for (const targetDocument of runtime.documents.keys()) {
9021 injectStyle2(targetDocument, hash, css);
9022 }
9023 }
9024 if (typeof process === "undefined" || true) {
9025 registerStyle2("b51ff41489", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._19ce0419607e1896__stack{display:flex}}");
9026 }
9027 var style_default2 = { "stack": "_19ce0419607e1896__stack" };
9028 var gapTokens = {
9029 xs: "var(--wpds-dimension-gap-xs, 4px)",
9030 sm: "var(--wpds-dimension-gap-sm, 8px)",
9031 md: "var(--wpds-dimension-gap-md, 12px)",
9032 lg: "var(--wpds-dimension-gap-lg, 16px)",
9033 xl: "var(--wpds-dimension-gap-xl, 24px)",
9034 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
9035 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
9036 };
9037 var Stack = (0, import_element11.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
9038 const style = {
9039 gap: gap && gapTokens[gap],
9040 alignItems: align,
9041 justifyContent: justify,
9042 flexDirection: direction,
9043 flexWrap: wrap
9044 };
9045 const element = useRender({
9046 render: render4,
9047 ref,
9048 props: mergeProps(props, { style, className: style_default2.stack })
9049 });
9050 return element;
9051 });
9052
9053 // packages/ui/build-module/tooltip/index.mjs
9054 var tooltip_exports = {};
9055 __export(tooltip_exports, {
9056 Popup: () => Popup,
9057 Portal: () => Portal,
9058 Positioner: () => Positioner,
9059 Provider: () => Provider,
9060 Root: () => Root,
9061 Trigger: () => Trigger
9062 });
9063
9064 // packages/ui/build-module/tooltip/popup.mjs
9065 var import_element14 = __toESM(require_element(), 1);
9066 var import_theme = __toESM(require_theme(), 1);
9067
9068 // packages/ui/build-module/tooltip/portal.mjs
9069 var import_element12 = __toESM(require_element(), 1);
9070
9071 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
9072 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
9073 function getRuntime3() {
9074 const globalScope = globalThis;
9075 if (globalScope.__wpStyleRuntime) {
9076 return globalScope.__wpStyleRuntime;
9077 }
9078 globalScope.__wpStyleRuntime = {
9079 documents: /* @__PURE__ */ new Map(),
9080 styles: /* @__PURE__ */ new Map(),
9081 injectedStyles: /* @__PURE__ */ new WeakMap()
9082 };
9083 if (typeof document !== "undefined") {
9084 registerDocument3(document);
9085 }
9086 return globalScope.__wpStyleRuntime;
9087 }
9088 function documentContainsStyleHash3(targetDocument, hash) {
9089 if (!targetDocument.head) {
9090 return false;
9091 }
9092 for (const style of targetDocument.head.querySelectorAll(
9093 `style[${STYLE_HASH_ATTRIBUTE3}]`
9094 )) {
9095 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
9096 return true;
9097 }
9098 }
9099 return false;
9100 }
9101 function injectStyle3(targetDocument, hash, css) {
9102 if (!targetDocument.head) {
9103 return;
9104 }
9105 const runtime = getRuntime3();
9106 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9107 if (!injectedStyles) {
9108 injectedStyles = /* @__PURE__ */ new Set();
9109 runtime.injectedStyles.set(targetDocument, injectedStyles);
9110 }
9111 if (injectedStyles.has(hash)) {
9112 return;
9113 }
9114 if (documentContainsStyleHash3(targetDocument, hash)) {
9115 injectedStyles.add(hash);
9116 return;
9117 }
9118 const style = targetDocument.createElement("style");
9119 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
9120 style.appendChild(targetDocument.createTextNode(css));
9121 targetDocument.head.appendChild(style);
9122 injectedStyles.add(hash);
9123 }
9124 function registerDocument3(targetDocument) {
9125 const runtime = getRuntime3();
9126 runtime.documents.set(
9127 targetDocument,
9128 (runtime.documents.get(targetDocument) ?? 0) + 1
9129 );
9130 for (const [hash, css] of runtime.styles) {
9131 injectStyle3(targetDocument, hash, css);
9132 }
9133 return () => {
9134 const count = runtime.documents.get(targetDocument);
9135 if (count === void 0) {
9136 return;
9137 }
9138 if (count <= 1) {
9139 runtime.documents.delete(targetDocument);
9140 return;
9141 }
9142 runtime.documents.set(targetDocument, count - 1);
9143 };
9144 }
9145 function registerStyle3(hash, css) {
9146 const runtime = getRuntime3();
9147 runtime.styles.set(hash, css);
9148 for (const targetDocument of runtime.documents.keys()) {
9149 injectStyle3(targetDocument, hash, css);
9150 }
9151 }
9152 if (typeof process === "undefined" || true) {
9153 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}}");
9154 }
9155 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
9156 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
9157 function resolveOwnerDocument() {
9158 return typeof document === "undefined" ? null : document;
9159 }
9160 function isInWordPressEnvironment() {
9161 let topWp;
9162 try {
9163 topWp = window.top?.wp;
9164 } catch {
9165 }
9166 const wp = topWp ?? window.wp;
9167 return typeof wp?.components === "object" && wp.components !== null;
9168 }
9169 var cachedSlot = null;
9170 function createSlot(ownerDocument2) {
9171 const element = ownerDocument2.createElement("div");
9172 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
9173 if (wp_compat_overlay_slot_default.slot) {
9174 element.classList.add(wp_compat_overlay_slot_default.slot);
9175 }
9176 ownerDocument2.body.appendChild(element);
9177 return element;
9178 }
9179 function getWpCompatOverlaySlot() {
9180 if (typeof window === "undefined") {
9181 return void 0;
9182 }
9183 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
9184 return void 0;
9185 }
9186 const ownerDocument2 = resolveOwnerDocument();
9187 if (!ownerDocument2 || !ownerDocument2.body) {
9188 return void 0;
9189 }
9190 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
9191 return cachedSlot;
9192 }
9193 const existing = ownerDocument2.querySelector(
9194 `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
9195 );
9196 if (existing instanceof HTMLDivElement) {
9197 cachedSlot = existing;
9198 return existing;
9199 }
9200 if (cachedSlot?.isConnected) {
9201 cachedSlot.remove();
9202 }
9203 cachedSlot = createSlot(ownerDocument2);
9204 return cachedSlot;
9205 }
9206
9207 // packages/ui/build-module/tooltip/portal.mjs
9208 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
9209 var Portal = (0, import_element12.forwardRef)(
9210 function TooltipPortal3({ container, ...restProps }, ref) {
9211 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
9212 index_parts_exports.Portal,
9213 {
9214 container: container ?? getWpCompatOverlaySlot(),
9215 ...restProps,
9216 ref
9217 }
9218 );
9219 }
9220 );
9221
9222 // packages/ui/build-module/tooltip/positioner.mjs
9223 var import_element13 = __toESM(require_element(), 1);
9224 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
9225 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
9226 function getRuntime4() {
9227 const globalScope = globalThis;
9228 if (globalScope.__wpStyleRuntime) {
9229 return globalScope.__wpStyleRuntime;
9230 }
9231 globalScope.__wpStyleRuntime = {
9232 documents: /* @__PURE__ */ new Map(),
9233 styles: /* @__PURE__ */ new Map(),
9234 injectedStyles: /* @__PURE__ */ new WeakMap()
9235 };
9236 if (typeof document !== "undefined") {
9237 registerDocument4(document);
9238 }
9239 return globalScope.__wpStyleRuntime;
9240 }
9241 function documentContainsStyleHash4(targetDocument, hash) {
9242 if (!targetDocument.head) {
9243 return false;
9244 }
9245 for (const style of targetDocument.head.querySelectorAll(
9246 `style[${STYLE_HASH_ATTRIBUTE4}]`
9247 )) {
9248 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
9249 return true;
9250 }
9251 }
9252 return false;
9253 }
9254 function injectStyle4(targetDocument, hash, css) {
9255 if (!targetDocument.head) {
9256 return;
9257 }
9258 const runtime = getRuntime4();
9259 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9260 if (!injectedStyles) {
9261 injectedStyles = /* @__PURE__ */ new Set();
9262 runtime.injectedStyles.set(targetDocument, injectedStyles);
9263 }
9264 if (injectedStyles.has(hash)) {
9265 return;
9266 }
9267 if (documentContainsStyleHash4(targetDocument, hash)) {
9268 injectedStyles.add(hash);
9269 return;
9270 }
9271 const style = targetDocument.createElement("style");
9272 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
9273 style.appendChild(targetDocument.createTextNode(css));
9274 targetDocument.head.appendChild(style);
9275 injectedStyles.add(hash);
9276 }
9277 function registerDocument4(targetDocument) {
9278 const runtime = getRuntime4();
9279 runtime.documents.set(
9280 targetDocument,
9281 (runtime.documents.get(targetDocument) ?? 0) + 1
9282 );
9283 for (const [hash, css] of runtime.styles) {
9284 injectStyle4(targetDocument, hash, css);
9285 }
9286 return () => {
9287 const count = runtime.documents.get(targetDocument);
9288 if (count === void 0) {
9289 return;
9290 }
9291 if (count <= 1) {
9292 runtime.documents.delete(targetDocument);
9293 return;
9294 }
9295 runtime.documents.set(targetDocument, count - 1);
9296 };
9297 }
9298 function registerStyle4(hash, css) {
9299 const runtime = getRuntime4();
9300 runtime.styles.set(hash, css);
9301 for (const targetDocument of runtime.documents.keys()) {
9302 injectStyle4(targetDocument, hash, css);
9303 }
9304 }
9305 if (typeof process === "undefined" || true) {
9306 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}}}");
9307 }
9308 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
9309 if (typeof process === "undefined" || true) {
9310 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}}}');
9311 }
9312 var style_default3 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9313 var Positioner = (0, import_element13.forwardRef)(
9314 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
9315 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
9316 index_parts_exports.Positioner,
9317 {
9318 ref,
9319 align,
9320 side,
9321 sideOffset,
9322 ...props,
9323 className: clsx_default(
9324 resets_default["box-sizing"],
9325 style_default3.positioner,
9326 className
9327 )
9328 }
9329 );
9330 }
9331 );
9332
9333 // packages/ui/build-module/tooltip/popup.mjs
9334 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
9335 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
9336 function getRuntime5() {
9337 const globalScope = globalThis;
9338 if (globalScope.__wpStyleRuntime) {
9339 return globalScope.__wpStyleRuntime;
9340 }
9341 globalScope.__wpStyleRuntime = {
9342 documents: /* @__PURE__ */ new Map(),
9343 styles: /* @__PURE__ */ new Map(),
9344 injectedStyles: /* @__PURE__ */ new WeakMap()
9345 };
9346 if (typeof document !== "undefined") {
9347 registerDocument5(document);
9348 }
9349 return globalScope.__wpStyleRuntime;
9350 }
9351 function documentContainsStyleHash5(targetDocument, hash) {
9352 if (!targetDocument.head) {
9353 return false;
9354 }
9355 for (const style of targetDocument.head.querySelectorAll(
9356 `style[${STYLE_HASH_ATTRIBUTE5}]`
9357 )) {
9358 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
9359 return true;
9360 }
9361 }
9362 return false;
9363 }
9364 function injectStyle5(targetDocument, hash, css) {
9365 if (!targetDocument.head) {
9366 return;
9367 }
9368 const runtime = getRuntime5();
9369 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9370 if (!injectedStyles) {
9371 injectedStyles = /* @__PURE__ */ new Set();
9372 runtime.injectedStyles.set(targetDocument, injectedStyles);
9373 }
9374 if (injectedStyles.has(hash)) {
9375 return;
9376 }
9377 if (documentContainsStyleHash5(targetDocument, hash)) {
9378 injectedStyles.add(hash);
9379 return;
9380 }
9381 const style = targetDocument.createElement("style");
9382 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
9383 style.appendChild(targetDocument.createTextNode(css));
9384 targetDocument.head.appendChild(style);
9385 injectedStyles.add(hash);
9386 }
9387 function registerDocument5(targetDocument) {
9388 const runtime = getRuntime5();
9389 runtime.documents.set(
9390 targetDocument,
9391 (runtime.documents.get(targetDocument) ?? 0) + 1
9392 );
9393 for (const [hash, css] of runtime.styles) {
9394 injectStyle5(targetDocument, hash, css);
9395 }
9396 return () => {
9397 const count = runtime.documents.get(targetDocument);
9398 if (count === void 0) {
9399 return;
9400 }
9401 if (count <= 1) {
9402 runtime.documents.delete(targetDocument);
9403 return;
9404 }
9405 runtime.documents.set(targetDocument, count - 1);
9406 };
9407 }
9408 function registerStyle5(hash, css) {
9409 const runtime = getRuntime5();
9410 runtime.styles.set(hash, css);
9411 for (const targetDocument of runtime.documents.keys()) {
9412 injectStyle5(targetDocument, hash, css);
9413 }
9414 }
9415 if (typeof process === "undefined" || true) {
9416 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}}}');
9417 }
9418 var style_default4 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9419 var ThemeProvider = unlock(import_theme.privateApis).ThemeProvider;
9420 var Popup = (0, import_element14.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
9421 const popupContent = (
9422 /* This should ideally use whatever dark color makes sense,
9423 * and not be hardcoded to #1e1e1e. The solutions would be to:
9424 * - review the design of the tooltip, in case we want to stop
9425 * hardcoding it to a dark background
9426 * - create new semantic tokens as needed (aliasing either the
9427 * "inverted bg" or "perma-dark bg" private tokens) and have
9428 * Tooltip.Popup use them;
9429 * - remove the hardcoded `bg` setting from the `ThemeProvider`
9430 * below
9431 */
9432 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(ThemeProvider, { color: { bg: "#1e1e1e" }, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
9433 index_parts_exports.Popup,
9434 {
9435 ref,
9436 className: clsx_default(style_default4.popup, className),
9437 ...props,
9438 children
9439 }
9440 ) })
9441 );
9442 const positionedPopup = renderSlotWithChildren(
9443 positioner,
9444 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Positioner, {}),
9445 popupContent
9446 );
9447 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Portal, {}), positionedPopup);
9448 });
9449
9450 // packages/ui/build-module/tooltip/trigger.mjs
9451 var import_element15 = __toESM(require_element(), 1);
9452 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
9453 var Trigger = (0, import_element15.forwardRef)(
9454 function TooltipTrigger3(props, ref) {
9455 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(index_parts_exports.Trigger, { ref, ...props });
9456 }
9457 );
9458
9459 // packages/ui/build-module/tooltip/root.mjs
9460 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
9461 function Root(props) {
9462 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(index_parts_exports.Root, { ...props });
9463 }
9464
9465 // packages/ui/build-module/tooltip/provider.mjs
9466 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
9467 function Provider({ ...props }) {
9468 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(index_parts_exports.Provider, { ...props });
9469 }
9470
9471 // packages/ui/build-module/empty-state/index.mjs
9472 var empty_state_exports = {};
9473 __export(empty_state_exports, {
9474 Actions: () => Actions,
9475 Description: () => Description,
9476 Icon: () => Icon3,
9477 Root: () => Root2,
9478 Title: () => Title,
9479 Visual: () => Visual
9480 });
9481
9482 // packages/ui/build-module/empty-state/root.mjs
9483 var import_element16 = __toESM(require_element(), 1);
9484 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash";
9485 function getRuntime6() {
9486 const globalScope = globalThis;
9487 if (globalScope.__wpStyleRuntime) {
9488 return globalScope.__wpStyleRuntime;
9489 }
9490 globalScope.__wpStyleRuntime = {
9491 documents: /* @__PURE__ */ new Map(),
9492 styles: /* @__PURE__ */ new Map(),
9493 injectedStyles: /* @__PURE__ */ new WeakMap()
9494 };
9495 if (typeof document !== "undefined") {
9496 registerDocument6(document);
9497 }
9498 return globalScope.__wpStyleRuntime;
9499 }
9500 function documentContainsStyleHash6(targetDocument, hash) {
9501 if (!targetDocument.head) {
9502 return false;
9503 }
9504 for (const style of targetDocument.head.querySelectorAll(
9505 `style[${STYLE_HASH_ATTRIBUTE6}]`
9506 )) {
9507 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) {
9508 return true;
9509 }
9510 }
9511 return false;
9512 }
9513 function injectStyle6(targetDocument, hash, css) {
9514 if (!targetDocument.head) {
9515 return;
9516 }
9517 const runtime = getRuntime6();
9518 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9519 if (!injectedStyles) {
9520 injectedStyles = /* @__PURE__ */ new Set();
9521 runtime.injectedStyles.set(targetDocument, injectedStyles);
9522 }
9523 if (injectedStyles.has(hash)) {
9524 return;
9525 }
9526 if (documentContainsStyleHash6(targetDocument, hash)) {
9527 injectedStyles.add(hash);
9528 return;
9529 }
9530 const style = targetDocument.createElement("style");
9531 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash);
9532 style.appendChild(targetDocument.createTextNode(css));
9533 targetDocument.head.appendChild(style);
9534 injectedStyles.add(hash);
9535 }
9536 function registerDocument6(targetDocument) {
9537 const runtime = getRuntime6();
9538 runtime.documents.set(
9539 targetDocument,
9540 (runtime.documents.get(targetDocument) ?? 0) + 1
9541 );
9542 for (const [hash, css] of runtime.styles) {
9543 injectStyle6(targetDocument, hash, css);
9544 }
9545 return () => {
9546 const count = runtime.documents.get(targetDocument);
9547 if (count === void 0) {
9548 return;
9549 }
9550 if (count <= 1) {
9551 runtime.documents.delete(targetDocument);
9552 return;
9553 }
9554 runtime.documents.set(targetDocument, count - 1);
9555 };
9556 }
9557 function registerStyle6(hash, css) {
9558 const runtime = getRuntime6();
9559 runtime.styles.set(hash, css);
9560 for (const targetDocument of runtime.documents.keys()) {
9561 injectStyle6(targetDocument, hash, css);
9562 }
9563 }
9564 if (typeof process === "undefined" || true) {
9565 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}}}');
9566 }
9567 var style_default5 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9568 var Root2 = (0, import_element16.forwardRef)(
9569 function EmptyStateRoot({ render: render4, ...props }, ref) {
9570 const className = clsx_default(style_default5.root);
9571 const element = useRender({
9572 defaultTagName: "div",
9573 render: render4,
9574 ref,
9575 props: mergeProps({ className }, props)
9576 });
9577 return element;
9578 }
9579 );
9580
9581 // packages/ui/build-module/empty-state/visual.mjs
9582 var import_element17 = __toESM(require_element(), 1);
9583 var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash";
9584 function getRuntime7() {
9585 const globalScope = globalThis;
9586 if (globalScope.__wpStyleRuntime) {
9587 return globalScope.__wpStyleRuntime;
9588 }
9589 globalScope.__wpStyleRuntime = {
9590 documents: /* @__PURE__ */ new Map(),
9591 styles: /* @__PURE__ */ new Map(),
9592 injectedStyles: /* @__PURE__ */ new WeakMap()
9593 };
9594 if (typeof document !== "undefined") {
9595 registerDocument7(document);
9596 }
9597 return globalScope.__wpStyleRuntime;
9598 }
9599 function documentContainsStyleHash7(targetDocument, hash) {
9600 if (!targetDocument.head) {
9601 return false;
9602 }
9603 for (const style of targetDocument.head.querySelectorAll(
9604 `style[${STYLE_HASH_ATTRIBUTE7}]`
9605 )) {
9606 if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) {
9607 return true;
9608 }
9609 }
9610 return false;
9611 }
9612 function injectStyle7(targetDocument, hash, css) {
9613 if (!targetDocument.head) {
9614 return;
9615 }
9616 const runtime = getRuntime7();
9617 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9618 if (!injectedStyles) {
9619 injectedStyles = /* @__PURE__ */ new Set();
9620 runtime.injectedStyles.set(targetDocument, injectedStyles);
9621 }
9622 if (injectedStyles.has(hash)) {
9623 return;
9624 }
9625 if (documentContainsStyleHash7(targetDocument, hash)) {
9626 injectedStyles.add(hash);
9627 return;
9628 }
9629 const style = targetDocument.createElement("style");
9630 style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash);
9631 style.appendChild(targetDocument.createTextNode(css));
9632 targetDocument.head.appendChild(style);
9633 injectedStyles.add(hash);
9634 }
9635 function registerDocument7(targetDocument) {
9636 const runtime = getRuntime7();
9637 runtime.documents.set(
9638 targetDocument,
9639 (runtime.documents.get(targetDocument) ?? 0) + 1
9640 );
9641 for (const [hash, css] of runtime.styles) {
9642 injectStyle7(targetDocument, hash, css);
9643 }
9644 return () => {
9645 const count = runtime.documents.get(targetDocument);
9646 if (count === void 0) {
9647 return;
9648 }
9649 if (count <= 1) {
9650 runtime.documents.delete(targetDocument);
9651 return;
9652 }
9653 runtime.documents.set(targetDocument, count - 1);
9654 };
9655 }
9656 function registerStyle7(hash, css) {
9657 const runtime = getRuntime7();
9658 runtime.styles.set(hash, css);
9659 for (const targetDocument of runtime.documents.keys()) {
9660 injectStyle7(targetDocument, hash, css);
9661 }
9662 }
9663 if (typeof process === "undefined" || true) {
9664 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}}}');
9665 }
9666 var style_default6 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9667 var Visual = (0, import_element17.forwardRef)(
9668 function EmptyStateVisual({ render: render4, ...props }, ref) {
9669 const className = clsx_default(style_default6.visual);
9670 const element = useRender({
9671 defaultTagName: "div",
9672 render: render4,
9673 ref,
9674 props: mergeProps({ className }, props)
9675 });
9676 return element;
9677 }
9678 );
9679
9680 // packages/ui/build-module/empty-state/icon.mjs
9681 var import_element18 = __toESM(require_element(), 1);
9682 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
9683 var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash";
9684 function getRuntime8() {
9685 const globalScope = globalThis;
9686 if (globalScope.__wpStyleRuntime) {
9687 return globalScope.__wpStyleRuntime;
9688 }
9689 globalScope.__wpStyleRuntime = {
9690 documents: /* @__PURE__ */ new Map(),
9691 styles: /* @__PURE__ */ new Map(),
9692 injectedStyles: /* @__PURE__ */ new WeakMap()
9693 };
9694 if (typeof document !== "undefined") {
9695 registerDocument8(document);
9696 }
9697 return globalScope.__wpStyleRuntime;
9698 }
9699 function documentContainsStyleHash8(targetDocument, hash) {
9700 if (!targetDocument.head) {
9701 return false;
9702 }
9703 for (const style of targetDocument.head.querySelectorAll(
9704 `style[${STYLE_HASH_ATTRIBUTE8}]`
9705 )) {
9706 if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) {
9707 return true;
9708 }
9709 }
9710 return false;
9711 }
9712 function injectStyle8(targetDocument, hash, css) {
9713 if (!targetDocument.head) {
9714 return;
9715 }
9716 const runtime = getRuntime8();
9717 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9718 if (!injectedStyles) {
9719 injectedStyles = /* @__PURE__ */ new Set();
9720 runtime.injectedStyles.set(targetDocument, injectedStyles);
9721 }
9722 if (injectedStyles.has(hash)) {
9723 return;
9724 }
9725 if (documentContainsStyleHash8(targetDocument, hash)) {
9726 injectedStyles.add(hash);
9727 return;
9728 }
9729 const style = targetDocument.createElement("style");
9730 style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash);
9731 style.appendChild(targetDocument.createTextNode(css));
9732 targetDocument.head.appendChild(style);
9733 injectedStyles.add(hash);
9734 }
9735 function registerDocument8(targetDocument) {
9736 const runtime = getRuntime8();
9737 runtime.documents.set(
9738 targetDocument,
9739 (runtime.documents.get(targetDocument) ?? 0) + 1
9740 );
9741 for (const [hash, css] of runtime.styles) {
9742 injectStyle8(targetDocument, hash, css);
9743 }
9744 return () => {
9745 const count = runtime.documents.get(targetDocument);
9746 if (count === void 0) {
9747 return;
9748 }
9749 if (count <= 1) {
9750 runtime.documents.delete(targetDocument);
9751 return;
9752 }
9753 runtime.documents.set(targetDocument, count - 1);
9754 };
9755 }
9756 function registerStyle8(hash, css) {
9757 const runtime = getRuntime8();
9758 runtime.styles.set(hash, css);
9759 for (const targetDocument of runtime.documents.keys()) {
9760 injectStyle8(targetDocument, hash, css);
9761 }
9762 }
9763 if (typeof process === "undefined" || true) {
9764 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}}}');
9765 }
9766 var style_default7 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9767 var Icon3 = (0, import_element18.forwardRef)(
9768 function EmptyStateIcon({ icon, className, ...restProps }, ref) {
9769 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
9770 Visual,
9771 {
9772 ref,
9773 className: clsx_default(style_default7.icon, className),
9774 ...restProps,
9775 children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Icon, { icon })
9776 }
9777 );
9778 }
9779 );
9780
9781 // packages/ui/build-module/empty-state/title.mjs
9782 var import_element19 = __toESM(require_element(), 1);
9783 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
9784 var STYLE_HASH_ATTRIBUTE9 = "data-wp-hash";
9785 function getRuntime9() {
9786 const globalScope = globalThis;
9787 if (globalScope.__wpStyleRuntime) {
9788 return globalScope.__wpStyleRuntime;
9789 }
9790 globalScope.__wpStyleRuntime = {
9791 documents: /* @__PURE__ */ new Map(),
9792 styles: /* @__PURE__ */ new Map(),
9793 injectedStyles: /* @__PURE__ */ new WeakMap()
9794 };
9795 if (typeof document !== "undefined") {
9796 registerDocument9(document);
9797 }
9798 return globalScope.__wpStyleRuntime;
9799 }
9800 function documentContainsStyleHash9(targetDocument, hash) {
9801 if (!targetDocument.head) {
9802 return false;
9803 }
9804 for (const style of targetDocument.head.querySelectorAll(
9805 `style[${STYLE_HASH_ATTRIBUTE9}]`
9806 )) {
9807 if (style.getAttribute(STYLE_HASH_ATTRIBUTE9) === hash) {
9808 return true;
9809 }
9810 }
9811 return false;
9812 }
9813 function injectStyle9(targetDocument, hash, css) {
9814 if (!targetDocument.head) {
9815 return;
9816 }
9817 const runtime = getRuntime9();
9818 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9819 if (!injectedStyles) {
9820 injectedStyles = /* @__PURE__ */ new Set();
9821 runtime.injectedStyles.set(targetDocument, injectedStyles);
9822 }
9823 if (injectedStyles.has(hash)) {
9824 return;
9825 }
9826 if (documentContainsStyleHash9(targetDocument, hash)) {
9827 injectedStyles.add(hash);
9828 return;
9829 }
9830 const style = targetDocument.createElement("style");
9831 style.setAttribute(STYLE_HASH_ATTRIBUTE9, hash);
9832 style.appendChild(targetDocument.createTextNode(css));
9833 targetDocument.head.appendChild(style);
9834 injectedStyles.add(hash);
9835 }
9836 function registerDocument9(targetDocument) {
9837 const runtime = getRuntime9();
9838 runtime.documents.set(
9839 targetDocument,
9840 (runtime.documents.get(targetDocument) ?? 0) + 1
9841 );
9842 for (const [hash, css] of runtime.styles) {
9843 injectStyle9(targetDocument, hash, css);
9844 }
9845 return () => {
9846 const count = runtime.documents.get(targetDocument);
9847 if (count === void 0) {
9848 return;
9849 }
9850 if (count <= 1) {
9851 runtime.documents.delete(targetDocument);
9852 return;
9853 }
9854 runtime.documents.set(targetDocument, count - 1);
9855 };
9856 }
9857 function registerStyle9(hash, css) {
9858 const runtime = getRuntime9();
9859 runtime.styles.set(hash, css);
9860 for (const targetDocument of runtime.documents.keys()) {
9861 injectStyle9(targetDocument, hash, css);
9862 }
9863 }
9864 if (typeof process === "undefined" || true) {
9865 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}}}');
9866 }
9867 var style_default8 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9868 var DEFAULT_TAG = /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h2", {});
9869 var Title = (0, import_element19.forwardRef)(
9870 function EmptyStateTitle({ render: render4 = DEFAULT_TAG, className, children, ...props }, ref) {
9871 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
9872 Text,
9873 {
9874 ref,
9875 variant: "heading-lg",
9876 render: render4,
9877 className: clsx_default(style_default8.title, className),
9878 ...props,
9879 children
9880 }
9881 );
9882 }
9883 );
9884
9885 // packages/ui/build-module/empty-state/description.mjs
9886 var import_element20 = __toESM(require_element(), 1);
9887 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
9888 var STYLE_HASH_ATTRIBUTE10 = "data-wp-hash";
9889 function getRuntime10() {
9890 const globalScope = globalThis;
9891 if (globalScope.__wpStyleRuntime) {
9892 return globalScope.__wpStyleRuntime;
9893 }
9894 globalScope.__wpStyleRuntime = {
9895 documents: /* @__PURE__ */ new Map(),
9896 styles: /* @__PURE__ */ new Map(),
9897 injectedStyles: /* @__PURE__ */ new WeakMap()
9898 };
9899 if (typeof document !== "undefined") {
9900 registerDocument10(document);
9901 }
9902 return globalScope.__wpStyleRuntime;
9903 }
9904 function documentContainsStyleHash10(targetDocument, hash) {
9905 if (!targetDocument.head) {
9906 return false;
9907 }
9908 for (const style of targetDocument.head.querySelectorAll(
9909 `style[${STYLE_HASH_ATTRIBUTE10}]`
9910 )) {
9911 if (style.getAttribute(STYLE_HASH_ATTRIBUTE10) === hash) {
9912 return true;
9913 }
9914 }
9915 return false;
9916 }
9917 function injectStyle10(targetDocument, hash, css) {
9918 if (!targetDocument.head) {
9919 return;
9920 }
9921 const runtime = getRuntime10();
9922 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9923 if (!injectedStyles) {
9924 injectedStyles = /* @__PURE__ */ new Set();
9925 runtime.injectedStyles.set(targetDocument, injectedStyles);
9926 }
9927 if (injectedStyles.has(hash)) {
9928 return;
9929 }
9930 if (documentContainsStyleHash10(targetDocument, hash)) {
9931 injectedStyles.add(hash);
9932 return;
9933 }
9934 const style = targetDocument.createElement("style");
9935 style.setAttribute(STYLE_HASH_ATTRIBUTE10, hash);
9936 style.appendChild(targetDocument.createTextNode(css));
9937 targetDocument.head.appendChild(style);
9938 injectedStyles.add(hash);
9939 }
9940 function registerDocument10(targetDocument) {
9941 const runtime = getRuntime10();
9942 runtime.documents.set(
9943 targetDocument,
9944 (runtime.documents.get(targetDocument) ?? 0) + 1
9945 );
9946 for (const [hash, css] of runtime.styles) {
9947 injectStyle10(targetDocument, hash, css);
9948 }
9949 return () => {
9950 const count = runtime.documents.get(targetDocument);
9951 if (count === void 0) {
9952 return;
9953 }
9954 if (count <= 1) {
9955 runtime.documents.delete(targetDocument);
9956 return;
9957 }
9958 runtime.documents.set(targetDocument, count - 1);
9959 };
9960 }
9961 function registerStyle10(hash, css) {
9962 const runtime = getRuntime10();
9963 runtime.styles.set(hash, css);
9964 for (const targetDocument of runtime.documents.keys()) {
9965 injectStyle10(targetDocument, hash, css);
9966 }
9967 }
9968 if (typeof process === "undefined" || true) {
9969 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}}}');
9970 }
9971 var style_default9 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9972 var DEFAULT_TAG2 = /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", {});
9973 var Description = (0, import_element20.forwardRef)(function EmptyStateDescription({ render: render4 = DEFAULT_TAG2, className, children, ...props }, ref) {
9974 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
9975 Text,
9976 {
9977 ref,
9978 variant: "body-md",
9979 render: render4,
9980 className: clsx_default(style_default9.description, className),
9981 ...props,
9982 children
9983 }
9984 );
9985 });
9986
9987 // packages/ui/build-module/empty-state/actions.mjs
9988 var import_element21 = __toESM(require_element(), 1);
9989 var STYLE_HASH_ATTRIBUTE11 = "data-wp-hash";
9990 function getRuntime11() {
9991 const globalScope = globalThis;
9992 if (globalScope.__wpStyleRuntime) {
9993 return globalScope.__wpStyleRuntime;
9994 }
9995 globalScope.__wpStyleRuntime = {
9996 documents: /* @__PURE__ */ new Map(),
9997 styles: /* @__PURE__ */ new Map(),
9998 injectedStyles: /* @__PURE__ */ new WeakMap()
9999 };
10000 if (typeof document !== "undefined") {
10001 registerDocument11(document);
10002 }
10003 return globalScope.__wpStyleRuntime;
10004 }
10005 function documentContainsStyleHash11(targetDocument, hash) {
10006 if (!targetDocument.head) {
10007 return false;
10008 }
10009 for (const style of targetDocument.head.querySelectorAll(
10010 `style[${STYLE_HASH_ATTRIBUTE11}]`
10011 )) {
10012 if (style.getAttribute(STYLE_HASH_ATTRIBUTE11) === hash) {
10013 return true;
10014 }
10015 }
10016 return false;
10017 }
10018 function injectStyle11(targetDocument, hash, css) {
10019 if (!targetDocument.head) {
10020 return;
10021 }
10022 const runtime = getRuntime11();
10023 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10024 if (!injectedStyles) {
10025 injectedStyles = /* @__PURE__ */ new Set();
10026 runtime.injectedStyles.set(targetDocument, injectedStyles);
10027 }
10028 if (injectedStyles.has(hash)) {
10029 return;
10030 }
10031 if (documentContainsStyleHash11(targetDocument, hash)) {
10032 injectedStyles.add(hash);
10033 return;
10034 }
10035 const style = targetDocument.createElement("style");
10036 style.setAttribute(STYLE_HASH_ATTRIBUTE11, hash);
10037 style.appendChild(targetDocument.createTextNode(css));
10038 targetDocument.head.appendChild(style);
10039 injectedStyles.add(hash);
10040 }
10041 function registerDocument11(targetDocument) {
10042 const runtime = getRuntime11();
10043 runtime.documents.set(
10044 targetDocument,
10045 (runtime.documents.get(targetDocument) ?? 0) + 1
10046 );
10047 for (const [hash, css] of runtime.styles) {
10048 injectStyle11(targetDocument, hash, css);
10049 }
10050 return () => {
10051 const count = runtime.documents.get(targetDocument);
10052 if (count === void 0) {
10053 return;
10054 }
10055 if (count <= 1) {
10056 runtime.documents.delete(targetDocument);
10057 return;
10058 }
10059 runtime.documents.set(targetDocument, count - 1);
10060 };
10061 }
10062 function registerStyle11(hash, css) {
10063 const runtime = getRuntime11();
10064 runtime.styles.set(hash, css);
10065 for (const targetDocument of runtime.documents.keys()) {
10066 injectStyle11(targetDocument, hash, css);
10067 }
10068 }
10069 if (typeof process === "undefined" || true) {
10070 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}}}');
10071 }
10072 var style_default10 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
10073 var Actions = (0, import_element21.forwardRef)(
10074 function EmptyStateActions({ render: render4, ...props }, ref) {
10075 const className = clsx_default(style_default10.actions);
10076 const element = useRender({
10077 defaultTagName: "div",
10078 render: render4,
10079 ref,
10080 props: mergeProps({ className }, props)
10081 });
10082 return element;
10083 }
10084 );
10085
10086 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
10087 var import_element22 = __toESM(require_element(), 1);
10088 var STYLE_HASH_ATTRIBUTE12 = "data-wp-hash";
10089 function getRuntime12() {
10090 const globalScope = globalThis;
10091 if (globalScope.__wpStyleRuntime) {
10092 return globalScope.__wpStyleRuntime;
10093 }
10094 globalScope.__wpStyleRuntime = {
10095 documents: /* @__PURE__ */ new Map(),
10096 styles: /* @__PURE__ */ new Map(),
10097 injectedStyles: /* @__PURE__ */ new WeakMap()
10098 };
10099 if (typeof document !== "undefined") {
10100 registerDocument12(document);
10101 }
10102 return globalScope.__wpStyleRuntime;
10103 }
10104 function documentContainsStyleHash12(targetDocument, hash) {
10105 if (!targetDocument.head) {
10106 return false;
10107 }
10108 for (const style of targetDocument.head.querySelectorAll(
10109 `style[${STYLE_HASH_ATTRIBUTE12}]`
10110 )) {
10111 if (style.getAttribute(STYLE_HASH_ATTRIBUTE12) === hash) {
10112 return true;
10113 }
10114 }
10115 return false;
10116 }
10117 function injectStyle12(targetDocument, hash, css) {
10118 if (!targetDocument.head) {
10119 return;
10120 }
10121 const runtime = getRuntime12();
10122 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10123 if (!injectedStyles) {
10124 injectedStyles = /* @__PURE__ */ new Set();
10125 runtime.injectedStyles.set(targetDocument, injectedStyles);
10126 }
10127 if (injectedStyles.has(hash)) {
10128 return;
10129 }
10130 if (documentContainsStyleHash12(targetDocument, hash)) {
10131 injectedStyles.add(hash);
10132 return;
10133 }
10134 const style = targetDocument.createElement("style");
10135 style.setAttribute(STYLE_HASH_ATTRIBUTE12, hash);
10136 style.appendChild(targetDocument.createTextNode(css));
10137 targetDocument.head.appendChild(style);
10138 injectedStyles.add(hash);
10139 }
10140 function registerDocument12(targetDocument) {
10141 const runtime = getRuntime12();
10142 runtime.documents.set(
10143 targetDocument,
10144 (runtime.documents.get(targetDocument) ?? 0) + 1
10145 );
10146 for (const [hash, css] of runtime.styles) {
10147 injectStyle12(targetDocument, hash, css);
10148 }
10149 return () => {
10150 const count = runtime.documents.get(targetDocument);
10151 if (count === void 0) {
10152 return;
10153 }
10154 if (count <= 1) {
10155 runtime.documents.delete(targetDocument);
10156 return;
10157 }
10158 runtime.documents.set(targetDocument, count - 1);
10159 };
10160 }
10161 function registerStyle12(hash, css) {
10162 const runtime = getRuntime12();
10163 runtime.styles.set(hash, css);
10164 for (const targetDocument of runtime.documents.keys()) {
10165 injectStyle12(targetDocument, hash, css);
10166 }
10167 }
10168 if (typeof process === "undefined" || true) {
10169 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}}");
10170 }
10171 var style_default11 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
10172 var VisuallyHidden = (0, import_element22.forwardRef)(
10173 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
10174 const element = useRender({
10175 render: render4,
10176 ref,
10177 props: mergeProps(
10178 { className: style_default11["visually-hidden"] },
10179 restProps,
10180 {
10181 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
10182 "data-visually-hidden": ""
10183 }
10184 )
10185 });
10186 return element;
10187 }
10188 );
10189
10190 // packages/ui/build-module/link/link.mjs
10191 var import_element23 = __toESM(require_element(), 1);
10192 var import_i18n = __toESM(require_i18n(), 1);
10193 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
10194 var STYLE_HASH_ATTRIBUTE13 = "data-wp-hash";
10195 function getRuntime13() {
10196 const globalScope = globalThis;
10197 if (globalScope.__wpStyleRuntime) {
10198 return globalScope.__wpStyleRuntime;
10199 }
10200 globalScope.__wpStyleRuntime = {
10201 documents: /* @__PURE__ */ new Map(),
10202 styles: /* @__PURE__ */ new Map(),
10203 injectedStyles: /* @__PURE__ */ new WeakMap()
10204 };
10205 if (typeof document !== "undefined") {
10206 registerDocument13(document);
10207 }
10208 return globalScope.__wpStyleRuntime;
10209 }
10210 function documentContainsStyleHash13(targetDocument, hash) {
10211 if (!targetDocument.head) {
10212 return false;
10213 }
10214 for (const style of targetDocument.head.querySelectorAll(
10215 `style[${STYLE_HASH_ATTRIBUTE13}]`
10216 )) {
10217 if (style.getAttribute(STYLE_HASH_ATTRIBUTE13) === hash) {
10218 return true;
10219 }
10220 }
10221 return false;
10222 }
10223 function injectStyle13(targetDocument, hash, css) {
10224 if (!targetDocument.head) {
10225 return;
10226 }
10227 const runtime = getRuntime13();
10228 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10229 if (!injectedStyles) {
10230 injectedStyles = /* @__PURE__ */ new Set();
10231 runtime.injectedStyles.set(targetDocument, injectedStyles);
10232 }
10233 if (injectedStyles.has(hash)) {
10234 return;
10235 }
10236 if (documentContainsStyleHash13(targetDocument, hash)) {
10237 injectedStyles.add(hash);
10238 return;
10239 }
10240 const style = targetDocument.createElement("style");
10241 style.setAttribute(STYLE_HASH_ATTRIBUTE13, hash);
10242 style.appendChild(targetDocument.createTextNode(css));
10243 targetDocument.head.appendChild(style);
10244 injectedStyles.add(hash);
10245 }
10246 function registerDocument13(targetDocument) {
10247 const runtime = getRuntime13();
10248 runtime.documents.set(
10249 targetDocument,
10250 (runtime.documents.get(targetDocument) ?? 0) + 1
10251 );
10252 for (const [hash, css] of runtime.styles) {
10253 injectStyle13(targetDocument, hash, css);
10254 }
10255 return () => {
10256 const count = runtime.documents.get(targetDocument);
10257 if (count === void 0) {
10258 return;
10259 }
10260 if (count <= 1) {
10261 runtime.documents.delete(targetDocument);
10262 return;
10263 }
10264 runtime.documents.set(targetDocument, count - 1);
10265 };
10266 }
10267 function registerStyle13(hash, css) {
10268 const runtime = getRuntime13();
10269 runtime.styles.set(hash, css);
10270 for (const targetDocument of runtime.documents.keys()) {
10271 injectStyle13(targetDocument, hash, css);
10272 }
10273 }
10274 if (typeof process === "undefined" || true) {
10275 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}}}");
10276 }
10277 var resets_default2 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
10278 if (typeof process === "undefined" || true) {
10279 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))}}");
10280 }
10281 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" };
10282 if (typeof process === "undefined" || true) {
10283 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"}}');
10284 }
10285 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" };
10286 if (typeof process === "undefined" || true) {
10287 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)}");
10288 }
10289 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" };
10290 var Link = (0, import_element23.forwardRef)(function Link2({
10291 children,
10292 variant = "default",
10293 tone = "brand",
10294 openInNewTab = false,
10295 render: render4,
10296 className,
10297 ...props
10298 }, ref) {
10299 const element = useRender({
10300 render: render4,
10301 defaultTagName: "a",
10302 ref,
10303 props: mergeProps(props, {
10304 className: clsx_default(
10305 global_css_defense_default2.a,
10306 resets_default2["box-sizing"],
10307 focus_default["outset-ring--focus"],
10308 variant !== "unstyled" && style_default12.link,
10309 variant !== "unstyled" && style_default12[`is-${tone}`],
10310 variant === "unstyled" && style_default12["is-unstyled"],
10311 className
10312 ),
10313 target: openInNewTab ? "_blank" : void 0,
10314 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
10315 children,
10316 openInNewTab && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
10317 "span",
10318 {
10319 className: style_default12["link-icon"],
10320 role: "img",
10321 "aria-label": (
10322 /* translators: accessibility text appended to link text */
10323 (0, import_i18n.__)("(opens in a new tab)")
10324 )
10325 }
10326 )
10327 ] })
10328 })
10329 });
10330 return element;
10331 });
10332
10333 // packages/dataviews/build-module/dataviews/index.mjs
10334 var import_element79 = __toESM(require_element(), 1);
10335 var import_compose12 = __toESM(require_compose(), 1);
10336
10337 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10338 var import_element24 = __toESM(require_element(), 1);
10339
10340 // packages/dataviews/build-module/constants.mjs
10341 var import_i18n2 = __toESM(require_i18n(), 1);
10342 var OPERATOR_IS_ANY = "isAny";
10343 var OPERATOR_IS_NONE = "isNone";
10344 var OPERATOR_IS_ALL = "isAll";
10345 var OPERATOR_IS_NOT_ALL = "isNotAll";
10346 var OPERATOR_BETWEEN = "between";
10347 var OPERATOR_IN_THE_PAST = "inThePast";
10348 var OPERATOR_OVER = "over";
10349 var OPERATOR_IS = "is";
10350 var OPERATOR_IS_NOT = "isNot";
10351 var OPERATOR_LESS_THAN = "lessThan";
10352 var OPERATOR_GREATER_THAN = "greaterThan";
10353 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
10354 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
10355 var OPERATOR_BEFORE = "before";
10356 var OPERATOR_AFTER = "after";
10357 var OPERATOR_BEFORE_INC = "beforeInc";
10358 var OPERATOR_AFTER_INC = "afterInc";
10359 var OPERATOR_CONTAINS = "contains";
10360 var OPERATOR_NOT_CONTAINS = "notContains";
10361 var OPERATOR_STARTS_WITH = "startsWith";
10362 var OPERATOR_ON = "on";
10363 var OPERATOR_NOT_ON = "notOn";
10364 var SORTING_DIRECTIONS = ["asc", "desc"];
10365 var sortArrows = { asc: "\u2191", desc: "\u2193" };
10366 var sortValues = { asc: "ascending", desc: "descending" };
10367 var sortLabels = {
10368 asc: (0, import_i18n2.__)("Sort ascending"),
10369 desc: (0, import_i18n2.__)("Sort descending")
10370 };
10371 var sortIcons = {
10372 asc: arrow_up_default,
10373 desc: arrow_down_default
10374 };
10375 var LAYOUT_TABLE = "table";
10376 var LAYOUT_GRID = "grid";
10377 var LAYOUT_LIST = "list";
10378 var LAYOUT_ACTIVITY = "activity";
10379 var LAYOUT_PICKER_GRID = "pickerGrid";
10380 var LAYOUT_PICKER_TABLE = "pickerTable";
10381
10382 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10383 var DataViewsContext = (0, import_element24.createContext)({
10384 view: { type: LAYOUT_TABLE },
10385 onChangeView: () => {
10386 },
10387 fields: [],
10388 data: [],
10389 paginationInfo: {
10390 totalItems: 0,
10391 totalPages: 0
10392 },
10393 selection: [],
10394 onChangeSelection: () => {
10395 },
10396 setOpenedFilter: () => {
10397 },
10398 openedFilter: null,
10399 getItemId: (item) => item.id,
10400 isItemClickable: () => true,
10401 renderItemLink: void 0,
10402 containerWidth: 0,
10403 containerRef: (0, import_element24.createRef)(),
10404 resizeObserverRef: () => {
10405 },
10406 defaultLayouts: { list: {}, grid: {}, table: {} },
10407 filters: [],
10408 isShowingFilter: false,
10409 setIsShowingFilter: () => {
10410 },
10411 hasInitiallyLoaded: false,
10412 config: {
10413 perPageSizes: []
10414 },
10415 intersectionObserver: null
10416 });
10417 DataViewsContext.displayName = "DataViewsContext";
10418 var dataviews_context_default = DataViewsContext;
10419
10420 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
10421 var import_i18n22 = __toESM(require_i18n(), 1);
10422
10423 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
10424 var import_i18n10 = __toESM(require_i18n(), 1);
10425 var import_components6 = __toESM(require_components(), 1);
10426 var import_element32 = __toESM(require_element(), 1);
10427 var import_keycodes = __toESM(require_keycodes(), 1);
10428
10429 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
10430 var import_components = __toESM(require_components(), 1);
10431 var import_i18n3 = __toESM(require_i18n(), 1);
10432 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
10433 function DataViewsSelectionCheckbox({
10434 selection,
10435 onChangeSelection,
10436 item,
10437 getItemId,
10438 titleField,
10439 disabled: disabled2,
10440 ...extraProps
10441 }) {
10442 const id = getItemId(item);
10443 const isInSelectionArray = selection.includes(id);
10444 const checked = !disabled2 && isInSelectionArray;
10445 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n3.__)("(no title)");
10446 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10447 import_components.CheckboxControl,
10448 {
10449 className: "dataviews-selection-checkbox",
10450 "aria-label": selectionLabel,
10451 "aria-disabled": disabled2,
10452 checked,
10453 onChange: () => {
10454 if (disabled2) {
10455 return;
10456 }
10457 onChangeSelection(
10458 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
10459 );
10460 },
10461 ...extraProps
10462 }
10463 );
10464 }
10465
10466 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10467 var import_components2 = __toESM(require_components(), 1);
10468 var import_i18n4 = __toESM(require_i18n(), 1);
10469 var import_element25 = __toESM(require_element(), 1);
10470 var import_data = __toESM(require_data(), 1);
10471 var import_compose = __toESM(require_compose(), 1);
10472
10473 // packages/dataviews/build-module/lock-unlock.mjs
10474 var import_private_apis2 = __toESM(require_private_apis(), 1);
10475 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
10476 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
10477 "@wordpress/dataviews"
10478 );
10479
10480 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10481 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
10482 var { Menu, kebabCase } = unlock2(import_components2.privateApis);
10483 function ButtonTrigger({
10484 action,
10485 onClick,
10486 items,
10487 variant
10488 }) {
10489 const label = typeof action.label === "string" ? action.label : action.label(items);
10490 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10491 import_components2.Button,
10492 {
10493 disabled: !!action.disabled,
10494 accessibleWhenDisabled: true,
10495 size: "compact",
10496 variant,
10497 onClick,
10498 children: label
10499 }
10500 );
10501 }
10502 function MenuItemTrigger({
10503 action,
10504 onClick,
10505 items
10506 }) {
10507 const label = typeof action.label === "string" ? action.label : action.label(items);
10508 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Menu.ItemLabel, { children: label }) });
10509 }
10510 function ActionModal({
10511 action,
10512 items,
10513 closeModal
10514 }) {
10515 const label = typeof action.label === "string" ? action.label : action.label(items);
10516 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
10517 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10518 import_components2.Modal,
10519 {
10520 title: modalHeader || label,
10521 __experimentalHideHeader: !!action.hideModalHeader,
10522 onRequestClose: closeModal,
10523 focusOnMount: action.modalFocusOnMount ?? true,
10524 size: action.modalSize || "medium",
10525 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
10526 action.id
10527 )}`,
10528 children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(action.RenderModal, { items, closeModal })
10529 }
10530 );
10531 }
10532 function ActionsMenuGroup({
10533 actions,
10534 item,
10535 registry,
10536 setActiveModalAction
10537 }) {
10538 const { primaryActions, regularActions } = (0, import_element25.useMemo)(() => {
10539 return actions.reduce(
10540 (acc, action) => {
10541 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
10542 return acc;
10543 },
10544 {
10545 primaryActions: [],
10546 regularActions: []
10547 }
10548 );
10549 }, [actions]);
10550 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10551 MenuItemTrigger,
10552 {
10553 action,
10554 onClick: () => {
10555 if ("RenderModal" in action) {
10556 setActiveModalAction(action);
10557 return;
10558 }
10559 action.callback([item], { registry });
10560 },
10561 items: [item]
10562 },
10563 action.id
10564 ));
10565 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(Menu.Group, { children: [
10566 renderActionGroup(primaryActions),
10567 renderActionGroup(regularActions)
10568 ] });
10569 }
10570 function ItemActions({
10571 item,
10572 actions,
10573 isCompact
10574 }) {
10575 const registry = (0, import_data.useRegistry)();
10576 const { primaryActions, eligibleActions } = (0, import_element25.useMemo)(() => {
10577 const _eligibleActions = actions.filter(
10578 (action) => !action.isEligible || action.isEligible(item)
10579 );
10580 const _primaryActions = _eligibleActions.filter(
10581 (action) => action.isPrimary
10582 );
10583 return {
10584 primaryActions: _primaryActions,
10585 eligibleActions: _eligibleActions
10586 };
10587 }, [actions, item]);
10588 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10589 if (isCompact) {
10590 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10591 CompactItemActions,
10592 {
10593 item,
10594 actions: eligibleActions,
10595 isSmall: true,
10596 registry
10597 }
10598 );
10599 }
10600 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
10601 Stack,
10602 {
10603 direction: "row",
10604 justify: "flex-end",
10605 className: "dataviews-item-actions",
10606 style: {
10607 flexShrink: 0,
10608 width: "auto"
10609 },
10610 children: [
10611 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10612 PrimaryActions,
10613 {
10614 item,
10615 actions: primaryActions,
10616 registry
10617 }
10618 ),
10619 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
10620 // there if there are any actions at all.
10621 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10622 CompactItemActions,
10623 {
10624 item,
10625 actions: eligibleActions,
10626 registry
10627 }
10628 )
10629 ]
10630 }
10631 );
10632 }
10633 function CompactItemActions({
10634 item,
10635 actions,
10636 isSmall,
10637 registry
10638 }) {
10639 const [activeModalAction, setActiveModalAction] = (0, import_element25.useState)(
10640 null
10641 );
10642 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
10643 /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(Menu, { placement: "bottom-end", children: [
10644 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10645 Menu.TriggerButton,
10646 {
10647 render: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10648 import_components2.Button,
10649 {
10650 size: isSmall ? "small" : "compact",
10651 icon: more_vertical_default,
10652 label: (0, import_i18n4.__)("Actions"),
10653 accessibleWhenDisabled: true,
10654 disabled: !actions.length,
10655 className: "dataviews-all-actions-button"
10656 }
10657 )
10658 }
10659 ),
10660 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10661 ActionsMenuGroup,
10662 {
10663 actions,
10664 item,
10665 registry,
10666 setActiveModalAction
10667 }
10668 ) })
10669 ] }),
10670 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10671 ActionModal,
10672 {
10673 action: activeModalAction,
10674 items: [item],
10675 closeModal: () => setActiveModalAction(null)
10676 }
10677 )
10678 ] });
10679 }
10680 function PrimaryActions({
10681 item,
10682 actions,
10683 registry,
10684 buttonVariant
10685 }) {
10686 const [activeModalAction, setActiveModalAction] = (0, import_element25.useState)(null);
10687 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10688 if (isMobileViewport) {
10689 return null;
10690 }
10691 if (!Array.isArray(actions) || actions.length === 0) {
10692 return null;
10693 }
10694 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
10695 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10696 ButtonTrigger,
10697 {
10698 action,
10699 onClick: () => {
10700 if ("RenderModal" in action) {
10701 setActiveModalAction(action);
10702 return;
10703 }
10704 action.callback([item], { registry });
10705 },
10706 items: [item],
10707 variant: buttonVariant
10708 },
10709 action.id
10710 )),
10711 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10712 ActionModal,
10713 {
10714 action: activeModalAction,
10715 items: [item],
10716 closeModal: () => setActiveModalAction(null)
10717 }
10718 )
10719 ] });
10720 }
10721
10722 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10723 var import_components3 = __toESM(require_components(), 1);
10724 var import_i18n6 = __toESM(require_i18n(), 1);
10725 var import_element26 = __toESM(require_element(), 1);
10726 var import_data2 = __toESM(require_data(), 1);
10727 var import_compose2 = __toESM(require_compose(), 1);
10728
10729 // packages/dataviews/build-module/utils/get-footer-message.mjs
10730 var import_i18n5 = __toESM(require_i18n(), 1);
10731 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
10732 if (selectionCount > 0) {
10733 return (0, import_i18n5.sprintf)(
10734 /* translators: %d: number of items. */
10735 (0, import_i18n5._n)("%d Item selected", "%d Items selected", selectionCount),
10736 selectionCount
10737 );
10738 }
10739 if (onlyTotalCount || totalItems <= itemsCount) {
10740 return (0, import_i18n5.sprintf)(
10741 /* translators: %d: number of items. */
10742 (0, import_i18n5._n)("%d Item", "%d Items", totalItems),
10743 totalItems
10744 );
10745 }
10746 return (0, import_i18n5.sprintf)(
10747 /* translators: %1$d: number of items. %2$d: total number of items. */
10748 (0, import_i18n5._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
10749 itemsCount,
10750 totalItems
10751 );
10752 }
10753
10754 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10755 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
10756 function ActionWithModal({
10757 action,
10758 items,
10759 ActionTriggerComponent
10760 }) {
10761 const [isModalOpen, setIsModalOpen] = (0, import_element26.useState)(false);
10762 const actionTriggerProps = {
10763 action,
10764 onClick: () => {
10765 setIsModalOpen(true);
10766 },
10767 items
10768 };
10769 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
10770 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ActionTriggerComponent, { ...actionTriggerProps }),
10771 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10772 ActionModal,
10773 {
10774 action,
10775 items,
10776 closeModal: () => setIsModalOpen(false)
10777 }
10778 )
10779 ] });
10780 }
10781 function useHasAPossibleBulkAction(actions, item) {
10782 return (0, import_element26.useMemo)(() => {
10783 return actions.some((action) => {
10784 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
10785 });
10786 }, [actions, item]);
10787 }
10788 function useSomeItemHasAPossibleBulkAction(actions, data) {
10789 return (0, import_element26.useMemo)(() => {
10790 return data.some((item) => {
10791 return actions.some((action) => {
10792 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
10793 });
10794 });
10795 }, [actions, data]);
10796 }
10797 function BulkSelectionCheckbox({
10798 selection,
10799 onChangeSelection,
10800 data,
10801 actions,
10802 getItemId,
10803 disableSelectAll = false
10804 }) {
10805 const selectableItems = (0, import_element26.useMemo)(() => {
10806 return data.filter((item) => {
10807 return actions.some(
10808 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
10809 );
10810 });
10811 }, [data, actions]);
10812 const selectedItems = data.filter(
10813 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
10814 );
10815 const hasSelection = selection.length > 0;
10816 const areAllSelected = selectedItems.length === selectableItems.length;
10817 if (disableSelectAll) {
10818 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10819 import_components3.CheckboxControl,
10820 {
10821 className: "dataviews-view-table-selection-checkbox",
10822 checked: hasSelection,
10823 disabled: !hasSelection,
10824 onChange: () => {
10825 onChangeSelection([]);
10826 },
10827 "aria-label": (0, import_i18n6.__)("Deselect all")
10828 }
10829 );
10830 }
10831 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10832 import_components3.CheckboxControl,
10833 {
10834 className: "dataviews-view-table-selection-checkbox",
10835 checked: areAllSelected,
10836 indeterminate: !areAllSelected && !!selectedItems.length,
10837 onChange: () => {
10838 if (areAllSelected) {
10839 onChangeSelection([]);
10840 } else {
10841 onChangeSelection(
10842 selectableItems.map((item) => getItemId(item))
10843 );
10844 }
10845 },
10846 "aria-label": areAllSelected ? (0, import_i18n6.__)("Deselect all") : (0, import_i18n6.__)("Select all")
10847 }
10848 );
10849 }
10850 function ActionTrigger({
10851 action,
10852 onClick,
10853 isBusy,
10854 items
10855 }) {
10856 const label = typeof action.label === "string" ? action.label : action.label(items);
10857 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
10858 if (isMobile) {
10859 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10860 import_components3.Button,
10861 {
10862 disabled: isBusy,
10863 accessibleWhenDisabled: true,
10864 label,
10865 icon: action.icon,
10866 size: "compact",
10867 onClick,
10868 isBusy
10869 }
10870 );
10871 }
10872 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10873 import_components3.Button,
10874 {
10875 disabled: isBusy,
10876 accessibleWhenDisabled: true,
10877 size: "compact",
10878 onClick,
10879 isBusy,
10880 children: label
10881 }
10882 );
10883 }
10884 var EMPTY_ARRAY2 = [];
10885 function ActionButton({
10886 action,
10887 selectedItems,
10888 actionInProgress,
10889 setActionInProgress
10890 }) {
10891 const registry = (0, import_data2.useRegistry)();
10892 const selectedEligibleItems = (0, import_element26.useMemo)(() => {
10893 return selectedItems.filter((item) => {
10894 return !action.isEligible || action.isEligible(item);
10895 });
10896 }, [action, selectedItems]);
10897 if ("RenderModal" in action) {
10898 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10899 ActionWithModal,
10900 {
10901 action,
10902 items: selectedEligibleItems,
10903 ActionTriggerComponent: ActionTrigger
10904 },
10905 action.id
10906 );
10907 }
10908 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10909 ActionTrigger,
10910 {
10911 action,
10912 onClick: async () => {
10913 setActionInProgress(action.id);
10914 await action.callback(selectedItems, {
10915 registry
10916 });
10917 setActionInProgress(null);
10918 },
10919 items: selectedEligibleItems,
10920 isBusy: actionInProgress === action.id
10921 },
10922 action.id
10923 );
10924 }
10925 function renderFooterContent(data, actions, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) {
10926 const message2 = getFooterMessage(
10927 selection.length,
10928 data.length,
10929 paginationInfo.totalItems,
10930 isInfiniteScroll
10931 );
10932 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
10933 Stack,
10934 {
10935 direction: "row",
10936 className: "dataviews-bulk-actions-footer__container",
10937 gap: "md",
10938 align: "center",
10939 children: [
10940 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10941 BulkSelectionCheckbox,
10942 {
10943 selection,
10944 onChangeSelection,
10945 data,
10946 actions,
10947 getItemId,
10948 disableSelectAll: isInfiniteScroll
10949 }
10950 ),
10951 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }),
10952 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
10953 Stack,
10954 {
10955 direction: "row",
10956 className: "dataviews-bulk-actions-footer__action-buttons",
10957 gap: "xs",
10958 children: [
10959 actionsToShow.map((action) => {
10960 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10961 ActionButton,
10962 {
10963 action,
10964 selectedItems,
10965 actionInProgress,
10966 setActionInProgress
10967 },
10968 action.id
10969 );
10970 }),
10971 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10972 import_components3.Button,
10973 {
10974 icon: close_small_default,
10975 showTooltip: true,
10976 tooltipPosition: "top",
10977 size: "compact",
10978 label: (0, import_i18n6.__)("Cancel"),
10979 disabled: !!actionInProgress,
10980 accessibleWhenDisabled: false,
10981 onClick: () => {
10982 onChangeSelection(EMPTY_ARRAY2);
10983 }
10984 }
10985 )
10986 ]
10987 }
10988 )
10989 ]
10990 }
10991 );
10992 }
10993 function FooterContent({
10994 selection,
10995 actions,
10996 onChangeSelection,
10997 data,
10998 getItemId,
10999 isInfiniteScroll,
11000 paginationInfo
11001 }) {
11002 const [actionInProgress, setActionInProgress] = (0, import_element26.useState)(
11003 null
11004 );
11005 const footerContentRef = (0, import_element26.useRef)(void 0);
11006 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
11007 const bulkActions = (0, import_element26.useMemo)(
11008 () => actions.filter((action) => action.supportsBulk),
11009 [actions]
11010 );
11011 const selectableItems = (0, import_element26.useMemo)(() => {
11012 return data.filter((item) => {
11013 return bulkActions.some(
11014 (action) => !action.isEligible || action.isEligible(item)
11015 );
11016 });
11017 }, [data, bulkActions]);
11018 const selectedItems = (0, import_element26.useMemo)(() => {
11019 return data.filter(
11020 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
11021 );
11022 }, [selection, data, getItemId, selectableItems]);
11023 const actionsToShow = (0, import_element26.useMemo)(
11024 () => actions.filter((action) => {
11025 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some(
11026 (item) => !action.isEligible || action.isEligible(item)
11027 );
11028 }),
11029 [actions, selectedItems, isMobile]
11030 );
11031 if (!actionInProgress) {
11032 if (footerContentRef.current) {
11033 footerContentRef.current = void 0;
11034 }
11035 return renderFooterContent(
11036 data,
11037 actions,
11038 getItemId,
11039 isInfiniteScroll,
11040 selection,
11041 actionsToShow,
11042 selectedItems,
11043 actionInProgress,
11044 setActionInProgress,
11045 onChangeSelection,
11046 paginationInfo
11047 );
11048 } else if (!footerContentRef.current) {
11049 footerContentRef.current = renderFooterContent(
11050 data,
11051 actions,
11052 getItemId,
11053 isInfiniteScroll,
11054 selection,
11055 actionsToShow,
11056 selectedItems,
11057 actionInProgress,
11058 setActionInProgress,
11059 onChangeSelection,
11060 paginationInfo
11061 );
11062 }
11063 return footerContentRef.current;
11064 }
11065 function BulkActionsFooter() {
11066 const {
11067 data,
11068 selection,
11069 actions = EMPTY_ARRAY2,
11070 onChangeSelection,
11071 getItemId,
11072 paginationInfo,
11073 view
11074 } = (0, import_element26.useContext)(dataviews_context_default);
11075 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11076 FooterContent,
11077 {
11078 selection,
11079 onChangeSelection,
11080 data,
11081 actions,
11082 getItemId,
11083 isInfiniteScroll: !!view.infiniteScrollEnabled,
11084 paginationInfo
11085 }
11086 );
11087 }
11088
11089 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
11090 var import_i18n7 = __toESM(require_i18n(), 1);
11091 var import_components4 = __toESM(require_components(), 1);
11092 var import_element27 = __toESM(require_element(), 1);
11093
11094 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
11095 function getHideableFields(view, fields) {
11096 const togglableFields = [
11097 view?.titleField,
11098 view?.mediaField,
11099 view?.descriptionField
11100 ].filter(Boolean);
11101 return fields.filter(
11102 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
11103 );
11104 }
11105
11106 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
11107 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
11108 var { Menu: Menu2 } = unlock2(import_components4.privateApis);
11109 function WithMenuSeparators({ children }) {
11110 return import_element27.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_element27.Fragment, { children: [
11111 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Separator, {}),
11112 child
11113 ] }, i2));
11114 }
11115 var _HeaderMenu = (0, import_element27.forwardRef)(function HeaderMenu({
11116 fieldId,
11117 view,
11118 fields,
11119 onChangeView,
11120 onHide,
11121 setOpenedFilter,
11122 canMove = true,
11123 canInsertLeft = true,
11124 canInsertRight = true
11125 }, ref) {
11126 const visibleFieldIds = view.fields ?? [];
11127 const index2 = visibleFieldIds?.indexOf(fieldId);
11128 const isSorted = view.sort?.field === fieldId;
11129 let isHidable = false;
11130 let isSortable = false;
11131 let canAddFilter = false;
11132 let operators = [];
11133 const field = fields.find((f2) => f2.id === fieldId);
11134 const { setIsShowingFilter } = (0, import_element27.useContext)(dataviews_context_default);
11135 if (!field) {
11136 return null;
11137 }
11138 isHidable = field.enableHiding !== false;
11139 isSortable = field.enableSorting !== false;
11140 const header = field.header;
11141 operators = !!field.filterBy && field.filterBy?.operators || [];
11142 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
11143 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
11144 return header;
11145 }
11146 const hiddenFields = getHideableFields(view, fields).filter(
11147 (f2) => !visibleFieldIds.includes(f2.id)
11148 );
11149 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
11150 const isRtl = (0, import_i18n7.isRTL)();
11151 return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2, { children: [
11152 /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
11153 Menu2.TriggerButton,
11154 {
11155 render: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11156 import_components4.Button,
11157 {
11158 size: "compact",
11159 className: "dataviews-view-table-header-button",
11160 ref,
11161 variant: "tertiary"
11162 }
11163 ),
11164 children: [
11165 header,
11166 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
11167 ]
11168 }
11169 ),
11170 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(WithMenuSeparators, { children: [
11171 isSortable && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
11172 (direction) => {
11173 const isChecked = view.sort && isSorted && view.sort.direction === direction;
11174 const value = `${fieldId}-${direction}`;
11175 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11176 Menu2.RadioItem,
11177 {
11178 name: "view-table-sorting",
11179 value,
11180 checked: isChecked,
11181 onChange: () => {
11182 onChangeView({
11183 ...view,
11184 sort: {
11185 field: fieldId,
11186 direction
11187 },
11188 showLevels: false
11189 });
11190 },
11191 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
11192 },
11193 value
11194 );
11195 }
11196 ) }),
11197 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11198 Menu2.Item,
11199 {
11200 prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: funnel_default }),
11201 onClick: () => {
11202 setOpenedFilter(fieldId);
11203 setIsShowingFilter(true);
11204 onChangeView({
11205 ...view,
11206 page: 1,
11207 filters: [
11208 ...view.filters || [],
11209 {
11210 field: fieldId,
11211 value: void 0,
11212 operator: operators[0]
11213 }
11214 ]
11215 });
11216 },
11217 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Add filter") })
11218 }
11219 ) }),
11220 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2.Group, { children: [
11221 canMove && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11222 Menu2.Item,
11223 {
11224 prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: arrow_left_default }),
11225 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1,
11226 onClick: () => {
11227 const targetIndex = isRtl ? index2 + 1 : index2 - 1;
11228 const newFields = [
11229 ...visibleFieldIds
11230 ];
11231 newFields.splice(index2, 1);
11232 newFields.splice(
11233 targetIndex,
11234 0,
11235 fieldId
11236 );
11237 onChangeView({
11238 ...view,
11239 fields: newFields
11240 });
11241 },
11242 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Move left") })
11243 }
11244 ),
11245 canMove && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11246 Menu2.Item,
11247 {
11248 prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: arrow_right_default }),
11249 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1,
11250 onClick: () => {
11251 const targetIndex = isRtl ? index2 - 1 : index2 + 1;
11252 const newFields = [
11253 ...visibleFieldIds
11254 ];
11255 newFields.splice(index2, 1);
11256 newFields.splice(
11257 targetIndex,
11258 0,
11259 fieldId
11260 );
11261 onChangeView({
11262 ...view,
11263 fields: newFields
11264 });
11265 },
11266 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Move right") })
11267 }
11268 ),
11269 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2, { children: [
11270 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Insert left") }) }),
11271 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11272 const insertIndex = isRtl ? index2 + 1 : index2;
11273 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11274 Menu2.Item,
11275 {
11276 onClick: () => {
11277 onChangeView({
11278 ...view,
11279 fields: [
11280 ...visibleFieldIds.slice(
11281 0,
11282 insertIndex
11283 ),
11284 hiddenField.id,
11285 ...visibleFieldIds.slice(
11286 insertIndex
11287 )
11288 ]
11289 });
11290 },
11291 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11292 },
11293 hiddenField.id
11294 );
11295 }) })
11296 ] }),
11297 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2, { children: [
11298 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Insert right") }) }),
11299 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11300 const insertIndex = isRtl ? index2 : index2 + 1;
11301 return /* @__PURE__ */ (0, import_jsx_runtime51.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_runtime51.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11320 },
11321 hiddenField.id
11322 );
11323 }) })
11324 ] }),
11325 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11326 Menu2.Item,
11327 {
11328 prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: unseen_default }),
11329 onClick: () => {
11330 onHide(field);
11331 onChangeView({
11332 ...view,
11333 fields: visibleFieldIds.filter(
11334 (id) => id !== fieldId
11335 )
11336 });
11337 },
11338 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Hide column") })
11339 }
11340 )
11341 ] })
11342 ] }) })
11343 ] });
11344 });
11345 var ColumnHeaderMenu = _HeaderMenu;
11346 var column_header_menu_default = ColumnHeaderMenu;
11347
11348 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
11349 var import_element28 = __toESM(require_element(), 1);
11350 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
11351 function getClickableItemProps({
11352 item,
11353 isItemClickable,
11354 onClickItem,
11355 className
11356 }) {
11357 if (!isItemClickable(item) || !onClickItem) {
11358 return { className };
11359 }
11360 return {
11361 className: className ? `${className} ${className}--clickable` : void 0,
11362 role: "button",
11363 tabIndex: 0,
11364 onClick: (event) => {
11365 event.stopPropagation();
11366 onClickItem(item);
11367 },
11368 onKeyDown: (event) => {
11369 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11370 event.stopPropagation();
11371 onClickItem(item);
11372 }
11373 }
11374 };
11375 }
11376 function ItemClickWrapper({
11377 item,
11378 isItemClickable,
11379 onClickItem,
11380 renderItemLink,
11381 className,
11382 children,
11383 ...extraProps
11384 }) {
11385 if (!isItemClickable(item)) {
11386 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className, ...extraProps, children });
11387 }
11388 if (renderItemLink) {
11389 const renderedElement = renderItemLink({
11390 item,
11391 className: `${className} ${className}--clickable`,
11392 ...extraProps,
11393 children
11394 });
11395 return (0, import_element28.cloneElement)(renderedElement, {
11396 onClick: (event) => {
11397 event.stopPropagation();
11398 if (renderedElement.props.onClick) {
11399 renderedElement.props.onClick(event);
11400 }
11401 },
11402 onKeyDown: (event) => {
11403 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11404 event.stopPropagation();
11405 if (renderedElement.props.onKeyDown) {
11406 renderedElement.props.onKeyDown(event);
11407 }
11408 }
11409 }
11410 });
11411 }
11412 const clickProps = getClickableItemProps({
11413 item,
11414 isItemClickable,
11415 onClickItem,
11416 className
11417 });
11418 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { ...clickProps, ...extraProps, children });
11419 }
11420
11421 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
11422 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
11423 function ColumnPrimary({
11424 item,
11425 level,
11426 titleField,
11427 mediaField,
11428 descriptionField,
11429 onClickItem,
11430 renderItemLink,
11431 isItemClickable
11432 }) {
11433 return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
11434 mediaField && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11435 ItemClickWrapper,
11436 {
11437 item,
11438 isItemClickable,
11439 onClickItem,
11440 renderItemLink,
11441 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
11442 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
11443 children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11444 mediaField.render,
11445 {
11446 item,
11447 field: mediaField,
11448 config: { sizes: "32px" }
11449 }
11450 )
11451 }
11452 ),
11453 /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
11454 Stack,
11455 {
11456 direction: "column",
11457 align: "flex-start",
11458 className: "dataviews-view-table__primary-column-content",
11459 children: [
11460 titleField && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
11461 ItemClickWrapper,
11462 {
11463 item,
11464 isItemClickable,
11465 onClickItem,
11466 renderItemLink,
11467 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
11468 children: [
11469 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("span", { className: "dataviews-view-table__level", children: [
11470 Array(level).fill("\u2014").join(" "),
11471 "\xA0"
11472 ] }),
11473 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(titleField.render, { item, field: titleField })
11474 ]
11475 }
11476 ),
11477 descriptionField && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11478 descriptionField.render,
11479 {
11480 item,
11481 field: descriptionField
11482 }
11483 )
11484 ]
11485 }
11486 )
11487 ] });
11488 }
11489 var column_primary_default = ColumnPrimary;
11490
11491 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
11492 var import_element29 = __toESM(require_element(), 1);
11493 var import_i18n8 = __toESM(require_i18n(), 1);
11494 var isScrolledToEnd = (element) => {
11495 if ((0, import_i18n8.isRTL)()) {
11496 const scrollLeft = Math.abs(element.scrollLeft);
11497 return scrollLeft <= 1;
11498 }
11499 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
11500 };
11501 function useScrollState({
11502 scrollContainerRef,
11503 enabledHorizontal = false
11504 }) {
11505 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element29.useState)(false);
11506 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element29.useState)(false);
11507 const handleScroll = (0, import_element29.useCallback)(() => {
11508 const scrollContainer = scrollContainerRef.current;
11509 if (!scrollContainer) {
11510 return;
11511 }
11512 if (enabledHorizontal) {
11513 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
11514 }
11515 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
11516 }, [scrollContainerRef, enabledHorizontal]);
11517 (0, import_element29.useEffect)(() => {
11518 if (typeof window === "undefined" || !scrollContainerRef.current) {
11519 return () => {
11520 };
11521 }
11522 const scrollContainer = scrollContainerRef.current;
11523 handleScroll();
11524 scrollContainer.addEventListener("scroll", handleScroll);
11525 window.addEventListener("resize", handleScroll);
11526 return () => {
11527 scrollContainer.removeEventListener("scroll", handleScroll);
11528 window.removeEventListener("resize", handleScroll);
11529 };
11530 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
11531 return { isHorizontalScrollEnd, isVerticallyScrolled };
11532 }
11533
11534 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
11535 function getDataByGroup(data, groupByField) {
11536 return data.reduce((groups, item) => {
11537 const groupName = groupByField.getValue({ item });
11538 if (!groups.has(groupName)) {
11539 groups.set(groupName, []);
11540 }
11541 groups.get(groupName)?.push(item);
11542 return groups;
11543 }, /* @__PURE__ */ new Map());
11544 }
11545
11546 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
11547 var import_components5 = __toESM(require_components(), 1);
11548 var import_i18n9 = __toESM(require_i18n(), 1);
11549 var import_element30 = __toESM(require_element(), 1);
11550 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
11551 function FieldItem({
11552 field,
11553 isVisible: isVisible2,
11554 onToggleVisibility
11555 }) {
11556 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components5.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(Stack, { direction: "row", gap: "sm", justify: "flex-start", align: "center", children: [
11557 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components5.Icon, { icon: check_default }) }),
11558 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
11559 ] }) });
11560 }
11561 function isDefined(item) {
11562 return !!item;
11563 }
11564 function PropertiesSection({
11565 showLabel = true
11566 }) {
11567 const { view, fields, onChangeView } = (0, import_element30.useContext)(dataviews_context_default);
11568 const regularFields = getHideableFields(view, fields);
11569 if (!regularFields?.length) {
11570 return null;
11571 }
11572 const titleField = fields.find((f2) => f2.id === view.titleField);
11573 const previewField = fields.find((f2) => f2.id === view.mediaField);
11574 const descriptionField = fields.find(
11575 (f2) => f2.id === view.descriptionField
11576 );
11577 const lockedFields = [
11578 {
11579 field: titleField,
11580 isVisibleFlag: "showTitle"
11581 },
11582 {
11583 field: previewField,
11584 isVisibleFlag: "showMedia"
11585 },
11586 {
11587 field: descriptionField,
11588 isVisibleFlag: "showDescription"
11589 }
11590 ].filter(({ field }) => isDefined(field));
11591 const visibleFieldIds = view.fields ?? [];
11592 const visibleRegularFieldsCount = regularFields.filter(
11593 (f2) => visibleFieldIds.includes(f2.id)
11594 ).length;
11595 const visibleLockedFields = lockedFields.filter(
11596 ({ isVisibleFlag }) => (
11597 // @ts-expect-error
11598 view[isVisibleFlag] ?? true
11599 )
11600 );
11601 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
11602 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
11603 return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
11604 showLabel && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components5.BaseControl.VisualLabel, { children: (0, import_i18n9.__)("Properties") }),
11605 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11606 Stack,
11607 {
11608 direction: "column",
11609 className: "dataviews-view-config__properties",
11610 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(import_components5.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
11611 lockedFields.map(({ field, isVisibleFlag }) => {
11612 const isVisible2 = view[isVisibleFlag] ?? true;
11613 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
11614 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11615 FieldItem,
11616 {
11617 field: fieldToRender,
11618 isVisible: isVisible2,
11619 onToggleVisibility: () => {
11620 onChangeView({
11621 ...view,
11622 [isVisibleFlag]: !isVisible2
11623 });
11624 }
11625 },
11626 field.id
11627 );
11628 }),
11629 regularFields.map((field) => {
11630 const isVisible2 = visibleFieldIds.includes(field.id);
11631 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
11632 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11633 FieldItem,
11634 {
11635 field: fieldToRender,
11636 isVisible: isVisible2,
11637 onToggleVisibility: () => {
11638 onChangeView({
11639 ...view,
11640 fields: isVisible2 ? visibleFieldIds.filter(
11641 (fieldId) => fieldId !== field.id
11642 ) : [...visibleFieldIds, field.id]
11643 });
11644 }
11645 },
11646 field.id
11647 );
11648 })
11649 ] })
11650 }
11651 )
11652 ] });
11653 }
11654
11655 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
11656 var import_element31 = __toESM(require_element(), 1);
11657 function useDelayedLoading(isLoading, options = { delay: 400 }) {
11658 const [showLoader, setShowLoader] = (0, import_element31.useState)(false);
11659 (0, import_element31.useEffect)(() => {
11660 if (!isLoading) {
11661 return;
11662 }
11663 const timeout = setTimeout(() => {
11664 setShowLoader(true);
11665 }, options.delay);
11666 return () => {
11667 clearTimeout(timeout);
11668 setShowLoader(false);
11669 };
11670 }, [isLoading, options.delay]);
11671 return showLoader;
11672 }
11673
11674 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
11675 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
11676 function getEffectiveAlign(explicitAlign, fieldType) {
11677 if (explicitAlign) {
11678 return explicitAlign;
11679 }
11680 if (fieldType === "integer" || fieldType === "number") {
11681 return "end";
11682 }
11683 return void 0;
11684 }
11685 function TableColumnField({
11686 item,
11687 fields,
11688 column,
11689 align
11690 }) {
11691 const field = fields.find((f2) => f2.id === column);
11692 if (!field) {
11693 return null;
11694 }
11695 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
11696 "dataviews-view-table__cell-align-end": align === "end",
11697 "dataviews-view-table__cell-align-center": align === "center"
11698 });
11699 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(field.render, { item, field }) });
11700 }
11701 function TableRow({
11702 hasBulkActions,
11703 item,
11704 level,
11705 actions,
11706 fields,
11707 id,
11708 view,
11709 titleField,
11710 mediaField,
11711 descriptionField,
11712 selection,
11713 getItemId,
11714 isItemClickable,
11715 onClickItem,
11716 renderItemLink,
11717 onChangeSelection,
11718 isActionsColumnSticky,
11719 posinset
11720 }) {
11721 const { paginationInfo } = (0, import_element32.useContext)(dataviews_context_default);
11722 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
11723 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
11724 const {
11725 showTitle = true,
11726 showMedia = true,
11727 showDescription = true,
11728 infiniteScrollEnabled
11729 } = view;
11730 const isTouchDeviceRef = (0, import_element32.useRef)(false);
11731 const columns = view.fields ?? [];
11732 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
11733 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
11734 "tr",
11735 {
11736 className: clsx_default("dataviews-view-table__row", {
11737 "is-selected": hasPossibleBulkAction && isSelected2,
11738 "has-bulk-actions": hasPossibleBulkAction
11739 }),
11740 onTouchStart: () => {
11741 isTouchDeviceRef.current = true;
11742 },
11743 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
11744 "aria-posinset": posinset,
11745 role: infiniteScrollEnabled ? "article" : void 0,
11746 onMouseDown: (event) => {
11747 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11748 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
11749 event?.preventDefault();
11750 }
11751 },
11752 onClick: (event) => {
11753 if (!hasPossibleBulkAction) {
11754 return;
11755 }
11756 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11757 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") {
11758 onChangeSelection(
11759 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
11760 );
11761 }
11762 },
11763 children: [
11764 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11765 DataViewsSelectionCheckbox,
11766 {
11767 item,
11768 selection,
11769 onChangeSelection,
11770 getItemId,
11771 titleField,
11772 disabled: !hasPossibleBulkAction
11773 }
11774 ) }) }),
11775 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11776 column_primary_default,
11777 {
11778 item,
11779 level,
11780 titleField: showTitle ? titleField : void 0,
11781 mediaField: showMedia ? mediaField : void 0,
11782 descriptionField: showDescription ? descriptionField : void 0,
11783 isItemClickable,
11784 onClickItem,
11785 renderItemLink
11786 }
11787 ) }),
11788 columns.map((column) => {
11789 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
11790 const field = fields.find((f2) => f2.id === column);
11791 const effectiveAlign = getEffectiveAlign(align, field?.type);
11792 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11793 "td",
11794 {
11795 style: {
11796 width,
11797 maxWidth,
11798 minWidth
11799 },
11800 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11801 TableColumnField,
11802 {
11803 fields,
11804 item,
11805 column,
11806 align: effectiveAlign
11807 }
11808 )
11809 },
11810 column
11811 );
11812 }),
11813 !!actions?.length && // Disable reason: we are not making the element interactive,
11814 // but preventing any click events from bubbling up to the
11815 // table row. This allows us to add a click handler to the row
11816 // itself (to toggle row selection) without erroneously
11817 // intercepting click events from ItemActions.
11818 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11819 "td",
11820 {
11821 className: clsx_default("dataviews-view-table__actions-column", {
11822 "dataviews-view-table__actions-column--sticky": true,
11823 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
11824 }),
11825 onClick: (e2) => e2.stopPropagation(),
11826 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ItemActions, { item, actions })
11827 }
11828 )
11829 ]
11830 }
11831 );
11832 }
11833 function ViewTable({
11834 actions,
11835 data,
11836 fields,
11837 getItemId,
11838 getItemLevel,
11839 isLoading = false,
11840 onChangeView,
11841 onChangeSelection,
11842 selection,
11843 setOpenedFilter,
11844 onClickItem,
11845 isItemClickable,
11846 renderItemLink,
11847 view,
11848 className,
11849 empty
11850 }) {
11851 const { containerRef } = (0, import_element32.useContext)(dataviews_context_default);
11852 const isDelayedLoading = useDelayedLoading(isLoading);
11853 const headerMenuRefs = (0, import_element32.useRef)(/* @__PURE__ */ new Map());
11854 const headerMenuToFocusRef = (0, import_element32.useRef)(void 0);
11855 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element32.useState)();
11856 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element32.useState)(null);
11857 (0, import_element32.useEffect)(() => {
11858 if (headerMenuToFocusRef.current) {
11859 headerMenuToFocusRef.current.focus();
11860 headerMenuToFocusRef.current = void 0;
11861 }
11862 });
11863 const tableNoticeId = (0, import_element32.useId)();
11864 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
11865 scrollContainerRef: containerRef,
11866 enabledHorizontal: !!actions?.length
11867 });
11868 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
11869 if (nextHeaderMenuToFocus) {
11870 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
11871 setNextHeaderMenuToFocus(void 0);
11872 return;
11873 }
11874 const onHide = (field) => {
11875 const hidden = headerMenuRefs.current.get(field.id);
11876 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
11877 setNextHeaderMenuToFocus(fallback?.node);
11878 };
11879 const handleHeaderContextMenu = (event) => {
11880 event.preventDefault();
11881 event.stopPropagation();
11882 const virtualAnchor = {
11883 getBoundingClientRect: () => ({
11884 x: event.clientX,
11885 y: event.clientY,
11886 top: event.clientY,
11887 left: event.clientX,
11888 right: event.clientX,
11889 bottom: event.clientY,
11890 width: 0,
11891 height: 0,
11892 toJSON: () => ({})
11893 })
11894 };
11895 window.requestAnimationFrame(() => {
11896 setContextMenuAnchor(virtualAnchor);
11897 });
11898 };
11899 const hasData = !!data?.length;
11900 const titleField = fields.find((field) => field.id === view.titleField);
11901 const mediaField = fields.find((field) => field.id === view.mediaField);
11902 const descriptionField = fields.find(
11903 (field) => field.id === view.descriptionField
11904 );
11905 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
11906 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
11907 const { showTitle = true, showMedia = true, showDescription = true } = view;
11908 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
11909 const columns = view.fields ?? [];
11910 const headerMenuRef = (column, index2) => (node) => {
11911 if (node) {
11912 headerMenuRefs.current.set(column, {
11913 node,
11914 fallback: columns[index2 > 0 ? index2 - 1 : 1]
11915 });
11916 } else {
11917 headerMenuRefs.current.delete(column);
11918 }
11919 };
11920 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
11921 const isRtl = (0, import_i18n10.isRTL)();
11922 if (!hasData) {
11923 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11924 "div",
11925 {
11926 className: clsx_default("dataviews-no-results", {
11927 "is-refreshing": isDelayedLoading
11928 }),
11929 id: tableNoticeId,
11930 children: empty
11931 }
11932 );
11933 }
11934 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
11935 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
11936 "table",
11937 {
11938 className: clsx_default("dataviews-view-table", className, {
11939 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
11940 view.layout.density
11941 ),
11942 "has-bulk-actions": hasBulkActions,
11943 "is-refreshing": !isInfiniteScroll && isDelayedLoading
11944 }),
11945 "aria-busy": isLoading,
11946 "aria-describedby": tableNoticeId,
11947 role: isInfiniteScroll ? "feed" : void 0,
11948 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
11949 children: [
11950 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("colgroup", { children: [
11951 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
11952 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
11953 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11954 "col",
11955 {
11956 className: clsx_default(
11957 `dataviews-view-table__col-${column}`,
11958 {
11959 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1
11960 }
11961 )
11962 },
11963 `col-${column}`
11964 )),
11965 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("col", { className: "dataviews-view-table__col-actions" })
11966 ] }),
11967 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11968 import_components6.Popover,
11969 {
11970 anchor: contextMenuAnchor,
11971 onClose: () => setContextMenuAnchor(null),
11972 placement: "bottom-start",
11973 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(PropertiesSection, { showLabel: false })
11974 }
11975 ),
11976 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11977 "thead",
11978 {
11979 className: clsx_default({
11980 "dataviews-view-table__thead--stuck": isVerticallyScrolled
11981 }),
11982 onContextMenu: handleHeaderContextMenu,
11983 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("tr", { className: "dataviews-view-table__row", children: [
11984 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11985 "th",
11986 {
11987 className: "dataviews-view-table__checkbox-column",
11988 scope: "col",
11989 onContextMenu: handleHeaderContextMenu,
11990 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11991 BulkSelectionCheckbox,
11992 {
11993 selection,
11994 onChangeSelection,
11995 data,
11996 actions,
11997 getItemId
11998 }
11999 )
12000 }
12001 ),
12002 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12003 column_header_menu_default,
12004 {
12005 ref: headerMenuRef(
12006 titleField.id,
12007 0
12008 ),
12009 fieldId: titleField.id,
12010 view,
12011 fields,
12012 onChangeView,
12013 onHide,
12014 setOpenedFilter,
12015 canMove: false,
12016 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
12017 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
12018 }
12019 ) }),
12020 columns.map((column, index2) => {
12021 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
12022 const field = fields.find(
12023 (f2) => f2.id === column
12024 );
12025 const effectiveAlign = getEffectiveAlign(
12026 align,
12027 field?.type
12028 );
12029 const canInsertOrMove = view.layout?.enableMoving ?? true;
12030 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12031 "th",
12032 {
12033 style: {
12034 width,
12035 maxWidth,
12036 minWidth,
12037 textAlign: effectiveAlign
12038 },
12039 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
12040 scope: "col",
12041 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12042 column_header_menu_default,
12043 {
12044 ref: headerMenuRef(column, index2),
12045 fieldId: column,
12046 view,
12047 fields,
12048 onChangeView,
12049 onHide,
12050 setOpenedFilter,
12051 canMove: canInsertOrMove,
12052 canInsertLeft: canInsertOrMove,
12053 canInsertRight: canInsertOrMove
12054 }
12055 )
12056 },
12057 column
12058 );
12059 }),
12060 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12061 "th",
12062 {
12063 className: clsx_default(
12064 "dataviews-view-table__actions-column",
12065 {
12066 "dataviews-view-table__actions-column--sticky": true,
12067 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
12068 }
12069 ),
12070 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n10.__)("Actions") })
12071 }
12072 )
12073 ] })
12074 }
12075 ),
12076 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
12077 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("tbody", { children: [
12078 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12079 "td",
12080 {
12081 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
12082 className: "dataviews-view-table__group-header-cell",
12083 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n10.sprintf)(
12084 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12085 (0, import_i18n10.__)("%1$s: %2$s"),
12086 groupField.label,
12087 groupName
12088 )
12089 }
12090 ) }),
12091 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12092 TableRow,
12093 {
12094 item,
12095 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
12096 hasBulkActions,
12097 actions,
12098 fields,
12099 id: getItemId(item) || index2.toString(),
12100 view,
12101 titleField,
12102 mediaField,
12103 descriptionField,
12104 selection,
12105 getItemId,
12106 onChangeSelection,
12107 onClickItem,
12108 renderItemLink,
12109 isItemClickable,
12110 isActionsColumnSticky: !isHorizontalScrollEnd
12111 },
12112 getItemId(item)
12113 ))
12114 ] }, `group-${groupName}`)
12115 ) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("tbody", { children: hasData && data.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12116 TableRow,
12117 {
12118 item,
12119 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
12120 hasBulkActions,
12121 actions,
12122 fields,
12123 id: getItemId(item) || index2.toString(),
12124 view,
12125 titleField,
12126 mediaField,
12127 descriptionField,
12128 selection,
12129 getItemId,
12130 onChangeSelection,
12131 onClickItem,
12132 renderItemLink,
12133 isItemClickable,
12134 isActionsColumnSticky: !isHorizontalScrollEnd,
12135 posinset: isInfiniteScroll ? index2 + 1 : void 0
12136 },
12137 getItemId(item)
12138 )) })
12139 ]
12140 }
12141 ),
12142 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "dataviews-loading", id: tableNoticeId, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_components6.Spinner, {}) }) })
12143 ] });
12144 }
12145 var table_default = ViewTable;
12146
12147 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12148 var import_components9 = __toESM(require_components(), 1);
12149 var import_i18n13 = __toESM(require_i18n(), 1);
12150
12151 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
12152 var import_components8 = __toESM(require_components(), 1);
12153 var import_i18n12 = __toESM(require_i18n(), 1);
12154 var import_compose3 = __toESM(require_compose(), 1);
12155 var import_keycodes2 = __toESM(require_keycodes(), 1);
12156 var import_element36 = __toESM(require_element(), 1);
12157
12158 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
12159 var import_components7 = __toESM(require_components(), 1);
12160 var import_i18n11 = __toESM(require_i18n(), 1);
12161 var import_element33 = __toESM(require_element(), 1);
12162 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
12163 var imageSizes = [
12164 {
12165 value: 120,
12166 breakpoint: 1
12167 },
12168 {
12169 value: 170,
12170 breakpoint: 1
12171 },
12172 {
12173 value: 230,
12174 breakpoint: 1
12175 },
12176 {
12177 value: 290,
12178 breakpoint: 1112
12179 // at minimum image width, 4 images display at this container size
12180 },
12181 {
12182 value: 350,
12183 breakpoint: 1636
12184 // at minimum image width, 6 images display at this container size
12185 },
12186 {
12187 value: 430,
12188 breakpoint: 588
12189 // at minimum image width, 2 images display at this container size
12190 }
12191 ];
12192 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
12193 function useGridColumns() {
12194 const context = (0, import_element33.useContext)(dataviews_context_default);
12195 const view = context.view;
12196 return (0, import_element33.useMemo)(() => {
12197 const containerWidth = context.containerWidth;
12198 const gap = 32;
12199 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
12200 const columns = Math.floor(
12201 (containerWidth + gap) / (previewSize + gap)
12202 );
12203 return Math.max(1, columns);
12204 }, [context.containerWidth, view.layout?.previewSize]);
12205 }
12206
12207 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
12208 var import_element34 = __toESM(require_element(), 1);
12209 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
12210 var GridItems = (0, import_element34.forwardRef)(({ className, previewSize, ...props }, ref) => {
12211 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12212 "div",
12213 {
12214 ref,
12215 className: clsx_default("dataviews-view-grid-items", className),
12216 style: {
12217 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
12218 },
12219 ...props
12220 }
12221 );
12222 });
12223
12224 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
12225 var import_element35 = __toESM(require_element(), 1);
12226 function useIntersectionObserver(elementRef, posinset) {
12227 const { intersectionObserver } = (0, import_element35.useContext)(dataviews_context_default);
12228 (0, import_element35.useEffect)(() => {
12229 const element = elementRef.current;
12230 if (!element || posinset === void 0 || !intersectionObserver) {
12231 return;
12232 }
12233 intersectionObserver.observe(element);
12234 return () => {
12235 intersectionObserver.unobserve(element);
12236 };
12237 }, [elementRef, intersectionObserver, posinset]);
12238 }
12239 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
12240 const hasData = !!data?.length;
12241 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
12242 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
12243 }
12244
12245 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
12246 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
12247 var { Badge: WCBadge } = unlock2(import_components8.privateApis);
12248 function chunk(array, size4) {
12249 const chunks = [];
12250 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) {
12251 chunks.push(array.slice(i2, i2 + size4));
12252 }
12253 return chunks;
12254 }
12255 var GridItem = (0, import_element36.forwardRef)(
12256 function GridItem2({
12257 view,
12258 selection,
12259 onChangeSelection,
12260 onClickItem,
12261 isItemClickable,
12262 renderItemLink,
12263 getItemId,
12264 item,
12265 actions,
12266 mediaField,
12267 titleField,
12268 descriptionField,
12269 regularFields,
12270 badgeFields,
12271 hasBulkActions,
12272 config,
12273 posinset,
12274 setsize,
12275 ...props
12276 }, forwardedRef) {
12277 const {
12278 showTitle = true,
12279 showMedia = true,
12280 showDescription = true
12281 } = view;
12282 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
12283 const id = getItemId(item);
12284 const elementRef = (0, import_element36.useRef)(null);
12285 const setRefs = (0, import_element36.useCallback)(
12286 (node) => {
12287 elementRef.current = node;
12288 if (typeof forwardedRef === "function") {
12289 forwardedRef(node);
12290 } else if (forwardedRef) {
12291 forwardedRef.current = node;
12292 }
12293 },
12294 [forwardedRef]
12295 );
12296 useIntersectionObserver(elementRef, posinset);
12297 const instanceId = (0, import_compose3.useInstanceId)(GridItem2);
12298 const isSelected2 = selection.includes(id);
12299 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
12300 const rendersMediaField = showMedia && mediaField?.render;
12301 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12302 mediaField.render,
12303 {
12304 item,
12305 field: mediaField,
12306 config
12307 }
12308 ) : mediaPlaceholder;
12309 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(titleField.render, { item, field: titleField }) : null;
12310 let mediaA11yProps;
12311 let titleA11yProps;
12312 if (isItemClickable(item) && onClickItem) {
12313 if (renderedTitleField) {
12314 mediaA11yProps = {
12315 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
12316 };
12317 titleA11yProps = {
12318 id: `dataviews-view-grid__title-field-${instanceId}`
12319 };
12320 } else {
12321 mediaA11yProps = {
12322 "aria-label": (0, import_i18n12.__)("Navigate to item")
12323 };
12324 }
12325 }
12326 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
12327 Stack,
12328 {
12329 direction: "column",
12330 ...props,
12331 ref: setRefs,
12332 "aria-setsize": setsize,
12333 "aria-posinset": posinset,
12334 className: clsx_default(
12335 props.className,
12336 "dataviews-view-grid__row__gridcell",
12337 "dataviews-view-grid__card",
12338 {
12339 "is-selected": hasBulkAction && isSelected2
12340 }
12341 ),
12342 onClickCapture: (event) => {
12343 props.onClickCapture?.(event);
12344 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) {
12345 event.stopPropagation();
12346 event.preventDefault();
12347 if (!hasBulkAction) {
12348 return;
12349 }
12350 onChangeSelection(
12351 isSelected2 ? selection.filter(
12352 (itemId) => id !== itemId
12353 ) : [...selection, id]
12354 );
12355 }
12356 },
12357 children: [
12358 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12359 ItemClickWrapper,
12360 {
12361 item,
12362 isItemClickable,
12363 onClickItem,
12364 renderItemLink,
12365 className: clsx_default("dataviews-view-grid__media", {
12366 "dataviews-view-grid__media--placeholder": !rendersMediaField
12367 }),
12368 ...mediaA11yProps,
12369 children: renderedMediaField
12370 }
12371 ),
12372 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12373 DataViewsSelectionCheckbox,
12374 {
12375 item,
12376 selection,
12377 onChangeSelection,
12378 getItemId,
12379 titleField,
12380 disabled: !hasBulkAction
12381 }
12382 ),
12383 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12384 ItemActions,
12385 {
12386 item,
12387 actions,
12388 isCompact: true
12389 }
12390 ) }),
12391 showTitle && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12392 ItemClickWrapper,
12393 {
12394 item,
12395 isItemClickable,
12396 onClickItem,
12397 renderItemLink,
12398 className: "dataviews-view-grid__title-field dataviews-title-field",
12399 ...titleA11yProps,
12400 title: titleField?.getValueFormatted({
12401 item,
12402 field: titleField
12403 }) || void 0,
12404 children: renderedTitleField
12405 }
12406 ) }),
12407 /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(Stack, { direction: "column", gap: "xs", children: [
12408 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12409 descriptionField.render,
12410 {
12411 item,
12412 field: descriptionField
12413 }
12414 ),
12415 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12416 Stack,
12417 {
12418 direction: "row",
12419 className: "dataviews-view-grid__badge-fields",
12420 gap: "sm",
12421 wrap: "wrap",
12422 align: "top",
12423 justify: "flex-start",
12424 children: badgeFields.map((field) => {
12425 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12426 WCBadge,
12427 {
12428 className: "dataviews-view-grid__field-value",
12429 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12430 field.render,
12431 {
12432 item,
12433 field
12434 }
12435 )
12436 },
12437 field.id
12438 );
12439 })
12440 }
12441 ),
12442 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12443 Stack,
12444 {
12445 direction: "column",
12446 className: "dataviews-view-grid__fields",
12447 gap: "xs",
12448 children: regularFields.map((field) => {
12449 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12450 import_components8.Flex,
12451 {
12452 className: "dataviews-view-grid__field",
12453 gap: 1,
12454 justify: "flex-start",
12455 expanded: true,
12456 style: { height: "auto" },
12457 direction: "row",
12458 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
12459 /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(tooltip_exports.Root, { children: [
12460 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12461 tooltip_exports.Trigger,
12462 {
12463 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components8.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header })
12464 }
12465 ),
12466 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(tooltip_exports.Popup, { children: field.label })
12467 ] }),
12468 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12469 import_components8.FlexItem,
12470 {
12471 className: "dataviews-view-grid__field-value",
12472 style: { maxHeight: "none" },
12473 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12474 field.render,
12475 {
12476 item,
12477 field
12478 }
12479 )
12480 }
12481 )
12482 ] })
12483 },
12484 field.id
12485 );
12486 })
12487 }
12488 )
12489 ] })
12490 ]
12491 }
12492 );
12493 }
12494 );
12495 function CompositeGrid({
12496 data,
12497 isInfiniteScroll,
12498 className,
12499 inert,
12500 isLoading,
12501 view,
12502 fields,
12503 selection,
12504 onChangeSelection,
12505 onClickItem,
12506 isItemClickable,
12507 renderItemLink,
12508 getItemId,
12509 actions
12510 }) {
12511 const { paginationInfo, resizeObserverRef } = (0, import_element36.useContext)(dataviews_context_default);
12512 const gridColumns = useGridColumns();
12513 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
12514 const titleField = fields.find(
12515 (field) => field.id === view?.titleField
12516 );
12517 const mediaField = fields.find(
12518 (field) => field.id === view?.mediaField
12519 );
12520 const descriptionField = fields.find(
12521 (field) => field.id === view?.descriptionField
12522 );
12523 const otherFields = view.fields ?? [];
12524 const { regularFields, badgeFields } = otherFields.reduce(
12525 (accumulator, fieldId) => {
12526 const field = fields.find((f2) => f2.id === fieldId);
12527 if (!field) {
12528 return accumulator;
12529 }
12530 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
12531 accumulator[key].push(field);
12532 return accumulator;
12533 },
12534 { regularFields: [], badgeFields: [] }
12535 );
12536 const size4 = "900px";
12537 const totalRows = Math.ceil(data.length / gridColumns);
12538 const placeholdersNeeded = usePlaceholdersNeeded(
12539 data,
12540 isInfiniteScroll,
12541 gridColumns
12542 );
12543 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, {
12544 // Render infinite scroll layout (no rows, feed semantics)
12545 children: [
12546 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
12547 import_components8.Composite,
12548 {
12549 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12550 GridItems,
12551 {
12552 className: clsx_default(
12553 "dataviews-view-grid-infinite-scroll",
12554 className,
12555 {
12556 [`has-${view.layout?.density}-density`]: view.layout?.density && [
12557 "compact",
12558 "comfortable"
12559 ].includes(view.layout.density)
12560 }
12561 ),
12562 previewSize: view.layout?.previewSize,
12563 "aria-busy": isLoading,
12564 ref: resizeObserverRef
12565 }
12566 ),
12567 role: "feed",
12568 focusWrap: true,
12569 inert,
12570 children: [
12571 Array.from({ length: placeholdersNeeded }).map(
12572 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12573 import_components8.Composite.Item,
12574 {
12575 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12576 Stack,
12577 {
12578 ...props,
12579 direction: "column",
12580 role: "article",
12581 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
12582 }
12583 ),
12584 "aria-hidden": true,
12585 tabIndex: -1
12586 },
12587 `placeholder-${index2}`
12588 )
12589 ),
12590 data.map((item) => {
12591 const itemId = getItemId(item);
12592 const stablePosition = item.position;
12593 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12594 import_components8.Composite.Item,
12595 {
12596 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12597 GridItem,
12598 {
12599 ...props,
12600 id: itemId,
12601 role: "article",
12602 view,
12603 selection,
12604 onChangeSelection,
12605 onClickItem,
12606 isItemClickable,
12607 renderItemLink,
12608 getItemId,
12609 item,
12610 actions,
12611 mediaField,
12612 titleField,
12613 descriptionField,
12614 regularFields,
12615 badgeFields,
12616 hasBulkActions,
12617 posinset: stablePosition,
12618 setsize: paginationInfo.totalItems,
12619 config: {
12620 sizes: size4
12621 }
12622 }
12623 )
12624 },
12625 itemId
12626 );
12627 })
12628 ]
12629 }
12630 ),
12631 // Render standard grid layout (with rows, grid semantics)
12632 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12633 import_components8.Composite,
12634 {
12635 role: "grid",
12636 className: clsx_default("dataviews-view-grid", className, {
12637 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12638 view.layout.density
12639 )
12640 }),
12641 focusWrap: true,
12642 "aria-busy": isLoading,
12643 "aria-rowcount": totalRows,
12644 ref: resizeObserverRef,
12645 inert,
12646 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12647 import_components8.Composite.Row,
12648 {
12649 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12650 "div",
12651 {
12652 role: "row",
12653 "aria-rowindex": i2 + 1,
12654 "aria-label": (0, import_i18n12.sprintf)(
12655 /* translators: %d: The row number in the grid */
12656 (0, import_i18n12.__)("Row %d"),
12657 i2 + 1
12658 ),
12659 className: "dataviews-view-grid__row",
12660 style: {
12661 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
12662 }
12663 }
12664 ),
12665 children: row.map((item) => {
12666 const itemId = getItemId(item);
12667 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12668 import_components8.Composite.Item,
12669 {
12670 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12671 GridItem,
12672 {
12673 ...props,
12674 id: itemId,
12675 role: "gridcell",
12676 view,
12677 selection,
12678 onChangeSelection,
12679 onClickItem,
12680 isItemClickable,
12681 renderItemLink,
12682 getItemId,
12683 item,
12684 actions,
12685 mediaField,
12686 titleField,
12687 descriptionField,
12688 regularFields,
12689 badgeFields,
12690 hasBulkActions,
12691 config: {
12692 sizes: size4
12693 }
12694 }
12695 )
12696 },
12697 itemId
12698 );
12699 })
12700 },
12701 i2
12702 ))
12703 }
12704 )
12705 ]
12706 });
12707 }
12708
12709 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12710 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
12711 function ViewGrid({
12712 actions,
12713 data,
12714 fields,
12715 getItemId,
12716 isLoading,
12717 onChangeSelection,
12718 onClickItem,
12719 isItemClickable,
12720 renderItemLink,
12721 selection,
12722 view,
12723 className,
12724 empty
12725 }) {
12726 const isDelayedLoading = useDelayedLoading(!!isLoading);
12727 const hasData = !!data?.length;
12728 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
12729 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
12730 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12731 if (!hasData) {
12732 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12733 "div",
12734 {
12735 className: clsx_default("dataviews-no-results", {
12736 "is-refreshing": isDelayedLoading
12737 }),
12738 children: empty
12739 }
12740 );
12741 }
12742 const gridProps = {
12743 className: clsx_default(className, {
12744 "is-refreshing": !isInfiniteScroll && isDelayedLoading
12745 }),
12746 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
12747 isLoading,
12748 view,
12749 fields,
12750 selection,
12751 onChangeSelection,
12752 onClickItem,
12753 isItemClickable,
12754 renderItemLink,
12755 getItemId,
12756 actions
12757 };
12758 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, {
12759 // Render multiple groups.
12760 children: [
12761 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
12762 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
12763 Stack,
12764 {
12765 direction: "column",
12766 gap: "sm",
12767 children: [
12768 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n13.sprintf)(
12769 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12770 (0, import_i18n13.__)("%1$s: %2$s"),
12771 groupField.label,
12772 groupName
12773 ) }),
12774 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12775 CompositeGrid,
12776 {
12777 ...gridProps,
12778 data: groupItems,
12779 isInfiniteScroll: false
12780 }
12781 )
12782 ]
12783 },
12784 groupName
12785 )
12786 ) }),
12787 // Render a single grid with all data.
12788 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12789 CompositeGrid,
12790 {
12791 ...gridProps,
12792 data,
12793 isInfiniteScroll: !!isInfiniteScroll
12794 }
12795 ),
12796 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components9.Spinner, {}) })
12797 ]
12798 });
12799 }
12800 var grid_default = ViewGrid;
12801
12802 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
12803 var import_compose4 = __toESM(require_compose(), 1);
12804 var import_components10 = __toESM(require_components(), 1);
12805 var import_element37 = __toESM(require_element(), 1);
12806 var import_i18n14 = __toESM(require_i18n(), 1);
12807 var import_data3 = __toESM(require_data(), 1);
12808 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
12809 var { Menu: Menu3 } = unlock2(import_components10.privateApis);
12810 function generateItemWrapperCompositeId(idPrefix) {
12811 return `${idPrefix}-item-wrapper`;
12812 }
12813 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
12814 return `${idPrefix}-primary-action-${primaryActionId}`;
12815 }
12816 function generateDropdownTriggerCompositeId(idPrefix) {
12817 return `${idPrefix}-dropdown`;
12818 }
12819 function PrimaryActionGridCell({
12820 idPrefix,
12821 primaryAction,
12822 item
12823 }) {
12824 const registry = (0, import_data3.useRegistry)();
12825 const [isModalOpen, setIsModalOpen] = (0, import_element37.useState)(false);
12826 const compositeItemId = generatePrimaryActionCompositeId(
12827 idPrefix,
12828 primaryAction.id
12829 );
12830 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
12831 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12832 import_components10.Composite.Item,
12833 {
12834 id: compositeItemId,
12835 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12836 import_components10.Button,
12837 {
12838 disabled: !!primaryAction.disabled,
12839 accessibleWhenDisabled: true,
12840 text: label,
12841 size: "small",
12842 onClick: () => setIsModalOpen(true)
12843 }
12844 ),
12845 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12846 ActionModal,
12847 {
12848 action: primaryAction,
12849 items: [item],
12850 closeModal: () => setIsModalOpen(false)
12851 }
12852 )
12853 }
12854 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12855 import_components10.Composite.Item,
12856 {
12857 id: compositeItemId,
12858 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12859 import_components10.Button,
12860 {
12861 disabled: !!primaryAction.disabled,
12862 accessibleWhenDisabled: true,
12863 size: "small",
12864 onClick: () => {
12865 primaryAction.callback([item], { registry });
12866 },
12867 children: label
12868 }
12869 )
12870 }
12871 ) }, primaryAction.id);
12872 }
12873 function ListItem({
12874 view,
12875 actions,
12876 idPrefix,
12877 isSelected: isSelected2,
12878 item,
12879 titleField,
12880 mediaField,
12881 descriptionField,
12882 onSelect,
12883 otherFields,
12884 onDropdownTriggerKeyDown,
12885 posinset
12886 }) {
12887 const {
12888 showTitle = true,
12889 showMedia = true,
12890 showDescription = true,
12891 infiniteScrollEnabled
12892 } = view;
12893 const itemRef = (0, import_element37.useRef)(null);
12894 const labelId = `${idPrefix}-label`;
12895 const descriptionId = `${idPrefix}-description`;
12896 const registry = (0, import_data3.useRegistry)();
12897 const [isHovered, setIsHovered] = (0, import_element37.useState)(false);
12898 const [activeModalAction, setActiveModalAction] = (0, import_element37.useState)(
12899 null
12900 );
12901 const handleHover = ({ type }) => {
12902 const isHover = type === "mouseenter";
12903 setIsHovered(isHover);
12904 };
12905 const { paginationInfo } = (0, import_element37.useContext)(dataviews_context_default);
12906 (0, import_element37.useEffect)(() => {
12907 if (isSelected2) {
12908 itemRef.current?.scrollIntoView({
12909 behavior: "auto",
12910 block: "nearest",
12911 inline: "nearest"
12912 });
12913 }
12914 }, [isSelected2]);
12915 const { primaryAction, eligibleActions } = (0, import_element37.useMemo)(() => {
12916 const _eligibleActions = actions.filter(
12917 (action) => !action.isEligible || action.isEligible(item)
12918 );
12919 const _primaryActions = _eligibleActions.filter(
12920 (action) => action.isPrimary
12921 );
12922 return {
12923 primaryAction: _primaryActions[0],
12924 eligibleActions: _eligibleActions
12925 };
12926 }, [actions, item]);
12927 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
12928 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12929 mediaField.render,
12930 {
12931 item,
12932 field: mediaField,
12933 config: { sizes: "52px" }
12934 }
12935 ) }) : null;
12936 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(titleField.render, { item, field: titleField }) : null;
12937 const renderDescription = showDescription && descriptionField?.render;
12938 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
12939 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
12940 Stack,
12941 {
12942 direction: "row",
12943 gap: "md",
12944 className: "dataviews-view-list__item-actions",
12945 children: [
12946 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12947 PrimaryActionGridCell,
12948 {
12949 idPrefix,
12950 primaryAction,
12951 item
12952 }
12953 ),
12954 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { role: "gridcell", children: [
12955 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Menu3, { placement: "bottom-end", children: [
12956 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12957 Menu3.TriggerButton,
12958 {
12959 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12960 import_components10.Composite.Item,
12961 {
12962 id: generateDropdownTriggerCompositeId(
12963 idPrefix
12964 ),
12965 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12966 import_components10.Button,
12967 {
12968 size: "small",
12969 icon: more_vertical_default,
12970 label: (0, import_i18n14.__)("Actions"),
12971 accessibleWhenDisabled: true,
12972 disabled: !actions.length,
12973 onKeyDown: onDropdownTriggerKeyDown
12974 }
12975 )
12976 }
12977 )
12978 }
12979 ),
12980 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12981 ActionsMenuGroup,
12982 {
12983 actions: eligibleActions,
12984 item,
12985 registry,
12986 setActiveModalAction
12987 }
12988 ) })
12989 ] }),
12990 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12991 ActionModal,
12992 {
12993 action: activeModalAction,
12994 items: [item],
12995 closeModal: () => setActiveModalAction(null)
12996 }
12997 )
12998 ] })
12999 ]
13000 }
13001 );
13002 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13003 import_components10.Composite.Row,
13004 {
13005 ref: itemRef,
13006 render: (
13007 /* aria-posinset breaks Composite.Row if passed to it directly. */
13008 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13009 "div",
13010 {
13011 "aria-posinset": posinset,
13012 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
13013 }
13014 )
13015 ),
13016 role: infiniteScrollEnabled ? "article" : "row",
13017 className: clsx_default({
13018 "is-selected": isSelected2,
13019 "is-hovered": isHovered
13020 }),
13021 onMouseEnter: handleHover,
13022 onMouseLeave: handleHover,
13023 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13024 Stack,
13025 {
13026 direction: "row",
13027 className: "dataviews-view-list__item-wrapper",
13028 children: [
13029 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13030 import_components10.Composite.Item,
13031 {
13032 id: generateItemWrapperCompositeId(idPrefix),
13033 "aria-pressed": isSelected2,
13034 "aria-labelledby": labelId,
13035 "aria-describedby": descriptionId,
13036 className: "dataviews-view-list__item",
13037 onClick: () => onSelect(item)
13038 }
13039 ) }),
13040 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13041 Stack,
13042 {
13043 direction: "row",
13044 gap: "md",
13045 justify: "start",
13046 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
13047 style: { flex: 1, minWidth: 0 },
13048 children: [
13049 renderedMediaField,
13050 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13051 Stack,
13052 {
13053 direction: "column",
13054 gap: "xs",
13055 className: "dataviews-view-list__field-wrapper",
13056 children: [
13057 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Stack, { direction: "row", align: "center", children: [
13058 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13059 "div",
13060 {
13061 className: "dataviews-title-field dataviews-view-list__title-field",
13062 id: labelId,
13063 children: renderedTitleField
13064 }
13065 ),
13066 usedActions
13067 ] }),
13068 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13069 descriptionField.render,
13070 {
13071 item,
13072 field: descriptionField
13073 }
13074 ) }),
13075 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13076 "div",
13077 {
13078 className: "dataviews-view-list__fields",
13079 id: descriptionId,
13080 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13081 "div",
13082 {
13083 className: "dataviews-view-list__field",
13084 children: [
13085 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13086 VisuallyHidden,
13087 {
13088 className: "dataviews-view-list__field-label",
13089 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", {}),
13090 children: field.label
13091 }
13092 ),
13093 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13094 field.render,
13095 {
13096 item,
13097 field
13098 }
13099 ) })
13100 ]
13101 },
13102 field.id
13103 ))
13104 }
13105 )
13106 ]
13107 }
13108 )
13109 ]
13110 }
13111 )
13112 ]
13113 }
13114 )
13115 }
13116 );
13117 }
13118 function isDefined2(item) {
13119 return !!item;
13120 }
13121 function ViewList(props) {
13122 const {
13123 actions,
13124 data,
13125 fields,
13126 getItemId,
13127 isLoading,
13128 onChangeSelection,
13129 selection,
13130 view,
13131 className,
13132 empty
13133 } = props;
13134 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list");
13135 const isDelayedLoading = useDelayedLoading(!!isLoading);
13136 const selectedItem = data?.findLast(
13137 (item) => selection.includes(getItemId(item))
13138 );
13139 const titleField = fields.find((field) => field.id === view.titleField);
13140 const mediaField = fields.find((field) => field.id === view.mediaField);
13141 const descriptionField = fields.find(
13142 (field) => field.id === view.descriptionField
13143 );
13144 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
13145 const onSelect = (item) => onChangeSelection([getItemId(item)]);
13146 const generateCompositeItemIdPrefix = (0, import_element37.useCallback)(
13147 (item) => `${baseId}-${getItemId(item)}`,
13148 [baseId, getItemId]
13149 );
13150 const isActiveCompositeItem = (0, import_element37.useCallback)(
13151 (item, idToCheck) => {
13152 return idToCheck.startsWith(
13153 generateCompositeItemIdPrefix(item)
13154 );
13155 },
13156 [generateCompositeItemIdPrefix]
13157 );
13158 const [activeCompositeId, setActiveCompositeId] = (0, import_element37.useState)(void 0);
13159 const compositeRef = (0, import_element37.useRef)(null);
13160 (0, import_element37.useEffect)(() => {
13161 if (selectedItem) {
13162 setActiveCompositeId(
13163 generateItemWrapperCompositeId(
13164 generateCompositeItemIdPrefix(selectedItem)
13165 )
13166 );
13167 }
13168 }, [selectedItem, generateCompositeItemIdPrefix]);
13169 const activeItemIndex = data.findIndex(
13170 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
13171 );
13172 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex);
13173 const isActiveIdInList = activeItemIndex !== -1;
13174 const selectCompositeItem = (0, import_element37.useCallback)(
13175 (targetIndex, generateCompositeId) => {
13176 const clampedIndex = Math.min(
13177 data.length - 1,
13178 Math.max(0, targetIndex)
13179 );
13180 if (!data[clampedIndex]) {
13181 return;
13182 }
13183 const itemIdPrefix = generateCompositeItemIdPrefix(
13184 data[clampedIndex]
13185 );
13186 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
13187 setActiveCompositeId(targetCompositeItemId);
13188 if (compositeRef.current?.contains(
13189 compositeRef.current.ownerDocument.activeElement
13190 )) {
13191 document.getElementById(targetCompositeItemId)?.focus();
13192 }
13193 },
13194 [data, generateCompositeItemIdPrefix]
13195 );
13196 (0, import_element37.useEffect)(() => {
13197 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
13198 if (!isActiveIdInList && wasActiveIdInList) {
13199 selectCompositeItem(
13200 previousActiveItemIndex,
13201 generateItemWrapperCompositeId
13202 );
13203 }
13204 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
13205 const onDropdownTriggerKeyDown = (0, import_element37.useCallback)(
13206 (event) => {
13207 if (event.key === "ArrowDown") {
13208 event.preventDefault();
13209 selectCompositeItem(
13210 activeItemIndex + 1,
13211 generateDropdownTriggerCompositeId
13212 );
13213 }
13214 if (event.key === "ArrowUp") {
13215 event.preventDefault();
13216 selectCompositeItem(
13217 activeItemIndex - 1,
13218 generateDropdownTriggerCompositeId
13219 );
13220 }
13221 },
13222 [selectCompositeItem, activeItemIndex]
13223 );
13224 const hasData = !!data?.length;
13225 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13226 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13227 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13228 if (!hasData) {
13229 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13230 "div",
13231 {
13232 className: clsx_default("dataviews-no-results", {
13233 "is-refreshing": isDelayedLoading
13234 }),
13235 children: empty
13236 }
13237 );
13238 }
13239 if (hasData && groupField && dataByGroup) {
13240 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13241 import_components10.Composite,
13242 {
13243 ref: compositeRef,
13244 id: `${baseId}`,
13245 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", {}),
13246 className: "dataviews-view-list__group",
13247 role: "grid",
13248 activeId: activeCompositeId,
13249 setActiveId: setActiveCompositeId,
13250 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13251 Stack,
13252 {
13253 direction: "column",
13254 gap: "lg",
13255 className: clsx_default("dataviews-view-list", className),
13256 children: Array.from(dataByGroup.entries()).map(
13257 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13258 Stack,
13259 {
13260 direction: "column",
13261 gap: "sm",
13262 children: [
13263 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n14.sprintf)(
13264 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
13265 (0, import_i18n14.__)("%1$s: %2$s"),
13266 groupField.label,
13267 groupName
13268 ) }),
13269 groupItems.map((item) => {
13270 const id = generateCompositeItemIdPrefix(item);
13271 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13272 ListItem,
13273 {
13274 view,
13275 idPrefix: id,
13276 actions,
13277 item,
13278 isSelected: item === selectedItem,
13279 onSelect,
13280 mediaField,
13281 titleField,
13282 descriptionField,
13283 otherFields,
13284 onDropdownTriggerKeyDown
13285 },
13286 id
13287 );
13288 })
13289 ]
13290 },
13291 groupName
13292 )
13293 )
13294 }
13295 )
13296 }
13297 );
13298 }
13299 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(import_jsx_runtime60.Fragment, { children: [
13300 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13301 import_components10.Composite,
13302 {
13303 ref: compositeRef,
13304 id: baseId,
13305 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", {}),
13306 className: clsx_default("dataviews-view-list", className, {
13307 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
13308 view.layout.density
13309 ),
13310 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13311 }),
13312 role: view.infiniteScrollEnabled ? "feed" : "grid",
13313 activeId: activeCompositeId,
13314 setActiveId: setActiveCompositeId,
13315 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
13316 children: data.map((item, index2) => {
13317 const id = generateCompositeItemIdPrefix(item);
13318 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13319 ListItem,
13320 {
13321 view,
13322 idPrefix: id,
13323 actions,
13324 item,
13325 isSelected: item === selectedItem,
13326 onSelect,
13327 mediaField,
13328 titleField,
13329 descriptionField,
13330 otherFields,
13331 onDropdownTriggerKeyDown,
13332 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13333 },
13334 id
13335 );
13336 })
13337 }
13338 ),
13339 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components10.Spinner, {}) })
13340 ] });
13341 }
13342
13343 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13344 var import_components11 = __toESM(require_components(), 1);
13345
13346 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
13347 var import_i18n15 = __toESM(require_i18n(), 1);
13348 var import_element38 = __toESM(require_element(), 1);
13349 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
13350 function ActivityGroup({
13351 groupName,
13352 groupData,
13353 groupField,
13354 showLabel = true,
13355 children
13356 }) {
13357 const groupHeader = showLabel ? (0, import_element38.createInterpolateElement)(
13358 // translators: %s: The label of the field e.g. "Status".
13359 (0, import_i18n15.sprintf)((0, import_i18n15.__)("%s: <groupName />"), groupField.label).trim(),
13360 {
13361 groupName: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13362 groupField.render,
13363 {
13364 item: groupData[0],
13365 field: groupField
13366 }
13367 )
13368 }
13369 ) : /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(groupField.render, { item: groupData[0], field: groupField });
13370 return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
13371 Stack,
13372 {
13373 direction: "column",
13374 className: "dataviews-view-activity__group",
13375 children: [
13376 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
13377 children
13378 ]
13379 },
13380 groupName
13381 );
13382 }
13383
13384 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
13385 var import_element39 = __toESM(require_element(), 1);
13386 var import_data4 = __toESM(require_data(), 1);
13387 var import_compose5 = __toESM(require_compose(), 1);
13388 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
13389 function ActivityItem(props) {
13390 const {
13391 view,
13392 actions,
13393 item,
13394 titleField,
13395 mediaField,
13396 descriptionField,
13397 otherFields,
13398 posinset,
13399 onClickItem,
13400 renderItemLink,
13401 isItemClickable
13402 } = props;
13403 const {
13404 showTitle = true,
13405 showMedia = true,
13406 showDescription = true,
13407 infiniteScrollEnabled
13408 } = view;
13409 const itemRef = (0, import_element39.useRef)(null);
13410 const registry = (0, import_data4.useRegistry)();
13411 const { paginationInfo } = (0, import_element39.useContext)(dataviews_context_default);
13412 const { primaryActions, eligibleActions } = (0, import_element39.useMemo)(() => {
13413 const _eligibleActions = actions.filter(
13414 (action) => !action.isEligible || action.isEligible(item)
13415 );
13416 const _primaryActions = _eligibleActions.filter(
13417 (action) => action.isPrimary
13418 );
13419 return {
13420 primaryActions: _primaryActions,
13421 eligibleActions: _eligibleActions
13422 };
13423 }, [actions, item]);
13424 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
13425 const density = view.layout?.density ?? "balanced";
13426 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13427 mediaField.render,
13428 {
13429 item,
13430 field: mediaField,
13431 config: {
13432 sizes: density === "comfortable" ? "32px" : "24px"
13433 }
13434 }
13435 ) : null;
13436 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13437 "span",
13438 {
13439 className: "dataviews-view-activity__item-bullet",
13440 "aria-hidden": "true"
13441 }
13442 ) });
13443 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(titleField.render, { item, field: titleField }) : null;
13444 const verticalGap = (0, import_element39.useMemo)(() => {
13445 switch (density) {
13446 case "comfortable":
13447 return "md";
13448 default:
13449 return "sm";
13450 }
13451 }, [density]);
13452 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13453 "div",
13454 {
13455 ref: itemRef,
13456 role: infiniteScrollEnabled ? "article" : void 0,
13457 "aria-posinset": posinset,
13458 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
13459 className: clsx_default(
13460 "dataviews-view-activity__item",
13461 density === "compact" && "is-compact",
13462 density === "balanced" && "is-balanced",
13463 density === "comfortable" && "is-comfortable"
13464 ),
13465 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
13466 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13467 Stack,
13468 {
13469 direction: "column",
13470 gap: "xs",
13471 align: "center",
13472 className: "dataviews-view-activity__item-type",
13473 children: renderedMediaField
13474 }
13475 ),
13476 /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
13477 Stack,
13478 {
13479 direction: "column",
13480 gap: verticalGap,
13481 align: "flex-start",
13482 className: "dataviews-view-activity__item-content",
13483 children: [
13484 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13485 ItemClickWrapper,
13486 {
13487 item,
13488 isItemClickable,
13489 onClickItem,
13490 renderItemLink,
13491 className: "dataviews-view-activity__item-title",
13492 children: renderedTitleField
13493 }
13494 ),
13495 showDescription && descriptionField && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13496 descriptionField.render,
13497 {
13498 item,
13499 field: descriptionField
13500 }
13501 ) }),
13502 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
13503 "div",
13504 {
13505 className: "dataviews-view-activity__item-field",
13506 children: [
13507 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13508 VisuallyHidden,
13509 {
13510 className: "dataviews-view-activity__item-field-label",
13511 render: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", {}),
13512 children: field.label
13513 }
13514 ),
13515 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13516 field.render,
13517 {
13518 item,
13519 field
13520 }
13521 ) })
13522 ]
13523 },
13524 field.id
13525 )) }),
13526 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13527 PrimaryActions,
13528 {
13529 item,
13530 actions: primaryActions,
13531 registry,
13532 buttonVariant: "secondary"
13533 }
13534 )
13535 ]
13536 }
13537 ),
13538 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
13539 // there if there are any actions at all.
13540 isMobileViewport && // At the same time, only show the menu if there are actions to show.
13541 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13542 ItemActions,
13543 {
13544 item,
13545 actions: eligibleActions,
13546 isCompact: true
13547 }
13548 ) })
13549 ] })
13550 }
13551 );
13552 }
13553 var activity_item_default = ActivityItem;
13554
13555 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
13556 var import_react10 = __toESM(require_react(), 1);
13557 function isDefined3(item) {
13558 return !!item;
13559 }
13560 function ActivityItems(props) {
13561 const { data, fields, getItemId, view } = props;
13562 const titleField = fields.find((field) => field.id === view.titleField);
13563 const mediaField = fields.find((field) => field.id === view.mediaField);
13564 const descriptionField = fields.find(
13565 (field) => field.id === view.descriptionField
13566 );
13567 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
13568 return data.map((item, index2) => {
13569 return /* @__PURE__ */ (0, import_react10.createElement)(
13570 activity_item_default,
13571 {
13572 ...props,
13573 key: getItemId(item),
13574 item,
13575 mediaField,
13576 titleField,
13577 descriptionField,
13578 otherFields,
13579 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13580 }
13581 );
13582 });
13583 }
13584
13585 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13586 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
13587 function ViewActivity(props) {
13588 const { empty, data, fields, isLoading, view, className } = props;
13589 const isDelayedLoading = useDelayedLoading(!!isLoading);
13590 const hasData = !!data?.length;
13591 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13592 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13593 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13594 if (!hasData) {
13595 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13596 "div",
13597 {
13598 className: clsx_default("dataviews-no-results", {
13599 "is-refreshing": isDelayedLoading
13600 }),
13601 children: empty
13602 }
13603 );
13604 }
13605 const isInert = !isInfiniteScroll && !!isLoading;
13606 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
13607 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13608 });
13609 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
13610 if (hasData && groupField && dataByGroup) {
13611 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13612 Stack,
13613 {
13614 direction: "column",
13615 gap: "sm",
13616 className: wrapperClassName,
13617 inert: isInert ? "true" : void 0,
13618 children: groupedEntries.map(
13619 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13620 ActivityGroup,
13621 {
13622 groupName,
13623 groupData,
13624 groupField,
13625 showLabel: view.groupBy?.showLabel !== false,
13626 children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13627 ActivityItems,
13628 {
13629 ...props,
13630 data: groupData
13631 }
13632 )
13633 },
13634 groupName
13635 )
13636 )
13637 }
13638 );
13639 }
13640 return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_jsx_runtime63.Fragment, { children: [
13641 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13642 "div",
13643 {
13644 className: wrapperClassName,
13645 role: view.infiniteScrollEnabled ? "feed" : void 0,
13646 inert: isInert ? "true" : void 0,
13647 children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(ActivityItems, { ...props })
13648 }
13649 ),
13650 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_components11.Spinner, {}) })
13651 ] });
13652 }
13653
13654 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13655 var import_components14 = __toESM(require_components(), 1);
13656 var import_i18n18 = __toESM(require_i18n(), 1);
13657 var import_compose6 = __toESM(require_compose(), 1);
13658 var import_element42 = __toESM(require_element(), 1);
13659
13660 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13661 var import_components13 = __toESM(require_components(), 1);
13662 var import_data5 = __toESM(require_data(), 1);
13663 var import_element41 = __toESM(require_element(), 1);
13664 var import_i18n17 = __toESM(require_i18n(), 1);
13665
13666 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
13667 var import_components12 = __toESM(require_components(), 1);
13668 var import_element40 = __toESM(require_element(), 1);
13669 var import_i18n16 = __toESM(require_i18n(), 1);
13670 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
13671 function DataViewsPagination() {
13672 const {
13673 view,
13674 onChangeView,
13675 paginationInfo: { totalItems = 0, totalPages }
13676 } = (0, import_element40.useContext)(dataviews_context_default);
13677 if (!totalItems || !totalPages || view.infiniteScrollEnabled) {
13678 return null;
13679 }
13680 const currentPage = view.page ?? 1;
13681 const pageSelectOptions = Array.from(Array(totalPages)).map(
13682 (_, i2) => {
13683 const page = i2 + 1;
13684 return {
13685 value: page.toString(),
13686 label: page.toString(),
13687 "aria-label": currentPage === page ? (0, import_i18n16.sprintf)(
13688 // translators: 1: current page number. 2: total number of pages.
13689 (0, import_i18n16.__)("Page %1$d of %2$d"),
13690 currentPage,
13691 totalPages
13692 ) : page.toString()
13693 };
13694 }
13695 );
13696 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
13697 Stack,
13698 {
13699 direction: "row",
13700 className: "dataviews-pagination",
13701 justify: "end",
13702 align: "center",
13703 gap: "xl",
13704 children: [
13705 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13706 Stack,
13707 {
13708 direction: "row",
13709 justify: "flex-start",
13710 align: "center",
13711 gap: "xs",
13712 className: "dataviews-pagination__page-select",
13713 children: (0, import_element40.createInterpolateElement)(
13714 (0, import_i18n16.sprintf)(
13715 // translators: 1: Current page number, 2: Total number of pages.
13716 (0, import_i18n16._x)(
13717 "<div>Page</div>%1$s<div>of %2$d</div>",
13718 "paging"
13719 ),
13720 "<CurrentPage />",
13721 totalPages
13722 ),
13723 {
13724 div: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { "aria-hidden": true }),
13725 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
13726 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13727 import_components12.SelectControl,
13728 {
13729 "aria-label": (0, import_i18n16.__)("Current page"),
13730 value: currentPage.toString(),
13731 options: pageSelectOptions,
13732 onChange: (newValue) => {
13733 onChangeView({
13734 ...view,
13735 page: +newValue
13736 });
13737 },
13738 size: "small",
13739 variant: "minimal"
13740 }
13741 )
13742 }
13743 )
13744 }
13745 ),
13746 /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
13747 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13748 import_components12.Button,
13749 {
13750 onClick: () => onChangeView({
13751 ...view,
13752 page: currentPage - 1
13753 }),
13754 disabled: currentPage === 1,
13755 accessibleWhenDisabled: true,
13756 label: (0, import_i18n16.__)("Previous page"),
13757 icon: (0, import_i18n16.isRTL)() ? next_default : previous_default,
13758 showTooltip: true,
13759 size: "compact",
13760 tooltipPosition: "top"
13761 }
13762 ),
13763 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13764 import_components12.Button,
13765 {
13766 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
13767 disabled: currentPage >= totalPages,
13768 accessibleWhenDisabled: true,
13769 label: (0, import_i18n16.__)("Next page"),
13770 icon: (0, import_i18n16.isRTL)() ? previous_default : next_default,
13771 showTooltip: true,
13772 size: "compact",
13773 tooltipPosition: "top"
13774 }
13775 )
13776 ] })
13777 ]
13778 }
13779 );
13780 }
13781 var dataviews_pagination_default = (0, import_element40.memo)(DataViewsPagination);
13782
13783 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13784 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
13785 function useIsMultiselectPicker(actions) {
13786 return (0, import_element41.useMemo)(() => {
13787 return actions?.every((action) => action.supportsBulk);
13788 }, [actions]);
13789 }
13790
13791 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13792 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
13793 var { Badge: WCBadge2 } = unlock2(import_components14.privateApis);
13794 function GridItem3({
13795 view,
13796 multiselect,
13797 selection,
13798 onChangeSelection,
13799 getItemId,
13800 item,
13801 mediaField,
13802 titleField,
13803 descriptionField,
13804 regularFields,
13805 badgeFields,
13806 config,
13807 posinset,
13808 setsize
13809 }) {
13810 const { showTitle = true, showMedia = true, showDescription = true } = view;
13811 const id = getItemId(item);
13812 const elementRef = (0, import_element42.useRef)(null);
13813 const isSelected2 = selection.includes(id);
13814 useIntersectionObserver(elementRef, posinset);
13815 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13816 mediaField.render,
13817 {
13818 item,
13819 field: mediaField,
13820 config
13821 }
13822 ) : null;
13823 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(titleField.render, { item, field: titleField }) : null;
13824 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
13825 import_components14.Composite.Item,
13826 {
13827 ref: elementRef,
13828 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n18.__)("(no title)") : void 0,
13829 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Stack, { direction: "column", children, ...props }),
13830 role: "option",
13831 "aria-posinset": posinset,
13832 "aria-setsize": setsize,
13833 className: clsx_default("dataviews-view-picker-grid__card", {
13834 "is-selected": isSelected2
13835 }),
13836 "aria-selected": isSelected2,
13837 onClick: () => {
13838 if (isSelected2) {
13839 onChangeSelection(
13840 selection.filter((itemId) => id !== itemId)
13841 );
13842 } else {
13843 const newSelection = multiselect ? [...selection, id] : [id];
13844 onChangeSelection(newSelection);
13845 }
13846 },
13847 children: [
13848 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
13849 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13850 DataViewsSelectionCheckbox,
13851 {
13852 item,
13853 selection,
13854 onChangeSelection,
13855 getItemId,
13856 titleField,
13857 disabled: false,
13858 "aria-hidden": true,
13859 tabIndex: -1
13860 }
13861 ),
13862 showTitle && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13863 Stack,
13864 {
13865 direction: "row",
13866 justify: "space-between",
13867 className: "dataviews-view-picker-grid__title-actions",
13868 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
13869 }
13870 ),
13871 /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(Stack, { direction: "column", gap: "xs", children: [
13872 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13873 descriptionField.render,
13874 {
13875 item,
13876 field: descriptionField
13877 }
13878 ),
13879 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13880 Stack,
13881 {
13882 direction: "row",
13883 className: "dataviews-view-picker-grid__badge-fields",
13884 gap: "sm",
13885 wrap: "wrap",
13886 align: "top",
13887 justify: "flex-start",
13888 children: badgeFields.map((field) => {
13889 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13890 WCBadge2,
13891 {
13892 className: "dataviews-view-picker-grid__field-value",
13893 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13894 field.render,
13895 {
13896 item,
13897 field
13898 }
13899 )
13900 },
13901 field.id
13902 );
13903 })
13904 }
13905 ),
13906 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13907 Stack,
13908 {
13909 direction: "column",
13910 className: "dataviews-view-picker-grid__fields",
13911 gap: "xs",
13912 children: regularFields.map((field) => {
13913 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13914 import_components14.Flex,
13915 {
13916 className: "dataviews-view-picker-grid__field",
13917 gap: 1,
13918 justify: "flex-start",
13919 expanded: true,
13920 style: { height: "auto" },
13921 direction: "row",
13922 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
13923 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components14.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
13924 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13925 import_components14.FlexItem,
13926 {
13927 className: "dataviews-view-picker-grid__field-value",
13928 style: { maxHeight: "none" },
13929 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13930 field.render,
13931 {
13932 item,
13933 field
13934 }
13935 )
13936 }
13937 )
13938 ] })
13939 },
13940 field.id
13941 );
13942 })
13943 }
13944 )
13945 ] })
13946 ]
13947 },
13948 id
13949 );
13950 }
13951 function GridGroup({
13952 groupName,
13953 groupField,
13954 showLabel = true,
13955 children
13956 }) {
13957 const headerId = (0, import_compose6.useInstanceId)(
13958 GridGroup,
13959 "dataviews-view-picker-grid-group__header"
13960 );
13961 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
13962 Stack,
13963 {
13964 direction: "column",
13965 gap: "sm",
13966 role: "group",
13967 "aria-labelledby": headerId,
13968 children: [
13969 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13970 "h3",
13971 {
13972 className: "dataviews-view-picker-grid-group__header",
13973 id: headerId,
13974 children: showLabel ? (0, import_i18n18.sprintf)(
13975 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
13976 (0, import_i18n18.__)("%1$s: %2$s"),
13977 groupField.label,
13978 groupName
13979 ) : groupName
13980 }
13981 ),
13982 children
13983 ]
13984 },
13985 groupName
13986 );
13987 }
13988 function ViewPickerGrid({
13989 actions,
13990 data,
13991 fields,
13992 getItemId,
13993 isLoading,
13994 onChangeSelection,
13995 selection,
13996 view,
13997 className,
13998 empty
13999 }) {
14000 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element42.useContext)(dataviews_context_default);
14001 const titleField = fields.find(
14002 (field) => field.id === view?.titleField
14003 );
14004 const mediaField = fields.find(
14005 (field) => field.id === view?.mediaField
14006 );
14007 const descriptionField = fields.find(
14008 (field) => field.id === view?.descriptionField
14009 );
14010 const otherFields = view.fields ?? [];
14011 const { regularFields, badgeFields } = otherFields.reduce(
14012 (accumulator, fieldId) => {
14013 const field = fields.find((f2) => f2.id === fieldId);
14014 if (!field) {
14015 return accumulator;
14016 }
14017 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
14018 accumulator[key].push(field);
14019 return accumulator;
14020 },
14021 { regularFields: [], badgeFields: [] }
14022 );
14023 const hasData = !!data?.length;
14024 const usedPreviewSize = view.layout?.previewSize;
14025 const isMultiselect = useIsMultiselectPicker(actions);
14026 const size4 = "900px";
14027 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14028 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14029 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
14030 const currentPage = view?.page ?? 1;
14031 const perPage = view?.perPage ?? 0;
14032 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
14033 const gridColumns = useGridColumns();
14034 const placeholdersNeeded = usePlaceholdersNeeded(
14035 data,
14036 isInfiniteScroll,
14037 gridColumns
14038 );
14039 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, {
14040 // Render multiple groups.
14041 children: [
14042 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14043 import_components14.Composite,
14044 {
14045 virtualFocus: true,
14046 orientation: "horizontal",
14047 role: "listbox",
14048 "aria-multiselectable": isMultiselect,
14049 className: clsx_default(
14050 "dataviews-view-picker-grid",
14051 className,
14052 {
14053 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14054 view.layout.density
14055 )
14056 }
14057 ),
14058 "aria-label": itemListLabel,
14059 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14060 Stack,
14061 {
14062 direction: "column",
14063 gap: "lg",
14064 children,
14065 ...props
14066 }
14067 ),
14068 children: Array.from(dataByGroup.entries()).map(
14069 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14070 GridGroup,
14071 {
14072 groupName,
14073 groupField,
14074 showLabel: view.groupBy?.showLabel !== false,
14075 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14076 GridItems,
14077 {
14078 previewSize: usedPreviewSize,
14079 style: {
14080 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
14081 },
14082 "aria-busy": isLoading,
14083 ref: resizeObserverRef,
14084 children: groupItems.map((item) => {
14085 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
14086 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14087 GridItem3,
14088 {
14089 view,
14090 multiselect: isMultiselect,
14091 selection,
14092 onChangeSelection,
14093 getItemId,
14094 item,
14095 mediaField,
14096 titleField,
14097 descriptionField,
14098 regularFields,
14099 badgeFields,
14100 config: {
14101 sizes: size4
14102 },
14103 posinset: posInSet,
14104 setsize: setSize
14105 },
14106 getItemId(item)
14107 );
14108 })
14109 }
14110 )
14111 },
14112 groupName
14113 )
14114 )
14115 }
14116 ),
14117 // Render a single grid with all data.
14118 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14119 import_components14.Composite,
14120 {
14121 render: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14122 GridItems,
14123 {
14124 className: clsx_default(
14125 "dataviews-view-picker-grid",
14126 className,
14127 {
14128 [`has-${view.layout?.density}-density`]: view.layout?.density && [
14129 "compact",
14130 "comfortable"
14131 ].includes(view.layout.density)
14132 }
14133 ),
14134 previewSize: usedPreviewSize,
14135 "aria-busy": isLoading,
14136 ref: resizeObserverRef
14137 }
14138 ),
14139 virtualFocus: true,
14140 orientation: "horizontal",
14141 role: "listbox",
14142 "aria-multiselectable": isMultiselect,
14143 "aria-label": itemListLabel,
14144 children: [
14145 Array.from({ length: placeholdersNeeded }).map(
14146 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14147 import_components14.Composite.Item,
14148 {
14149 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14150 Stack,
14151 {
14152 direction: "column",
14153 children,
14154 ...props
14155 }
14156 ),
14157 role: "option",
14158 "aria-hidden": true,
14159 tabIndex: -1,
14160 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
14161 },
14162 `placeholder-${index2}`
14163 )
14164 ),
14165 data.map((item) => {
14166 const posinset = item.position;
14167 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14168 GridItem3,
14169 {
14170 view,
14171 multiselect: isMultiselect,
14172 selection,
14173 onChangeSelection,
14174 getItemId,
14175 item,
14176 mediaField,
14177 titleField,
14178 descriptionField,
14179 regularFields,
14180 badgeFields,
14181 config: {
14182 sizes: size4
14183 },
14184 posinset,
14185 setsize: setSize
14186 },
14187 getItemId(item)
14188 );
14189 })
14190 ]
14191 }
14192 ),
14193 // Render empty state.
14194 !hasData && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14195 "div",
14196 {
14197 className: clsx_default({
14198 "dataviews-loading": isLoading,
14199 "dataviews-no-results": !isLoading
14200 }),
14201 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components14.Spinner, {}) }) : empty
14202 }
14203 ),
14204 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components14.Spinner, {}) })
14205 ]
14206 });
14207 }
14208 var picker_grid_default = ViewPickerGrid;
14209
14210 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
14211 var import_i18n19 = __toESM(require_i18n(), 1);
14212 var import_components15 = __toESM(require_components(), 1);
14213 var import_element43 = __toESM(require_element(), 1);
14214 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
14215 function TableColumnField2({
14216 item,
14217 fields,
14218 column,
14219 align
14220 }) {
14221 const field = fields.find((f2) => f2.id === column);
14222 if (!field) {
14223 return null;
14224 }
14225 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
14226 "dataviews-view-table__cell-align-end": align === "end",
14227 "dataviews-view-table__cell-align-center": align === "center"
14228 });
14229 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(field.render, { item, field }) });
14230 }
14231 function TableRow2({
14232 item,
14233 fields,
14234 id,
14235 view,
14236 titleField,
14237 mediaField,
14238 descriptionField,
14239 selection,
14240 getItemId,
14241 onChangeSelection,
14242 multiselect,
14243 posinset
14244 }) {
14245 const { paginationInfo } = (0, import_element43.useContext)(dataviews_context_default);
14246 const isSelected2 = selection.includes(id);
14247 const [isHovered, setIsHovered] = (0, import_element43.useState)(false);
14248 const elementRef = (0, import_element43.useRef)(null);
14249 useIntersectionObserver(elementRef, posinset);
14250 const {
14251 showTitle = true,
14252 showMedia = true,
14253 showDescription = true,
14254 infiniteScrollEnabled
14255 } = view;
14256 const handleMouseEnter = () => {
14257 setIsHovered(true);
14258 };
14259 const handleMouseLeave = () => {
14260 setIsHovered(false);
14261 };
14262 const columns = view.fields ?? [];
14263 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14264 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14265 import_components15.Composite.Item,
14266 {
14267 ref: elementRef,
14268 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14269 "tr",
14270 {
14271 className: clsx_default("dataviews-view-table__row", {
14272 "is-selected": isSelected2,
14273 "is-hovered": isHovered
14274 }),
14275 onMouseEnter: handleMouseEnter,
14276 onMouseLeave: handleMouseLeave,
14277 children,
14278 ...props
14279 }
14280 ),
14281 "aria-selected": isSelected2,
14282 "aria-setsize": paginationInfo.totalItems || void 0,
14283 "aria-posinset": posinset,
14284 role: infiniteScrollEnabled ? "article" : "option",
14285 onMouseDown: (event) => {
14286 if (event.button !== 0) {
14287 return;
14288 }
14289 event.currentTarget.parentElement?.focus({
14290 preventScroll: true
14291 });
14292 },
14293 onClick: () => {
14294 if (isSelected2) {
14295 onChangeSelection(
14296 selection.filter((itemId) => id !== itemId)
14297 );
14298 } else {
14299 const newSelection = multiselect ? [...selection, id] : [id];
14300 onChangeSelection(newSelection);
14301 }
14302 },
14303 children: [
14304 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14305 "td",
14306 {
14307 className: "dataviews-view-table__checkbox-column",
14308 role: "presentation",
14309 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14310 DataViewsSelectionCheckbox,
14311 {
14312 item,
14313 selection,
14314 onChangeSelection,
14315 getItemId,
14316 titleField,
14317 disabled: false,
14318 "aria-hidden": true,
14319 tabIndex: -1
14320 }
14321 ) })
14322 }
14323 ),
14324 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14325 "td",
14326 {
14327 role: "presentation",
14328 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14329 column_primary_default,
14330 {
14331 item,
14332 titleField: showTitle ? titleField : void 0,
14333 mediaField: showMedia ? mediaField : void 0,
14334 descriptionField: showDescription ? descriptionField : void 0,
14335 isItemClickable: () => false
14336 }
14337 )
14338 }
14339 ),
14340 columns.map((column) => {
14341 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14342 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14343 "td",
14344 {
14345 style: {
14346 width,
14347 maxWidth,
14348 minWidth
14349 },
14350 role: "presentation",
14351 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14352 TableColumnField2,
14353 {
14354 fields,
14355 item,
14356 column,
14357 align
14358 }
14359 )
14360 },
14361 column
14362 );
14363 })
14364 ]
14365 },
14366 id
14367 );
14368 }
14369 function ViewPickerTable({
14370 actions,
14371 data,
14372 fields,
14373 getItemId,
14374 isLoading = false,
14375 onChangeView,
14376 onChangeSelection,
14377 selection,
14378 setOpenedFilter,
14379 view,
14380 className,
14381 empty
14382 }) {
14383 const headerMenuRefs = (0, import_element43.useRef)(/* @__PURE__ */ new Map());
14384 const headerMenuToFocusRef = (0, import_element43.useRef)(void 0);
14385 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element43.useState)();
14386 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
14387 (0, import_element43.useEffect)(() => {
14388 if (headerMenuToFocusRef.current) {
14389 headerMenuToFocusRef.current.focus();
14390 headerMenuToFocusRef.current = void 0;
14391 }
14392 });
14393 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14394 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14395 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
14396 const tableNoticeId = (0, import_element43.useId)();
14397 if (nextHeaderMenuToFocus) {
14398 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
14399 setNextHeaderMenuToFocus(void 0);
14400 return;
14401 }
14402 const onHide = (field) => {
14403 const hidden = headerMenuRefs.current.get(field.id);
14404 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
14405 setNextHeaderMenuToFocus(fallback?.node);
14406 };
14407 const hasData = !!data?.length;
14408 const titleField = fields.find((field) => field.id === view.titleField);
14409 const mediaField = fields.find((field) => field.id === view.mediaField);
14410 const descriptionField = fields.find(
14411 (field) => field.id === view.descriptionField
14412 );
14413 const { showTitle = true, showMedia = true, showDescription = true } = view;
14414 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14415 const columns = view.fields ?? [];
14416 const headerMenuRef = (column, index2) => (node) => {
14417 if (node) {
14418 headerMenuRefs.current.set(column, {
14419 node,
14420 fallback: columns[index2 > 0 ? index2 - 1 : 1]
14421 });
14422 } else {
14423 headerMenuRefs.current.delete(column);
14424 }
14425 };
14426 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
14427 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14428 "table",
14429 {
14430 className: clsx_default(
14431 "dataviews-view-table",
14432 "dataviews-view-picker-table",
14433 className,
14434 {
14435 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14436 view.layout.density
14437 )
14438 }
14439 ),
14440 "aria-busy": isLoading,
14441 "aria-describedby": tableNoticeId,
14442 role: isInfiniteScroll ? "feed" : "listbox",
14443 children: [
14444 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14445 "tr",
14446 {
14447 className: "dataviews-view-table__row",
14448 role: "presentation",
14449 children: [
14450 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14451 BulkSelectionCheckbox,
14452 {
14453 selection,
14454 onChangeSelection,
14455 data,
14456 actions,
14457 getItemId,
14458 disableSelectAll: isInfiniteScroll
14459 }
14460 ) }),
14461 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14462 column_header_menu_default,
14463 {
14464 ref: headerMenuRef(
14465 titleField.id,
14466 0
14467 ),
14468 fieldId: titleField.id,
14469 view,
14470 fields,
14471 onChangeView,
14472 onHide,
14473 setOpenedFilter,
14474 canMove: false
14475 }
14476 ) }),
14477 columns.map((column, index2) => {
14478 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14479 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14480 "th",
14481 {
14482 style: {
14483 width,
14484 maxWidth,
14485 minWidth,
14486 textAlign: align
14487 },
14488 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
14489 scope: "col",
14490 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14491 column_header_menu_default,
14492 {
14493 ref: headerMenuRef(column, index2),
14494 fieldId: column,
14495 view,
14496 fields,
14497 onChangeView,
14498 onHide,
14499 setOpenedFilter,
14500 canMove: view.layout?.enableMoving ?? true
14501 }
14502 )
14503 },
14504 column
14505 );
14506 })
14507 ]
14508 }
14509 ) }),
14510 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
14511 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14512 import_components15.Composite,
14513 {
14514 virtualFocus: true,
14515 orientation: "vertical",
14516 render: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("tbody", { role: "group" }),
14517 children: [
14518 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14519 "tr",
14520 {
14521 className: "dataviews-view-table__group-header-row",
14522 role: "presentation",
14523 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14524 "td",
14525 {
14526 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
14527 className: "dataviews-view-table__group-header-cell",
14528 role: "presentation",
14529 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n19.sprintf)(
14530 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14531 (0, import_i18n19.__)("%1$s: %2$s"),
14532 groupField.label,
14533 groupName
14534 )
14535 }
14536 )
14537 }
14538 ),
14539 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14540 TableRow2,
14541 {
14542 item,
14543 fields,
14544 id: getItemId(item) || index2.toString(),
14545 view,
14546 titleField,
14547 mediaField,
14548 descriptionField,
14549 selection,
14550 getItemId,
14551 onChangeSelection,
14552 multiselect: isMultiselect
14553 },
14554 getItemId(item)
14555 ))
14556 ]
14557 },
14558 `group-${groupName}`
14559 )
14560 ) : /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14561 import_components15.Composite,
14562 {
14563 render: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("tbody", { role: "presentation" }),
14564 virtualFocus: true,
14565 orientation: "vertical",
14566 children: hasData && data.map((item, index2) => {
14567 const itemId = getItemId(item);
14568 const posinset = item.position;
14569 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14570 TableRow2,
14571 {
14572 item,
14573 fields,
14574 id: itemId || index2.toString(),
14575 view,
14576 titleField,
14577 mediaField,
14578 descriptionField,
14579 selection,
14580 getItemId,
14581 onChangeSelection,
14582 multiselect: isMultiselect,
14583 posinset
14584 },
14585 itemId
14586 );
14587 })
14588 }
14589 )
14590 ]
14591 }
14592 ),
14593 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14594 "div",
14595 {
14596 className: clsx_default({
14597 "dataviews-loading": isLoading,
14598 "dataviews-no-results": !hasData && !isLoading
14599 }),
14600 id: tableNoticeId,
14601 children: [
14602 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components15.Spinner, {}) }) : empty),
14603 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components15.Spinner, {}) })
14604 ]
14605 }
14606 )
14607 ] });
14608 }
14609 var picker_table_default = ViewPickerTable;
14610
14611 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
14612 var import_components16 = __toESM(require_components(), 1);
14613 var import_i18n20 = __toESM(require_i18n(), 1);
14614 var import_element44 = __toESM(require_element(), 1);
14615 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
14616 function DensityPicker() {
14617 const context = (0, import_element44.useContext)(dataviews_context_default);
14618 const view = context.view;
14619 return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
14620 import_components16.__experimentalToggleGroupControl,
14621 {
14622 size: "__unstable-large",
14623 label: (0, import_i18n20.__)("Density"),
14624 value: view.layout?.density || "balanced",
14625 onChange: (value) => {
14626 context.onChangeView({
14627 ...view,
14628 layout: {
14629 ...view.layout,
14630 density: value
14631 }
14632 });
14633 },
14634 isBlock: true,
14635 children: [
14636 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14637 import_components16.__experimentalToggleGroupControlOption,
14638 {
14639 value: "comfortable",
14640 label: (0, import_i18n20._x)(
14641 "Comfortable",
14642 "Density option for DataView layout"
14643 )
14644 },
14645 "comfortable"
14646 ),
14647 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14648 import_components16.__experimentalToggleGroupControlOption,
14649 {
14650 value: "balanced",
14651 label: (0, import_i18n20._x)("Balanced", "Density option for DataView layout")
14652 },
14653 "balanced"
14654 ),
14655 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14656 import_components16.__experimentalToggleGroupControlOption,
14657 {
14658 value: "compact",
14659 label: (0, import_i18n20._x)("Compact", "Density option for DataView layout")
14660 },
14661 "compact"
14662 )
14663 ]
14664 }
14665 );
14666 }
14667
14668 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
14669 var import_components17 = __toESM(require_components(), 1);
14670 var import_i18n21 = __toESM(require_i18n(), 1);
14671 var import_element45 = __toESM(require_element(), 1);
14672 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
14673 var imageSizes2 = [
14674 {
14675 value: 120,
14676 breakpoint: 1
14677 },
14678 {
14679 value: 170,
14680 breakpoint: 1
14681 },
14682 {
14683 value: 230,
14684 breakpoint: 1
14685 },
14686 {
14687 value: 290,
14688 breakpoint: 1112
14689 // at minimum image width, 4 images display at this container size
14690 },
14691 {
14692 value: 350,
14693 breakpoint: 1636
14694 // at minimum image width, 6 images display at this container size
14695 },
14696 {
14697 value: 430,
14698 breakpoint: 588
14699 // at minimum image width, 2 images display at this container size
14700 }
14701 ];
14702 function PreviewSizePicker() {
14703 const context = (0, import_element45.useContext)(dataviews_context_default);
14704 const view = context.view;
14705 const breakValues = imageSizes2.filter((size4) => {
14706 return context.containerWidth >= size4.breakpoint;
14707 });
14708 const layoutPreviewSize = view.layout?.previewSize ?? 230;
14709 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
14710 const marks = breakValues.map((size4, index2) => {
14711 return {
14712 value: index2
14713 };
14714 });
14715 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
14716 import_components17.RangeControl,
14717 {
14718 __next40pxDefaultSize: true,
14719 showTooltip: false,
14720 label: (0, import_i18n21.__)("Preview size"),
14721 value: previewSizeToUse,
14722 min: 0,
14723 max: breakValues.length - 1,
14724 withInputField: false,
14725 onChange: (value = 0) => {
14726 context.onChangeView({
14727 ...view,
14728 layout: {
14729 ...view.layout,
14730 previewSize: breakValues[value].value
14731 }
14732 });
14733 },
14734 step: 1,
14735 marks
14736 }
14737 );
14738 }
14739
14740 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
14741 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
14742 function GridConfigOptions() {
14743 return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(import_jsx_runtime70.Fragment, { children: [
14744 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(DensityPicker, {}),
14745 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(PreviewSizePicker, {})
14746 ] });
14747 }
14748
14749 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
14750 var VIEW_LAYOUTS = [
14751 {
14752 type: LAYOUT_TABLE,
14753 label: (0, import_i18n22.__)("Table"),
14754 component: table_default,
14755 icon: block_table_default,
14756 viewConfigOptions: DensityPicker
14757 },
14758 {
14759 type: LAYOUT_GRID,
14760 label: (0, import_i18n22.__)("Grid"),
14761 component: grid_default,
14762 icon: category_default,
14763 viewConfigOptions: GridConfigOptions
14764 },
14765 {
14766 type: LAYOUT_LIST,
14767 label: (0, import_i18n22.__)("List"),
14768 component: ViewList,
14769 icon: (0, import_i18n22.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
14770 viewConfigOptions: DensityPicker
14771 },
14772 {
14773 type: LAYOUT_ACTIVITY,
14774 label: (0, import_i18n22.__)("Activity"),
14775 component: ViewActivity,
14776 icon: scheduled_default,
14777 viewConfigOptions: DensityPicker
14778 },
14779 {
14780 type: LAYOUT_PICKER_GRID,
14781 label: (0, import_i18n22.__)("Grid"),
14782 component: picker_grid_default,
14783 icon: category_default,
14784 viewConfigOptions: GridConfigOptions,
14785 isPicker: true
14786 },
14787 {
14788 type: LAYOUT_PICKER_TABLE,
14789 label: (0, import_i18n22.__)("Table"),
14790 component: picker_table_default,
14791 icon: block_table_default,
14792 viewConfigOptions: DensityPicker,
14793 isPicker: true
14794 }
14795 ];
14796
14797 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
14798 var import_element53 = __toESM(require_element(), 1);
14799
14800 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
14801 var import_components20 = __toESM(require_components(), 1);
14802 var import_i18n25 = __toESM(require_i18n(), 1);
14803 var import_element50 = __toESM(require_element(), 1);
14804
14805 // node_modules/@ariakit/core/esm/__chunks/XMCVU3LR.js
14806 function noop4(..._) {
14807 }
14808 function applyState(argument, currentValue) {
14809 if (isUpdater(argument)) {
14810 const value = isLazyValue(currentValue) ? currentValue() : currentValue;
14811 return argument(value);
14812 }
14813 return argument;
14814 }
14815 function isUpdater(argument) {
14816 return typeof argument === "function";
14817 }
14818 function isLazyValue(value) {
14819 return typeof value === "function";
14820 }
14821 function hasOwnProperty(object, prop) {
14822 if (typeof Object.hasOwn === "function") {
14823 return Object.hasOwn(object, prop);
14824 }
14825 return Object.prototype.hasOwnProperty.call(object, prop);
14826 }
14827 function chain(...fns) {
14828 return (...args) => {
14829 for (const fn of fns) {
14830 if (typeof fn === "function") {
14831 fn(...args);
14832 }
14833 }
14834 };
14835 }
14836 function normalizeString(str) {
14837 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
14838 }
14839 function omit(object, keys) {
14840 const result = { ...object };
14841 for (const key of keys) {
14842 if (hasOwnProperty(result, key)) {
14843 delete result[key];
14844 }
14845 }
14846 return result;
14847 }
14848 function pick(object, paths) {
14849 const result = {};
14850 for (const key of paths) {
14851 if (hasOwnProperty(object, key)) {
14852 result[key] = object[key];
14853 }
14854 }
14855 return result;
14856 }
14857 function identity(value) {
14858 return value;
14859 }
14860 function invariant(condition, message2) {
14861 if (condition) return;
14862 if (typeof message2 !== "string") throw new Error("Invariant failed");
14863 throw new Error(message2);
14864 }
14865 function getKeys(obj) {
14866 return Object.keys(obj);
14867 }
14868 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
14869 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
14870 if (result == null) return false;
14871 return !result;
14872 }
14873 function disabledFromProps(props) {
14874 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
14875 }
14876 function removeUndefinedValues(obj) {
14877 const result = {};
14878 for (const key in obj) {
14879 if (obj[key] !== void 0) {
14880 result[key] = obj[key];
14881 }
14882 }
14883 return result;
14884 }
14885 function defaultValue(...values) {
14886 for (const value of values) {
14887 if (value !== void 0) return value;
14888 }
14889 return void 0;
14890 }
14891
14892 // node_modules/@ariakit/react-core/esm/__chunks/YXGXYGQX.js
14893 var import_react11 = __toESM(require_react(), 1);
14894 function setRef(ref, value) {
14895 if (typeof ref === "function") {
14896 ref(value);
14897 } else if (ref) {
14898 ref.current = value;
14899 }
14900 }
14901 function isValidElementWithRef(element) {
14902 if (!element) return false;
14903 if (!(0, import_react11.isValidElement)(element)) return false;
14904 if ("ref" in element.props) return true;
14905 if ("ref" in element) return true;
14906 return false;
14907 }
14908 function getRefProperty(element) {
14909 if (!isValidElementWithRef(element)) return null;
14910 const props = { ...element.props };
14911 return props.ref || element.ref;
14912 }
14913 function mergeProps3(base, overrides) {
14914 const props = { ...base };
14915 for (const key in overrides) {
14916 if (!hasOwnProperty(overrides, key)) continue;
14917 if (key === "className") {
14918 const prop = "className";
14919 props[prop] = base[prop] ? `${base[prop]} ${overrides[prop]}` : overrides[prop];
14920 continue;
14921 }
14922 if (key === "style") {
14923 const prop = "style";
14924 props[prop] = base[prop] ? { ...base[prop], ...overrides[prop] } : overrides[prop];
14925 continue;
14926 }
14927 const overrideValue = overrides[key];
14928 if (typeof overrideValue === "function" && key.startsWith("on")) {
14929 const baseValue = base[key];
14930 if (typeof baseValue === "function") {
14931 props[key] = (...args) => {
14932 overrideValue(...args);
14933 baseValue(...args);
14934 };
14935 continue;
14936 }
14937 }
14938 props[key] = overrideValue;
14939 }
14940 return props;
14941 }
14942
14943 // node_modules/@ariakit/core/esm/__chunks/3DNM6L6E.js
14944 var canUseDOM = checkIsBrowser();
14945 function checkIsBrowser() {
14946 var _a;
14947 return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement);
14948 }
14949 function getDocument(node) {
14950 if (!node) return document;
14951 if ("self" in node) return node.document;
14952 return node.ownerDocument || document;
14953 }
14954 function getActiveElement(node, activeDescendant = false) {
14955 var _a;
14956 const { activeElement: activeElement2 } = getDocument(node);
14957 if (!(activeElement2 == null ? void 0 : activeElement2.nodeName)) {
14958 return null;
14959 }
14960 if (isFrame(activeElement2) && ((_a = activeElement2.contentDocument) == null ? void 0 : _a.body)) {
14961 return getActiveElement(
14962 activeElement2.contentDocument.body,
14963 activeDescendant
14964 );
14965 }
14966 if (activeDescendant) {
14967 const id = activeElement2.getAttribute("aria-activedescendant");
14968 if (id) {
14969 const element = getDocument(activeElement2).getElementById(id);
14970 if (element) {
14971 return element;
14972 }
14973 }
14974 }
14975 return activeElement2;
14976 }
14977 function contains2(parent, child) {
14978 return parent === child || parent.contains(child);
14979 }
14980 function isFrame(element) {
14981 return element.tagName === "IFRAME";
14982 }
14983 function isButton(element) {
14984 const tagName = element.tagName.toLowerCase();
14985 if (tagName === "button") return true;
14986 if (tagName === "input" && element.type) {
14987 return buttonInputTypes.indexOf(element.type) !== -1;
14988 }
14989 return false;
14990 }
14991 var buttonInputTypes = [
14992 "button",
14993 "color",
14994 "file",
14995 "image",
14996 "reset",
14997 "submit"
14998 ];
14999 function isVisible(element) {
15000 if (typeof element.checkVisibility === "function") {
15001 return element.checkVisibility();
15002 }
15003 const htmlElement = element;
15004 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
15005 }
15006 function isTextField(element) {
15007 try {
15008 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
15009 const isTextArea = element.tagName === "TEXTAREA";
15010 return isTextInput || isTextArea || false;
15011 } catch (_error) {
15012 return false;
15013 }
15014 }
15015 function isTextbox(element) {
15016 return element.isContentEditable || isTextField(element);
15017 }
15018 function getTextboxValue(element) {
15019 if (isTextField(element)) {
15020 return element.value;
15021 }
15022 if (element.isContentEditable) {
15023 const range = getDocument(element).createRange();
15024 range.selectNodeContents(element);
15025 return range.toString();
15026 }
15027 return "";
15028 }
15029 function getTextboxSelection(element) {
15030 let start = 0;
15031 let end = 0;
15032 if (isTextField(element)) {
15033 start = element.selectionStart || 0;
15034 end = element.selectionEnd || 0;
15035 } else if (element.isContentEditable) {
15036 const selection = getDocument(element).getSelection();
15037 if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) {
15038 const range = selection.getRangeAt(0);
15039 const nextRange = range.cloneRange();
15040 nextRange.selectNodeContents(element);
15041 nextRange.setEnd(range.startContainer, range.startOffset);
15042 start = nextRange.toString().length;
15043 nextRange.setEnd(range.endContainer, range.endOffset);
15044 end = nextRange.toString().length;
15045 }
15046 }
15047 return { start, end };
15048 }
15049 function getPopupRole(element, fallback) {
15050 const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"];
15051 const role = element == null ? void 0 : element.getAttribute("role");
15052 if (role && allowedPopupRoles.indexOf(role) !== -1) {
15053 return role;
15054 }
15055 return fallback;
15056 }
15057 function getScrollingElement(element) {
15058 if (!element) return null;
15059 const isScrollableOverflow = (overflow) => {
15060 if (overflow === "auto") return true;
15061 if (overflow === "scroll") return true;
15062 return false;
15063 };
15064 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
15065 const { overflowY } = getComputedStyle(element);
15066 if (isScrollableOverflow(overflowY)) return element;
15067 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
15068 const { overflowX } = getComputedStyle(element);
15069 if (isScrollableOverflow(overflowX)) return element;
15070 }
15071 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body;
15072 }
15073 function setSelectionRange(element, ...args) {
15074 if (/text|search|password|tel|url/i.test(element.type)) {
15075 element.setSelectionRange(...args);
15076 }
15077 }
15078 function sortBasedOnDOMPosition(items, getElement) {
15079 const pairs = items.map((item, index2) => [index2, item]);
15080 let isOrderDifferent = false;
15081 pairs.sort(([indexA, a2], [indexB, b2]) => {
15082 const elementA = getElement(a2);
15083 const elementB = getElement(b2);
15084 if (elementA === elementB) return 0;
15085 if (!elementA || !elementB) return 0;
15086 if (isElementPreceding(elementA, elementB)) {
15087 if (indexA > indexB) {
15088 isOrderDifferent = true;
15089 }
15090 return -1;
15091 }
15092 if (indexA < indexB) {
15093 isOrderDifferent = true;
15094 }
15095 return 1;
15096 });
15097 if (isOrderDifferent) {
15098 return pairs.map(([_, item]) => item);
15099 }
15100 return items;
15101 }
15102 function isElementPreceding(a2, b2) {
15103 return Boolean(
15104 b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING
15105 );
15106 }
15107
15108 // node_modules/@ariakit/core/esm/__chunks/SNHYQNEZ.js
15109 function isTouchDevice() {
15110 return canUseDOM && !!navigator.maxTouchPoints;
15111 }
15112 function isApple() {
15113 if (!canUseDOM) return false;
15114 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
15115 }
15116 function isSafari2() {
15117 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
15118 }
15119 function isFirefox2() {
15120 return canUseDOM && /firefox\//i.test(navigator.userAgent);
15121 }
15122
15123 // node_modules/@ariakit/core/esm/utils/events.js
15124 function isPortalEvent(event) {
15125 return Boolean(
15126 event.currentTarget && !contains2(event.currentTarget, event.target)
15127 );
15128 }
15129 function isSelfTarget(event) {
15130 return event.target === event.currentTarget;
15131 }
15132 function isOpeningInNewTab(event) {
15133 const element = event.currentTarget;
15134 if (!element) return false;
15135 const isAppleDevice = isApple();
15136 if (isAppleDevice && !event.metaKey) return false;
15137 if (!isAppleDevice && !event.ctrlKey) return false;
15138 const tagName = element.tagName.toLowerCase();
15139 if (tagName === "a") return true;
15140 if (tagName === "button" && element.type === "submit") return true;
15141 if (tagName === "input" && element.type === "submit") return true;
15142 return false;
15143 }
15144 function isDownloading(event) {
15145 const element = event.currentTarget;
15146 if (!element) return false;
15147 const tagName = element.tagName.toLowerCase();
15148 if (!event.altKey) return false;
15149 if (tagName === "a") return true;
15150 if (tagName === "button" && element.type === "submit") return true;
15151 if (tagName === "input" && element.type === "submit") return true;
15152 return false;
15153 }
15154 function fireBlurEvent(element, eventInit) {
15155 const event = new FocusEvent("blur", eventInit);
15156 const defaultAllowed = element.dispatchEvent(event);
15157 const bubbleInit = { ...eventInit, bubbles: true };
15158 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
15159 return defaultAllowed;
15160 }
15161 function fireKeyboardEvent(element, type, eventInit) {
15162 const event = new KeyboardEvent(type, eventInit);
15163 return element.dispatchEvent(event);
15164 }
15165 function fireClickEvent(element, eventInit) {
15166 const event = new MouseEvent("click", eventInit);
15167 return element.dispatchEvent(event);
15168 }
15169 function isFocusEventOutside(event, container) {
15170 const containerElement = container || event.currentTarget;
15171 const relatedTarget = event.relatedTarget;
15172 return !relatedTarget || !contains2(containerElement, relatedTarget);
15173 }
15174 function queueBeforeEvent(element, type, callback, timeout) {
15175 const createTimer = (callback2) => {
15176 if (timeout) {
15177 const timerId2 = setTimeout(callback2, timeout);
15178 return () => clearTimeout(timerId2);
15179 }
15180 const timerId = requestAnimationFrame(callback2);
15181 return () => cancelAnimationFrame(timerId);
15182 };
15183 const cancelTimer = createTimer(() => {
15184 element.removeEventListener(type, callSync, true);
15185 callback();
15186 });
15187 const callSync = () => {
15188 cancelTimer();
15189 callback();
15190 };
15191 element.addEventListener(type, callSync, { once: true, capture: true });
15192 return cancelTimer;
15193 }
15194 function addGlobalEventListener(type, listener, options, scope = window) {
15195 const children = [];
15196 try {
15197 scope.document.addEventListener(type, listener, options);
15198 for (const frame of Array.from(scope.frames)) {
15199 children.push(addGlobalEventListener(type, listener, options, frame));
15200 }
15201 } catch (e2) {
15202 }
15203 const removeEventListener = () => {
15204 try {
15205 scope.document.removeEventListener(type, listener, options);
15206 } catch (e2) {
15207 }
15208 for (const remove of children) {
15209 remove();
15210 }
15211 };
15212 return removeEventListener;
15213 }
15214
15215 // node_modules/@ariakit/react-core/esm/__chunks/KPHZR4MB.js
15216 var React48 = __toESM(require_react(), 1);
15217 var import_react12 = __toESM(require_react(), 1);
15218 var _React = { ...React48 };
15219 var useReactId = _React.useId;
15220 var useReactDeferredValue = _React.useDeferredValue;
15221 var useReactInsertionEffect = _React.useInsertionEffect;
15222 var useSafeLayoutEffect = canUseDOM ? import_react12.useLayoutEffect : import_react12.useEffect;
15223 function useInitialValue(value) {
15224 const [initialValue] = (0, import_react12.useState)(value);
15225 return initialValue;
15226 }
15227 function useLiveRef(value) {
15228 const ref = (0, import_react12.useRef)(value);
15229 useSafeLayoutEffect(() => {
15230 ref.current = value;
15231 });
15232 return ref;
15233 }
15234 function useEvent(callback) {
15235 const ref = (0, import_react12.useRef)(() => {
15236 throw new Error("Cannot call an event handler while rendering.");
15237 });
15238 if (useReactInsertionEffect) {
15239 useReactInsertionEffect(() => {
15240 ref.current = callback;
15241 });
15242 } else {
15243 ref.current = callback;
15244 }
15245 return (0, import_react12.useCallback)((...args) => {
15246 var _a;
15247 return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args);
15248 }, []);
15249 }
15250 function useTransactionState(callback) {
15251 const [state, setState] = (0, import_react12.useState)(null);
15252 useSafeLayoutEffect(() => {
15253 if (state == null) return;
15254 if (!callback) return;
15255 let prevState = null;
15256 callback((prev) => {
15257 prevState = prev;
15258 return state;
15259 });
15260 return () => {
15261 callback(prevState);
15262 };
15263 }, [state, callback]);
15264 return [state, setState];
15265 }
15266 function useMergeRefs(...refs) {
15267 return (0, import_react12.useMemo)(() => {
15268 if (!refs.some(Boolean)) return;
15269 return (value) => {
15270 for (const ref of refs) {
15271 setRef(ref, value);
15272 }
15273 };
15274 }, refs);
15275 }
15276 function useId4(defaultId) {
15277 if (useReactId) {
15278 const reactId = useReactId();
15279 if (defaultId) return defaultId;
15280 return reactId;
15281 }
15282 const [id, setId] = (0, import_react12.useState)(defaultId);
15283 useSafeLayoutEffect(() => {
15284 if (defaultId || id) return;
15285 const random = Math.random().toString(36).slice(2, 8);
15286 setId(`id-${random}`);
15287 }, [defaultId, id]);
15288 return defaultId || id;
15289 }
15290 function useTagName(refOrElement, type) {
15291 const stringOrUndefined = (type2) => {
15292 if (typeof type2 !== "string") return;
15293 return type2;
15294 };
15295 const [tagName, setTagName] = (0, import_react12.useState)(() => stringOrUndefined(type));
15296 useSafeLayoutEffect(() => {
15297 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
15298 setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type));
15299 }, [refOrElement, type]);
15300 return tagName;
15301 }
15302 function useAttribute(refOrElement, attributeName, defaultValue2) {
15303 const initialValue = useInitialValue(defaultValue2);
15304 const [attribute, setAttribute] = (0, import_react12.useState)(initialValue);
15305 (0, import_react12.useEffect)(() => {
15306 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
15307 if (!element) return;
15308 const callback = () => {
15309 const value = element.getAttribute(attributeName);
15310 setAttribute(value == null ? initialValue : value);
15311 };
15312 const observer = new MutationObserver(callback);
15313 observer.observe(element, { attributeFilter: [attributeName] });
15314 callback();
15315 return () => observer.disconnect();
15316 }, [refOrElement, attributeName, initialValue]);
15317 return attribute;
15318 }
15319 function useUpdateEffect(effect, deps) {
15320 const mounted = (0, import_react12.useRef)(false);
15321 (0, import_react12.useEffect)(() => {
15322 if (mounted.current) {
15323 return effect();
15324 }
15325 mounted.current = true;
15326 }, deps);
15327 (0, import_react12.useEffect)(
15328 () => () => {
15329 mounted.current = false;
15330 },
15331 []
15332 );
15333 }
15334 function useUpdateLayoutEffect(effect, deps) {
15335 const mounted = (0, import_react12.useRef)(false);
15336 useSafeLayoutEffect(() => {
15337 if (mounted.current) {
15338 return effect();
15339 }
15340 mounted.current = true;
15341 }, deps);
15342 useSafeLayoutEffect(
15343 () => () => {
15344 mounted.current = false;
15345 },
15346 []
15347 );
15348 }
15349 function useForceUpdate() {
15350 return (0, import_react12.useReducer)(() => [], []);
15351 }
15352 function useBooleanEvent(booleanOrCallback) {
15353 return useEvent(
15354 typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback
15355 );
15356 }
15357 function useWrapElement(props, callback, deps = []) {
15358 const wrapElement = (0, import_react12.useCallback)(
15359 (element) => {
15360 if (props.wrapElement) {
15361 element = props.wrapElement(element);
15362 }
15363 return callback(element);
15364 },
15365 [...deps, props.wrapElement]
15366 );
15367 return { ...props, wrapElement };
15368 }
15369 function useMetadataProps(props, key, value) {
15370 const parent = props.onLoadedMetadataCapture;
15371 const onLoadedMetadataCapture = (0, import_react12.useMemo)(() => {
15372 return Object.assign(() => {
15373 }, { ...parent, [key]: value });
15374 }, [parent, key, value]);
15375 return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }];
15376 }
15377 var hasInstalledGlobalEventListeners = false;
15378 function useIsMouseMoving() {
15379 (0, import_react12.useEffect)(() => {
15380 if (hasInstalledGlobalEventListeners) return;
15381 addGlobalEventListener("mousemove", setMouseMoving, true);
15382 addGlobalEventListener("mousedown", resetMouseMoving, true);
15383 addGlobalEventListener("mouseup", resetMouseMoving, true);
15384 addGlobalEventListener("keydown", resetMouseMoving, true);
15385 addGlobalEventListener("scroll", resetMouseMoving, true);
15386 hasInstalledGlobalEventListeners = true;
15387 }, []);
15388 const isMouseMoving = useEvent(() => mouseMoving);
15389 return isMouseMoving;
15390 }
15391 var mouseMoving = false;
15392 var previousScreenX = 0;
15393 var previousScreenY = 0;
15394 function hasMouseMovement(event) {
15395 const movementX = event.movementX || event.screenX - previousScreenX;
15396 const movementY = event.movementY || event.screenY - previousScreenY;
15397 previousScreenX = event.screenX;
15398 previousScreenY = event.screenY;
15399 return movementX || movementY || false;
15400 }
15401 function setMouseMoving(event) {
15402 if (!hasMouseMovement(event)) return;
15403 mouseMoving = true;
15404 }
15405 function resetMouseMoving() {
15406 mouseMoving = false;
15407 }
15408
15409 // node_modules/@ariakit/react-core/esm/__chunks/GWSL6KNJ.js
15410 var React49 = __toESM(require_react(), 1);
15411 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
15412 function forwardRef29(render4) {
15413 const Role = React49.forwardRef(
15414 // @ts-ignore Incompatible with React 19 types. Ignore for now.
15415 (props, ref) => render4({ ...props, ref })
15416 );
15417 Role.displayName = render4.displayName || render4.name;
15418 return Role;
15419 }
15420 function memo22(Component, propsAreEqual) {
15421 return React49.memo(Component, propsAreEqual);
15422 }
15423 function createElement3(Type, props) {
15424 const { wrapElement, render: render4, ...rest } = props;
15425 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
15426 let element;
15427 if (React49.isValidElement(render4)) {
15428 const renderProps = {
15429 // @ts-ignore Incompatible with React 19 types. Ignore for now.
15430 ...render4.props,
15431 ref: mergedRef
15432 };
15433 element = React49.cloneElement(render4, mergeProps3(rest, renderProps));
15434 } else if (render4) {
15435 element = render4(rest);
15436 } else {
15437 element = /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Type, { ...rest });
15438 }
15439 if (wrapElement) {
15440 return wrapElement(element);
15441 }
15442 return element;
15443 }
15444 function createHook(useProps) {
15445 const useRole = (props = {}) => {
15446 return useProps(props);
15447 };
15448 useRole.displayName = useProps.name;
15449 return useRole;
15450 }
15451 function createStoreContext(providers = [], scopedProviders = []) {
15452 const context = React49.createContext(void 0);
15453 const scopedContext = React49.createContext(void 0);
15454 const useContext210 = () => React49.useContext(context);
15455 const useScopedContext = (onlyScoped = false) => {
15456 const scoped = React49.useContext(scopedContext);
15457 const store = useContext210();
15458 if (onlyScoped) return scoped;
15459 return scoped || store;
15460 };
15461 const useProviderContext = () => {
15462 const scoped = React49.useContext(scopedContext);
15463 const store = useContext210();
15464 if (scoped && scoped === store) return;
15465 return store;
15466 };
15467 const ContextProvider = (props) => {
15468 return providers.reduceRight(
15469 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Provider2, { ...props, children }),
15470 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(context.Provider, { ...props })
15471 );
15472 };
15473 const ScopedContextProvider = (props) => {
15474 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(ContextProvider, { ...props, children: scopedProviders.reduceRight(
15475 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Provider2, { ...props, children }),
15476 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(scopedContext.Provider, { ...props })
15477 ) });
15478 };
15479 return {
15480 context,
15481 scopedContext,
15482 useContext: useContext210,
15483 useScopedContext,
15484 useProviderContext,
15485 ContextProvider,
15486 ScopedContextProvider
15487 };
15488 }
15489
15490 // node_modules/@ariakit/react-core/esm/__chunks/SMPCIMZM.js
15491 var ctx = createStoreContext();
15492 var useCollectionContext = ctx.useContext;
15493 var useCollectionScopedContext = ctx.useScopedContext;
15494 var useCollectionProviderContext = ctx.useProviderContext;
15495 var CollectionContextProvider = ctx.ContextProvider;
15496 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
15497
15498 // node_modules/@ariakit/react-core/esm/__chunks/AVVXDJMZ.js
15499 var import_react13 = __toESM(require_react(), 1);
15500 var ctx2 = createStoreContext(
15501 [CollectionContextProvider],
15502 [CollectionScopedContextProvider]
15503 );
15504 var useCompositeContext = ctx2.useContext;
15505 var useCompositeScopedContext = ctx2.useScopedContext;
15506 var useCompositeProviderContext = ctx2.useProviderContext;
15507 var CompositeContextProvider = ctx2.ContextProvider;
15508 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
15509 var CompositeItemContext = (0, import_react13.createContext)(
15510 void 0
15511 );
15512 var CompositeRowContext = (0, import_react13.createContext)(
15513 void 0
15514 );
15515
15516 // node_modules/@ariakit/react-core/esm/__chunks/5VQZOHHZ.js
15517 function findFirstEnabledItem(items, excludeId) {
15518 return items.find((item) => {
15519 if (excludeId) {
15520 return !item.disabled && item.id !== excludeId;
15521 }
15522 return !item.disabled;
15523 });
15524 }
15525 function getEnabledItem(store, id) {
15526 if (!id) return null;
15527 return store.item(id) || null;
15528 }
15529 function groupItemsByRows(items) {
15530 const rows = [];
15531 for (const item of items) {
15532 const row = rows.find((currentRow) => {
15533 var _a;
15534 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
15535 });
15536 if (row) {
15537 row.push(item);
15538 } else {
15539 rows.push([item]);
15540 }
15541 }
15542 return rows;
15543 }
15544 function selectTextField(element, collapseToEnd = false) {
15545 if (isTextField(element)) {
15546 element.setSelectionRange(
15547 collapseToEnd ? element.value.length : 0,
15548 element.value.length
15549 );
15550 } else if (element.isContentEditable) {
15551 const selection = getDocument(element).getSelection();
15552 selection == null ? void 0 : selection.selectAllChildren(element);
15553 if (collapseToEnd) {
15554 selection == null ? void 0 : selection.collapseToEnd();
15555 }
15556 }
15557 }
15558 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
15559 function focusSilently(element) {
15560 element[FOCUS_SILENTLY] = true;
15561 element.focus({ preventScroll: true });
15562 }
15563 function silentlyFocused(element) {
15564 const isSilentlyFocused = element[FOCUS_SILENTLY];
15565 delete element[FOCUS_SILENTLY];
15566 return isSilentlyFocused;
15567 }
15568 function isItem(store, element, exclude) {
15569 if (!element) return false;
15570 if (element === exclude) return false;
15571 const item = store.item(element.id);
15572 if (!item) return false;
15573 if (exclude && item.element === exclude) return false;
15574 return true;
15575 }
15576
15577 // node_modules/@ariakit/react-core/esm/__chunks/Z2O3VLAQ.js
15578 var import_react14 = __toESM(require_react(), 1);
15579 var TagName = "div";
15580 var useCollectionItem = createHook(
15581 function useCollectionItem2({
15582 store,
15583 shouldRegisterItem = true,
15584 getItem = identity,
15585 // @ts-expect-error This prop may come from a collection renderer.
15586 element,
15587 ...props
15588 }) {
15589 const context = useCollectionContext();
15590 store = store || context;
15591 const id = useId4(props.id);
15592 const ref = (0, import_react14.useRef)(element);
15593 (0, import_react14.useEffect)(() => {
15594 const element2 = ref.current;
15595 if (!id) return;
15596 if (!element2) return;
15597 if (!shouldRegisterItem) return;
15598 const item = getItem({ id, element: element2 });
15599 return store == null ? void 0 : store.renderItem(item);
15600 }, [id, shouldRegisterItem, getItem, store]);
15601 props = {
15602 ...props,
15603 ref: useMergeRefs(ref, props.ref)
15604 };
15605 return removeUndefinedValues(props);
15606 }
15607 );
15608 var CollectionItem = forwardRef29(function CollectionItem2(props) {
15609 const htmlProps = useCollectionItem(props);
15610 return createElement3(TagName, htmlProps);
15611 });
15612
15613 // node_modules/@ariakit/react-core/esm/__chunks/SWN3JYXT.js
15614 var import_react15 = __toESM(require_react(), 1);
15615 var FocusableContext = (0, import_react15.createContext)(true);
15616
15617 // node_modules/@ariakit/core/esm/utils/focus.js
15618 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'])";
15619 function isFocusable(element) {
15620 if (!element.matches(selector)) return false;
15621 if (!isVisible(element)) return false;
15622 if (element.closest("[inert]")) return false;
15623 return true;
15624 }
15625 function getClosestFocusable(element) {
15626 while (element && !isFocusable(element)) {
15627 element = element.closest(selector);
15628 }
15629 return element || null;
15630 }
15631 function hasFocus(element) {
15632 const activeElement2 = getActiveElement(element);
15633 if (!activeElement2) return false;
15634 if (activeElement2 === element) return true;
15635 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15636 if (!activeDescendant) return false;
15637 return activeDescendant === element.id;
15638 }
15639 function hasFocusWithin(element) {
15640 const activeElement2 = getActiveElement(element);
15641 if (!activeElement2) return false;
15642 if (contains2(element, activeElement2)) return true;
15643 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15644 if (!activeDescendant) return false;
15645 if (!("id" in element)) return false;
15646 if (activeDescendant === element.id) return true;
15647 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
15648 }
15649 function focusIfNeeded(element) {
15650 if (!hasFocusWithin(element) && isFocusable(element)) {
15651 element.focus();
15652 }
15653 }
15654 function focusIntoView(element, options) {
15655 if (!("scrollIntoView" in element)) {
15656 element.focus();
15657 } else {
15658 element.focus({ preventScroll: true });
15659 element.scrollIntoView({ block: "nearest", inline: "nearest", ...options });
15660 }
15661 }
15662
15663 // node_modules/@ariakit/react-core/esm/__chunks/U6HHPQDW.js
15664 var import_react16 = __toESM(require_react(), 1);
15665 var TagName2 = "div";
15666 var isSafariBrowser = isSafari2();
15667 var alwaysFocusVisibleInputTypes = [
15668 "text",
15669 "search",
15670 "url",
15671 "tel",
15672 "email",
15673 "password",
15674 "number",
15675 "date",
15676 "month",
15677 "week",
15678 "time",
15679 "datetime",
15680 "datetime-local"
15681 ];
15682 var safariFocusAncestorSymbol = /* @__PURE__ */ Symbol("safariFocusAncestor");
15683 function markSafariFocusAncestor(element, value) {
15684 if (!element) return;
15685 element[safariFocusAncestorSymbol] = value;
15686 }
15687 function isAlwaysFocusVisible(element) {
15688 const { tagName, readOnly, type } = element;
15689 if (tagName === "TEXTAREA" && !readOnly) return true;
15690 if (tagName === "SELECT" && !readOnly) return true;
15691 if (tagName === "INPUT" && !readOnly) {
15692 return alwaysFocusVisibleInputTypes.includes(type);
15693 }
15694 if (element.isContentEditable) return true;
15695 const role = element.getAttribute("role");
15696 if (role === "combobox" && element.dataset.name) {
15697 return true;
15698 }
15699 return false;
15700 }
15701 function getLabels(element) {
15702 if ("labels" in element) {
15703 return element.labels;
15704 }
15705 return null;
15706 }
15707 function isNativeCheckboxOrRadio(element) {
15708 const tagName = element.tagName.toLowerCase();
15709 if (tagName === "input" && element.type) {
15710 return element.type === "radio" || element.type === "checkbox";
15711 }
15712 return false;
15713 }
15714 function isNativeTabbable(tagName) {
15715 if (!tagName) return true;
15716 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
15717 }
15718 function supportsDisabledAttribute(tagName) {
15719 if (!tagName) return true;
15720 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
15721 }
15722 function getTabIndex2(focusable2, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) {
15723 if (!focusable2) {
15724 return tabIndexProp;
15725 }
15726 if (trulyDisabled) {
15727 if (nativeTabbable && !supportsDisabled) {
15728 return -1;
15729 }
15730 return;
15731 }
15732 if (nativeTabbable) {
15733 return tabIndexProp;
15734 }
15735 return tabIndexProp || 0;
15736 }
15737 function useDisableEvent(onEvent, disabled2) {
15738 return useEvent((event) => {
15739 onEvent == null ? void 0 : onEvent(event);
15740 if (event.defaultPrevented) return;
15741 if (disabled2) {
15742 event.stopPropagation();
15743 event.preventDefault();
15744 }
15745 });
15746 }
15747 var hasInstalledGlobalEventListeners2 = false;
15748 var isKeyboardModality = true;
15749 function onGlobalMouseDown(event) {
15750 const target = event.target;
15751 if (target && "hasAttribute" in target) {
15752 if (!target.hasAttribute("data-focus-visible")) {
15753 isKeyboardModality = false;
15754 }
15755 }
15756 }
15757 function onGlobalKeyDown(event) {
15758 if (event.metaKey) return;
15759 if (event.ctrlKey) return;
15760 if (event.altKey) return;
15761 isKeyboardModality = true;
15762 }
15763 var useFocusable = createHook(
15764 function useFocusable2({
15765 focusable: focusable2 = true,
15766 accessibleWhenDisabled,
15767 autoFocus,
15768 onFocusVisible,
15769 ...props
15770 }) {
15771 const ref = (0, import_react16.useRef)(null);
15772 (0, import_react16.useEffect)(() => {
15773 if (!focusable2) return;
15774 if (hasInstalledGlobalEventListeners2) return;
15775 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
15776 addGlobalEventListener("keydown", onGlobalKeyDown, true);
15777 hasInstalledGlobalEventListeners2 = true;
15778 }, [focusable2]);
15779 if (isSafariBrowser) {
15780 (0, import_react16.useEffect)(() => {
15781 if (!focusable2) return;
15782 const element = ref.current;
15783 if (!element) return;
15784 if (!isNativeCheckboxOrRadio(element)) return;
15785 const labels = getLabels(element);
15786 if (!labels) return;
15787 const onMouseUp = () => queueMicrotask(() => element.focus());
15788 for (const label of labels) {
15789 label.addEventListener("mouseup", onMouseUp);
15790 }
15791 return () => {
15792 for (const label of labels) {
15793 label.removeEventListener("mouseup", onMouseUp);
15794 }
15795 };
15796 }, [focusable2]);
15797 }
15798 const disabled2 = focusable2 && disabledFromProps(props);
15799 const trulyDisabled = !!disabled2 && !accessibleWhenDisabled;
15800 const [focusVisible, setFocusVisible] = (0, import_react16.useState)(false);
15801 (0, import_react16.useEffect)(() => {
15802 if (!focusable2) return;
15803 if (trulyDisabled && focusVisible) {
15804 setFocusVisible(false);
15805 }
15806 }, [focusable2, trulyDisabled, focusVisible]);
15807 (0, import_react16.useEffect)(() => {
15808 if (!focusable2) return;
15809 if (!focusVisible) return;
15810 const element = ref.current;
15811 if (!element) return;
15812 if (typeof IntersectionObserver === "undefined") return;
15813 const observer = new IntersectionObserver(() => {
15814 if (!isFocusable(element)) {
15815 setFocusVisible(false);
15816 }
15817 });
15818 observer.observe(element);
15819 return () => observer.disconnect();
15820 }, [focusable2, focusVisible]);
15821 const onKeyPressCapture = useDisableEvent(
15822 props.onKeyPressCapture,
15823 disabled2
15824 );
15825 const onMouseDownCapture = useDisableEvent(
15826 props.onMouseDownCapture,
15827 disabled2
15828 );
15829 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
15830 const onMouseDownProp = props.onMouseDown;
15831 const onMouseDown = useEvent((event) => {
15832 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
15833 if (event.defaultPrevented) return;
15834 if (!focusable2) return;
15835 const element = event.currentTarget;
15836 if (!isSafariBrowser) return;
15837 if (isPortalEvent(event)) return;
15838 if (!isButton(element) && !isNativeCheckboxOrRadio(element)) return;
15839 let receivedFocus = false;
15840 const onFocus = () => {
15841 receivedFocus = true;
15842 };
15843 const options = { capture: true, once: true };
15844 element.addEventListener("focusin", onFocus, options);
15845 const focusableContainer = getClosestFocusable(element.parentElement);
15846 markSafariFocusAncestor(focusableContainer, true);
15847 queueBeforeEvent(element, "mouseup", () => {
15848 element.removeEventListener("focusin", onFocus, true);
15849 markSafariFocusAncestor(focusableContainer, false);
15850 if (receivedFocus) return;
15851 focusIfNeeded(element);
15852 });
15853 });
15854 const handleFocusVisible = (event, currentTarget) => {
15855 if (currentTarget) {
15856 event.currentTarget = currentTarget;
15857 }
15858 if (!focusable2) return;
15859 const element = event.currentTarget;
15860 if (!element) return;
15861 if (!hasFocus(element)) return;
15862 onFocusVisible == null ? void 0 : onFocusVisible(event);
15863 if (event.defaultPrevented) return;
15864 element.dataset.focusVisible = "true";
15865 setFocusVisible(true);
15866 };
15867 const onKeyDownCaptureProp = props.onKeyDownCapture;
15868 const onKeyDownCapture = useEvent((event) => {
15869 onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event);
15870 if (event.defaultPrevented) return;
15871 if (!focusable2) return;
15872 if (focusVisible) return;
15873 if (event.metaKey) return;
15874 if (event.altKey) return;
15875 if (event.ctrlKey) return;
15876 if (!isSelfTarget(event)) return;
15877 const element = event.currentTarget;
15878 const applyFocusVisible = () => handleFocusVisible(event, element);
15879 queueBeforeEvent(element, "focusout", applyFocusVisible);
15880 });
15881 const onFocusCaptureProp = props.onFocusCapture;
15882 const onFocusCapture = useEvent((event) => {
15883 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
15884 if (event.defaultPrevented) return;
15885 if (!focusable2) return;
15886 if (!isSelfTarget(event)) {
15887 setFocusVisible(false);
15888 return;
15889 }
15890 const element = event.currentTarget;
15891 const applyFocusVisible = () => handleFocusVisible(event, element);
15892 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) {
15893 queueBeforeEvent(event.target, "focusout", applyFocusVisible);
15894 } else {
15895 setFocusVisible(false);
15896 }
15897 });
15898 const onBlurProp = props.onBlur;
15899 const onBlur = useEvent((event) => {
15900 onBlurProp == null ? void 0 : onBlurProp(event);
15901 if (!focusable2) return;
15902 if (!isFocusEventOutside(event)) return;
15903 event.currentTarget.removeAttribute("data-focus-visible");
15904 setFocusVisible(false);
15905 });
15906 const autoFocusOnShow = (0, import_react16.useContext)(FocusableContext);
15907 const autoFocusRef = useEvent((element) => {
15908 if (!focusable2) return;
15909 if (!autoFocus) return;
15910 if (!element) return;
15911 if (!autoFocusOnShow) return;
15912 queueMicrotask(() => {
15913 if (hasFocus(element)) return;
15914 if (!isFocusable(element)) return;
15915 element.focus();
15916 });
15917 });
15918 const tagName = useTagName(ref);
15919 const nativeTabbable = focusable2 && isNativeTabbable(tagName);
15920 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName);
15921 const styleProp = props.style;
15922 const style = (0, import_react16.useMemo)(() => {
15923 if (trulyDisabled) {
15924 return { pointerEvents: "none", ...styleProp };
15925 }
15926 return styleProp;
15927 }, [trulyDisabled, styleProp]);
15928 props = {
15929 "data-focus-visible": focusable2 && focusVisible || void 0,
15930 "data-autofocus": autoFocus || void 0,
15931 "aria-disabled": disabled2 || void 0,
15932 ...props,
15933 ref: useMergeRefs(ref, autoFocusRef, props.ref),
15934 style,
15935 tabIndex: getTabIndex2(
15936 focusable2,
15937 trulyDisabled,
15938 nativeTabbable,
15939 supportsDisabled,
15940 props.tabIndex
15941 ),
15942 disabled: supportsDisabled && trulyDisabled ? true : void 0,
15943 // TODO: Test Focusable contentEditable.
15944 contentEditable: disabled2 ? void 0 : props.contentEditable,
15945 onKeyPressCapture,
15946 onClickCapture,
15947 onMouseDownCapture,
15948 onMouseDown,
15949 onKeyDownCapture,
15950 onFocusCapture,
15951 onBlur
15952 };
15953 return removeUndefinedValues(props);
15954 }
15955 );
15956 var Focusable = forwardRef29(function Focusable2(props) {
15957 const htmlProps = useFocusable(props);
15958 return createElement3(TagName2, htmlProps);
15959 });
15960
15961 // node_modules/@ariakit/react-core/esm/__chunks/PZ3OL7I2.js
15962 var import_react17 = __toESM(require_react(), 1);
15963 var TagName3 = "button";
15964 function isNativeClick(event) {
15965 if (!event.isTrusted) return false;
15966 const element = event.currentTarget;
15967 if (event.key === "Enter") {
15968 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
15969 }
15970 if (event.key === " ") {
15971 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
15972 }
15973 return false;
15974 }
15975 var symbol = /* @__PURE__ */ Symbol("command");
15976 var useCommand = createHook(
15977 function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
15978 const ref = (0, import_react17.useRef)(null);
15979 const [isNativeButton, setIsNativeButton] = (0, import_react17.useState)(false);
15980 (0, import_react17.useEffect)(() => {
15981 if (!ref.current) return;
15982 setIsNativeButton(isButton(ref.current));
15983 }, []);
15984 const [active, setActive] = (0, import_react17.useState)(false);
15985 const activeRef = (0, import_react17.useRef)(false);
15986 const disabled2 = disabledFromProps(props);
15987 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
15988 const onKeyDownProp = props.onKeyDown;
15989 const onKeyDown = useEvent((event) => {
15990 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
15991 const element = event.currentTarget;
15992 if (event.defaultPrevented) return;
15993 if (isDuplicate) return;
15994 if (disabled2) return;
15995 if (!isSelfTarget(event)) return;
15996 if (isTextField(element)) return;
15997 if (element.isContentEditable) return;
15998 const isEnter = clickOnEnter && event.key === "Enter";
15999 const isSpace = clickOnSpace && event.key === " ";
16000 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
16001 const shouldPreventSpace = event.key === " " && !clickOnSpace;
16002 if (shouldPreventEnter || shouldPreventSpace) {
16003 event.preventDefault();
16004 return;
16005 }
16006 if (isEnter || isSpace) {
16007 const nativeClick = isNativeClick(event);
16008 if (isEnter) {
16009 if (!nativeClick) {
16010 event.preventDefault();
16011 const { view, ...eventInit } = event;
16012 const click = () => fireClickEvent(element, eventInit);
16013 if (isFirefox2()) {
16014 queueBeforeEvent(element, "keyup", click);
16015 } else {
16016 queueMicrotask(click);
16017 }
16018 }
16019 } else if (isSpace) {
16020 activeRef.current = true;
16021 if (!nativeClick) {
16022 event.preventDefault();
16023 setActive(true);
16024 }
16025 }
16026 }
16027 });
16028 const onKeyUpProp = props.onKeyUp;
16029 const onKeyUp = useEvent((event) => {
16030 onKeyUpProp == null ? void 0 : onKeyUpProp(event);
16031 if (event.defaultPrevented) return;
16032 if (isDuplicate) return;
16033 if (disabled2) return;
16034 if (event.metaKey) return;
16035 const isSpace = clickOnSpace && event.key === " ";
16036 if (activeRef.current && isSpace) {
16037 activeRef.current = false;
16038 if (!isNativeClick(event)) {
16039 event.preventDefault();
16040 setActive(false);
16041 const element = event.currentTarget;
16042 const { view, ...eventInit } = event;
16043 queueMicrotask(() => fireClickEvent(element, eventInit));
16044 }
16045 }
16046 });
16047 props = {
16048 "data-active": active || void 0,
16049 type: isNativeButton ? "button" : void 0,
16050 ...metadataProps,
16051 ...props,
16052 ref: useMergeRefs(ref, props.ref),
16053 onKeyDown,
16054 onKeyUp
16055 };
16056 props = useFocusable(props);
16057 return props;
16058 }
16059 );
16060 var Command = forwardRef29(function Command2(props) {
16061 const htmlProps = useCommand(props);
16062 return createElement3(TagName3, htmlProps);
16063 });
16064
16065 // node_modules/@ariakit/core/esm/__chunks/SXKM4CGU.js
16066 function getInternal(store, key) {
16067 const internals = store.__unstableInternals;
16068 invariant(internals, "Invalid store");
16069 return internals[key];
16070 }
16071 function createStore(initialState, ...stores) {
16072 let state = initialState;
16073 let prevStateBatch = state;
16074 let lastUpdate = /* @__PURE__ */ Symbol();
16075 let destroy = noop4;
16076 const instances = /* @__PURE__ */ new Set();
16077 const updatedKeys = /* @__PURE__ */ new Set();
16078 const setups = /* @__PURE__ */ new Set();
16079 const listeners = /* @__PURE__ */ new Set();
16080 const batchListeners = /* @__PURE__ */ new Set();
16081 const disposables = /* @__PURE__ */ new WeakMap();
16082 const listenerKeys = /* @__PURE__ */ new WeakMap();
16083 const storeSetup = (callback) => {
16084 setups.add(callback);
16085 return () => setups.delete(callback);
16086 };
16087 const storeInit = () => {
16088 const initialized = instances.size;
16089 const instance = /* @__PURE__ */ Symbol();
16090 instances.add(instance);
16091 const maybeDestroy = () => {
16092 instances.delete(instance);
16093 if (instances.size) return;
16094 destroy();
16095 };
16096 if (initialized) return maybeDestroy;
16097 const desyncs = getKeys(state).map(
16098 (key) => chain(
16099 ...stores.map((store) => {
16100 var _a;
16101 const storeState = (_a = store == null ? void 0 : store.getState) == null ? void 0 : _a.call(store);
16102 if (!storeState) return;
16103 if (!hasOwnProperty(storeState, key)) return;
16104 return sync(store, [key], (state2) => {
16105 setState(
16106 key,
16107 state2[key],
16108 // @ts-expect-error - Not public API. This is just to prevent
16109 // infinite loops.
16110 true
16111 );
16112 });
16113 })
16114 )
16115 );
16116 const teardowns = [];
16117 for (const setup2 of setups) {
16118 teardowns.push(setup2());
16119 }
16120 const cleanups = stores.map(init);
16121 destroy = chain(...desyncs, ...teardowns, ...cleanups);
16122 return maybeDestroy;
16123 };
16124 const sub = (keys, listener, set2 = listeners) => {
16125 set2.add(listener);
16126 listenerKeys.set(listener, keys);
16127 return () => {
16128 var _a;
16129 (_a = disposables.get(listener)) == null ? void 0 : _a();
16130 disposables.delete(listener);
16131 listenerKeys.delete(listener);
16132 set2.delete(listener);
16133 };
16134 };
16135 const storeSubscribe = (keys, listener) => sub(keys, listener);
16136 const storeSync = (keys, listener) => {
16137 disposables.set(listener, listener(state, state));
16138 return sub(keys, listener);
16139 };
16140 const storeBatch = (keys, listener) => {
16141 disposables.set(listener, listener(state, prevStateBatch));
16142 return sub(keys, listener, batchListeners);
16143 };
16144 const storePick = (keys) => createStore(pick(state, keys), finalStore);
16145 const storeOmit = (keys) => createStore(omit(state, keys), finalStore);
16146 const getState = () => state;
16147 const setState = (key, value, fromStores = false) => {
16148 var _a;
16149 if (!hasOwnProperty(state, key)) return;
16150 const nextValue = applyState(value, state[key]);
16151 if (nextValue === state[key]) return;
16152 if (!fromStores) {
16153 for (const store of stores) {
16154 (_a = store == null ? void 0 : store.setState) == null ? void 0 : _a.call(store, key, nextValue);
16155 }
16156 }
16157 const prevState = state;
16158 state = { ...state, [key]: nextValue };
16159 const thisUpdate = /* @__PURE__ */ Symbol();
16160 lastUpdate = thisUpdate;
16161 updatedKeys.add(key);
16162 const run = (listener, prev, uKeys) => {
16163 var _a2;
16164 const keys = listenerKeys.get(listener);
16165 const updated = (k) => uKeys ? uKeys.has(k) : k === key;
16166 if (!keys || keys.some(updated)) {
16167 (_a2 = disposables.get(listener)) == null ? void 0 : _a2();
16168 disposables.set(listener, listener(state, prev));
16169 }
16170 };
16171 for (const listener of listeners) {
16172 run(listener, prevState);
16173 }
16174 queueMicrotask(() => {
16175 if (lastUpdate !== thisUpdate) return;
16176 const snapshot = state;
16177 for (const listener of batchListeners) {
16178 run(listener, prevStateBatch, updatedKeys);
16179 }
16180 prevStateBatch = snapshot;
16181 updatedKeys.clear();
16182 });
16183 };
16184 const finalStore = {
16185 getState,
16186 setState,
16187 __unstableInternals: {
16188 setup: storeSetup,
16189 init: storeInit,
16190 subscribe: storeSubscribe,
16191 sync: storeSync,
16192 batch: storeBatch,
16193 pick: storePick,
16194 omit: storeOmit
16195 }
16196 };
16197 return finalStore;
16198 }
16199 function setup(store, ...args) {
16200 if (!store) return;
16201 return getInternal(store, "setup")(...args);
16202 }
16203 function init(store, ...args) {
16204 if (!store) return;
16205 return getInternal(store, "init")(...args);
16206 }
16207 function subscribe(store, ...args) {
16208 if (!store) return;
16209 return getInternal(store, "subscribe")(...args);
16210 }
16211 function sync(store, ...args) {
16212 if (!store) return;
16213 return getInternal(store, "sync")(...args);
16214 }
16215 function batch(store, ...args) {
16216 if (!store) return;
16217 return getInternal(store, "batch")(...args);
16218 }
16219 function omit2(store, ...args) {
16220 if (!store) return;
16221 return getInternal(store, "omit")(...args);
16222 }
16223 function pick2(store, ...args) {
16224 if (!store) return;
16225 return getInternal(store, "pick")(...args);
16226 }
16227 function mergeStore(...stores) {
16228 var _a;
16229 const initialState = {};
16230 for (const store2 of stores) {
16231 const nextState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2);
16232 if (nextState) {
16233 Object.assign(initialState, nextState);
16234 }
16235 }
16236 const store = createStore(initialState, ...stores);
16237 return Object.assign({}, ...stores, store);
16238 }
16239 function throwOnConflictingProps(props, store) {
16240 if (false) return;
16241 if (!store) return;
16242 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
16243 var _a;
16244 const stateKey = key.replace("default", "");
16245 return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}${stateKey.slice(1)}`;
16246 });
16247 if (!defaultKeys.length) return;
16248 const storeState = store.getState();
16249 const conflictingProps = defaultKeys.filter(
16250 (key) => hasOwnProperty(storeState, key)
16251 );
16252 if (!conflictingProps.length) return;
16253 throw new Error(
16254 `Passing a store prop in conjunction with a default state is not supported.
16255
16256 const store = useSelectStore();
16257 <SelectProvider store={store} defaultValue="Apple" />
16258 ^ ^
16259
16260 Instead, pass the default state to the topmost store:
16261
16262 const store = useSelectStore({ defaultValue: "Apple" });
16263 <SelectProvider store={store} />
16264
16265 See https://github.com/ariakit/ariakit/pull/2745 for more details.
16266
16267 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
16268 `
16269 );
16270 }
16271
16272 // node_modules/@ariakit/react-core/esm/__chunks/Q5W46E73.js
16273 var React50 = __toESM(require_react(), 1);
16274 var import_shim2 = __toESM(require_shim(), 1);
16275 var { useSyncExternalStore: useSyncExternalStore2 } = import_shim2.default;
16276 var noopSubscribe = () => () => {
16277 };
16278 function useStoreState(store, keyOrSelector = identity) {
16279 const storeSubscribe = React50.useCallback(
16280 (callback) => {
16281 if (!store) return noopSubscribe();
16282 return subscribe(store, null, callback);
16283 },
16284 [store]
16285 );
16286 const getSnapshot = () => {
16287 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
16288 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
16289 const state = store == null ? void 0 : store.getState();
16290 if (selector2) return selector2(state);
16291 if (!state) return;
16292 if (!key) return;
16293 if (!hasOwnProperty(state, key)) return;
16294 return state[key];
16295 };
16296 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot);
16297 }
16298 function useStoreStateObject(store, object) {
16299 const objRef = React50.useRef(
16300 {}
16301 );
16302 const storeSubscribe = React50.useCallback(
16303 (callback) => {
16304 if (!store) return noopSubscribe();
16305 return subscribe(store, null, callback);
16306 },
16307 [store]
16308 );
16309 const getSnapshot = () => {
16310 const state = store == null ? void 0 : store.getState();
16311 let updated = false;
16312 const obj = objRef.current;
16313 for (const prop in object) {
16314 const keyOrSelector = object[prop];
16315 if (typeof keyOrSelector === "function") {
16316 const value = keyOrSelector(state);
16317 if (value !== obj[prop]) {
16318 obj[prop] = value;
16319 updated = true;
16320 }
16321 }
16322 if (typeof keyOrSelector === "string") {
16323 if (!state) continue;
16324 if (!hasOwnProperty(state, keyOrSelector)) continue;
16325 const value = state[keyOrSelector];
16326 if (value !== obj[prop]) {
16327 obj[prop] = value;
16328 updated = true;
16329 }
16330 }
16331 }
16332 if (updated) {
16333 objRef.current = { ...obj };
16334 }
16335 return objRef.current;
16336 };
16337 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot);
16338 }
16339 function useStoreProps(store, props, key, setKey) {
16340 const value = hasOwnProperty(props, key) ? props[key] : void 0;
16341 const setValue = setKey ? props[setKey] : void 0;
16342 const propsRef = useLiveRef({ value, setValue });
16343 useSafeLayoutEffect(() => {
16344 return sync(store, [key], (state, prev) => {
16345 const { value: value2, setValue: setValue2 } = propsRef.current;
16346 if (!setValue2) return;
16347 if (state[key] === prev[key]) return;
16348 if (state[key] === value2) return;
16349 setValue2(state[key]);
16350 });
16351 }, [store, key]);
16352 useSafeLayoutEffect(() => {
16353 if (value === void 0) return;
16354 store.setState(key, value);
16355 return batch(store, [key], () => {
16356 if (value === void 0) return;
16357 store.setState(key, value);
16358 });
16359 });
16360 }
16361 function useStore2(createStore2, props) {
16362 const [store, setStore] = React50.useState(() => createStore2(props));
16363 useSafeLayoutEffect(() => init(store), [store]);
16364 const useState210 = React50.useCallback(
16365 (keyOrSelector) => useStoreState(store, keyOrSelector),
16366 [store]
16367 );
16368 const memoizedStore = React50.useMemo(
16369 () => ({ ...store, useState: useState210 }),
16370 [store, useState210]
16371 );
16372 const updateStore = useEvent(() => {
16373 setStore((store2) => createStore2({ ...props, ...store2.getState() }));
16374 });
16375 return [memoizedStore, updateStore];
16376 }
16377
16378 // node_modules/@ariakit/react-core/esm/__chunks/WZWDIE3S.js
16379 var import_react18 = __toESM(require_react(), 1);
16380 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
16381 var TagName4 = "button";
16382 function isEditableElement(element) {
16383 if (isTextbox(element)) return true;
16384 return element.tagName === "INPUT" && !isButton(element);
16385 }
16386 function getNextPageOffset(scrollingElement, pageUp = false) {
16387 const height = scrollingElement.clientHeight;
16388 const { top } = scrollingElement.getBoundingClientRect();
16389 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
16390 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
16391 if (scrollingElement.tagName === "HTML") {
16392 return pageOffset + scrollingElement.scrollTop;
16393 }
16394 return pageOffset;
16395 }
16396 function getItemOffset(itemElement, pageUp = false) {
16397 const { top } = itemElement.getBoundingClientRect();
16398 if (pageUp) {
16399 return top + itemElement.clientHeight;
16400 }
16401 return top;
16402 }
16403 function findNextPageItemId(element, store, next, pageUp = false) {
16404 var _a;
16405 if (!store) return;
16406 if (!next) return;
16407 const { renderedItems } = store.getState();
16408 const scrollingElement = getScrollingElement(element);
16409 if (!scrollingElement) return;
16410 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
16411 let id;
16412 let prevDifference;
16413 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
16414 const previousId = id;
16415 id = next(i2);
16416 if (!id) break;
16417 if (id === previousId) continue;
16418 const itemElement = (_a = getEnabledItem(store, id)) == null ? void 0 : _a.element;
16419 if (!itemElement) continue;
16420 const itemOffset = getItemOffset(itemElement, pageUp);
16421 const difference = itemOffset - nextPageOffset;
16422 const absDifference = Math.abs(difference);
16423 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
16424 if (prevDifference !== void 0 && prevDifference < absDifference) {
16425 id = previousId;
16426 }
16427 break;
16428 }
16429 prevDifference = absDifference;
16430 }
16431 return id;
16432 }
16433 function targetIsAnotherItem(event, store) {
16434 if (isSelfTarget(event)) return false;
16435 return isItem(store, event.target);
16436 }
16437 var useCompositeItem = createHook(
16438 function useCompositeItem2({
16439 store,
16440 rowId: rowIdProp,
16441 preventScrollOnKeyDown = false,
16442 moveOnKeyPress = true,
16443 tabbable: tabbable2 = false,
16444 getItem: getItemProp,
16445 "aria-setsize": ariaSetSizeProp,
16446 "aria-posinset": ariaPosInSetProp,
16447 ...props
16448 }) {
16449 const context = useCompositeContext();
16450 store = store || context;
16451 const id = useId4(props.id);
16452 const ref = (0, import_react18.useRef)(null);
16453 const row = (0, import_react18.useContext)(CompositeRowContext);
16454 const disabled2 = disabledFromProps(props);
16455 const trulyDisabled = disabled2 && !props.accessibleWhenDisabled;
16456 const {
16457 rowId,
16458 baseElement,
16459 isActiveItem,
16460 ariaSetSize,
16461 ariaPosInSet,
16462 isTabbable
16463 } = useStoreStateObject(store, {
16464 rowId(state) {
16465 if (rowIdProp) return rowIdProp;
16466 if (!state) return;
16467 if (!(row == null ? void 0 : row.baseElement)) return;
16468 if (row.baseElement !== state.baseElement) return;
16469 return row.id;
16470 },
16471 baseElement(state) {
16472 return (state == null ? void 0 : state.baseElement) || void 0;
16473 },
16474 isActiveItem(state) {
16475 return !!state && state.activeId === id;
16476 },
16477 ariaSetSize(state) {
16478 if (ariaSetSizeProp != null) return ariaSetSizeProp;
16479 if (!state) return;
16480 if (!(row == null ? void 0 : row.ariaSetSize)) return;
16481 if (row.baseElement !== state.baseElement) return;
16482 return row.ariaSetSize;
16483 },
16484 ariaPosInSet(state) {
16485 if (ariaPosInSetProp != null) return ariaPosInSetProp;
16486 if (!state) return;
16487 if (!(row == null ? void 0 : row.ariaPosInSet)) return;
16488 if (row.baseElement !== state.baseElement) return;
16489 const itemsInRow = state.renderedItems.filter(
16490 (item) => item.rowId === rowId
16491 );
16492 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
16493 },
16494 isTabbable(state) {
16495 if (!(state == null ? void 0 : state.renderedItems.length)) return true;
16496 if (state.virtualFocus) return false;
16497 if (tabbable2) return true;
16498 if (state.activeId === null) return false;
16499 const item = store == null ? void 0 : store.item(state.activeId);
16500 if (item == null ? void 0 : item.disabled) return true;
16501 if (!(item == null ? void 0 : item.element)) return true;
16502 return state.activeId === id;
16503 }
16504 });
16505 const getItem = (0, import_react18.useCallback)(
16506 (item) => {
16507 var _a;
16508 const nextItem = {
16509 ...item,
16510 id: id || item.id,
16511 rowId,
16512 disabled: !!trulyDisabled,
16513 children: (_a = item.element) == null ? void 0 : _a.textContent
16514 };
16515 if (getItemProp) {
16516 return getItemProp(nextItem);
16517 }
16518 return nextItem;
16519 },
16520 [id, rowId, trulyDisabled, getItemProp]
16521 );
16522 const onFocusProp = props.onFocus;
16523 const hasFocusedComposite = (0, import_react18.useRef)(false);
16524 const onFocus = useEvent((event) => {
16525 onFocusProp == null ? void 0 : onFocusProp(event);
16526 if (event.defaultPrevented) return;
16527 if (isPortalEvent(event)) return;
16528 if (!id) return;
16529 if (!store) return;
16530 if (targetIsAnotherItem(event, store)) return;
16531 const { virtualFocus, baseElement: baseElement2 } = store.getState();
16532 store.setActiveId(id);
16533 if (isTextbox(event.currentTarget)) {
16534 selectTextField(event.currentTarget);
16535 }
16536 if (!virtualFocus) return;
16537 if (!isSelfTarget(event)) return;
16538 if (isEditableElement(event.currentTarget)) return;
16539 if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) return;
16540 if (isSafari2() && event.currentTarget.hasAttribute("data-autofocus")) {
16541 event.currentTarget.scrollIntoView({
16542 block: "nearest",
16543 inline: "nearest"
16544 });
16545 }
16546 hasFocusedComposite.current = true;
16547 const fromComposite = event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget);
16548 if (fromComposite) {
16549 focusSilently(baseElement2);
16550 } else {
16551 baseElement2.focus();
16552 }
16553 });
16554 const onBlurCaptureProp = props.onBlurCapture;
16555 const onBlurCapture = useEvent((event) => {
16556 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
16557 if (event.defaultPrevented) return;
16558 const state = store == null ? void 0 : store.getState();
16559 if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) {
16560 hasFocusedComposite.current = false;
16561 event.preventDefault();
16562 event.stopPropagation();
16563 }
16564 });
16565 const onKeyDownProp = props.onKeyDown;
16566 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
16567 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
16568 const onKeyDown = useEvent((event) => {
16569 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
16570 if (event.defaultPrevented) return;
16571 if (!isSelfTarget(event)) return;
16572 if (!store) return;
16573 const { currentTarget } = event;
16574 const state = store.getState();
16575 const item = store.item(id);
16576 const isGrid2 = !!(item == null ? void 0 : item.rowId);
16577 const isVertical = state.orientation !== "horizontal";
16578 const isHorizontal = state.orientation !== "vertical";
16579 const canHomeEnd = () => {
16580 if (isGrid2) return true;
16581 if (isHorizontal) return true;
16582 if (!state.baseElement) return true;
16583 if (!isTextField(state.baseElement)) return true;
16584 return false;
16585 };
16586 const keyMap = {
16587 ArrowUp: (isGrid2 || isVertical) && store.up,
16588 ArrowRight: (isGrid2 || isHorizontal) && store.next,
16589 ArrowDown: (isGrid2 || isVertical) && store.down,
16590 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
16591 Home: () => {
16592 if (!canHomeEnd()) return;
16593 if (!isGrid2 || event.ctrlKey) {
16594 return store == null ? void 0 : store.first();
16595 }
16596 return store == null ? void 0 : store.previous(-1);
16597 },
16598 End: () => {
16599 if (!canHomeEnd()) return;
16600 if (!isGrid2 || event.ctrlKey) {
16601 return store == null ? void 0 : store.last();
16602 }
16603 return store == null ? void 0 : store.next(-1);
16604 },
16605 PageUp: () => {
16606 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.up, true);
16607 },
16608 PageDown: () => {
16609 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.down);
16610 }
16611 };
16612 const action = keyMap[event.key];
16613 if (action) {
16614 if (isTextbox(currentTarget)) {
16615 const selection = getTextboxSelection(currentTarget);
16616 const isLeft = isHorizontal && event.key === "ArrowLeft";
16617 const isRight = isHorizontal && event.key === "ArrowRight";
16618 const isUp = isVertical && event.key === "ArrowUp";
16619 const isDown = isVertical && event.key === "ArrowDown";
16620 if (isRight || isDown) {
16621 const { length: valueLength } = getTextboxValue(currentTarget);
16622 if (selection.end !== valueLength) return;
16623 } else if ((isLeft || isUp) && selection.start !== 0) return;
16624 }
16625 const nextId = action();
16626 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
16627 if (!moveOnKeyPressProp(event)) return;
16628 event.preventDefault();
16629 store.move(nextId);
16630 }
16631 }
16632 });
16633 const providerValue = (0, import_react18.useMemo)(
16634 () => ({ id, baseElement }),
16635 [id, baseElement]
16636 );
16637 props = useWrapElement(
16638 props,
16639 (element) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }),
16640 [providerValue]
16641 );
16642 props = {
16643 id,
16644 "data-active-item": isActiveItem || void 0,
16645 ...props,
16646 ref: useMergeRefs(ref, props.ref),
16647 tabIndex: isTabbable ? props.tabIndex : -1,
16648 onFocus,
16649 onBlurCapture,
16650 onKeyDown
16651 };
16652 props = useCommand(props);
16653 props = useCollectionItem({
16654 store,
16655 ...props,
16656 getItem,
16657 shouldRegisterItem: id ? props.shouldRegisterItem : false
16658 });
16659 return removeUndefinedValues({
16660 ...props,
16661 "aria-setsize": ariaSetSize,
16662 "aria-posinset": ariaPosInSet
16663 });
16664 }
16665 );
16666 var CompositeItem = memo22(
16667 forwardRef29(function CompositeItem2(props) {
16668 const htmlProps = useCompositeItem(props);
16669 return createElement3(TagName4, htmlProps);
16670 })
16671 );
16672
16673 // node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js
16674 function toArray(arg) {
16675 if (Array.isArray(arg)) {
16676 return arg;
16677 }
16678 return typeof arg !== "undefined" ? [arg] : [];
16679 }
16680 function flatten2DArray(array) {
16681 const flattened = [];
16682 for (const row of array) {
16683 flattened.push(...row);
16684 }
16685 return flattened;
16686 }
16687 function reverseArray(array) {
16688 return array.slice().reverse();
16689 }
16690
16691 // node_modules/@ariakit/react-core/esm/__chunks/ZMWF7ASR.js
16692 var import_react19 = __toESM(require_react(), 1);
16693 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
16694 var TagName5 = "div";
16695 function isGrid(items) {
16696 return items.some((item) => !!item.rowId);
16697 }
16698 function isPrintableKey(event) {
16699 const target = event.target;
16700 if (target && !isTextField(target)) return false;
16701 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
16702 }
16703 function isModifierKey(event) {
16704 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
16705 }
16706 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
16707 return useEvent((event) => {
16708 var _a;
16709 onKeyboardEvent == null ? void 0 : onKeyboardEvent(event);
16710 if (event.defaultPrevented) return;
16711 if (event.isPropagationStopped()) return;
16712 if (!isSelfTarget(event)) return;
16713 if (isModifierKey(event)) return;
16714 if (isPrintableKey(event)) return;
16715 const state = store.getState();
16716 const activeElement2 = (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.element;
16717 if (!activeElement2) return;
16718 const { view, ...eventInit } = event;
16719 const previousElement = previousElementRef == null ? void 0 : previousElementRef.current;
16720 if (activeElement2 !== previousElement) {
16721 activeElement2.focus();
16722 }
16723 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) {
16724 event.preventDefault();
16725 }
16726 if (event.currentTarget.contains(activeElement2)) {
16727 event.stopPropagation();
16728 }
16729 });
16730 }
16731 function findFirstEnabledItemInTheLastRow(items) {
16732 return findFirstEnabledItem(
16733 flatten2DArray(reverseArray(groupItemsByRows(items)))
16734 );
16735 }
16736 function useScheduleFocus(store) {
16737 const [scheduled, setScheduled] = (0, import_react19.useState)(false);
16738 const schedule = (0, import_react19.useCallback)(() => setScheduled(true), []);
16739 const activeItem = store.useState(
16740 (state) => getEnabledItem(store, state.activeId)
16741 );
16742 (0, import_react19.useEffect)(() => {
16743 const activeElement2 = activeItem == null ? void 0 : activeItem.element;
16744 if (!scheduled) return;
16745 if (!activeElement2) return;
16746 setScheduled(false);
16747 activeElement2.focus({ preventScroll: true });
16748 }, [activeItem, scheduled]);
16749 return schedule;
16750 }
16751 var useComposite = createHook(
16752 function useComposite2({
16753 store,
16754 composite = true,
16755 focusOnMove = composite,
16756 moveOnKeyPress = true,
16757 ...props
16758 }) {
16759 const context = useCompositeProviderContext();
16760 store = store || context;
16761 invariant(
16762 store,
16763 "Composite must receive a `store` prop or be wrapped in a CompositeProvider component."
16764 );
16765 const ref = (0, import_react19.useRef)(null);
16766 const previousElementRef = (0, import_react19.useRef)(null);
16767 const scheduleFocus = useScheduleFocus(store);
16768 const moves = store.useState("moves");
16769 const [, setBaseElement] = useTransactionState(
16770 composite ? store.setBaseElement : null
16771 );
16772 (0, import_react19.useEffect)(() => {
16773 var _a;
16774 if (!store) return;
16775 if (!moves) return;
16776 if (!composite) return;
16777 if (!focusOnMove) return;
16778 const { activeId: activeId2 } = store.getState();
16779 const itemElement = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
16780 if (!itemElement) return;
16781 focusIntoView(itemElement);
16782 }, [store, moves, composite, focusOnMove]);
16783 useSafeLayoutEffect(() => {
16784 if (!store) return;
16785 if (!moves) return;
16786 if (!composite) return;
16787 const { baseElement, activeId: activeId2 } = store.getState();
16788 const isSelfAcive = activeId2 === null;
16789 if (!isSelfAcive) return;
16790 if (!baseElement) return;
16791 const previousElement = previousElementRef.current;
16792 previousElementRef.current = null;
16793 if (previousElement) {
16794 fireBlurEvent(previousElement, { relatedTarget: baseElement });
16795 }
16796 if (!hasFocus(baseElement)) {
16797 baseElement.focus();
16798 }
16799 }, [store, moves, composite]);
16800 const activeId = store.useState("activeId");
16801 const virtualFocus = store.useState("virtualFocus");
16802 useSafeLayoutEffect(() => {
16803 var _a;
16804 if (!store) return;
16805 if (!composite) return;
16806 if (!virtualFocus) return;
16807 const previousElement = previousElementRef.current;
16808 previousElementRef.current = null;
16809 if (!previousElement) return;
16810 const activeElement2 = (_a = getEnabledItem(store, activeId)) == null ? void 0 : _a.element;
16811 const relatedTarget = activeElement2 || getActiveElement(previousElement);
16812 if (relatedTarget === previousElement) return;
16813 fireBlurEvent(previousElement, { relatedTarget });
16814 }, [store, activeId, virtualFocus, composite]);
16815 const onKeyDownCapture = useKeyboardEventProxy(
16816 store,
16817 props.onKeyDownCapture,
16818 previousElementRef
16819 );
16820 const onKeyUpCapture = useKeyboardEventProxy(
16821 store,
16822 props.onKeyUpCapture,
16823 previousElementRef
16824 );
16825 const onFocusCaptureProp = props.onFocusCapture;
16826 const onFocusCapture = useEvent((event) => {
16827 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
16828 if (event.defaultPrevented) return;
16829 if (!store) return;
16830 const { virtualFocus: virtualFocus2 } = store.getState();
16831 if (!virtualFocus2) return;
16832 const previousActiveElement = event.relatedTarget;
16833 const isSilentlyFocused = silentlyFocused(event.currentTarget);
16834 if (isSelfTarget(event) && isSilentlyFocused) {
16835 event.stopPropagation();
16836 previousElementRef.current = previousActiveElement;
16837 }
16838 });
16839 const onFocusProp = props.onFocus;
16840 const onFocus = useEvent((event) => {
16841 onFocusProp == null ? void 0 : onFocusProp(event);
16842 if (event.defaultPrevented) return;
16843 if (!composite) return;
16844 if (!store) return;
16845 const { relatedTarget } = event;
16846 const { virtualFocus: virtualFocus2 } = store.getState();
16847 if (virtualFocus2) {
16848 if (isSelfTarget(event) && !isItem(store, relatedTarget)) {
16849 queueMicrotask(scheduleFocus);
16850 }
16851 } else if (isSelfTarget(event)) {
16852 store.setActiveId(null);
16853 }
16854 });
16855 const onBlurCaptureProp = props.onBlurCapture;
16856 const onBlurCapture = useEvent((event) => {
16857 var _a;
16858 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
16859 if (event.defaultPrevented) return;
16860 if (!store) return;
16861 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
16862 if (!virtualFocus2) return;
16863 const activeElement2 = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
16864 const nextActiveElement = event.relatedTarget;
16865 const nextActiveElementIsItem = isItem(store, nextActiveElement);
16866 const previousElement = previousElementRef.current;
16867 previousElementRef.current = null;
16868 if (isSelfTarget(event) && nextActiveElementIsItem) {
16869 if (nextActiveElement === activeElement2) {
16870 if (previousElement && previousElement !== nextActiveElement) {
16871 fireBlurEvent(previousElement, event);
16872 }
16873 } else if (activeElement2) {
16874 fireBlurEvent(activeElement2, event);
16875 } else if (previousElement) {
16876 fireBlurEvent(previousElement, event);
16877 }
16878 event.stopPropagation();
16879 } else {
16880 const targetIsItem = isItem(store, event.target);
16881 if (!targetIsItem && activeElement2) {
16882 fireBlurEvent(activeElement2, event);
16883 }
16884 }
16885 });
16886 const onKeyDownProp = props.onKeyDown;
16887 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
16888 const onKeyDown = useEvent((event) => {
16889 var _a;
16890 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
16891 if (event.nativeEvent.isComposing) return;
16892 if (event.defaultPrevented) return;
16893 if (!store) return;
16894 if (!isSelfTarget(event)) return;
16895 const { orientation, renderedItems, activeId: activeId2 } = store.getState();
16896 const activeItem = getEnabledItem(store, activeId2);
16897 if ((_a = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a.isConnected) return;
16898 const isVertical = orientation !== "horizontal";
16899 const isHorizontal = orientation !== "vertical";
16900 const grid = isGrid(renderedItems);
16901 const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End";
16902 if (isHorizontalKey && isTextField(event.currentTarget)) return;
16903 const up = () => {
16904 if (grid) {
16905 const item = findFirstEnabledItemInTheLastRow(renderedItems);
16906 return item == null ? void 0 : item.id;
16907 }
16908 return store == null ? void 0 : store.last();
16909 };
16910 const keyMap = {
16911 ArrowUp: (grid || isVertical) && up,
16912 ArrowRight: (grid || isHorizontal) && store.first,
16913 ArrowDown: (grid || isVertical) && store.first,
16914 ArrowLeft: (grid || isHorizontal) && store.last,
16915 Home: store.first,
16916 End: store.last,
16917 PageUp: store.first,
16918 PageDown: store.last
16919 };
16920 const action = keyMap[event.key];
16921 if (action) {
16922 const id = action();
16923 if (id !== void 0) {
16924 if (!moveOnKeyPressProp(event)) return;
16925 event.preventDefault();
16926 store.move(id);
16927 }
16928 }
16929 });
16930 props = useWrapElement(
16931 props,
16932 (element) => /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(CompositeContextProvider, { value: store, children: element }),
16933 [store]
16934 );
16935 const activeDescendant = store.useState((state) => {
16936 var _a;
16937 if (!store) return;
16938 if (!composite) return;
16939 if (!state.virtualFocus) return;
16940 return (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.id;
16941 });
16942 props = {
16943 "aria-activedescendant": activeDescendant,
16944 ...props,
16945 ref: useMergeRefs(ref, setBaseElement, props.ref),
16946 onKeyDownCapture,
16947 onKeyUpCapture,
16948 onFocusCapture,
16949 onFocus,
16950 onBlurCapture,
16951 onKeyDown
16952 };
16953 const focusable2 = store.useState(
16954 (state) => composite && (state.virtualFocus || state.activeId === null)
16955 );
16956 props = useFocusable({ focusable: focusable2, ...props });
16957 return props;
16958 }
16959 );
16960 var Composite5 = forwardRef29(function Composite22(props) {
16961 const htmlProps = useComposite(props);
16962 return createElement3(TagName5, htmlProps);
16963 });
16964
16965 // node_modules/@ariakit/react-core/esm/__chunks/LVDQFHCH.js
16966 var ctx3 = createStoreContext();
16967 var useDisclosureContext = ctx3.useContext;
16968 var useDisclosureScopedContext = ctx3.useScopedContext;
16969 var useDisclosureProviderContext = ctx3.useProviderContext;
16970 var DisclosureContextProvider = ctx3.ContextProvider;
16971 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
16972
16973 // node_modules/@ariakit/react-core/esm/__chunks/A62MDFCW.js
16974 var import_react20 = __toESM(require_react(), 1);
16975 var ctx4 = createStoreContext(
16976 [DisclosureContextProvider],
16977 [DisclosureScopedContextProvider]
16978 );
16979 var useDialogContext = ctx4.useContext;
16980 var useDialogScopedContext = ctx4.useScopedContext;
16981 var useDialogProviderContext = ctx4.useProviderContext;
16982 var DialogContextProvider = ctx4.ContextProvider;
16983 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
16984 var DialogHeadingContext = (0, import_react20.createContext)(void 0);
16985 var DialogDescriptionContext = (0, import_react20.createContext)(void 0);
16986
16987 // node_modules/@ariakit/react-core/esm/__chunks/6B3RXHKP.js
16988 var import_react21 = __toESM(require_react(), 1);
16989 var import_react_dom4 = __toESM(require_react_dom(), 1);
16990 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
16991 var TagName6 = "div";
16992 function afterTimeout(timeoutMs, cb) {
16993 const timeoutId = setTimeout(cb, timeoutMs);
16994 return () => clearTimeout(timeoutId);
16995 }
16996 function afterPaint2(cb) {
16997 let raf = requestAnimationFrame(() => {
16998 raf = requestAnimationFrame(cb);
16999 });
17000 return () => cancelAnimationFrame(raf);
17001 }
17002 function parseCSSTime(...times) {
17003 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => {
17004 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3;
17005 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier;
17006 if (currentTime > longestTime) return currentTime;
17007 return longestTime;
17008 }, 0);
17009 }
17010 function isHidden(mounted, hidden, alwaysVisible) {
17011 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
17012 }
17013 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, ...props }) {
17014 const context = useDisclosureProviderContext();
17015 store = store || context;
17016 invariant(
17017 store,
17018 "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component."
17019 );
17020 const ref = (0, import_react21.useRef)(null);
17021 const id = useId4(props.id);
17022 const [transition, setTransition] = (0, import_react21.useState)(null);
17023 const open = store.useState("open");
17024 const mounted = store.useState("mounted");
17025 const animated = store.useState("animated");
17026 const contentElement = store.useState("contentElement");
17027 const otherElement = useStoreState(store.disclosure, "contentElement");
17028 useSafeLayoutEffect(() => {
17029 if (!ref.current) return;
17030 store == null ? void 0 : store.setContentElement(ref.current);
17031 }, [store]);
17032 useSafeLayoutEffect(() => {
17033 let previousAnimated;
17034 store == null ? void 0 : store.setState("animated", (animated2) => {
17035 previousAnimated = animated2;
17036 return true;
17037 });
17038 return () => {
17039 if (previousAnimated === void 0) return;
17040 store == null ? void 0 : store.setState("animated", previousAnimated);
17041 };
17042 }, [store]);
17043 useSafeLayoutEffect(() => {
17044 if (!animated) return;
17045 if (!(contentElement == null ? void 0 : contentElement.isConnected)) {
17046 setTransition(null);
17047 return;
17048 }
17049 return afterPaint2(() => {
17050 setTransition(open ? "enter" : mounted ? "leave" : null);
17051 });
17052 }, [animated, contentElement, open, mounted]);
17053 useSafeLayoutEffect(() => {
17054 if (!store) return;
17055 if (!animated) return;
17056 if (!transition) return;
17057 if (!contentElement) return;
17058 const stopAnimation = () => store == null ? void 0 : store.setState("animating", false);
17059 const stopAnimationSync = () => (0, import_react_dom4.flushSync)(stopAnimation);
17060 if (transition === "leave" && open) return;
17061 if (transition === "enter" && !open) return;
17062 if (typeof animated === "number") {
17063 const timeout2 = animated;
17064 return afterTimeout(timeout2, stopAnimationSync);
17065 }
17066 const {
17067 transitionDuration,
17068 animationDuration,
17069 transitionDelay,
17070 animationDelay
17071 } = getComputedStyle(contentElement);
17072 const {
17073 transitionDuration: transitionDuration2 = "0",
17074 animationDuration: animationDuration2 = "0",
17075 transitionDelay: transitionDelay2 = "0",
17076 animationDelay: animationDelay2 = "0"
17077 } = otherElement ? getComputedStyle(otherElement) : {};
17078 const delay = parseCSSTime(
17079 transitionDelay,
17080 animationDelay,
17081 transitionDelay2,
17082 animationDelay2
17083 );
17084 const duration = parseCSSTime(
17085 transitionDuration,
17086 animationDuration,
17087 transitionDuration2,
17088 animationDuration2
17089 );
17090 const timeout = delay + duration;
17091 if (!timeout) {
17092 if (transition === "enter") {
17093 store.setState("animated", false);
17094 }
17095 stopAnimation();
17096 return;
17097 }
17098 const frameRate = 1e3 / 60;
17099 const maxTimeout = Math.max(timeout - frameRate, 0);
17100 return afterTimeout(maxTimeout, stopAnimationSync);
17101 }, [store, animated, contentElement, otherElement, open, transition]);
17102 props = useWrapElement(
17103 props,
17104 (element) => /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(DialogScopedContextProvider, { value: store, children: element }),
17105 [store]
17106 );
17107 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
17108 const styleProp = props.style;
17109 const style = (0, import_react21.useMemo)(() => {
17110 if (hidden) {
17111 return { ...styleProp, display: "none" };
17112 }
17113 return styleProp;
17114 }, [hidden, styleProp]);
17115 props = {
17116 id,
17117 "data-open": open || void 0,
17118 "data-enter": transition === "enter" || void 0,
17119 "data-leave": transition === "leave" || void 0,
17120 hidden,
17121 ...props,
17122 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref),
17123 style
17124 };
17125 return removeUndefinedValues(props);
17126 });
17127 var DisclosureContentImpl = forwardRef29(function DisclosureContentImpl2(props) {
17128 const htmlProps = useDisclosureContent(props);
17129 return createElement3(TagName6, htmlProps);
17130 });
17131 var DisclosureContent = forwardRef29(function DisclosureContent2({
17132 unmountOnHide,
17133 ...props
17134 }) {
17135 const context = useDisclosureProviderContext();
17136 const store = props.store || context;
17137 const mounted = useStoreState(
17138 store,
17139 (state) => !unmountOnHide || (state == null ? void 0 : state.mounted)
17140 );
17141 if (mounted === false) return null;
17142 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(DisclosureContentImpl, { ...props });
17143 });
17144
17145 // node_modules/@ariakit/core/esm/__chunks/75BJEVSH.js
17146 function createDisclosureStore(props = {}) {
17147 const store = mergeStore(
17148 props.store,
17149 omit2(props.disclosure, ["contentElement", "disclosureElement"])
17150 );
17151 throwOnConflictingProps(props, store);
17152 const syncState = store == null ? void 0 : store.getState();
17153 const open = defaultValue(
17154 props.open,
17155 syncState == null ? void 0 : syncState.open,
17156 props.defaultOpen,
17157 false
17158 );
17159 const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false);
17160 const initialState = {
17161 open,
17162 animated,
17163 animating: !!animated && open,
17164 mounted: open,
17165 contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null),
17166 disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null)
17167 };
17168 const disclosure = createStore(initialState, store);
17169 setup(
17170 disclosure,
17171 () => sync(disclosure, ["animated", "animating"], (state) => {
17172 if (state.animated) return;
17173 disclosure.setState("animating", false);
17174 })
17175 );
17176 setup(
17177 disclosure,
17178 () => subscribe(disclosure, ["open"], () => {
17179 if (!disclosure.getState().animated) return;
17180 disclosure.setState("animating", true);
17181 })
17182 );
17183 setup(
17184 disclosure,
17185 () => sync(disclosure, ["open", "animating"], (state) => {
17186 disclosure.setState("mounted", state.open || state.animating);
17187 })
17188 );
17189 return {
17190 ...disclosure,
17191 disclosure: props.disclosure,
17192 setOpen: (value) => disclosure.setState("open", value),
17193 show: () => disclosure.setState("open", true),
17194 hide: () => disclosure.setState("open", false),
17195 toggle: () => disclosure.setState("open", (open2) => !open2),
17196 stopAnimation: () => disclosure.setState("animating", false),
17197 setContentElement: (value) => disclosure.setState("contentElement", value),
17198 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
17199 };
17200 }
17201
17202 // node_modules/@ariakit/react-core/esm/__chunks/WLZ6H5FH.js
17203 function useDisclosureStoreProps(store, update2, props) {
17204 useUpdateEffect(update2, [props.store, props.disclosure]);
17205 useStoreProps(store, props, "open", "setOpen");
17206 useStoreProps(store, props, "mounted", "setMounted");
17207 useStoreProps(store, props, "animated");
17208 return Object.assign(store, { disclosure: props.disclosure });
17209 }
17210
17211 // node_modules/@ariakit/react-core/esm/__chunks/JMU4N4M5.js
17212 var ctx5 = createStoreContext(
17213 [DialogContextProvider],
17214 [DialogScopedContextProvider]
17215 );
17216 var usePopoverContext = ctx5.useContext;
17217 var usePopoverScopedContext = ctx5.useScopedContext;
17218 var usePopoverProviderContext = ctx5.useProviderContext;
17219 var PopoverContextProvider = ctx5.ContextProvider;
17220 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
17221
17222 // node_modules/@ariakit/core/esm/__chunks/N5XGANPW.js
17223 function getCommonParent(items) {
17224 var _a;
17225 const firstItem = items.find((item) => !!item.element);
17226 const lastItem = [...items].reverse().find((item) => !!item.element);
17227 let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement;
17228 while (parentElement && (lastItem == null ? void 0 : lastItem.element)) {
17229 const parent = parentElement;
17230 if (lastItem && parent.contains(lastItem.element)) {
17231 return parentElement;
17232 }
17233 parentElement = parentElement.parentElement;
17234 }
17235 return getDocument(parentElement).body;
17236 }
17237 function getPrivateStore(store) {
17238 return store == null ? void 0 : store.__unstablePrivateStore;
17239 }
17240 function createCollectionStore(props = {}) {
17241 var _a;
17242 throwOnConflictingProps(props, props.store);
17243 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
17244 const items = defaultValue(
17245 props.items,
17246 syncState == null ? void 0 : syncState.items,
17247 props.defaultItems,
17248 []
17249 );
17250 const itemsMap = new Map(items.map((item) => [item.id, item]));
17251 const initialState = {
17252 items,
17253 renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, [])
17254 };
17255 const syncPrivateStore = getPrivateStore(props.store);
17256 const privateStore = createStore(
17257 { items, renderedItems: initialState.renderedItems },
17258 syncPrivateStore
17259 );
17260 const collection = createStore(initialState, props.store);
17261 const sortItems = (renderedItems) => {
17262 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
17263 privateStore.setState("renderedItems", sortedItems);
17264 collection.setState("renderedItems", sortedItems);
17265 };
17266 setup(collection, () => init(privateStore));
17267 setup(privateStore, () => {
17268 return batch(privateStore, ["items"], (state) => {
17269 collection.setState("items", state.items);
17270 });
17271 });
17272 setup(privateStore, () => {
17273 return batch(privateStore, ["renderedItems"], (state) => {
17274 let firstRun = true;
17275 let raf = requestAnimationFrame(() => {
17276 const { renderedItems } = collection.getState();
17277 if (state.renderedItems === renderedItems) return;
17278 sortItems(state.renderedItems);
17279 });
17280 if (typeof IntersectionObserver !== "function") {
17281 return () => cancelAnimationFrame(raf);
17282 }
17283 const ioCallback = () => {
17284 if (firstRun) {
17285 firstRun = false;
17286 return;
17287 }
17288 cancelAnimationFrame(raf);
17289 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
17290 };
17291 const root = getCommonParent(state.renderedItems);
17292 const observer = new IntersectionObserver(ioCallback, { root });
17293 for (const item of state.renderedItems) {
17294 if (!item.element) continue;
17295 observer.observe(item.element);
17296 }
17297 return () => {
17298 cancelAnimationFrame(raf);
17299 observer.disconnect();
17300 };
17301 });
17302 });
17303 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
17304 let prevItem;
17305 setItems((items2) => {
17306 const index2 = items2.findIndex(({ id }) => id === item.id);
17307 const nextItems = items2.slice();
17308 if (index2 !== -1) {
17309 prevItem = items2[index2];
17310 const nextItem = { ...prevItem, ...item };
17311 nextItems[index2] = nextItem;
17312 itemsMap.set(item.id, nextItem);
17313 } else {
17314 nextItems.push(item);
17315 itemsMap.set(item.id, item);
17316 }
17317 return nextItems;
17318 });
17319 const unmergeItem = () => {
17320 setItems((items2) => {
17321 if (!prevItem) {
17322 if (canDeleteFromMap) {
17323 itemsMap.delete(item.id);
17324 }
17325 return items2.filter(({ id }) => id !== item.id);
17326 }
17327 const index2 = items2.findIndex(({ id }) => id === item.id);
17328 if (index2 === -1) return items2;
17329 const nextItems = items2.slice();
17330 nextItems[index2] = prevItem;
17331 itemsMap.set(item.id, prevItem);
17332 return nextItems;
17333 });
17334 };
17335 return unmergeItem;
17336 };
17337 const registerItem = (item) => mergeItem(
17338 item,
17339 (getItems) => privateStore.setState("items", getItems),
17340 true
17341 );
17342 return {
17343 ...collection,
17344 registerItem,
17345 renderItem: (item) => chain(
17346 registerItem(item),
17347 mergeItem(
17348 item,
17349 (getItems) => privateStore.setState("renderedItems", getItems)
17350 )
17351 ),
17352 item: (id) => {
17353 if (!id) return null;
17354 let item = itemsMap.get(id);
17355 if (!item) {
17356 const { items: items2 } = privateStore.getState();
17357 item = items2.find((item2) => item2.id === id);
17358 if (item) {
17359 itemsMap.set(id, item);
17360 }
17361 }
17362 return item || null;
17363 },
17364 // @ts-expect-error Internal
17365 __unstablePrivateStore: privateStore
17366 };
17367 }
17368
17369 // node_modules/@ariakit/react-core/esm/__chunks/GVAFFF2B.js
17370 function useCollectionStoreProps(store, update2, props) {
17371 useUpdateEffect(update2, [props.store]);
17372 useStoreProps(store, props, "items", "setItems");
17373 return store;
17374 }
17375
17376 // node_modules/@ariakit/core/esm/__chunks/RVTIKFRL.js
17377 var NULL_ITEM = { id: null };
17378 function findFirstEnabledItem2(items, excludeId) {
17379 return items.find((item) => {
17380 if (excludeId) {
17381 return !item.disabled && item.id !== excludeId;
17382 }
17383 return !item.disabled;
17384 });
17385 }
17386 function getEnabledItems(items, excludeId) {
17387 return items.filter((item) => {
17388 if (excludeId) {
17389 return !item.disabled && item.id !== excludeId;
17390 }
17391 return !item.disabled;
17392 });
17393 }
17394 function getItemsInRow(items, rowId) {
17395 return items.filter((item) => item.rowId === rowId);
17396 }
17397 function flipItems(items, activeId, shouldInsertNullItem = false) {
17398 const index2 = items.findIndex((item) => item.id === activeId);
17399 return [
17400 ...items.slice(index2 + 1),
17401 ...shouldInsertNullItem ? [NULL_ITEM] : [],
17402 ...items.slice(0, index2)
17403 ];
17404 }
17405 function groupItemsByRows2(items) {
17406 const rows = [];
17407 for (const item of items) {
17408 const row = rows.find((currentRow) => {
17409 var _a;
17410 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
17411 });
17412 if (row) {
17413 row.push(item);
17414 } else {
17415 rows.push([item]);
17416 }
17417 }
17418 return rows;
17419 }
17420 function getMaxRowLength(array) {
17421 let maxLength = 0;
17422 for (const { length } of array) {
17423 if (length > maxLength) {
17424 maxLength = length;
17425 }
17426 }
17427 return maxLength;
17428 }
17429 function createEmptyItem(rowId) {
17430 return {
17431 id: "__EMPTY_ITEM__",
17432 disabled: true,
17433 rowId
17434 };
17435 }
17436 function normalizeRows(rows, activeId, focusShift) {
17437 const maxLength = getMaxRowLength(rows);
17438 for (const row of rows) {
17439 for (let i2 = 0; i2 < maxLength; i2 += 1) {
17440 const item = row[i2];
17441 if (!item || focusShift && item.disabled) {
17442 const isFirst = i2 === 0;
17443 const previousItem = isFirst && focusShift ? findFirstEnabledItem2(row) : row[i2 - 1];
17444 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId);
17445 }
17446 }
17447 }
17448 return rows;
17449 }
17450 function verticalizeItems(items) {
17451 const rows = groupItemsByRows2(items);
17452 const maxLength = getMaxRowLength(rows);
17453 const verticalized = [];
17454 for (let i2 = 0; i2 < maxLength; i2 += 1) {
17455 for (const row of rows) {
17456 const item = row[i2];
17457 if (item) {
17458 verticalized.push({
17459 ...item,
17460 // If there's no rowId, it means that it's not a grid composite, but
17461 // a single row instead. So, instead of verticalizing it, that is,
17462 // assigning a different rowId based on the column index, we keep it
17463 // undefined so they will be part of the same row. This is useful
17464 // when using up/down on one-dimensional composites.
17465 rowId: item.rowId ? `${i2}` : void 0
17466 });
17467 }
17468 }
17469 }
17470 return verticalized;
17471 }
17472 function createCompositeStore(props = {}) {
17473 var _a;
17474 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
17475 const collection = createCollectionStore(props);
17476 const activeId = defaultValue(
17477 props.activeId,
17478 syncState == null ? void 0 : syncState.activeId,
17479 props.defaultActiveId
17480 );
17481 const initialState = {
17482 ...collection.getState(),
17483 id: defaultValue(
17484 props.id,
17485 syncState == null ? void 0 : syncState.id,
17486 `id-${Math.random().toString(36).slice(2, 8)}`
17487 ),
17488 activeId,
17489 baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null),
17490 includesBaseElement: defaultValue(
17491 props.includesBaseElement,
17492 syncState == null ? void 0 : syncState.includesBaseElement,
17493 activeId === null
17494 ),
17495 moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0),
17496 orientation: defaultValue(
17497 props.orientation,
17498 syncState == null ? void 0 : syncState.orientation,
17499 "both"
17500 ),
17501 rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false),
17502 virtualFocus: defaultValue(
17503 props.virtualFocus,
17504 syncState == null ? void 0 : syncState.virtualFocus,
17505 false
17506 ),
17507 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false),
17508 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false),
17509 focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false)
17510 };
17511 const composite = createStore(initialState, collection, props.store);
17512 setup(
17513 composite,
17514 () => sync(composite, ["renderedItems", "activeId"], (state) => {
17515 composite.setState("activeId", (activeId2) => {
17516 var _a2;
17517 if (activeId2 !== void 0) return activeId2;
17518 return (_a2 = findFirstEnabledItem2(state.renderedItems)) == null ? void 0 : _a2.id;
17519 });
17520 })
17521 );
17522 const getNextId = (direction = "next", options = {}) => {
17523 var _a2, _b;
17524 const defaultState = composite.getState();
17525 const {
17526 skip = 0,
17527 activeId: activeId2 = defaultState.activeId,
17528 focusShift = defaultState.focusShift,
17529 focusLoop = defaultState.focusLoop,
17530 focusWrap = defaultState.focusWrap,
17531 includesBaseElement = defaultState.includesBaseElement,
17532 renderedItems = defaultState.renderedItems,
17533 rtl = defaultState.rtl
17534 } = options;
17535 const isVerticalDirection = direction === "up" || direction === "down";
17536 const isNextDirection = direction === "next" || direction === "down";
17537 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
17538 const canShift = focusShift && !skip;
17539 let items = !isVerticalDirection ? renderedItems : flatten2DArray(
17540 normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift)
17541 );
17542 items = canReverse ? reverseArray(items) : items;
17543 items = isVerticalDirection ? verticalizeItems(items) : items;
17544 if (activeId2 == null) {
17545 return (_a2 = findFirstEnabledItem2(items)) == null ? void 0 : _a2.id;
17546 }
17547 const activeItem = items.find((item) => item.id === activeId2);
17548 if (!activeItem) {
17549 return (_b = findFirstEnabledItem2(items)) == null ? void 0 : _b.id;
17550 }
17551 const isGrid2 = items.some((item) => item.rowId);
17552 const activeIndex = items.indexOf(activeItem);
17553 const nextItems = items.slice(activeIndex + 1);
17554 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
17555 if (skip) {
17556 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
17557 const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one.
17558 nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1];
17559 return nextItem2 == null ? void 0 : nextItem2.id;
17560 }
17561 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
17562 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
17563 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
17564 if (canLoop) {
17565 const loopItems = canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId);
17566 const sortedItems = flipItems(loopItems, activeId2, hasNullItem);
17567 const nextItem2 = findFirstEnabledItem2(sortedItems, activeId2);
17568 return nextItem2 == null ? void 0 : nextItem2.id;
17569 }
17570 if (canWrap) {
17571 const nextItem2 = findFirstEnabledItem2(
17572 // We can use nextItems, which contains all the next items, including
17573 // items from other rows, to wrap between rows. However, if there is a
17574 // null item (the composite container), we'll only use the next items in
17575 // the row. So moving next from the last item will focus on the
17576 // composite container. On grid composites, horizontal navigation never
17577 // focuses on the composite container, only vertical.
17578 hasNullItem ? nextItemsInRow : nextItems,
17579 activeId2
17580 );
17581 const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id;
17582 return nextId;
17583 }
17584 const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2);
17585 if (!nextItem && hasNullItem) {
17586 return null;
17587 }
17588 return nextItem == null ? void 0 : nextItem.id;
17589 };
17590 return {
17591 ...collection,
17592 ...composite,
17593 setBaseElement: (element) => composite.setState("baseElement", element),
17594 setActiveId: (id) => composite.setState("activeId", id),
17595 move: (id) => {
17596 if (id === void 0) return;
17597 composite.setState("activeId", id);
17598 composite.setState("moves", (moves) => moves + 1);
17599 },
17600 first: () => {
17601 var _a2;
17602 return (_a2 = findFirstEnabledItem2(composite.getState().renderedItems)) == null ? void 0 : _a2.id;
17603 },
17604 last: () => {
17605 var _a2;
17606 return (_a2 = findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id;
17607 },
17608 next: (options) => {
17609 if (options !== void 0 && typeof options === "number") {
17610 options = { skip: options };
17611 }
17612 return getNextId("next", options);
17613 },
17614 previous: (options) => {
17615 if (options !== void 0 && typeof options === "number") {
17616 options = { skip: options };
17617 }
17618 return getNextId("previous", options);
17619 },
17620 down: (options) => {
17621 if (options !== void 0 && typeof options === "number") {
17622 options = { skip: options };
17623 }
17624 return getNextId("down", options);
17625 },
17626 up: (options) => {
17627 if (options !== void 0 && typeof options === "number") {
17628 options = { skip: options };
17629 }
17630 return getNextId("up", options);
17631 }
17632 };
17633 }
17634
17635 // node_modules/@ariakit/react-core/esm/__chunks/IQYAUKXT.js
17636 function useCompositeStoreOptions(props) {
17637 const id = useId4(props.id);
17638 return { id, ...props };
17639 }
17640 function useCompositeStoreProps(store, update2, props) {
17641 store = useCollectionStoreProps(store, update2, props);
17642 useStoreProps(store, props, "activeId", "setActiveId");
17643 useStoreProps(store, props, "includesBaseElement");
17644 useStoreProps(store, props, "virtualFocus");
17645 useStoreProps(store, props, "orientation");
17646 useStoreProps(store, props, "rtl");
17647 useStoreProps(store, props, "focusLoop");
17648 useStoreProps(store, props, "focusWrap");
17649 useStoreProps(store, props, "focusShift");
17650 return store;
17651 }
17652
17653 // node_modules/@ariakit/react-core/esm/__chunks/CVCFNOHX.js
17654 var import_react22 = __toESM(require_react(), 1);
17655 var ComboboxListRoleContext = (0, import_react22.createContext)(
17656 void 0
17657 );
17658 var ctx6 = createStoreContext(
17659 [PopoverContextProvider, CompositeContextProvider],
17660 [PopoverScopedContextProvider, CompositeScopedContextProvider]
17661 );
17662 var useComboboxContext = ctx6.useContext;
17663 var useComboboxScopedContext = ctx6.useScopedContext;
17664 var useComboboxProviderContext = ctx6.useProviderContext;
17665 var ComboboxContextProvider = ctx6.ContextProvider;
17666 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
17667 var ComboboxItemValueContext = (0, import_react22.createContext)(
17668 void 0
17669 );
17670 var ComboboxItemCheckedContext = (0, import_react22.createContext)(false);
17671
17672 // node_modules/@ariakit/core/esm/__chunks/KMAUV3TY.js
17673 function createDialogStore(props = {}) {
17674 return createDisclosureStore(props);
17675 }
17676
17677 // node_modules/@ariakit/react-core/esm/__chunks/4NYSH4UO.js
17678 function useDialogStoreProps(store, update2, props) {
17679 return useDisclosureStoreProps(store, update2, props);
17680 }
17681
17682 // node_modules/@ariakit/core/esm/__chunks/BFGNM53A.js
17683 function createPopoverStore({
17684 popover: otherPopover,
17685 ...props
17686 } = {}) {
17687 const store = mergeStore(
17688 props.store,
17689 omit2(otherPopover, [
17690 "arrowElement",
17691 "anchorElement",
17692 "contentElement",
17693 "popoverElement",
17694 "disclosureElement"
17695 ])
17696 );
17697 throwOnConflictingProps(props, store);
17698 const syncState = store == null ? void 0 : store.getState();
17699 const dialog = createDialogStore({ ...props, store });
17700 const placement = defaultValue(
17701 props.placement,
17702 syncState == null ? void 0 : syncState.placement,
17703 "bottom"
17704 );
17705 const initialState = {
17706 ...dialog.getState(),
17707 placement,
17708 currentPlacement: placement,
17709 anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null),
17710 popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null),
17711 arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null),
17712 rendered: /* @__PURE__ */ Symbol("rendered")
17713 };
17714 const popover = createStore(initialState, dialog, store);
17715 return {
17716 ...dialog,
17717 ...popover,
17718 setAnchorElement: (element) => popover.setState("anchorElement", element),
17719 setPopoverElement: (element) => popover.setState("popoverElement", element),
17720 setArrowElement: (element) => popover.setState("arrowElement", element),
17721 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
17722 };
17723 }
17724
17725 // node_modules/@ariakit/react-core/esm/__chunks/B6FLPFJM.js
17726 function usePopoverStoreProps(store, update2, props) {
17727 useUpdateEffect(update2, [props.popover]);
17728 useStoreProps(store, props, "placement");
17729 return useDialogStoreProps(store, update2, props);
17730 }
17731
17732 // node_modules/@ariakit/react-core/esm/__chunks/4POTBZ2J.js
17733 var TagName7 = "div";
17734 var usePopoverAnchor = createHook(
17735 function usePopoverAnchor2({ store, ...props }) {
17736 const context = usePopoverProviderContext();
17737 store = store || context;
17738 props = {
17739 ...props,
17740 ref: useMergeRefs(store == null ? void 0 : store.setAnchorElement, props.ref)
17741 };
17742 return props;
17743 }
17744 );
17745 var PopoverAnchor = forwardRef29(function PopoverAnchor2(props) {
17746 const htmlProps = usePopoverAnchor(props);
17747 return createElement3(TagName7, htmlProps);
17748 });
17749
17750 // node_modules/@ariakit/react-core/esm/__chunks/X6LNAU2F.js
17751 var import_react23 = __toESM(require_react(), 1);
17752 var TagName8 = "div";
17753 function getMouseDestination(event) {
17754 const relatedTarget = event.relatedTarget;
17755 if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) {
17756 return relatedTarget;
17757 }
17758 return null;
17759 }
17760 function hoveringInside(event) {
17761 const nextElement = getMouseDestination(event);
17762 if (!nextElement) return false;
17763 return contains2(event.currentTarget, nextElement);
17764 }
17765 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
17766 function movingToAnotherItem(event) {
17767 let dest = getMouseDestination(event);
17768 if (!dest) return false;
17769 do {
17770 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
17771 dest = dest.parentElement;
17772 } while (dest);
17773 return false;
17774 }
17775 var useCompositeHover = createHook(
17776 function useCompositeHover2({
17777 store,
17778 focusOnHover = true,
17779 blurOnHoverEnd = !!focusOnHover,
17780 ...props
17781 }) {
17782 const context = useCompositeContext();
17783 store = store || context;
17784 invariant(
17785 store,
17786 "CompositeHover must be wrapped in a Composite component."
17787 );
17788 const isMouseMoving = useIsMouseMoving();
17789 const onMouseMoveProp = props.onMouseMove;
17790 const focusOnHoverProp = useBooleanEvent(focusOnHover);
17791 const onMouseMove = useEvent((event) => {
17792 onMouseMoveProp == null ? void 0 : onMouseMoveProp(event);
17793 if (event.defaultPrevented) return;
17794 if (!isMouseMoving()) return;
17795 if (!focusOnHoverProp(event)) return;
17796 if (!hasFocusWithin(event.currentTarget)) {
17797 const baseElement = store == null ? void 0 : store.getState().baseElement;
17798 if (baseElement && !hasFocus(baseElement)) {
17799 baseElement.focus();
17800 }
17801 }
17802 store == null ? void 0 : store.setActiveId(event.currentTarget.id);
17803 });
17804 const onMouseLeaveProp = props.onMouseLeave;
17805 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
17806 const onMouseLeave = useEvent((event) => {
17807 var _a;
17808 onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event);
17809 if (event.defaultPrevented) return;
17810 if (!isMouseMoving()) return;
17811 if (hoveringInside(event)) return;
17812 if (movingToAnotherItem(event)) return;
17813 if (!focusOnHoverProp(event)) return;
17814 if (!blurOnHoverEndProp(event)) return;
17815 store == null ? void 0 : store.setActiveId(null);
17816 (_a = store == null ? void 0 : store.getState().baseElement) == null ? void 0 : _a.focus();
17817 });
17818 const ref = (0, import_react23.useCallback)((element) => {
17819 if (!element) return;
17820 element[symbol2] = true;
17821 }, []);
17822 props = {
17823 ...props,
17824 ref: useMergeRefs(ref, props.ref),
17825 onMouseMove,
17826 onMouseLeave
17827 };
17828 return removeUndefinedValues(props);
17829 }
17830 );
17831 var CompositeHover = memo22(
17832 forwardRef29(function CompositeHover2(props) {
17833 const htmlProps = useCompositeHover(props);
17834 return createElement3(TagName8, htmlProps);
17835 })
17836 );
17837
17838 // node_modules/@ariakit/react-core/esm/combobox/combobox.js
17839 var import_react24 = __toESM(require_react(), 1);
17840 var TagName9 = "input";
17841 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
17842 if (!autoSelect) return false;
17843 const firstItem = items.find((item) => !item.disabled && item.value);
17844 return (firstItem == null ? void 0 : firstItem.value) === activeValue;
17845 }
17846 function hasCompletionString(value, activeValue) {
17847 if (!activeValue) return false;
17848 if (value == null) return false;
17849 value = normalizeString(value);
17850 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0;
17851 }
17852 function isInputEvent(event) {
17853 return event.type === "input";
17854 }
17855 function isAriaAutoCompleteValue(value) {
17856 return value === "inline" || value === "list" || value === "both" || value === "none";
17857 }
17858 function getDefaultAutoSelectId(items) {
17859 const item = items.find((item2) => {
17860 var _a;
17861 if (item2.disabled) return false;
17862 return ((_a = item2.element) == null ? void 0 : _a.getAttribute("role")) !== "tab";
17863 });
17864 return item == null ? void 0 : item.id;
17865 }
17866 var useCombobox = createHook(
17867 function useCombobox2({
17868 store,
17869 focusable: focusable2 = true,
17870 autoSelect: autoSelectProp = false,
17871 getAutoSelectId,
17872 setValueOnChange,
17873 showMinLength = 0,
17874 showOnChange,
17875 showOnMouseDown,
17876 showOnClick = showOnMouseDown,
17877 showOnKeyDown,
17878 showOnKeyPress = showOnKeyDown,
17879 blurActiveItemOnClick,
17880 setValueOnClick = true,
17881 moveOnKeyPress = true,
17882 autoComplete = "list",
17883 ...props
17884 }) {
17885 const context = useComboboxProviderContext();
17886 store = store || context;
17887 invariant(
17888 store,
17889 "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component."
17890 );
17891 const ref = (0, import_react24.useRef)(null);
17892 const [valueUpdated, forceValueUpdate] = useForceUpdate();
17893 const canAutoSelectRef = (0, import_react24.useRef)(false);
17894 const composingRef = (0, import_react24.useRef)(false);
17895 const autoSelect = store.useState(
17896 (state) => state.virtualFocus && autoSelectProp
17897 );
17898 const inline4 = autoComplete === "inline" || autoComplete === "both";
17899 const [canInline, setCanInline] = (0, import_react24.useState)(inline4);
17900 useUpdateLayoutEffect(() => {
17901 if (!inline4) return;
17902 setCanInline(true);
17903 }, [inline4]);
17904 const storeValue = store.useState("value");
17905 const prevSelectedValueRef = (0, import_react24.useRef)(void 0);
17906 (0, import_react24.useEffect)(() => {
17907 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
17908 prevSelectedValueRef.current = prev.selectedValue;
17909 });
17910 }, []);
17911 const inlineActiveValue = store.useState((state) => {
17912 var _a;
17913 if (!inline4) return;
17914 if (!canInline) return;
17915 if (state.activeValue && Array.isArray(state.selectedValue)) {
17916 if (state.selectedValue.includes(state.activeValue)) return;
17917 if ((_a = prevSelectedValueRef.current) == null ? void 0 : _a.includes(state.activeValue)) return;
17918 }
17919 return state.activeValue;
17920 });
17921 const items = store.useState("renderedItems");
17922 const open = store.useState("open");
17923 const contentElement = store.useState("contentElement");
17924 const value = (0, import_react24.useMemo)(() => {
17925 if (!inline4) return storeValue;
17926 if (!canInline) return storeValue;
17927 const firstItemAutoSelected = isFirstItemAutoSelected(
17928 items,
17929 inlineActiveValue,
17930 autoSelect
17931 );
17932 if (firstItemAutoSelected) {
17933 if (hasCompletionString(storeValue, inlineActiveValue)) {
17934 const slice = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || "";
17935 return storeValue + slice;
17936 }
17937 return storeValue;
17938 }
17939 return inlineActiveValue || storeValue;
17940 }, [inline4, canInline, items, inlineActiveValue, autoSelect, storeValue]);
17941 (0, import_react24.useEffect)(() => {
17942 const element = ref.current;
17943 if (!element) return;
17944 const onCompositeItemMove = () => setCanInline(true);
17945 element.addEventListener("combobox-item-move", onCompositeItemMove);
17946 return () => {
17947 element.removeEventListener("combobox-item-move", onCompositeItemMove);
17948 };
17949 }, []);
17950 (0, import_react24.useEffect)(() => {
17951 if (!inline4) return;
17952 if (!canInline) return;
17953 if (!inlineActiveValue) return;
17954 const firstItemAutoSelected = isFirstItemAutoSelected(
17955 items,
17956 inlineActiveValue,
17957 autoSelect
17958 );
17959 if (!firstItemAutoSelected) return;
17960 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
17961 let cleanup = noop4;
17962 queueMicrotask(() => {
17963 const element = ref.current;
17964 if (!element) return;
17965 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
17966 const nextStart = storeValue.length;
17967 const nextEnd = inlineActiveValue.length;
17968 setSelectionRange(element, nextStart, nextEnd);
17969 cleanup = () => {
17970 if (!hasFocus(element)) return;
17971 const { start, end } = getTextboxSelection(element);
17972 if (start !== nextStart) return;
17973 if (end !== nextEnd) return;
17974 setSelectionRange(element, prevStart, prevEnd);
17975 };
17976 });
17977 return () => cleanup();
17978 }, [
17979 valueUpdated,
17980 inline4,
17981 canInline,
17982 inlineActiveValue,
17983 items,
17984 autoSelect,
17985 storeValue
17986 ]);
17987 const scrollingElementRef = (0, import_react24.useRef)(null);
17988 const getAutoSelectIdProp = useEvent(getAutoSelectId);
17989 const autoSelectIdRef = (0, import_react24.useRef)(null);
17990 (0, import_react24.useEffect)(() => {
17991 if (!open) return;
17992 if (!contentElement) return;
17993 const scrollingElement = getScrollingElement(contentElement);
17994 if (!scrollingElement) return;
17995 scrollingElementRef.current = scrollingElement;
17996 const onUserScroll = () => {
17997 canAutoSelectRef.current = false;
17998 };
17999 const onScroll = () => {
18000 if (!store) return;
18001 if (!canAutoSelectRef.current) return;
18002 const { activeId } = store.getState();
18003 if (activeId === null) return;
18004 if (activeId === autoSelectIdRef.current) return;
18005 canAutoSelectRef.current = false;
18006 };
18007 const options = { passive: true, capture: true };
18008 scrollingElement.addEventListener("wheel", onUserScroll, options);
18009 scrollingElement.addEventListener("touchmove", onUserScroll, options);
18010 scrollingElement.addEventListener("scroll", onScroll, options);
18011 return () => {
18012 scrollingElement.removeEventListener("wheel", onUserScroll, true);
18013 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
18014 scrollingElement.removeEventListener("scroll", onScroll, true);
18015 };
18016 }, [open, contentElement, store]);
18017 useSafeLayoutEffect(() => {
18018 if (!storeValue) return;
18019 if (composingRef.current) return;
18020 canAutoSelectRef.current = true;
18021 }, [storeValue]);
18022 useSafeLayoutEffect(() => {
18023 if (autoSelect !== "always" && open) return;
18024 canAutoSelectRef.current = open;
18025 }, [autoSelect, open]);
18026 const resetValueOnSelect = store.useState("resetValueOnSelect");
18027 useUpdateEffect(() => {
18028 var _a, _b;
18029 const canAutoSelect = canAutoSelectRef.current;
18030 if (!store) return;
18031 if (!open) return;
18032 if (!canAutoSelect && !resetValueOnSelect) return;
18033 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
18034 if (baseElement && !hasFocus(baseElement)) return;
18035 if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) {
18036 const observer = new MutationObserver(forceValueUpdate);
18037 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
18038 return () => observer.disconnect();
18039 }
18040 if (autoSelect && canAutoSelect) {
18041 const userAutoSelectId = getAutoSelectIdProp(items);
18042 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : (_a = getDefaultAutoSelectId(items)) != null ? _a : store.first();
18043 autoSelectIdRef.current = autoSelectId;
18044 store.move(autoSelectId != null ? autoSelectId : null);
18045 } else {
18046 const element = (_b = store.item(activeId || store.first())) == null ? void 0 : _b.element;
18047 if (element && "scrollIntoView" in element) {
18048 element.scrollIntoView({ block: "nearest", inline: "nearest" });
18049 }
18050 }
18051 return;
18052 }, [
18053 store,
18054 open,
18055 valueUpdated,
18056 storeValue,
18057 autoSelect,
18058 resetValueOnSelect,
18059 getAutoSelectIdProp,
18060 items
18061 ]);
18062 (0, import_react24.useEffect)(() => {
18063 if (!inline4) return;
18064 const combobox = ref.current;
18065 if (!combobox) return;
18066 const elements = [combobox, contentElement].filter(
18067 (value2) => !!value2
18068 );
18069 const onBlur2 = (event) => {
18070 if (elements.every((el) => isFocusEventOutside(event, el))) {
18071 store == null ? void 0 : store.setValue(value);
18072 }
18073 };
18074 for (const element of elements) {
18075 element.addEventListener("focusout", onBlur2);
18076 }
18077 return () => {
18078 for (const element of elements) {
18079 element.removeEventListener("focusout", onBlur2);
18080 }
18081 };
18082 }, [inline4, contentElement, store, value]);
18083 const canShow = (event) => {
18084 const currentTarget = event.currentTarget;
18085 return currentTarget.value.length >= showMinLength;
18086 };
18087 const onChangeProp = props.onChange;
18088 const showOnChangeProp = useBooleanEvent(showOnChange != null ? showOnChange : canShow);
18089 const setValueOnChangeProp = useBooleanEvent(
18090 // If the combobox is combined with tags, the value will be set by the tag
18091 // input component.
18092 setValueOnChange != null ? setValueOnChange : !store.tag
18093 );
18094 const onChange = useEvent((event) => {
18095 onChangeProp == null ? void 0 : onChangeProp(event);
18096 if (event.defaultPrevented) return;
18097 if (!store) return;
18098 const currentTarget = event.currentTarget;
18099 const { value: value2, selectionStart, selectionEnd } = currentTarget;
18100 const nativeEvent = event.nativeEvent;
18101 canAutoSelectRef.current = true;
18102 if (isInputEvent(nativeEvent)) {
18103 if (nativeEvent.isComposing) {
18104 canAutoSelectRef.current = false;
18105 composingRef.current = true;
18106 }
18107 if (inline4) {
18108 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
18109 const caretAtEnd = selectionStart === value2.length;
18110 setCanInline(textInserted && caretAtEnd);
18111 }
18112 }
18113 if (setValueOnChangeProp(event)) {
18114 const isSameValue = value2 === store.getState().value;
18115 store.setValue(value2);
18116 queueMicrotask(() => {
18117 setSelectionRange(currentTarget, selectionStart, selectionEnd);
18118 });
18119 if (inline4 && autoSelect && isSameValue) {
18120 forceValueUpdate();
18121 }
18122 }
18123 if (showOnChangeProp(event)) {
18124 store.show();
18125 }
18126 if (!autoSelect || !canAutoSelectRef.current) {
18127 store.setActiveId(null);
18128 }
18129 });
18130 const onCompositionEndProp = props.onCompositionEnd;
18131 const onCompositionEnd = useEvent((event) => {
18132 canAutoSelectRef.current = true;
18133 composingRef.current = false;
18134 onCompositionEndProp == null ? void 0 : onCompositionEndProp(event);
18135 if (event.defaultPrevented) return;
18136 if (!autoSelect) return;
18137 forceValueUpdate();
18138 });
18139 const onMouseDownProp = props.onMouseDown;
18140 const blurActiveItemOnClickProp = useBooleanEvent(
18141 blurActiveItemOnClick != null ? blurActiveItemOnClick : (() => !!(store == null ? void 0 : store.getState().includesBaseElement))
18142 );
18143 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18144 const showOnClickProp = useBooleanEvent(showOnClick != null ? showOnClick : canShow);
18145 const onMouseDown = useEvent((event) => {
18146 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
18147 if (event.defaultPrevented) return;
18148 if (event.button) return;
18149 if (event.ctrlKey) return;
18150 if (!store) return;
18151 if (blurActiveItemOnClickProp(event)) {
18152 store.setActiveId(null);
18153 }
18154 if (setValueOnClickProp(event)) {
18155 store.setValue(value);
18156 }
18157 if (showOnClickProp(event)) {
18158 queueBeforeEvent(event.currentTarget, "mouseup", store.show);
18159 }
18160 });
18161 const onKeyDownProp = props.onKeyDown;
18162 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress != null ? showOnKeyPress : canShow);
18163 const onKeyDown = useEvent((event) => {
18164 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
18165 if (!event.repeat) {
18166 canAutoSelectRef.current = false;
18167 }
18168 if (event.defaultPrevented) return;
18169 if (event.ctrlKey) return;
18170 if (event.altKey) return;
18171 if (event.shiftKey) return;
18172 if (event.metaKey) return;
18173 if (!store) return;
18174 const { open: open2 } = store.getState();
18175 if (open2) return;
18176 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
18177 if (showOnKeyPressProp(event)) {
18178 event.preventDefault();
18179 store.show();
18180 }
18181 }
18182 });
18183 const onBlurProp = props.onBlur;
18184 const onBlur = useEvent((event) => {
18185 canAutoSelectRef.current = false;
18186 onBlurProp == null ? void 0 : onBlurProp(event);
18187 if (event.defaultPrevented) return;
18188 });
18189 const id = useId4(props.id);
18190 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
18191 const isActiveItem = store.useState((state) => state.activeId === null);
18192 props = {
18193 id,
18194 role: "combobox",
18195 "aria-autocomplete": ariaAutoComplete,
18196 "aria-haspopup": getPopupRole(contentElement, "listbox"),
18197 "aria-expanded": open,
18198 "aria-controls": contentElement == null ? void 0 : contentElement.id,
18199 "data-active-item": isActiveItem || void 0,
18200 value,
18201 ...props,
18202 ref: useMergeRefs(ref, props.ref),
18203 onChange,
18204 onCompositionEnd,
18205 onMouseDown,
18206 onKeyDown,
18207 onBlur
18208 };
18209 props = useComposite({
18210 store,
18211 focusable: focusable2,
18212 ...props,
18213 // Enable inline autocomplete when the user moves from the combobox input
18214 // to an item.
18215 moveOnKeyPress: (event) => {
18216 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
18217 if (inline4) setCanInline(true);
18218 return true;
18219 }
18220 });
18221 props = usePopoverAnchor({ store, ...props });
18222 return { autoComplete: "off", ...props };
18223 }
18224 );
18225 var Combobox = forwardRef29(function Combobox2(props) {
18226 const htmlProps = useCombobox(props);
18227 return createElement3(TagName9, htmlProps);
18228 });
18229
18230 // node_modules/@ariakit/react-core/esm/__chunks/IBXZ2LQC.js
18231 var import_react25 = __toESM(require_react(), 1);
18232 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
18233 var TagName10 = "div";
18234 function isSelected(storeValue, itemValue) {
18235 if (itemValue == null) return;
18236 if (storeValue == null) return false;
18237 if (Array.isArray(storeValue)) {
18238 return storeValue.includes(itemValue);
18239 }
18240 return storeValue === itemValue;
18241 }
18242 function getItemRole(popupRole) {
18243 var _a;
18244 const itemRoleByPopupRole = {
18245 menu: "menuitem",
18246 listbox: "option",
18247 tree: "treeitem"
18248 };
18249 const key = popupRole;
18250 return (_a = itemRoleByPopupRole[key]) != null ? _a : "option";
18251 }
18252 var useComboboxItem = createHook(
18253 function useComboboxItem2({
18254 store,
18255 value,
18256 hideOnClick,
18257 setValueOnClick,
18258 selectValueOnClick = true,
18259 resetValueOnSelect,
18260 focusOnHover = false,
18261 moveOnKeyPress = true,
18262 getItem: getItemProp,
18263 ...props
18264 }) {
18265 var _a;
18266 const context = useComboboxScopedContext();
18267 store = store || context;
18268 invariant(
18269 store,
18270 "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component."
18271 );
18272 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
18273 resetValueOnSelectState: "resetValueOnSelect",
18274 multiSelectable(state) {
18275 return Array.isArray(state.selectedValue);
18276 },
18277 selected(state) {
18278 return isSelected(state.selectedValue, value);
18279 }
18280 });
18281 const getItem = (0, import_react25.useCallback)(
18282 (item) => {
18283 const nextItem = { ...item, value };
18284 if (getItemProp) {
18285 return getItemProp(nextItem);
18286 }
18287 return nextItem;
18288 },
18289 [value, getItemProp]
18290 );
18291 setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable;
18292 hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable;
18293 const onClickProp = props.onClick;
18294 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18295 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
18296 const resetValueOnSelectProp = useBooleanEvent(
18297 (_a = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a : multiSelectable
18298 );
18299 const hideOnClickProp = useBooleanEvent(hideOnClick);
18300 const onClick = useEvent((event) => {
18301 onClickProp == null ? void 0 : onClickProp(event);
18302 if (event.defaultPrevented) return;
18303 if (isDownloading(event)) return;
18304 if (isOpeningInNewTab(event)) return;
18305 if (value != null) {
18306 if (selectValueOnClickProp(event)) {
18307 if (resetValueOnSelectProp(event)) {
18308 store == null ? void 0 : store.resetValue();
18309 }
18310 store == null ? void 0 : store.setSelectedValue((prevValue) => {
18311 if (!Array.isArray(prevValue)) return value;
18312 if (prevValue.includes(value)) {
18313 return prevValue.filter((v2) => v2 !== value);
18314 }
18315 return [...prevValue, value];
18316 });
18317 }
18318 if (setValueOnClickProp(event)) {
18319 store == null ? void 0 : store.setValue(value);
18320 }
18321 }
18322 if (hideOnClickProp(event)) {
18323 store == null ? void 0 : store.hide();
18324 }
18325 });
18326 const onKeyDownProp = props.onKeyDown;
18327 const onKeyDown = useEvent((event) => {
18328 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
18329 if (event.defaultPrevented) return;
18330 const baseElement = store == null ? void 0 : store.getState().baseElement;
18331 if (!baseElement) return;
18332 if (hasFocus(baseElement)) return;
18333 const printable = event.key.length === 1;
18334 if (printable || event.key === "Backspace" || event.key === "Delete") {
18335 queueMicrotask(() => baseElement.focus());
18336 if (isTextField(baseElement)) {
18337 store == null ? void 0 : store.setValue(baseElement.value);
18338 }
18339 }
18340 });
18341 if (multiSelectable && selected != null) {
18342 props = {
18343 "aria-selected": selected,
18344 ...props
18345 };
18346 }
18347 props = useWrapElement(
18348 props,
18349 (element) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }),
18350 [value, selected]
18351 );
18352 const popupRole = (0, import_react25.useContext)(ComboboxListRoleContext);
18353 props = {
18354 role: getItemRole(popupRole),
18355 children: value,
18356 ...props,
18357 onClick,
18358 onKeyDown
18359 };
18360 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
18361 props = useCompositeItem({
18362 store,
18363 ...props,
18364 getItem,
18365 // Dispatch a custom event on the combobox input when moving to an item
18366 // with the keyboard so the Combobox component can enable inline
18367 // autocompletion.
18368 moveOnKeyPress: (event) => {
18369 if (!moveOnKeyPressProp(event)) return false;
18370 const moveEvent = new Event("combobox-item-move");
18371 const baseElement = store == null ? void 0 : store.getState().baseElement;
18372 baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent);
18373 return true;
18374 }
18375 });
18376 props = useCompositeHover({ store, focusOnHover, ...props });
18377 return props;
18378 }
18379 );
18380 var ComboboxItem = memo22(
18381 forwardRef29(function ComboboxItem2(props) {
18382 const htmlProps = useComboboxItem(props);
18383 return createElement3(TagName10, htmlProps);
18384 })
18385 );
18386
18387 // node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js
18388 var import_react26 = __toESM(require_react(), 1);
18389 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
18390 var TagName11 = "span";
18391 function normalizeValue(value) {
18392 return normalizeString(value).toLowerCase();
18393 }
18394 function getOffsets(string, values) {
18395 const offsets = [];
18396 for (const value of values) {
18397 let pos = 0;
18398 const length = value.length;
18399 while (string.indexOf(value, pos) !== -1) {
18400 const index2 = string.indexOf(value, pos);
18401 if (index2 !== -1) {
18402 offsets.push([index2, length]);
18403 }
18404 pos = index2 + 1;
18405 }
18406 }
18407 return offsets;
18408 }
18409 function filterOverlappingOffsets(offsets) {
18410 return offsets.filter(([offset4, length], i2, arr) => {
18411 return !arr.some(
18412 ([o2, l2], j2) => j2 !== i2 && o2 <= offset4 && o2 + l2 >= offset4 + length
18413 );
18414 });
18415 }
18416 function sortOffsets(offsets) {
18417 return offsets.sort(([a2], [b2]) => a2 - b2);
18418 }
18419 function splitValue(itemValue, userValue) {
18420 if (!itemValue) return itemValue;
18421 if (!userValue) return itemValue;
18422 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue);
18423 const parts = [];
18424 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
18425 "span",
18426 {
18427 "data-autocomplete-value": autocomplete ? "" : void 0,
18428 "data-user-value": autocomplete ? void 0 : "",
18429 children: value
18430 },
18431 parts.length
18432 );
18433 const offsets = sortOffsets(
18434 filterOverlappingOffsets(
18435 // Convert userValues into a set to avoid duplicates
18436 getOffsets(normalizeValue(itemValue), new Set(userValues))
18437 )
18438 );
18439 if (!offsets.length) {
18440 parts.push(span(itemValue, true));
18441 return parts;
18442 }
18443 const [firstOffset] = offsets[0];
18444 const values = [
18445 itemValue.slice(0, firstOffset),
18446 ...offsets.flatMap(([offset4, length], i2) => {
18447 var _a;
18448 const value = itemValue.slice(offset4, offset4 + length);
18449 const nextOffset = (_a = offsets[i2 + 1]) == null ? void 0 : _a[0];
18450 const nextValue = itemValue.slice(offset4 + length, nextOffset);
18451 return [value, nextValue];
18452 })
18453 ];
18454 values.forEach((value, i2) => {
18455 if (!value) return;
18456 parts.push(span(value, i2 % 2 === 0));
18457 });
18458 return parts;
18459 }
18460 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
18461 const context = useComboboxScopedContext();
18462 store = store || context;
18463 const itemContext = (0, import_react26.useContext)(ComboboxItemValueContext);
18464 const itemValue = value != null ? value : itemContext;
18465 const inputValue = useStoreState(store, (state) => userValue != null ? userValue : state == null ? void 0 : state.value);
18466 const children = (0, import_react26.useMemo)(() => {
18467 if (!itemValue) return;
18468 if (!inputValue) return itemValue;
18469 return splitValue(itemValue, inputValue);
18470 }, [itemValue, inputValue]);
18471 props = {
18472 children,
18473 ...props
18474 };
18475 return removeUndefinedValues(props);
18476 });
18477 var ComboboxItemValue = forwardRef29(function ComboboxItemValue2(props) {
18478 const htmlProps = useComboboxItemValue(props);
18479 return createElement3(TagName11, htmlProps);
18480 });
18481
18482 // node_modules/@ariakit/react-core/esm/combobox/combobox-label.js
18483 var TagName12 = "label";
18484 var useComboboxLabel = createHook(
18485 function useComboboxLabel2({ store, ...props }) {
18486 const context = useComboboxProviderContext();
18487 store = store || context;
18488 invariant(
18489 store,
18490 "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component."
18491 );
18492 const comboboxId = store.useState((state) => {
18493 var _a;
18494 return (_a = state.baseElement) == null ? void 0 : _a.id;
18495 });
18496 props = {
18497 htmlFor: comboboxId,
18498 ...props
18499 };
18500 return removeUndefinedValues(props);
18501 }
18502 );
18503 var ComboboxLabel = memo22(
18504 forwardRef29(function ComboboxLabel2(props) {
18505 const htmlProps = useComboboxLabel(props);
18506 return createElement3(TagName12, htmlProps);
18507 })
18508 );
18509
18510 // node_modules/@ariakit/react-core/esm/__chunks/2G6YEJT4.js
18511 var import_react27 = __toESM(require_react(), 1);
18512 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
18513 var TagName13 = "div";
18514 var useComboboxList = createHook(
18515 function useComboboxList2({ store, alwaysVisible, ...props }) {
18516 const scopedContext = useComboboxScopedContext(true);
18517 const context = useComboboxContext();
18518 store = store || context;
18519 const scopedContextSameStore = !!store && store === scopedContext;
18520 invariant(
18521 store,
18522 "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component."
18523 );
18524 const ref = (0, import_react27.useRef)(null);
18525 const id = useId4(props.id);
18526 const mounted = store.useState("mounted");
18527 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
18528 const style = hidden ? { ...props.style, display: "none" } : props.style;
18529 const multiSelectable = store.useState(
18530 (state) => Array.isArray(state.selectedValue)
18531 );
18532 const role = useAttribute(ref, "role", props.role);
18533 const isCompositeRole = role === "listbox" || role === "tree" || role === "grid";
18534 const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0;
18535 const [hasListboxInside, setHasListboxInside] = (0, import_react27.useState)(false);
18536 const contentElement = store.useState("contentElement");
18537 useSafeLayoutEffect(() => {
18538 if (!mounted) return;
18539 const element = ref.current;
18540 if (!element) return;
18541 if (contentElement !== element) return;
18542 const callback = () => {
18543 setHasListboxInside(!!element.querySelector("[role='listbox']"));
18544 };
18545 const observer = new MutationObserver(callback);
18546 observer.observe(element, {
18547 subtree: true,
18548 childList: true,
18549 attributeFilter: ["role"]
18550 });
18551 callback();
18552 return () => observer.disconnect();
18553 }, [mounted, contentElement]);
18554 if (!hasListboxInside) {
18555 props = {
18556 role: "listbox",
18557 "aria-multiselectable": ariaMultiSelectable,
18558 ...props
18559 };
18560 }
18561 props = useWrapElement(
18562 props,
18563 (element) => /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(ComboboxScopedContextProvider, { value: store, children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(ComboboxListRoleContext.Provider, { value: role, children: element }) }),
18564 [store, role]
18565 );
18566 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
18567 props = {
18568 id,
18569 hidden,
18570 ...props,
18571 ref: useMergeRefs(setContentElement, ref, props.ref),
18572 style
18573 };
18574 return removeUndefinedValues(props);
18575 }
18576 );
18577 var ComboboxList = forwardRef29(function ComboboxList2(props) {
18578 const htmlProps = useComboboxList(props);
18579 return createElement3(TagName13, htmlProps);
18580 });
18581
18582 // node_modules/@ariakit/react-core/esm/__chunks/XSIEPKGA.js
18583 var import_react28 = __toESM(require_react(), 1);
18584 var TagValueContext = (0, import_react28.createContext)(null);
18585 var TagRemoveIdContext = (0, import_react28.createContext)(
18586 null
18587 );
18588 var ctx7 = createStoreContext(
18589 [CompositeContextProvider],
18590 [CompositeScopedContextProvider]
18591 );
18592 var useTagContext = ctx7.useContext;
18593 var useTagScopedContext = ctx7.useScopedContext;
18594 var useTagProviderContext = ctx7.useProviderContext;
18595 var TagContextProvider = ctx7.ContextProvider;
18596 var TagScopedContextProvider = ctx7.ScopedContextProvider;
18597
18598 // node_modules/@ariakit/core/esm/combobox/combobox-store.js
18599 var isTouchSafari = isSafari2() && isTouchDevice();
18600 function createComboboxStore({
18601 tag,
18602 ...props
18603 } = {}) {
18604 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
18605 throwOnConflictingProps(props, store);
18606 const tagState = tag == null ? void 0 : tag.getState();
18607 const syncState = store == null ? void 0 : store.getState();
18608 const activeId = defaultValue(
18609 props.activeId,
18610 syncState == null ? void 0 : syncState.activeId,
18611 props.defaultActiveId,
18612 null
18613 );
18614 const composite = createCompositeStore({
18615 ...props,
18616 activeId,
18617 includesBaseElement: defaultValue(
18618 props.includesBaseElement,
18619 syncState == null ? void 0 : syncState.includesBaseElement,
18620 true
18621 ),
18622 orientation: defaultValue(
18623 props.orientation,
18624 syncState == null ? void 0 : syncState.orientation,
18625 "vertical"
18626 ),
18627 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true),
18628 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true),
18629 virtualFocus: defaultValue(
18630 props.virtualFocus,
18631 syncState == null ? void 0 : syncState.virtualFocus,
18632 true
18633 )
18634 });
18635 const popover = createPopoverStore({
18636 ...props,
18637 placement: defaultValue(
18638 props.placement,
18639 syncState == null ? void 0 : syncState.placement,
18640 "bottom-start"
18641 )
18642 });
18643 const value = defaultValue(
18644 props.value,
18645 syncState == null ? void 0 : syncState.value,
18646 props.defaultValue,
18647 ""
18648 );
18649 const selectedValue = defaultValue(
18650 props.selectedValue,
18651 syncState == null ? void 0 : syncState.selectedValue,
18652 tagState == null ? void 0 : tagState.values,
18653 props.defaultSelectedValue,
18654 ""
18655 );
18656 const multiSelectable = Array.isArray(selectedValue);
18657 const initialState = {
18658 ...composite.getState(),
18659 ...popover.getState(),
18660 value,
18661 selectedValue,
18662 resetValueOnSelect: defaultValue(
18663 props.resetValueOnSelect,
18664 syncState == null ? void 0 : syncState.resetValueOnSelect,
18665 multiSelectable
18666 ),
18667 resetValueOnHide: defaultValue(
18668 props.resetValueOnHide,
18669 syncState == null ? void 0 : syncState.resetValueOnHide,
18670 multiSelectable && !tag
18671 ),
18672 activeValue: syncState == null ? void 0 : syncState.activeValue
18673 };
18674 const combobox = createStore(initialState, composite, popover, store);
18675 if (isTouchSafari) {
18676 setup(
18677 combobox,
18678 () => sync(combobox, ["virtualFocus"], () => {
18679 combobox.setState("virtualFocus", false);
18680 })
18681 );
18682 }
18683 setup(combobox, () => {
18684 if (!tag) return;
18685 return chain(
18686 sync(combobox, ["selectedValue"], (state) => {
18687 if (!Array.isArray(state.selectedValue)) return;
18688 tag.setValues(state.selectedValue);
18689 }),
18690 sync(tag, ["values"], (state) => {
18691 combobox.setState("selectedValue", state.values);
18692 })
18693 );
18694 });
18695 setup(
18696 combobox,
18697 () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
18698 if (!state.resetValueOnHide) return;
18699 if (state.mounted) return;
18700 combobox.setState("value", value);
18701 })
18702 );
18703 setup(
18704 combobox,
18705 () => sync(combobox, ["open"], (state) => {
18706 if (state.open) return;
18707 combobox.setState("activeId", activeId);
18708 combobox.setState("moves", 0);
18709 })
18710 );
18711 setup(
18712 combobox,
18713 () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
18714 if (state.moves === prevState.moves) {
18715 combobox.setState("activeValue", void 0);
18716 }
18717 })
18718 );
18719 setup(
18720 combobox,
18721 () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
18722 if (state.moves === prev.moves) return;
18723 const { activeId: activeId2 } = combobox.getState();
18724 const activeItem = composite.item(activeId2);
18725 combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value);
18726 })
18727 );
18728 return {
18729 ...popover,
18730 ...composite,
18731 ...combobox,
18732 tag,
18733 setValue: (value2) => combobox.setState("value", value2),
18734 resetValue: () => combobox.setState("value", initialState.value),
18735 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
18736 };
18737 }
18738
18739 // node_modules/@ariakit/react-core/esm/__chunks/SVN33SY6.js
18740 function useComboboxStoreOptions(props) {
18741 const tag = useTagContext();
18742 props = {
18743 ...props,
18744 tag: props.tag !== void 0 ? props.tag : tag
18745 };
18746 return useCompositeStoreOptions(props);
18747 }
18748 function useComboboxStoreProps(store, update2, props) {
18749 useUpdateEffect(update2, [props.tag]);
18750 useStoreProps(store, props, "value", "setValue");
18751 useStoreProps(store, props, "selectedValue", "setSelectedValue");
18752 useStoreProps(store, props, "resetValueOnHide");
18753 useStoreProps(store, props, "resetValueOnSelect");
18754 return Object.assign(
18755 useCompositeStoreProps(
18756 usePopoverStoreProps(store, update2, props),
18757 update2,
18758 props
18759 ),
18760 { tag: props.tag }
18761 );
18762 }
18763 function useComboboxStore(props = {}) {
18764 props = useComboboxStoreOptions(props);
18765 const [store, update2] = useStore2(createComboboxStore, props);
18766 return useComboboxStoreProps(store, update2, props);
18767 }
18768
18769 // node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js
18770 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
18771 function ComboboxProvider(props = {}) {
18772 const store = useComboboxStore(props);
18773 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(ComboboxContextProvider, { value: store, children: props.children });
18774 }
18775
18776 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
18777 var import_remove_accents = __toESM(require_remove_accents(), 1);
18778 var import_compose7 = __toESM(require_compose(), 1);
18779 var import_i18n23 = __toESM(require_i18n(), 1);
18780 var import_element47 = __toESM(require_element(), 1);
18781 var import_components18 = __toESM(require_components(), 1);
18782
18783 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
18784 var EMPTY_ARRAY3 = [];
18785 var getCurrentValue = (filterDefinition, currentFilter) => {
18786 if (filterDefinition.singleSelection) {
18787 return currentFilter?.value;
18788 }
18789 if (Array.isArray(currentFilter?.value)) {
18790 return currentFilter.value;
18791 }
18792 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
18793 return [currentFilter.value];
18794 }
18795 return EMPTY_ARRAY3;
18796 };
18797
18798 // packages/dataviews/build-module/hooks/use-elements.mjs
18799 var import_element46 = __toESM(require_element(), 1);
18800 var EMPTY_ARRAY4 = [];
18801 function useElements({
18802 elements,
18803 getElements
18804 }) {
18805 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
18806 const [records, setRecords] = (0, import_element46.useState)(staticElements);
18807 const [isLoading, setIsLoading] = (0, import_element46.useState)(false);
18808 (0, import_element46.useEffect)(() => {
18809 if (!getElements) {
18810 setRecords(staticElements);
18811 return;
18812 }
18813 let cancelled = false;
18814 setIsLoading(true);
18815 getElements().then((fetchedElements) => {
18816 if (!cancelled) {
18817 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
18818 setRecords(dynamicElements);
18819 }
18820 }).catch(() => {
18821 if (!cancelled) {
18822 setRecords(staticElements);
18823 }
18824 }).finally(() => {
18825 if (!cancelled) {
18826 setIsLoading(false);
18827 }
18828 });
18829 return () => {
18830 cancelled = true;
18831 };
18832 }, [getElements, staticElements]);
18833 return {
18834 elements: records,
18835 isLoading
18836 };
18837 }
18838
18839 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
18840 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
18841 function normalizeSearchInput(input = "") {
18842 return (0, import_remove_accents.default)(input.trim().toLowerCase());
18843 }
18844 var getNewValue = (filterDefinition, currentFilter, value) => {
18845 if (filterDefinition.singleSelection) {
18846 return value;
18847 }
18848 if (Array.isArray(currentFilter?.value)) {
18849 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
18850 }
18851 return [value];
18852 };
18853 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
18854 return `${prefix}-${filterElementValue}`;
18855 }
18856 var MultiSelectionOption = ({ selected }) => {
18857 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
18858 "span",
18859 {
18860 className: clsx_default(
18861 "dataviews-filters__search-widget-listitem-multi-selection",
18862 { "is-selected": selected }
18863 ),
18864 children: selected && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_components18.Icon, { icon: check_default })
18865 }
18866 );
18867 };
18868 var SingleSelectionOption = ({ selected }) => {
18869 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
18870 "span",
18871 {
18872 className: clsx_default(
18873 "dataviews-filters__search-widget-listitem-single-selection",
18874 { "is-selected": selected }
18875 )
18876 }
18877 );
18878 };
18879 function ListBox({ view, filter, onChangeView }) {
18880 const baseId = (0, import_compose7.useInstanceId)(ListBox, "dataviews-filter-list-box");
18881 const [activeCompositeId, setActiveCompositeId] = (0, import_element47.useState)(
18882 // When there are one or less operators, the first item is set as active
18883 // (by setting the initial `activeId` to `undefined`).
18884 // With 2 or more operators, the focus is moved on the operators control
18885 // (by setting the initial `activeId` to `null`), meaning that there won't
18886 // be an active item initially. Focus is then managed via the
18887 // `onFocusVisible` callback.
18888 filter.operators?.length === 1 ? void 0 : null
18889 );
18890 const currentFilter = view.filters?.find(
18891 (f2) => f2.field === filter.field
18892 );
18893 const currentValue = getCurrentValue(filter, currentFilter);
18894 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
18895 import_components18.Composite,
18896 {
18897 virtualFocus: true,
18898 focusLoop: true,
18899 activeId: activeCompositeId,
18900 setActiveId: setActiveCompositeId,
18901 role: "listbox",
18902 className: "dataviews-filters__search-widget-listbox",
18903 "aria-label": (0, import_i18n23.sprintf)(
18904 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
18905 (0, import_i18n23.__)("List of: %1$s"),
18906 filter.name
18907 ),
18908 onFocusVisible: () => {
18909 if (!activeCompositeId && filter.elements.length) {
18910 setActiveCompositeId(
18911 generateFilterElementCompositeItemId(
18912 baseId,
18913 filter.elements[0].value
18914 )
18915 );
18916 }
18917 },
18918 render: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_components18.Composite.Typeahead, {}),
18919 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
18920 import_components18.Composite.Hover,
18921 {
18922 render: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
18923 import_components18.Composite.Item,
18924 {
18925 id: generateFilterElementCompositeItemId(
18926 baseId,
18927 element.value
18928 ),
18929 render: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
18930 "div",
18931 {
18932 "aria-label": element.label,
18933 role: "option",
18934 className: "dataviews-filters__search-widget-listitem"
18935 }
18936 ),
18937 onClick: () => {
18938 const newFilters = currentFilter ? [
18939 ...(view.filters ?? []).map(
18940 (_filter) => {
18941 if (_filter.field === filter.field) {
18942 return {
18943 ..._filter,
18944 operator: currentFilter.operator || filter.operators[0],
18945 value: getNewValue(
18946 filter,
18947 currentFilter,
18948 element.value
18949 )
18950 };
18951 }
18952 return _filter;
18953 }
18954 )
18955 ] : [
18956 ...view.filters ?? [],
18957 {
18958 field: filter.field,
18959 operator: filter.operators[0],
18960 value: getNewValue(
18961 filter,
18962 currentFilter,
18963 element.value
18964 )
18965 }
18966 ];
18967 onChangeView({
18968 ...view,
18969 page: 1,
18970 filters: newFilters
18971 });
18972 }
18973 }
18974 ),
18975 children: [
18976 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
18977 SingleSelectionOption,
18978 {
18979 selected: currentValue === element.value
18980 }
18981 ),
18982 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
18983 MultiSelectionOption,
18984 {
18985 selected: currentValue.includes(element.value)
18986 }
18987 ),
18988 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
18989 "span",
18990 {
18991 className: "dataviews-filters__search-widget-listitem-value",
18992 title: element.label,
18993 children: element.label
18994 }
18995 )
18996 ]
18997 },
18998 element.value
18999 ))
19000 }
19001 );
19002 }
19003 function ComboboxList22({ view, filter, onChangeView }) {
19004 const [searchValue, setSearchValue] = (0, import_element47.useState)("");
19005 const deferredSearchValue = (0, import_element47.useDeferredValue)(searchValue);
19006 const currentFilter = view.filters?.find(
19007 (_filter) => _filter.field === filter.field
19008 );
19009 const currentValue = getCurrentValue(filter, currentFilter);
19010 const matches = (0, import_element47.useMemo)(() => {
19011 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
19012 return filter.elements.filter(
19013 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
19014 );
19015 }, [filter.elements, deferredSearchValue]);
19016 return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
19017 ComboboxProvider,
19018 {
19019 selectedValue: currentValue,
19020 setSelectedValue: (value) => {
19021 const newFilters = currentFilter ? [
19022 ...(view.filters ?? []).map((_filter) => {
19023 if (_filter.field === filter.field) {
19024 return {
19025 ..._filter,
19026 operator: currentFilter.operator || filter.operators[0],
19027 value
19028 };
19029 }
19030 return _filter;
19031 })
19032 ] : [
19033 ...view.filters ?? [],
19034 {
19035 field: filter.field,
19036 operator: filter.operators[0],
19037 value
19038 }
19039 ];
19040 onChangeView({
19041 ...view,
19042 page: 1,
19043 filters: newFilters
19044 });
19045 },
19046 setValue: setSearchValue,
19047 children: [
19048 /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
19049 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(ComboboxLabel, {}), children: (0, import_i18n23.__)("Search items") }),
19050 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19051 Combobox,
19052 {
19053 autoSelect: "always",
19054 placeholder: (0, import_i18n23.__)("Search"),
19055 className: "dataviews-filters__search-widget-filter-combobox__input"
19056 }
19057 ),
19058 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_components18.Icon, { icon: search_default }) })
19059 ] }),
19060 /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
19061 ComboboxList,
19062 {
19063 className: "dataviews-filters__search-widget-filter-combobox-list",
19064 alwaysVisible: true,
19065 children: [
19066 matches.map((element) => {
19067 return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
19068 ComboboxItem,
19069 {
19070 resetValueOnSelect: false,
19071 value: element.value,
19072 className: "dataviews-filters__search-widget-listitem",
19073 hideOnClick: false,
19074 setValueOnClick: false,
19075 focusOnHover: true,
19076 children: [
19077 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19078 SingleSelectionOption,
19079 {
19080 selected: currentValue === element.value
19081 }
19082 ),
19083 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19084 MultiSelectionOption,
19085 {
19086 selected: currentValue.includes(
19087 element.value
19088 )
19089 }
19090 ),
19091 /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
19092 "span",
19093 {
19094 className: "dataviews-filters__search-widget-listitem-value",
19095 title: element.label,
19096 children: [
19097 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19098 ComboboxItemValue,
19099 {
19100 className: "dataviews-filters__search-widget-filter-combobox-item-value",
19101 value: element.label
19102 }
19103 ),
19104 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
19105 ]
19106 }
19107 )
19108 ]
19109 },
19110 element.value
19111 );
19112 }),
19113 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("p", { children: (0, import_i18n23.__)("No results found") })
19114 ]
19115 }
19116 )
19117 ]
19118 }
19119 );
19120 }
19121 function SearchWidget(props) {
19122 const { elements, isLoading } = useElements({
19123 elements: props.filter.elements,
19124 getElements: props.filter.getElements
19125 });
19126 if (isLoading) {
19127 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_components18.Spinner, {}) });
19128 }
19129 if (elements.length === 0) {
19130 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n23.__)("No elements found") });
19131 }
19132 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
19133 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
19134 }
19135
19136 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
19137 var import_es6 = __toESM(require_es6(), 1);
19138 var import_compose8 = __toESM(require_compose(), 1);
19139 var import_element48 = __toESM(require_element(), 1);
19140 var import_components19 = __toESM(require_components(), 1);
19141 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
19142 function InputWidget({
19143 filter,
19144 view,
19145 onChangeView,
19146 fields
19147 }) {
19148 const currentFilter = view.filters?.find(
19149 (f2) => f2.field === filter.field
19150 );
19151 const currentValue = getCurrentValue(filter, currentFilter);
19152 const field = (0, import_element48.useMemo)(() => {
19153 const currentField = fields.find((f2) => f2.id === filter.field);
19154 if (currentField) {
19155 return {
19156 ...currentField,
19157 // Deactivate validation for filters.
19158 isValid: {},
19159 // Filter controls are always enabled.
19160 isDisabled: () => false,
19161 // Filter controls are always visible.
19162 isVisible: () => true,
19163 // Configure getValue/setValue as if Item was a plain object.
19164 getValue: ({ item }) => item[currentField.id],
19165 setValue: ({ value }) => ({
19166 [currentField.id]: value
19167 })
19168 };
19169 }
19170 return currentField;
19171 }, [fields, filter.field]);
19172 const data = (0, import_element48.useMemo)(() => {
19173 return (view.filters ?? []).reduce(
19174 (acc, activeFilter) => {
19175 acc[activeFilter.field] = activeFilter.value;
19176 return acc;
19177 },
19178 {}
19179 );
19180 }, [view.filters]);
19181 const handleChange = (0, import_compose8.useEvent)((updatedData) => {
19182 if (!field || !currentFilter) {
19183 return;
19184 }
19185 const nextValue = field.getValue({ item: updatedData });
19186 if ((0, import_es6.default)(nextValue, currentValue)) {
19187 return;
19188 }
19189 onChangeView({
19190 ...view,
19191 filters: (view.filters ?? []).map(
19192 (_filter) => _filter.field === filter.field ? {
19193 ..._filter,
19194 operator: currentFilter.operator || filter.operators[0],
19195 // Consider empty strings as undefined:
19196 //
19197 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
19198 // - empty string as value means "search empty string": returns only the records that have an empty string as value
19199 //
19200 // In practice, this means the filter will not be able to find an empty string as the value.
19201 value: nextValue === "" ? void 0 : nextValue
19202 } : _filter
19203 )
19204 });
19205 });
19206 if (!field || !field.Edit || !currentFilter) {
19207 return null;
19208 }
19209 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19210 import_components19.Flex,
19211 {
19212 className: "dataviews-filters__user-input-widget",
19213 gap: 2.5,
19214 direction: "column",
19215 children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19216 field.Edit,
19217 {
19218 hideLabelFromVision: true,
19219 data,
19220 field,
19221 operator: currentFilter.operator,
19222 onChange: handleChange
19223 }
19224 )
19225 }
19226 );
19227 }
19228
19229 // node_modules/date-fns/constants.js
19230 var daysInYear = 365.2425;
19231 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
19232 var minTime = -maxTime;
19233 var millisecondsInWeek = 6048e5;
19234 var millisecondsInDay = 864e5;
19235 var secondsInHour = 3600;
19236 var secondsInDay = secondsInHour * 24;
19237 var secondsInWeek = secondsInDay * 7;
19238 var secondsInYear = secondsInDay * daysInYear;
19239 var secondsInMonth = secondsInYear / 12;
19240 var secondsInQuarter = secondsInMonth * 3;
19241 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
19242
19243 // node_modules/date-fns/constructFrom.js
19244 function constructFrom(date, value) {
19245 if (typeof date === "function") return date(value);
19246 if (date && typeof date === "object" && constructFromSymbol in date)
19247 return date[constructFromSymbol](value);
19248 if (date instanceof Date) return new date.constructor(value);
19249 return new Date(value);
19250 }
19251
19252 // node_modules/date-fns/toDate.js
19253 function toDate(argument, context) {
19254 return constructFrom(context || argument, argument);
19255 }
19256
19257 // node_modules/date-fns/addDays.js
19258 function addDays(date, amount, options) {
19259 const _date = toDate(date, options?.in);
19260 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19261 if (!amount) return _date;
19262 _date.setDate(_date.getDate() + amount);
19263 return _date;
19264 }
19265
19266 // node_modules/date-fns/addMonths.js
19267 function addMonths(date, amount, options) {
19268 const _date = toDate(date, options?.in);
19269 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19270 if (!amount) {
19271 return _date;
19272 }
19273 const dayOfMonth = _date.getDate();
19274 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
19275 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
19276 const daysInMonth = endOfDesiredMonth.getDate();
19277 if (dayOfMonth >= daysInMonth) {
19278 return endOfDesiredMonth;
19279 } else {
19280 _date.setFullYear(
19281 endOfDesiredMonth.getFullYear(),
19282 endOfDesiredMonth.getMonth(),
19283 dayOfMonth
19284 );
19285 return _date;
19286 }
19287 }
19288
19289 // node_modules/date-fns/_lib/defaultOptions.js
19290 var defaultOptions = {};
19291 function getDefaultOptions() {
19292 return defaultOptions;
19293 }
19294
19295 // node_modules/date-fns/startOfWeek.js
19296 function startOfWeek(date, options) {
19297 const defaultOptions2 = getDefaultOptions();
19298 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
19299 const _date = toDate(date, options?.in);
19300 const day = _date.getDay();
19301 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
19302 _date.setDate(_date.getDate() - diff);
19303 _date.setHours(0, 0, 0, 0);
19304 return _date;
19305 }
19306
19307 // node_modules/date-fns/startOfISOWeek.js
19308 function startOfISOWeek(date, options) {
19309 return startOfWeek(date, { ...options, weekStartsOn: 1 });
19310 }
19311
19312 // node_modules/date-fns/getISOWeekYear.js
19313 function getISOWeekYear(date, options) {
19314 const _date = toDate(date, options?.in);
19315 const year = _date.getFullYear();
19316 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
19317 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
19318 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
19319 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
19320 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
19321 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
19322 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
19323 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
19324 if (_date.getTime() >= startOfNextYear.getTime()) {
19325 return year + 1;
19326 } else if (_date.getTime() >= startOfThisYear.getTime()) {
19327 return year;
19328 } else {
19329 return year - 1;
19330 }
19331 }
19332
19333 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
19334 function getTimezoneOffsetInMilliseconds(date) {
19335 const _date = toDate(date);
19336 const utcDate = new Date(
19337 Date.UTC(
19338 _date.getFullYear(),
19339 _date.getMonth(),
19340 _date.getDate(),
19341 _date.getHours(),
19342 _date.getMinutes(),
19343 _date.getSeconds(),
19344 _date.getMilliseconds()
19345 )
19346 );
19347 utcDate.setUTCFullYear(_date.getFullYear());
19348 return +date - +utcDate;
19349 }
19350
19351 // node_modules/date-fns/_lib/normalizeDates.js
19352 function normalizeDates(context, ...dates) {
19353 const normalize = constructFrom.bind(
19354 null,
19355 context || dates.find((date) => typeof date === "object")
19356 );
19357 return dates.map(normalize);
19358 }
19359
19360 // node_modules/date-fns/startOfDay.js
19361 function startOfDay(date, options) {
19362 const _date = toDate(date, options?.in);
19363 _date.setHours(0, 0, 0, 0);
19364 return _date;
19365 }
19366
19367 // node_modules/date-fns/differenceInCalendarDays.js
19368 function differenceInCalendarDays(laterDate, earlierDate, options) {
19369 const [laterDate_, earlierDate_] = normalizeDates(
19370 options?.in,
19371 laterDate,
19372 earlierDate
19373 );
19374 const laterStartOfDay = startOfDay(laterDate_);
19375 const earlierStartOfDay = startOfDay(earlierDate_);
19376 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
19377 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
19378 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
19379 }
19380
19381 // node_modules/date-fns/startOfISOWeekYear.js
19382 function startOfISOWeekYear(date, options) {
19383 const year = getISOWeekYear(date, options);
19384 const fourthOfJanuary = constructFrom(options?.in || date, 0);
19385 fourthOfJanuary.setFullYear(year, 0, 4);
19386 fourthOfJanuary.setHours(0, 0, 0, 0);
19387 return startOfISOWeek(fourthOfJanuary);
19388 }
19389
19390 // node_modules/date-fns/addWeeks.js
19391 function addWeeks(date, amount, options) {
19392 return addDays(date, amount * 7, options);
19393 }
19394
19395 // node_modules/date-fns/addYears.js
19396 function addYears(date, amount, options) {
19397 return addMonths(date, amount * 12, options);
19398 }
19399
19400 // node_modules/date-fns/isDate.js
19401 function isDate(value) {
19402 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
19403 }
19404
19405 // node_modules/date-fns/isValid.js
19406 function isValid(date) {
19407 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
19408 }
19409
19410 // node_modules/date-fns/startOfMonth.js
19411 function startOfMonth(date, options) {
19412 const _date = toDate(date, options?.in);
19413 _date.setDate(1);
19414 _date.setHours(0, 0, 0, 0);
19415 return _date;
19416 }
19417
19418 // node_modules/date-fns/startOfYear.js
19419 function startOfYear(date, options) {
19420 const date_ = toDate(date, options?.in);
19421 date_.setFullYear(date_.getFullYear(), 0, 1);
19422 date_.setHours(0, 0, 0, 0);
19423 return date_;
19424 }
19425
19426 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js
19427 var formatDistanceLocale = {
19428 lessThanXSeconds: {
19429 one: "less than a second",
19430 other: "less than {{count}} seconds"
19431 },
19432 xSeconds: {
19433 one: "1 second",
19434 other: "{{count}} seconds"
19435 },
19436 halfAMinute: "half a minute",
19437 lessThanXMinutes: {
19438 one: "less than a minute",
19439 other: "less than {{count}} minutes"
19440 },
19441 xMinutes: {
19442 one: "1 minute",
19443 other: "{{count}} minutes"
19444 },
19445 aboutXHours: {
19446 one: "about 1 hour",
19447 other: "about {{count}} hours"
19448 },
19449 xHours: {
19450 one: "1 hour",
19451 other: "{{count}} hours"
19452 },
19453 xDays: {
19454 one: "1 day",
19455 other: "{{count}} days"
19456 },
19457 aboutXWeeks: {
19458 one: "about 1 week",
19459 other: "about {{count}} weeks"
19460 },
19461 xWeeks: {
19462 one: "1 week",
19463 other: "{{count}} weeks"
19464 },
19465 aboutXMonths: {
19466 one: "about 1 month",
19467 other: "about {{count}} months"
19468 },
19469 xMonths: {
19470 one: "1 month",
19471 other: "{{count}} months"
19472 },
19473 aboutXYears: {
19474 one: "about 1 year",
19475 other: "about {{count}} years"
19476 },
19477 xYears: {
19478 one: "1 year",
19479 other: "{{count}} years"
19480 },
19481 overXYears: {
19482 one: "over 1 year",
19483 other: "over {{count}} years"
19484 },
19485 almostXYears: {
19486 one: "almost 1 year",
19487 other: "almost {{count}} years"
19488 }
19489 };
19490 var formatDistance = (token, count, options) => {
19491 let result;
19492 const tokenValue = formatDistanceLocale[token];
19493 if (typeof tokenValue === "string") {
19494 result = tokenValue;
19495 } else if (count === 1) {
19496 result = tokenValue.one;
19497 } else {
19498 result = tokenValue.other.replace("{{count}}", count.toString());
19499 }
19500 if (options?.addSuffix) {
19501 if (options.comparison && options.comparison > 0) {
19502 return "in " + result;
19503 } else {
19504 return result + " ago";
19505 }
19506 }
19507 return result;
19508 };
19509
19510 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js
19511 function buildFormatLongFn(args) {
19512 return (options = {}) => {
19513 const width = options.width ? String(options.width) : args.defaultWidth;
19514 const format6 = args.formats[width] || args.formats[args.defaultWidth];
19515 return format6;
19516 };
19517 }
19518
19519 // node_modules/date-fns/locale/en-US/_lib/formatLong.js
19520 var dateFormats = {
19521 full: "EEEE, MMMM do, y",
19522 long: "MMMM do, y",
19523 medium: "MMM d, y",
19524 short: "MM/dd/yyyy"
19525 };
19526 var timeFormats = {
19527 full: "h:mm:ss a zzzz",
19528 long: "h:mm:ss a z",
19529 medium: "h:mm:ss a",
19530 short: "h:mm a"
19531 };
19532 var dateTimeFormats = {
19533 full: "{{date}} 'at' {{time}}",
19534 long: "{{date}} 'at' {{time}}",
19535 medium: "{{date}}, {{time}}",
19536 short: "{{date}}, {{time}}"
19537 };
19538 var formatLong = {
19539 date: buildFormatLongFn({
19540 formats: dateFormats,
19541 defaultWidth: "full"
19542 }),
19543 time: buildFormatLongFn({
19544 formats: timeFormats,
19545 defaultWidth: "full"
19546 }),
19547 dateTime: buildFormatLongFn({
19548 formats: dateTimeFormats,
19549 defaultWidth: "full"
19550 })
19551 };
19552
19553 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js
19554 var formatRelativeLocale = {
19555 lastWeek: "'last' eeee 'at' p",
19556 yesterday: "'yesterday at' p",
19557 today: "'today at' p",
19558 tomorrow: "'tomorrow at' p",
19559 nextWeek: "eeee 'at' p",
19560 other: "P"
19561 };
19562 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
19563
19564 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js
19565 function buildLocalizeFn(args) {
19566 return (value, options) => {
19567 const context = options?.context ? String(options.context) : "standalone";
19568 let valuesArray;
19569 if (context === "formatting" && args.formattingValues) {
19570 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
19571 const width = options?.width ? String(options.width) : defaultWidth;
19572 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
19573 } else {
19574 const defaultWidth = args.defaultWidth;
19575 const width = options?.width ? String(options.width) : args.defaultWidth;
19576 valuesArray = args.values[width] || args.values[defaultWidth];
19577 }
19578 const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
19579 return valuesArray[index2];
19580 };
19581 }
19582
19583 // node_modules/date-fns/locale/en-US/_lib/localize.js
19584 var eraValues = {
19585 narrow: ["B", "A"],
19586 abbreviated: ["BC", "AD"],
19587 wide: ["Before Christ", "Anno Domini"]
19588 };
19589 var quarterValues = {
19590 narrow: ["1", "2", "3", "4"],
19591 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
19592 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
19593 };
19594 var monthValues = {
19595 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
19596 abbreviated: [
19597 "Jan",
19598 "Feb",
19599 "Mar",
19600 "Apr",
19601 "May",
19602 "Jun",
19603 "Jul",
19604 "Aug",
19605 "Sep",
19606 "Oct",
19607 "Nov",
19608 "Dec"
19609 ],
19610 wide: [
19611 "January",
19612 "February",
19613 "March",
19614 "April",
19615 "May",
19616 "June",
19617 "July",
19618 "August",
19619 "September",
19620 "October",
19621 "November",
19622 "December"
19623 ]
19624 };
19625 var dayValues = {
19626 narrow: ["S", "M", "T", "W", "T", "F", "S"],
19627 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
19628 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
19629 wide: [
19630 "Sunday",
19631 "Monday",
19632 "Tuesday",
19633 "Wednesday",
19634 "Thursday",
19635 "Friday",
19636 "Saturday"
19637 ]
19638 };
19639 var dayPeriodValues = {
19640 narrow: {
19641 am: "a",
19642 pm: "p",
19643 midnight: "mi",
19644 noon: "n",
19645 morning: "morning",
19646 afternoon: "afternoon",
19647 evening: "evening",
19648 night: "night"
19649 },
19650 abbreviated: {
19651 am: "AM",
19652 pm: "PM",
19653 midnight: "midnight",
19654 noon: "noon",
19655 morning: "morning",
19656 afternoon: "afternoon",
19657 evening: "evening",
19658 night: "night"
19659 },
19660 wide: {
19661 am: "a.m.",
19662 pm: "p.m.",
19663 midnight: "midnight",
19664 noon: "noon",
19665 morning: "morning",
19666 afternoon: "afternoon",
19667 evening: "evening",
19668 night: "night"
19669 }
19670 };
19671 var formattingDayPeriodValues = {
19672 narrow: {
19673 am: "a",
19674 pm: "p",
19675 midnight: "mi",
19676 noon: "n",
19677 morning: "in the morning",
19678 afternoon: "in the afternoon",
19679 evening: "in the evening",
19680 night: "at night"
19681 },
19682 abbreviated: {
19683 am: "AM",
19684 pm: "PM",
19685 midnight: "midnight",
19686 noon: "noon",
19687 morning: "in the morning",
19688 afternoon: "in the afternoon",
19689 evening: "in the evening",
19690 night: "at night"
19691 },
19692 wide: {
19693 am: "a.m.",
19694 pm: "p.m.",
19695 midnight: "midnight",
19696 noon: "noon",
19697 morning: "in the morning",
19698 afternoon: "in the afternoon",
19699 evening: "in the evening",
19700 night: "at night"
19701 }
19702 };
19703 var ordinalNumber = (dirtyNumber, _options) => {
19704 const number = Number(dirtyNumber);
19705 const rem100 = number % 100;
19706 if (rem100 > 20 || rem100 < 10) {
19707 switch (rem100 % 10) {
19708 case 1:
19709 return number + "st";
19710 case 2:
19711 return number + "nd";
19712 case 3:
19713 return number + "rd";
19714 }
19715 }
19716 return number + "th";
19717 };
19718 var localize = {
19719 ordinalNumber,
19720 era: buildLocalizeFn({
19721 values: eraValues,
19722 defaultWidth: "wide"
19723 }),
19724 quarter: buildLocalizeFn({
19725 values: quarterValues,
19726 defaultWidth: "wide",
19727 argumentCallback: (quarter) => quarter - 1
19728 }),
19729 month: buildLocalizeFn({
19730 values: monthValues,
19731 defaultWidth: "wide"
19732 }),
19733 day: buildLocalizeFn({
19734 values: dayValues,
19735 defaultWidth: "wide"
19736 }),
19737 dayPeriod: buildLocalizeFn({
19738 values: dayPeriodValues,
19739 defaultWidth: "wide",
19740 formattingValues: formattingDayPeriodValues,
19741 defaultFormattingWidth: "wide"
19742 })
19743 };
19744
19745 // node_modules/date-fns/locale/_lib/buildMatchFn.js
19746 function buildMatchFn(args) {
19747 return (string, options = {}) => {
19748 const width = options.width;
19749 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
19750 const matchResult = string.match(matchPattern);
19751 if (!matchResult) {
19752 return null;
19753 }
19754 const matchedString = matchResult[0];
19755 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
19756 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
19757 // [TODO] -- I challenge you to fix the type
19758 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
19759 );
19760 let value;
19761 value = args.valueCallback ? args.valueCallback(key) : key;
19762 value = options.valueCallback ? (
19763 // [TODO] -- I challenge you to fix the type
19764 options.valueCallback(value)
19765 ) : value;
19766 const rest = string.slice(matchedString.length);
19767 return { value, rest };
19768 };
19769 }
19770 function findKey(object, predicate) {
19771 for (const key in object) {
19772 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
19773 return key;
19774 }
19775 }
19776 return void 0;
19777 }
19778 function findIndex(array, predicate) {
19779 for (let key = 0; key < array.length; key++) {
19780 if (predicate(array[key])) {
19781 return key;
19782 }
19783 }
19784 return void 0;
19785 }
19786
19787 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
19788 function buildMatchPatternFn(args) {
19789 return (string, options = {}) => {
19790 const matchResult = string.match(args.matchPattern);
19791 if (!matchResult) return null;
19792 const matchedString = matchResult[0];
19793 const parseResult = string.match(args.parsePattern);
19794 if (!parseResult) return null;
19795 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
19796 value = options.valueCallback ? options.valueCallback(value) : value;
19797 const rest = string.slice(matchedString.length);
19798 return { value, rest };
19799 };
19800 }
19801
19802 // node_modules/date-fns/locale/en-US/_lib/match.js
19803 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
19804 var parseOrdinalNumberPattern = /\d+/i;
19805 var matchEraPatterns = {
19806 narrow: /^(b|a)/i,
19807 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
19808 wide: /^(before christ|before common era|anno domini|common era)/i
19809 };
19810 var parseEraPatterns = {
19811 any: [/^b/i, /^(a|c)/i]
19812 };
19813 var matchQuarterPatterns = {
19814 narrow: /^[1234]/i,
19815 abbreviated: /^q[1234]/i,
19816 wide: /^[1234](th|st|nd|rd)? quarter/i
19817 };
19818 var parseQuarterPatterns = {
19819 any: [/1/i, /2/i, /3/i, /4/i]
19820 };
19821 var matchMonthPatterns = {
19822 narrow: /^[jfmasond]/i,
19823 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
19824 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
19825 };
19826 var parseMonthPatterns = {
19827 narrow: [
19828 /^j/i,
19829 /^f/i,
19830 /^m/i,
19831 /^a/i,
19832 /^m/i,
19833 /^j/i,
19834 /^j/i,
19835 /^a/i,
19836 /^s/i,
19837 /^o/i,
19838 /^n/i,
19839 /^d/i
19840 ],
19841 any: [
19842 /^ja/i,
19843 /^f/i,
19844 /^mar/i,
19845 /^ap/i,
19846 /^may/i,
19847 /^jun/i,
19848 /^jul/i,
19849 /^au/i,
19850 /^s/i,
19851 /^o/i,
19852 /^n/i,
19853 /^d/i
19854 ]
19855 };
19856 var matchDayPatterns = {
19857 narrow: /^[smtwf]/i,
19858 short: /^(su|mo|tu|we|th|fr|sa)/i,
19859 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
19860 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
19861 };
19862 var parseDayPatterns = {
19863 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
19864 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
19865 };
19866 var matchDayPeriodPatterns = {
19867 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
19868 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
19869 };
19870 var parseDayPeriodPatterns = {
19871 any: {
19872 am: /^a/i,
19873 pm: /^p/i,
19874 midnight: /^mi/i,
19875 noon: /^no/i,
19876 morning: /morning/i,
19877 afternoon: /afternoon/i,
19878 evening: /evening/i,
19879 night: /night/i
19880 }
19881 };
19882 var match = {
19883 ordinalNumber: buildMatchPatternFn({
19884 matchPattern: matchOrdinalNumberPattern,
19885 parsePattern: parseOrdinalNumberPattern,
19886 valueCallback: (value) => parseInt(value, 10)
19887 }),
19888 era: buildMatchFn({
19889 matchPatterns: matchEraPatterns,
19890 defaultMatchWidth: "wide",
19891 parsePatterns: parseEraPatterns,
19892 defaultParseWidth: "any"
19893 }),
19894 quarter: buildMatchFn({
19895 matchPatterns: matchQuarterPatterns,
19896 defaultMatchWidth: "wide",
19897 parsePatterns: parseQuarterPatterns,
19898 defaultParseWidth: "any",
19899 valueCallback: (index2) => index2 + 1
19900 }),
19901 month: buildMatchFn({
19902 matchPatterns: matchMonthPatterns,
19903 defaultMatchWidth: "wide",
19904 parsePatterns: parseMonthPatterns,
19905 defaultParseWidth: "any"
19906 }),
19907 day: buildMatchFn({
19908 matchPatterns: matchDayPatterns,
19909 defaultMatchWidth: "wide",
19910 parsePatterns: parseDayPatterns,
19911 defaultParseWidth: "any"
19912 }),
19913 dayPeriod: buildMatchFn({
19914 matchPatterns: matchDayPeriodPatterns,
19915 defaultMatchWidth: "any",
19916 parsePatterns: parseDayPeriodPatterns,
19917 defaultParseWidth: "any"
19918 })
19919 };
19920
19921 // node_modules/date-fns/locale/en-US.js
19922 var enUS = {
19923 code: "en-US",
19924 formatDistance,
19925 formatLong,
19926 formatRelative,
19927 localize,
19928 match,
19929 options: {
19930 weekStartsOn: 0,
19931 firstWeekContainsDate: 1
19932 }
19933 };
19934
19935 // node_modules/date-fns/getDayOfYear.js
19936 function getDayOfYear(date, options) {
19937 const _date = toDate(date, options?.in);
19938 const diff = differenceInCalendarDays(_date, startOfYear(_date));
19939 const dayOfYear = diff + 1;
19940 return dayOfYear;
19941 }
19942
19943 // node_modules/date-fns/getISOWeek.js
19944 function getISOWeek(date, options) {
19945 const _date = toDate(date, options?.in);
19946 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
19947 return Math.round(diff / millisecondsInWeek) + 1;
19948 }
19949
19950 // node_modules/date-fns/getWeekYear.js
19951 function getWeekYear(date, options) {
19952 const _date = toDate(date, options?.in);
19953 const year = _date.getFullYear();
19954 const defaultOptions2 = getDefaultOptions();
19955 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
19956 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
19957 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
19958 firstWeekOfNextYear.setHours(0, 0, 0, 0);
19959 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
19960 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
19961 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
19962 firstWeekOfThisYear.setHours(0, 0, 0, 0);
19963 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
19964 if (+_date >= +startOfNextYear) {
19965 return year + 1;
19966 } else if (+_date >= +startOfThisYear) {
19967 return year;
19968 } else {
19969 return year - 1;
19970 }
19971 }
19972
19973 // node_modules/date-fns/startOfWeekYear.js
19974 function startOfWeekYear(date, options) {
19975 const defaultOptions2 = getDefaultOptions();
19976 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
19977 const year = getWeekYear(date, options);
19978 const firstWeek = constructFrom(options?.in || date, 0);
19979 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
19980 firstWeek.setHours(0, 0, 0, 0);
19981 const _date = startOfWeek(firstWeek, options);
19982 return _date;
19983 }
19984
19985 // node_modules/date-fns/getWeek.js
19986 function getWeek(date, options) {
19987 const _date = toDate(date, options?.in);
19988 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
19989 return Math.round(diff / millisecondsInWeek) + 1;
19990 }
19991
19992 // node_modules/date-fns/_lib/addLeadingZeros.js
19993 function addLeadingZeros(number, targetLength) {
19994 const sign = number < 0 ? "-" : "";
19995 const output = Math.abs(number).toString().padStart(targetLength, "0");
19996 return sign + output;
19997 }
19998
19999 // node_modules/date-fns/_lib/format/lightFormatters.js
20000 var lightFormatters = {
20001 // Year
20002 y(date, token) {
20003 const signedYear = date.getFullYear();
20004 const year = signedYear > 0 ? signedYear : 1 - signedYear;
20005 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
20006 },
20007 // Month
20008 M(date, token) {
20009 const month = date.getMonth();
20010 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
20011 },
20012 // Day of the month
20013 d(date, token) {
20014 return addLeadingZeros(date.getDate(), token.length);
20015 },
20016 // AM or PM
20017 a(date, token) {
20018 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
20019 switch (token) {
20020 case "a":
20021 case "aa":
20022 return dayPeriodEnumValue.toUpperCase();
20023 case "aaa":
20024 return dayPeriodEnumValue;
20025 case "aaaaa":
20026 return dayPeriodEnumValue[0];
20027 case "aaaa":
20028 default:
20029 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
20030 }
20031 },
20032 // Hour [1-12]
20033 h(date, token) {
20034 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
20035 },
20036 // Hour [0-23]
20037 H(date, token) {
20038 return addLeadingZeros(date.getHours(), token.length);
20039 },
20040 // Minute
20041 m(date, token) {
20042 return addLeadingZeros(date.getMinutes(), token.length);
20043 },
20044 // Second
20045 s(date, token) {
20046 return addLeadingZeros(date.getSeconds(), token.length);
20047 },
20048 // Fraction of second
20049 S(date, token) {
20050 const numberOfDigits = token.length;
20051 const milliseconds = date.getMilliseconds();
20052 const fractionalSeconds = Math.trunc(
20053 milliseconds * Math.pow(10, numberOfDigits - 3)
20054 );
20055 return addLeadingZeros(fractionalSeconds, token.length);
20056 }
20057 };
20058
20059 // node_modules/date-fns/_lib/format/formatters.js
20060 var dayPeriodEnum = {
20061 am: "am",
20062 pm: "pm",
20063 midnight: "midnight",
20064 noon: "noon",
20065 morning: "morning",
20066 afternoon: "afternoon",
20067 evening: "evening",
20068 night: "night"
20069 };
20070 var formatters = {
20071 // Era
20072 G: function(date, token, localize2) {
20073 const era = date.getFullYear() > 0 ? 1 : 0;
20074 switch (token) {
20075 // AD, BC
20076 case "G":
20077 case "GG":
20078 case "GGG":
20079 return localize2.era(era, { width: "abbreviated" });
20080 // A, B
20081 case "GGGGG":
20082 return localize2.era(era, { width: "narrow" });
20083 // Anno Domini, Before Christ
20084 case "GGGG":
20085 default:
20086 return localize2.era(era, { width: "wide" });
20087 }
20088 },
20089 // Year
20090 y: function(date, token, localize2) {
20091 if (token === "yo") {
20092 const signedYear = date.getFullYear();
20093 const year = signedYear > 0 ? signedYear : 1 - signedYear;
20094 return localize2.ordinalNumber(year, { unit: "year" });
20095 }
20096 return lightFormatters.y(date, token);
20097 },
20098 // Local week-numbering year
20099 Y: function(date, token, localize2, options) {
20100 const signedWeekYear = getWeekYear(date, options);
20101 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
20102 if (token === "YY") {
20103 const twoDigitYear = weekYear % 100;
20104 return addLeadingZeros(twoDigitYear, 2);
20105 }
20106 if (token === "Yo") {
20107 return localize2.ordinalNumber(weekYear, { unit: "year" });
20108 }
20109 return addLeadingZeros(weekYear, token.length);
20110 },
20111 // ISO week-numbering year
20112 R: function(date, token) {
20113 const isoWeekYear = getISOWeekYear(date);
20114 return addLeadingZeros(isoWeekYear, token.length);
20115 },
20116 // Extended year. This is a single number designating the year of this calendar system.
20117 // The main difference between `y` and `u` localizers are B.C. years:
20118 // | Year | `y` | `u` |
20119 // |------|-----|-----|
20120 // | AC 1 | 1 | 1 |
20121 // | BC 1 | 1 | 0 |
20122 // | BC 2 | 2 | -1 |
20123 // Also `yy` always returns the last two digits of a year,
20124 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
20125 u: function(date, token) {
20126 const year = date.getFullYear();
20127 return addLeadingZeros(year, token.length);
20128 },
20129 // Quarter
20130 Q: function(date, token, localize2) {
20131 const quarter = Math.ceil((date.getMonth() + 1) / 3);
20132 switch (token) {
20133 // 1, 2, 3, 4
20134 case "Q":
20135 return String(quarter);
20136 // 01, 02, 03, 04
20137 case "QQ":
20138 return addLeadingZeros(quarter, 2);
20139 // 1st, 2nd, 3rd, 4th
20140 case "Qo":
20141 return localize2.ordinalNumber(quarter, { unit: "quarter" });
20142 // Q1, Q2, Q3, Q4
20143 case "QQQ":
20144 return localize2.quarter(quarter, {
20145 width: "abbreviated",
20146 context: "formatting"
20147 });
20148 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20149 case "QQQQQ":
20150 return localize2.quarter(quarter, {
20151 width: "narrow",
20152 context: "formatting"
20153 });
20154 // 1st quarter, 2nd quarter, ...
20155 case "QQQQ":
20156 default:
20157 return localize2.quarter(quarter, {
20158 width: "wide",
20159 context: "formatting"
20160 });
20161 }
20162 },
20163 // Stand-alone quarter
20164 q: function(date, token, localize2) {
20165 const quarter = Math.ceil((date.getMonth() + 1) / 3);
20166 switch (token) {
20167 // 1, 2, 3, 4
20168 case "q":
20169 return String(quarter);
20170 // 01, 02, 03, 04
20171 case "qq":
20172 return addLeadingZeros(quarter, 2);
20173 // 1st, 2nd, 3rd, 4th
20174 case "qo":
20175 return localize2.ordinalNumber(quarter, { unit: "quarter" });
20176 // Q1, Q2, Q3, Q4
20177 case "qqq":
20178 return localize2.quarter(quarter, {
20179 width: "abbreviated",
20180 context: "standalone"
20181 });
20182 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20183 case "qqqqq":
20184 return localize2.quarter(quarter, {
20185 width: "narrow",
20186 context: "standalone"
20187 });
20188 // 1st quarter, 2nd quarter, ...
20189 case "qqqq":
20190 default:
20191 return localize2.quarter(quarter, {
20192 width: "wide",
20193 context: "standalone"
20194 });
20195 }
20196 },
20197 // Month
20198 M: function(date, token, localize2) {
20199 const month = date.getMonth();
20200 switch (token) {
20201 case "M":
20202 case "MM":
20203 return lightFormatters.M(date, token);
20204 // 1st, 2nd, ..., 12th
20205 case "Mo":
20206 return localize2.ordinalNumber(month + 1, { unit: "month" });
20207 // Jan, Feb, ..., Dec
20208 case "MMM":
20209 return localize2.month(month, {
20210 width: "abbreviated",
20211 context: "formatting"
20212 });
20213 // J, F, ..., D
20214 case "MMMMM":
20215 return localize2.month(month, {
20216 width: "narrow",
20217 context: "formatting"
20218 });
20219 // January, February, ..., December
20220 case "MMMM":
20221 default:
20222 return localize2.month(month, { width: "wide", context: "formatting" });
20223 }
20224 },
20225 // Stand-alone month
20226 L: function(date, token, localize2) {
20227 const month = date.getMonth();
20228 switch (token) {
20229 // 1, 2, ..., 12
20230 case "L":
20231 return String(month + 1);
20232 // 01, 02, ..., 12
20233 case "LL":
20234 return addLeadingZeros(month + 1, 2);
20235 // 1st, 2nd, ..., 12th
20236 case "Lo":
20237 return localize2.ordinalNumber(month + 1, { unit: "month" });
20238 // Jan, Feb, ..., Dec
20239 case "LLL":
20240 return localize2.month(month, {
20241 width: "abbreviated",
20242 context: "standalone"
20243 });
20244 // J, F, ..., D
20245 case "LLLLL":
20246 return localize2.month(month, {
20247 width: "narrow",
20248 context: "standalone"
20249 });
20250 // January, February, ..., December
20251 case "LLLL":
20252 default:
20253 return localize2.month(month, { width: "wide", context: "standalone" });
20254 }
20255 },
20256 // Local week of year
20257 w: function(date, token, localize2, options) {
20258 const week = getWeek(date, options);
20259 if (token === "wo") {
20260 return localize2.ordinalNumber(week, { unit: "week" });
20261 }
20262 return addLeadingZeros(week, token.length);
20263 },
20264 // ISO week of year
20265 I: function(date, token, localize2) {
20266 const isoWeek = getISOWeek(date);
20267 if (token === "Io") {
20268 return localize2.ordinalNumber(isoWeek, { unit: "week" });
20269 }
20270 return addLeadingZeros(isoWeek, token.length);
20271 },
20272 // Day of the month
20273 d: function(date, token, localize2) {
20274 if (token === "do") {
20275 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
20276 }
20277 return lightFormatters.d(date, token);
20278 },
20279 // Day of year
20280 D: function(date, token, localize2) {
20281 const dayOfYear = getDayOfYear(date);
20282 if (token === "Do") {
20283 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
20284 }
20285 return addLeadingZeros(dayOfYear, token.length);
20286 },
20287 // Day of week
20288 E: function(date, token, localize2) {
20289 const dayOfWeek = date.getDay();
20290 switch (token) {
20291 // Tue
20292 case "E":
20293 case "EE":
20294 case "EEE":
20295 return localize2.day(dayOfWeek, {
20296 width: "abbreviated",
20297 context: "formatting"
20298 });
20299 // T
20300 case "EEEEE":
20301 return localize2.day(dayOfWeek, {
20302 width: "narrow",
20303 context: "formatting"
20304 });
20305 // Tu
20306 case "EEEEEE":
20307 return localize2.day(dayOfWeek, {
20308 width: "short",
20309 context: "formatting"
20310 });
20311 // Tuesday
20312 case "EEEE":
20313 default:
20314 return localize2.day(dayOfWeek, {
20315 width: "wide",
20316 context: "formatting"
20317 });
20318 }
20319 },
20320 // Local day of week
20321 e: function(date, token, localize2, options) {
20322 const dayOfWeek = date.getDay();
20323 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20324 switch (token) {
20325 // Numerical value (Nth day of week with current locale or weekStartsOn)
20326 case "e":
20327 return String(localDayOfWeek);
20328 // Padded numerical value
20329 case "ee":
20330 return addLeadingZeros(localDayOfWeek, 2);
20331 // 1st, 2nd, ..., 7th
20332 case "eo":
20333 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20334 case "eee":
20335 return localize2.day(dayOfWeek, {
20336 width: "abbreviated",
20337 context: "formatting"
20338 });
20339 // T
20340 case "eeeee":
20341 return localize2.day(dayOfWeek, {
20342 width: "narrow",
20343 context: "formatting"
20344 });
20345 // Tu
20346 case "eeeeee":
20347 return localize2.day(dayOfWeek, {
20348 width: "short",
20349 context: "formatting"
20350 });
20351 // Tuesday
20352 case "eeee":
20353 default:
20354 return localize2.day(dayOfWeek, {
20355 width: "wide",
20356 context: "formatting"
20357 });
20358 }
20359 },
20360 // Stand-alone local day of week
20361 c: function(date, token, localize2, options) {
20362 const dayOfWeek = date.getDay();
20363 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20364 switch (token) {
20365 // Numerical value (same as in `e`)
20366 case "c":
20367 return String(localDayOfWeek);
20368 // Padded numerical value
20369 case "cc":
20370 return addLeadingZeros(localDayOfWeek, token.length);
20371 // 1st, 2nd, ..., 7th
20372 case "co":
20373 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20374 case "ccc":
20375 return localize2.day(dayOfWeek, {
20376 width: "abbreviated",
20377 context: "standalone"
20378 });
20379 // T
20380 case "ccccc":
20381 return localize2.day(dayOfWeek, {
20382 width: "narrow",
20383 context: "standalone"
20384 });
20385 // Tu
20386 case "cccccc":
20387 return localize2.day(dayOfWeek, {
20388 width: "short",
20389 context: "standalone"
20390 });
20391 // Tuesday
20392 case "cccc":
20393 default:
20394 return localize2.day(dayOfWeek, {
20395 width: "wide",
20396 context: "standalone"
20397 });
20398 }
20399 },
20400 // ISO day of week
20401 i: function(date, token, localize2) {
20402 const dayOfWeek = date.getDay();
20403 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
20404 switch (token) {
20405 // 2
20406 case "i":
20407 return String(isoDayOfWeek);
20408 // 02
20409 case "ii":
20410 return addLeadingZeros(isoDayOfWeek, token.length);
20411 // 2nd
20412 case "io":
20413 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
20414 // Tue
20415 case "iii":
20416 return localize2.day(dayOfWeek, {
20417 width: "abbreviated",
20418 context: "formatting"
20419 });
20420 // T
20421 case "iiiii":
20422 return localize2.day(dayOfWeek, {
20423 width: "narrow",
20424 context: "formatting"
20425 });
20426 // Tu
20427 case "iiiiii":
20428 return localize2.day(dayOfWeek, {
20429 width: "short",
20430 context: "formatting"
20431 });
20432 // Tuesday
20433 case "iiii":
20434 default:
20435 return localize2.day(dayOfWeek, {
20436 width: "wide",
20437 context: "formatting"
20438 });
20439 }
20440 },
20441 // AM or PM
20442 a: function(date, token, localize2) {
20443 const hours = date.getHours();
20444 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
20445 switch (token) {
20446 case "a":
20447 case "aa":
20448 return localize2.dayPeriod(dayPeriodEnumValue, {
20449 width: "abbreviated",
20450 context: "formatting"
20451 });
20452 case "aaa":
20453 return localize2.dayPeriod(dayPeriodEnumValue, {
20454 width: "abbreviated",
20455 context: "formatting"
20456 }).toLowerCase();
20457 case "aaaaa":
20458 return localize2.dayPeriod(dayPeriodEnumValue, {
20459 width: "narrow",
20460 context: "formatting"
20461 });
20462 case "aaaa":
20463 default:
20464 return localize2.dayPeriod(dayPeriodEnumValue, {
20465 width: "wide",
20466 context: "formatting"
20467 });
20468 }
20469 },
20470 // AM, PM, midnight, noon
20471 b: function(date, token, localize2) {
20472 const hours = date.getHours();
20473 let dayPeriodEnumValue;
20474 if (hours === 12) {
20475 dayPeriodEnumValue = dayPeriodEnum.noon;
20476 } else if (hours === 0) {
20477 dayPeriodEnumValue = dayPeriodEnum.midnight;
20478 } else {
20479 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
20480 }
20481 switch (token) {
20482 case "b":
20483 case "bb":
20484 return localize2.dayPeriod(dayPeriodEnumValue, {
20485 width: "abbreviated",
20486 context: "formatting"
20487 });
20488 case "bbb":
20489 return localize2.dayPeriod(dayPeriodEnumValue, {
20490 width: "abbreviated",
20491 context: "formatting"
20492 }).toLowerCase();
20493 case "bbbbb":
20494 return localize2.dayPeriod(dayPeriodEnumValue, {
20495 width: "narrow",
20496 context: "formatting"
20497 });
20498 case "bbbb":
20499 default:
20500 return localize2.dayPeriod(dayPeriodEnumValue, {
20501 width: "wide",
20502 context: "formatting"
20503 });
20504 }
20505 },
20506 // in the morning, in the afternoon, in the evening, at night
20507 B: function(date, token, localize2) {
20508 const hours = date.getHours();
20509 let dayPeriodEnumValue;
20510 if (hours >= 17) {
20511 dayPeriodEnumValue = dayPeriodEnum.evening;
20512 } else if (hours >= 12) {
20513 dayPeriodEnumValue = dayPeriodEnum.afternoon;
20514 } else if (hours >= 4) {
20515 dayPeriodEnumValue = dayPeriodEnum.morning;
20516 } else {
20517 dayPeriodEnumValue = dayPeriodEnum.night;
20518 }
20519 switch (token) {
20520 case "B":
20521 case "BB":
20522 case "BBB":
20523 return localize2.dayPeriod(dayPeriodEnumValue, {
20524 width: "abbreviated",
20525 context: "formatting"
20526 });
20527 case "BBBBB":
20528 return localize2.dayPeriod(dayPeriodEnumValue, {
20529 width: "narrow",
20530 context: "formatting"
20531 });
20532 case "BBBB":
20533 default:
20534 return localize2.dayPeriod(dayPeriodEnumValue, {
20535 width: "wide",
20536 context: "formatting"
20537 });
20538 }
20539 },
20540 // Hour [1-12]
20541 h: function(date, token, localize2) {
20542 if (token === "ho") {
20543 let hours = date.getHours() % 12;
20544 if (hours === 0) hours = 12;
20545 return localize2.ordinalNumber(hours, { unit: "hour" });
20546 }
20547 return lightFormatters.h(date, token);
20548 },
20549 // Hour [0-23]
20550 H: function(date, token, localize2) {
20551 if (token === "Ho") {
20552 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
20553 }
20554 return lightFormatters.H(date, token);
20555 },
20556 // Hour [0-11]
20557 K: function(date, token, localize2) {
20558 const hours = date.getHours() % 12;
20559 if (token === "Ko") {
20560 return localize2.ordinalNumber(hours, { unit: "hour" });
20561 }
20562 return addLeadingZeros(hours, token.length);
20563 },
20564 // Hour [1-24]
20565 k: function(date, token, localize2) {
20566 let hours = date.getHours();
20567 if (hours === 0) hours = 24;
20568 if (token === "ko") {
20569 return localize2.ordinalNumber(hours, { unit: "hour" });
20570 }
20571 return addLeadingZeros(hours, token.length);
20572 },
20573 // Minute
20574 m: function(date, token, localize2) {
20575 if (token === "mo") {
20576 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
20577 }
20578 return lightFormatters.m(date, token);
20579 },
20580 // Second
20581 s: function(date, token, localize2) {
20582 if (token === "so") {
20583 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
20584 }
20585 return lightFormatters.s(date, token);
20586 },
20587 // Fraction of second
20588 S: function(date, token) {
20589 return lightFormatters.S(date, token);
20590 },
20591 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
20592 X: function(date, token, _localize) {
20593 const timezoneOffset = date.getTimezoneOffset();
20594 if (timezoneOffset === 0) {
20595 return "Z";
20596 }
20597 switch (token) {
20598 // Hours and optional minutes
20599 case "X":
20600 return formatTimezoneWithOptionalMinutes(timezoneOffset);
20601 // Hours, minutes and optional seconds without `:` delimiter
20602 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20603 // so this token always has the same output as `XX`
20604 case "XXXX":
20605 case "XX":
20606 return formatTimezone(timezoneOffset);
20607 // Hours, minutes and optional seconds with `:` delimiter
20608 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20609 // so this token always has the same output as `XXX`
20610 case "XXXXX":
20611 case "XXX":
20612 // Hours and minutes with `:` delimiter
20613 default:
20614 return formatTimezone(timezoneOffset, ":");
20615 }
20616 },
20617 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
20618 x: function(date, token, _localize) {
20619 const timezoneOffset = date.getTimezoneOffset();
20620 switch (token) {
20621 // Hours and optional minutes
20622 case "x":
20623 return formatTimezoneWithOptionalMinutes(timezoneOffset);
20624 // Hours, minutes and optional seconds without `:` delimiter
20625 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20626 // so this token always has the same output as `xx`
20627 case "xxxx":
20628 case "xx":
20629 return formatTimezone(timezoneOffset);
20630 // Hours, minutes and optional seconds with `:` delimiter
20631 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20632 // so this token always has the same output as `xxx`
20633 case "xxxxx":
20634 case "xxx":
20635 // Hours and minutes with `:` delimiter
20636 default:
20637 return formatTimezone(timezoneOffset, ":");
20638 }
20639 },
20640 // Timezone (GMT)
20641 O: function(date, token, _localize) {
20642 const timezoneOffset = date.getTimezoneOffset();
20643 switch (token) {
20644 // Short
20645 case "O":
20646 case "OO":
20647 case "OOO":
20648 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
20649 // Long
20650 case "OOOO":
20651 default:
20652 return "GMT" + formatTimezone(timezoneOffset, ":");
20653 }
20654 },
20655 // Timezone (specific non-location)
20656 z: function(date, token, _localize) {
20657 const timezoneOffset = date.getTimezoneOffset();
20658 switch (token) {
20659 // Short
20660 case "z":
20661 case "zz":
20662 case "zzz":
20663 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
20664 // Long
20665 case "zzzz":
20666 default:
20667 return "GMT" + formatTimezone(timezoneOffset, ":");
20668 }
20669 },
20670 // Seconds timestamp
20671 t: function(date, token, _localize) {
20672 const timestamp = Math.trunc(+date / 1e3);
20673 return addLeadingZeros(timestamp, token.length);
20674 },
20675 // Milliseconds timestamp
20676 T: function(date, token, _localize) {
20677 return addLeadingZeros(+date, token.length);
20678 }
20679 };
20680 function formatTimezoneShort(offset4, delimiter = "") {
20681 const sign = offset4 > 0 ? "-" : "+";
20682 const absOffset = Math.abs(offset4);
20683 const hours = Math.trunc(absOffset / 60);
20684 const minutes = absOffset % 60;
20685 if (minutes === 0) {
20686 return sign + String(hours);
20687 }
20688 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
20689 }
20690 function formatTimezoneWithOptionalMinutes(offset4, delimiter) {
20691 if (offset4 % 60 === 0) {
20692 const sign = offset4 > 0 ? "-" : "+";
20693 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2);
20694 }
20695 return formatTimezone(offset4, delimiter);
20696 }
20697 function formatTimezone(offset4, delimiter = "") {
20698 const sign = offset4 > 0 ? "-" : "+";
20699 const absOffset = Math.abs(offset4);
20700 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
20701 const minutes = addLeadingZeros(absOffset % 60, 2);
20702 return sign + hours + delimiter + minutes;
20703 }
20704
20705 // node_modules/date-fns/_lib/format/longFormatters.js
20706 var dateLongFormatter = (pattern, formatLong2) => {
20707 switch (pattern) {
20708 case "P":
20709 return formatLong2.date({ width: "short" });
20710 case "PP":
20711 return formatLong2.date({ width: "medium" });
20712 case "PPP":
20713 return formatLong2.date({ width: "long" });
20714 case "PPPP":
20715 default:
20716 return formatLong2.date({ width: "full" });
20717 }
20718 };
20719 var timeLongFormatter = (pattern, formatLong2) => {
20720 switch (pattern) {
20721 case "p":
20722 return formatLong2.time({ width: "short" });
20723 case "pp":
20724 return formatLong2.time({ width: "medium" });
20725 case "ppp":
20726 return formatLong2.time({ width: "long" });
20727 case "pppp":
20728 default:
20729 return formatLong2.time({ width: "full" });
20730 }
20731 };
20732 var dateTimeLongFormatter = (pattern, formatLong2) => {
20733 const matchResult = pattern.match(/(P+)(p+)?/) || [];
20734 const datePattern = matchResult[1];
20735 const timePattern = matchResult[2];
20736 if (!timePattern) {
20737 return dateLongFormatter(pattern, formatLong2);
20738 }
20739 let dateTimeFormat;
20740 switch (datePattern) {
20741 case "P":
20742 dateTimeFormat = formatLong2.dateTime({ width: "short" });
20743 break;
20744 case "PP":
20745 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
20746 break;
20747 case "PPP":
20748 dateTimeFormat = formatLong2.dateTime({ width: "long" });
20749 break;
20750 case "PPPP":
20751 default:
20752 dateTimeFormat = formatLong2.dateTime({ width: "full" });
20753 break;
20754 }
20755 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
20756 };
20757 var longFormatters = {
20758 p: timeLongFormatter,
20759 P: dateTimeLongFormatter
20760 };
20761
20762 // node_modules/date-fns/_lib/protectedTokens.js
20763 var dayOfYearTokenRE = /^D+$/;
20764 var weekYearTokenRE = /^Y+$/;
20765 var throwTokens = ["D", "DD", "YY", "YYYY"];
20766 function isProtectedDayOfYearToken(token) {
20767 return dayOfYearTokenRE.test(token);
20768 }
20769 function isProtectedWeekYearToken(token) {
20770 return weekYearTokenRE.test(token);
20771 }
20772 function warnOrThrowProtectedError(token, format6, input) {
20773 const _message = message(token, format6, input);
20774 console.warn(_message);
20775 if (throwTokens.includes(token)) throw new RangeError(_message);
20776 }
20777 function message(token, format6, input) {
20778 const subject = token[0] === "Y" ? "years" : "days of the month";
20779 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`;
20780 }
20781
20782 // node_modules/date-fns/format.js
20783 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
20784 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
20785 var escapedStringRegExp = /^'([^]*?)'?$/;
20786 var doubleQuoteRegExp = /''/g;
20787 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
20788 function format(date, formatStr, options) {
20789 const defaultOptions2 = getDefaultOptions();
20790 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
20791 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20792 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
20793 const originalDate = toDate(date, options?.in);
20794 if (!isValid(originalDate)) {
20795 throw new RangeError("Invalid time value");
20796 }
20797 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
20798 const firstCharacter = substring[0];
20799 if (firstCharacter === "p" || firstCharacter === "P") {
20800 const longFormatter = longFormatters[firstCharacter];
20801 return longFormatter(substring, locale.formatLong);
20802 }
20803 return substring;
20804 }).join("").match(formattingTokensRegExp).map((substring) => {
20805 if (substring === "''") {
20806 return { isToken: false, value: "'" };
20807 }
20808 const firstCharacter = substring[0];
20809 if (firstCharacter === "'") {
20810 return { isToken: false, value: cleanEscapedString(substring) };
20811 }
20812 if (formatters[firstCharacter]) {
20813 return { isToken: true, value: substring };
20814 }
20815 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
20816 throw new RangeError(
20817 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
20818 );
20819 }
20820 return { isToken: false, value: substring };
20821 });
20822 if (locale.localize.preprocessor) {
20823 parts = locale.localize.preprocessor(originalDate, parts);
20824 }
20825 const formatterOptions = {
20826 firstWeekContainsDate,
20827 weekStartsOn,
20828 locale
20829 };
20830 return parts.map((part) => {
20831 if (!part.isToken) return part.value;
20832 const token = part.value;
20833 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
20834 warnOrThrowProtectedError(token, formatStr, String(date));
20835 }
20836 const formatter = formatters[token[0]];
20837 return formatter(originalDate, token, locale.localize, formatterOptions);
20838 }).join("");
20839 }
20840 function cleanEscapedString(input) {
20841 const matched = input.match(escapedStringRegExp);
20842 if (!matched) {
20843 return input;
20844 }
20845 return matched[1].replace(doubleQuoteRegExp, "'");
20846 }
20847
20848 // node_modules/date-fns/subDays.js
20849 function subDays(date, amount, options) {
20850 return addDays(date, -amount, options);
20851 }
20852
20853 // node_modules/date-fns/subMonths.js
20854 function subMonths(date, amount, options) {
20855 return addMonths(date, -amount, options);
20856 }
20857
20858 // node_modules/date-fns/subWeeks.js
20859 function subWeeks(date, amount, options) {
20860 return addWeeks(date, -amount, options);
20861 }
20862
20863 // node_modules/date-fns/subYears.js
20864 function subYears(date, amount, options) {
20865 return addYears(date, -amount, options);
20866 }
20867
20868 // packages/dataviews/build-module/utils/operators.mjs
20869 var import_i18n24 = __toESM(require_i18n(), 1);
20870 var import_element49 = __toESM(require_element(), 1);
20871 var import_date = __toESM(require_date(), 1);
20872 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
20873 var filterTextWrappers = {
20874 Name: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
20875 Value: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
20876 };
20877 function getRelativeDate(value, unit) {
20878 switch (unit) {
20879 case "days":
20880 return subDays(/* @__PURE__ */ new Date(), value);
20881 case "weeks":
20882 return subWeeks(/* @__PURE__ */ new Date(), value);
20883 case "months":
20884 return subMonths(/* @__PURE__ */ new Date(), value);
20885 case "years":
20886 return subYears(/* @__PURE__ */ new Date(), value);
20887 default:
20888 return /* @__PURE__ */ new Date();
20889 }
20890 }
20891 var isNoneOperatorDefinition = {
20892 /* translators: DataViews operator name */
20893 label: (0, import_i18n24.__)("Is none of"),
20894 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
20895 (0, import_i18n24.sprintf)(
20896 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
20897 (0, import_i18n24.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
20898 filter.name,
20899 activeElements.map((element) => element.label).join(", ")
20900 ),
20901 filterTextWrappers
20902 ),
20903 filter: ((item, field, filterValue) => {
20904 if (!filterValue?.length) {
20905 return true;
20906 }
20907 const fieldValue = field.getValue({ item });
20908 if (Array.isArray(fieldValue)) {
20909 return !filterValue.some(
20910 (fv) => fieldValue.includes(fv)
20911 );
20912 } else if (typeof fieldValue === "string") {
20913 return !filterValue.includes(fieldValue);
20914 }
20915 return false;
20916 }),
20917 selection: "multi"
20918 };
20919 var OPERATORS = [
20920 {
20921 name: OPERATOR_IS_ANY,
20922 /* translators: DataViews operator name */
20923 label: (0, import_i18n24.__)("Includes"),
20924 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
20925 (0, import_i18n24.sprintf)(
20926 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
20927 (0, import_i18n24.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
20928 filter.name,
20929 activeElements.map((element) => element.label).join(", ")
20930 ),
20931 filterTextWrappers
20932 ),
20933 filter(item, field, filterValue) {
20934 if (!filterValue?.length) {
20935 return true;
20936 }
20937 const fieldValue = field.getValue({ item });
20938 if (Array.isArray(fieldValue)) {
20939 return filterValue.some(
20940 (fv) => fieldValue.includes(fv)
20941 );
20942 } else if (typeof fieldValue === "string") {
20943 return filterValue.includes(fieldValue);
20944 }
20945 return false;
20946 },
20947 selection: "multi"
20948 },
20949 {
20950 name: OPERATOR_IS_NONE,
20951 ...isNoneOperatorDefinition
20952 },
20953 {
20954 name: OPERATOR_IS_ALL,
20955 /* translators: DataViews operator name */
20956 label: (0, import_i18n24.__)("Includes all"),
20957 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
20958 (0, import_i18n24.sprintf)(
20959 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
20960 (0, import_i18n24.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
20961 filter.name,
20962 activeElements.map((element) => element.label).join(", ")
20963 ),
20964 filterTextWrappers
20965 ),
20966 filter(item, field, filterValue) {
20967 if (!filterValue?.length) {
20968 return true;
20969 }
20970 return filterValue.every((value) => {
20971 return field.getValue({ item })?.includes(value);
20972 });
20973 },
20974 selection: "multi"
20975 },
20976 {
20977 name: OPERATOR_IS_NOT_ALL,
20978 ...isNoneOperatorDefinition
20979 },
20980 {
20981 name: OPERATOR_BETWEEN,
20982 /* translators: DataViews operator name */
20983 label: (0, import_i18n24.__)("Between (inc)"),
20984 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
20985 (0, import_i18n24.sprintf)(
20986 /* 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". */
20987 (0, import_i18n24.__)(
20988 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
20989 ),
20990 filter.name,
20991 activeElements[0].label[0],
20992 activeElements[0].label[1]
20993 ),
20994 filterTextWrappers
20995 ),
20996 filter(item, field, filterValue) {
20997 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
20998 return true;
20999 }
21000 const fieldValue = field.getValue({ item });
21001 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
21002 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
21003 }
21004 return false;
21005 },
21006 selection: "custom"
21007 },
21008 {
21009 name: OPERATOR_IN_THE_PAST,
21010 /* translators: DataViews operator name */
21011 label: (0, import_i18n24.__)("In the past"),
21012 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21013 (0, import_i18n24.sprintf)(
21014 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
21015 (0, import_i18n24.__)(
21016 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
21017 ),
21018 filter.name,
21019 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
21020 ),
21021 filterTextWrappers
21022 ),
21023 filter(item, field, filterValue) {
21024 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
21025 return true;
21026 }
21027 const targetDate = getRelativeDate(
21028 filterValue.value,
21029 filterValue.unit
21030 );
21031 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21032 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
21033 },
21034 selection: "custom"
21035 },
21036 {
21037 name: OPERATOR_OVER,
21038 /* translators: DataViews operator name */
21039 label: (0, import_i18n24.__)("Over"),
21040 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21041 (0, import_i18n24.sprintf)(
21042 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
21043 (0, import_i18n24.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
21044 filter.name,
21045 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
21046 ),
21047 filterTextWrappers
21048 ),
21049 filter(item, field, filterValue) {
21050 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
21051 return true;
21052 }
21053 const targetDate = getRelativeDate(
21054 filterValue.value,
21055 filterValue.unit
21056 );
21057 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21058 return fieldValue < targetDate;
21059 },
21060 selection: "custom"
21061 },
21062 {
21063 name: OPERATOR_IS,
21064 /* translators: DataViews operator name */
21065 label: (0, import_i18n24.__)("Is"),
21066 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21067 (0, import_i18n24.sprintf)(
21068 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
21069 (0, import_i18n24.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21070 filter.name,
21071 activeElements[0].label
21072 ),
21073 filterTextWrappers
21074 ),
21075 filter(item, field, filterValue) {
21076 return filterValue === field.getValue({ item }) || filterValue === void 0;
21077 },
21078 selection: "single"
21079 },
21080 {
21081 name: OPERATOR_IS_NOT,
21082 /* translators: DataViews operator name */
21083 label: (0, import_i18n24.__)("Is not"),
21084 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21085 (0, import_i18n24.sprintf)(
21086 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
21087 (0, import_i18n24.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21088 filter.name,
21089 activeElements[0].label
21090 ),
21091 filterTextWrappers
21092 ),
21093 filter(item, field, filterValue) {
21094 return filterValue !== field.getValue({ item });
21095 },
21096 selection: "single"
21097 },
21098 {
21099 name: OPERATOR_LESS_THAN,
21100 /* translators: DataViews operator name */
21101 label: (0, import_i18n24.__)("Less than"),
21102 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21103 (0, import_i18n24.sprintf)(
21104 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
21105 (0, import_i18n24.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
21106 filter.name,
21107 activeElements[0].label
21108 ),
21109 filterTextWrappers
21110 ),
21111 filter(item, field, filterValue) {
21112 if (filterValue === void 0) {
21113 return true;
21114 }
21115 const fieldValue = field.getValue({ item });
21116 return fieldValue < filterValue;
21117 },
21118 selection: "single"
21119 },
21120 {
21121 name: OPERATOR_GREATER_THAN,
21122 /* translators: DataViews operator name */
21123 label: (0, import_i18n24.__)("Greater than"),
21124 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21125 (0, import_i18n24.sprintf)(
21126 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
21127 (0, import_i18n24.__)(
21128 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
21129 ),
21130 filter.name,
21131 activeElements[0].label
21132 ),
21133 filterTextWrappers
21134 ),
21135 filter(item, field, filterValue) {
21136 if (filterValue === void 0) {
21137 return true;
21138 }
21139 const fieldValue = field.getValue({ item });
21140 return fieldValue > filterValue;
21141 },
21142 selection: "single"
21143 },
21144 {
21145 name: OPERATOR_LESS_THAN_OR_EQUAL,
21146 /* translators: DataViews operator name */
21147 label: (0, import_i18n24.__)("Less than or equal"),
21148 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21149 (0, import_i18n24.sprintf)(
21150 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
21151 (0, import_i18n24.__)(
21152 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
21153 ),
21154 filter.name,
21155 activeElements[0].label
21156 ),
21157 filterTextWrappers
21158 ),
21159 filter(item, field, filterValue) {
21160 if (filterValue === void 0) {
21161 return true;
21162 }
21163 const fieldValue = field.getValue({ item });
21164 return fieldValue <= filterValue;
21165 },
21166 selection: "single"
21167 },
21168 {
21169 name: OPERATOR_GREATER_THAN_OR_EQUAL,
21170 /* translators: DataViews operator name */
21171 label: (0, import_i18n24.__)("Greater than or equal"),
21172 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21173 (0, import_i18n24.sprintf)(
21174 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
21175 (0, import_i18n24.__)(
21176 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
21177 ),
21178 filter.name,
21179 activeElements[0].label
21180 ),
21181 filterTextWrappers
21182 ),
21183 filter(item, field, filterValue) {
21184 if (filterValue === void 0) {
21185 return true;
21186 }
21187 const fieldValue = field.getValue({ item });
21188 return fieldValue >= filterValue;
21189 },
21190 selection: "single"
21191 },
21192 {
21193 name: OPERATOR_BEFORE,
21194 /* translators: DataViews operator name */
21195 label: (0, import_i18n24.__)("Before"),
21196 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21197 (0, import_i18n24.sprintf)(
21198 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
21199 (0, import_i18n24.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
21200 filter.name,
21201 activeElements[0].label
21202 ),
21203 filterTextWrappers
21204 ),
21205 filter(item, field, filterValue) {
21206 if (filterValue === void 0) {
21207 return true;
21208 }
21209 const filterDate = (0, import_date.getDate)(filterValue);
21210 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21211 return fieldDate < filterDate;
21212 },
21213 selection: "single"
21214 },
21215 {
21216 name: OPERATOR_AFTER,
21217 /* translators: DataViews operator name */
21218 label: (0, import_i18n24.__)("After"),
21219 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21220 (0, import_i18n24.sprintf)(
21221 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
21222 (0, import_i18n24.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
21223 filter.name,
21224 activeElements[0].label
21225 ),
21226 filterTextWrappers
21227 ),
21228 filter(item, field, filterValue) {
21229 if (filterValue === void 0) {
21230 return true;
21231 }
21232 const filterDate = (0, import_date.getDate)(filterValue);
21233 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21234 return fieldDate > filterDate;
21235 },
21236 selection: "single"
21237 },
21238 {
21239 name: OPERATOR_BEFORE_INC,
21240 /* translators: DataViews operator name */
21241 label: (0, import_i18n24.__)("Before (inc)"),
21242 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21243 (0, import_i18n24.sprintf)(
21244 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
21245 (0, import_i18n24.__)(
21246 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
21247 ),
21248 filter.name,
21249 activeElements[0].label
21250 ),
21251 filterTextWrappers
21252 ),
21253 filter(item, field, filterValue) {
21254 if (filterValue === void 0) {
21255 return true;
21256 }
21257 const filterDate = (0, import_date.getDate)(filterValue);
21258 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21259 return fieldDate <= filterDate;
21260 },
21261 selection: "single"
21262 },
21263 {
21264 name: OPERATOR_AFTER_INC,
21265 /* translators: DataViews operator name */
21266 label: (0, import_i18n24.__)("After (inc)"),
21267 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21268 (0, import_i18n24.sprintf)(
21269 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
21270 (0, import_i18n24.__)(
21271 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
21272 ),
21273 filter.name,
21274 activeElements[0].label
21275 ),
21276 filterTextWrappers
21277 ),
21278 filter(item, field, filterValue) {
21279 if (filterValue === void 0) {
21280 return true;
21281 }
21282 const filterDate = (0, import_date.getDate)(filterValue);
21283 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21284 return fieldDate >= filterDate;
21285 },
21286 selection: "single"
21287 },
21288 {
21289 name: OPERATOR_CONTAINS,
21290 /* translators: DataViews operator name */
21291 label: (0, import_i18n24.__)("Contains"),
21292 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21293 (0, import_i18n24.sprintf)(
21294 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
21295 (0, import_i18n24.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
21296 filter.name,
21297 activeElements[0].label
21298 ),
21299 filterTextWrappers
21300 ),
21301 filter(item, field, filterValue) {
21302 if (filterValue === void 0) {
21303 return true;
21304 }
21305 const fieldValue = field.getValue({ item });
21306 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21307 },
21308 selection: "single"
21309 },
21310 {
21311 name: OPERATOR_NOT_CONTAINS,
21312 /* translators: DataViews operator name */
21313 label: (0, import_i18n24.__)("Doesn't contain"),
21314 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21315 (0, import_i18n24.sprintf)(
21316 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
21317 (0, import_i18n24.__)(
21318 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
21319 ),
21320 filter.name,
21321 activeElements[0].label
21322 ),
21323 filterTextWrappers
21324 ),
21325 filter(item, field, filterValue) {
21326 if (filterValue === void 0) {
21327 return true;
21328 }
21329 const fieldValue = field.getValue({ item });
21330 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21331 },
21332 selection: "single"
21333 },
21334 {
21335 name: OPERATOR_STARTS_WITH,
21336 /* translators: DataViews operator name */
21337 label: (0, import_i18n24.__)("Starts with"),
21338 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21339 (0, import_i18n24.sprintf)(
21340 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
21341 (0, import_i18n24.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
21342 filter.name,
21343 activeElements[0].label
21344 ),
21345 filterTextWrappers
21346 ),
21347 filter(item, field, filterValue) {
21348 if (filterValue === void 0) {
21349 return true;
21350 }
21351 const fieldValue = field.getValue({ item });
21352 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
21353 },
21354 selection: "single"
21355 },
21356 {
21357 name: OPERATOR_ON,
21358 /* translators: DataViews operator name */
21359 label: (0, import_i18n24.__)("On"),
21360 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21361 (0, import_i18n24.sprintf)(
21362 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
21363 (0, import_i18n24.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21364 filter.name,
21365 activeElements[0].label
21366 ),
21367 filterTextWrappers
21368 ),
21369 filter(item, field, filterValue) {
21370 if (filterValue === void 0) {
21371 return true;
21372 }
21373 const filterDate = (0, import_date.getDate)(filterValue);
21374 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21375 return filterDate.getTime() === fieldDate.getTime();
21376 },
21377 selection: "single"
21378 },
21379 {
21380 name: OPERATOR_NOT_ON,
21381 /* translators: DataViews operator name */
21382 label: (0, import_i18n24.__)("Not on"),
21383 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21384 (0, import_i18n24.sprintf)(
21385 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
21386 (0, import_i18n24.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21387 filter.name,
21388 activeElements[0].label
21389 ),
21390 filterTextWrappers
21391 ),
21392 filter(item, field, filterValue) {
21393 if (filterValue === void 0) {
21394 return true;
21395 }
21396 const filterDate = (0, import_date.getDate)(filterValue);
21397 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21398 return filterDate.getTime() !== fieldDate.getTime();
21399 },
21400 selection: "single"
21401 }
21402 ];
21403 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
21404 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
21405 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
21406 (op) => op.name === name
21407 );
21408 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
21409
21410 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
21411 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
21412 var ENTER = "Enter";
21413 var SPACE = " ";
21414 var FilterText = ({
21415 activeElements,
21416 filterInView,
21417 filter
21418 }) => {
21419 if (activeElements === void 0 || activeElements.length === 0) {
21420 return filter.name;
21421 }
21422 const operator = getOperatorByName(filterInView?.operator);
21423 if (operator !== void 0) {
21424 return operator.filterText(filter, activeElements);
21425 }
21426 return (0, import_i18n25.sprintf)(
21427 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
21428 (0, import_i18n25.__)("Unknown status for %1$s"),
21429 filter.name
21430 );
21431 };
21432 function OperatorSelector({
21433 filter,
21434 view,
21435 onChangeView
21436 }) {
21437 const operatorOptions = filter.operators?.map((operator) => ({
21438 value: operator,
21439 label: getOperatorByName(operator)?.label || operator
21440 }));
21441 const currentFilter = view.filters?.find(
21442 (_filter) => _filter.field === filter.field
21443 );
21444 const value = currentFilter?.operator || filter.operators[0];
21445 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(
21446 Stack,
21447 {
21448 direction: "row",
21449 gap: "sm",
21450 justify: "flex-start",
21451 className: "dataviews-filters__summary-operators-container",
21452 align: "center",
21453 children: [
21454 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_components20.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
21455 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21456 import_components20.SelectControl,
21457 {
21458 className: "dataviews-filters__summary-operators-filter-select",
21459 label: (0, import_i18n25.__)("Conditions"),
21460 value,
21461 options: operatorOptions,
21462 onChange: (newValue) => {
21463 const newOperator = newValue;
21464 const currentOperator = currentFilter?.operator;
21465 const newFilters = currentFilter ? [
21466 ...(view.filters ?? []).map(
21467 (_filter) => {
21468 if (_filter.field === filter.field) {
21469 const currentOpSelectionModel = getOperatorByName(
21470 currentOperator
21471 )?.selection;
21472 const newOpSelectionModel = getOperatorByName(
21473 newOperator
21474 )?.selection;
21475 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
21476 currentOpSelectionModel,
21477 newOpSelectionModel
21478 ].includes("custom");
21479 return {
21480 ..._filter,
21481 value: shouldResetValue ? void 0 : _filter.value,
21482 operator: newOperator
21483 };
21484 }
21485 return _filter;
21486 }
21487 )
21488 ] : [
21489 ...view.filters ?? [],
21490 {
21491 field: filter.field,
21492 operator: newOperator,
21493 value: void 0
21494 }
21495 ];
21496 onChangeView({
21497 ...view,
21498 page: 1,
21499 filters: newFilters
21500 });
21501 },
21502 size: "small",
21503 variant: "minimal",
21504 hideLabelFromVision: true
21505 }
21506 )
21507 ]
21508 }
21509 );
21510 }
21511 function Filter({
21512 addFilterRef,
21513 openedFilter,
21514 fields,
21515 ...commonProps
21516 }) {
21517 const toggleRef = (0, import_element50.useRef)(null);
21518 const { filter, view, onChangeView } = commonProps;
21519 const filterInView = view.filters?.find(
21520 (f2) => f2.field === filter.field
21521 );
21522 let activeElements = [];
21523 const field = (0, import_element50.useMemo)(() => {
21524 const currentField = fields.find((f2) => f2.id === filter.field);
21525 if (currentField) {
21526 return {
21527 ...currentField,
21528 // Configure getValue as if Item was a plain object.
21529 // See related input-widget.tsx
21530 getValue: ({ item }) => item[currentField.id]
21531 };
21532 }
21533 return currentField;
21534 }, [fields, filter.field]);
21535 const { elements } = useElements({
21536 elements: filter.elements,
21537 getElements: filter.getElements
21538 });
21539 if (elements.length > 0) {
21540 activeElements = elements.filter((element) => {
21541 if (filter.singleSelection) {
21542 return element.value === filterInView?.value;
21543 }
21544 return filterInView?.value?.includes(element.value);
21545 });
21546 } else if (Array.isArray(filterInView?.value)) {
21547 const label = filterInView.value.map((v2) => {
21548 const formattedValue = field?.getValueFormatted({
21549 item: { [field.id]: v2 },
21550 field
21551 });
21552 return formattedValue || String(v2);
21553 });
21554 activeElements = [
21555 {
21556 value: filterInView.value,
21557 // @ts-ignore
21558 label
21559 }
21560 ];
21561 } else if (typeof filterInView?.value === "object") {
21562 activeElements = [
21563 { value: filterInView.value, label: filterInView.value }
21564 ];
21565 } else if (filterInView?.value !== void 0) {
21566 const label = field !== void 0 ? field.getValueFormatted({
21567 item: { [field.id]: filterInView.value },
21568 field
21569 }) : String(filterInView.value);
21570 activeElements = [
21571 {
21572 value: filterInView.value,
21573 label
21574 }
21575 ];
21576 }
21577 const isPrimary = filter.isPrimary;
21578 const isLocked = filterInView?.isLocked;
21579 const hasValues = !isLocked && filterInView?.value !== void 0;
21580 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
21581 const resetOrRemoveLabel = isPrimary ? (0, import_i18n25.__)("Reset") : (0, import_i18n25.__)("Remove");
21582 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21583 import_components20.Dropdown,
21584 {
21585 defaultOpen: openedFilter === filter.field,
21586 contentClassName: "dataviews-filters__summary-popover",
21587 popoverProps: { placement: "bottom-start", role: "dialog" },
21588 onClose: () => {
21589 toggleRef.current?.focus();
21590 },
21591 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
21592 /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(tooltip_exports.Root, { children: [
21593 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21594 tooltip_exports.Trigger,
21595 {
21596 render: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21597 "div",
21598 {
21599 className: clsx_default(
21600 "dataviews-filters__summary-chip",
21601 {
21602 "has-reset": canResetOrRemove,
21603 "has-values": hasValues,
21604 "is-not-clickable": isLocked
21605 }
21606 ),
21607 role: "button",
21608 tabIndex: isLocked ? -1 : 0,
21609 onClick: () => {
21610 if (!isLocked) {
21611 onToggle();
21612 }
21613 },
21614 onKeyDown: (event) => {
21615 if (!isLocked && [ENTER, SPACE].includes(
21616 event.key
21617 )) {
21618 onToggle();
21619 event.preventDefault();
21620 }
21621 },
21622 "aria-disabled": isLocked,
21623 "aria-pressed": isOpen,
21624 "aria-expanded": isOpen,
21625 ref: toggleRef,
21626 children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21627 FilterText,
21628 {
21629 activeElements,
21630 filterInView,
21631 filter
21632 }
21633 )
21634 }
21635 )
21636 }
21637 ),
21638 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(tooltip_exports.Popup, { children: (0, import_i18n25.sprintf)(
21639 /* translators: 1: Filter name. */
21640 (0, import_i18n25.__)("Filter by: %1$s"),
21641 filter.name.toLowerCase()
21642 ) })
21643 ] }),
21644 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(tooltip_exports.Root, { children: [
21645 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21646 tooltip_exports.Trigger,
21647 {
21648 render: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21649 "button",
21650 {
21651 className: clsx_default(
21652 "dataviews-filters__summary-chip-remove",
21653 { "has-values": hasValues }
21654 ),
21655 "aria-label": resetOrRemoveLabel,
21656 onClick: () => {
21657 onChangeView({
21658 ...view,
21659 page: 1,
21660 filters: view.filters?.filter(
21661 (_filter) => _filter.field !== filter.field
21662 )
21663 });
21664 if (!isPrimary) {
21665 addFilterRef.current?.focus();
21666 } else {
21667 toggleRef.current?.focus();
21668 }
21669 },
21670 children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_components20.Icon, { icon: close_small_default })
21671 }
21672 )
21673 }
21674 ),
21675 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel })
21676 ] })
21677 ] }),
21678 renderContent: () => {
21679 return /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
21680 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(OperatorSelector, { ...commonProps }),
21681 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21682 SearchWidget,
21683 {
21684 ...commonProps,
21685 filter: {
21686 ...commonProps.filter,
21687 elements
21688 }
21689 }
21690 ) : /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(InputWidget, { ...commonProps, fields })
21691 ] });
21692 }
21693 }
21694 );
21695 }
21696
21697 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
21698 var import_components21 = __toESM(require_components(), 1);
21699 var import_i18n26 = __toESM(require_i18n(), 1);
21700 var import_element51 = __toESM(require_element(), 1);
21701 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
21702 var { Menu: Menu4 } = unlock2(import_components21.privateApis);
21703 function AddFilterMenu({
21704 filters,
21705 view,
21706 onChangeView,
21707 setOpenedFilter,
21708 triggerProps
21709 }) {
21710 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
21711 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(Menu4, { children: [
21712 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Menu4.TriggerButton, { ...triggerProps }),
21713 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
21714 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21715 Menu4.Item,
21716 {
21717 onClick: () => {
21718 setOpenedFilter(filter.field);
21719 onChangeView({
21720 ...view,
21721 page: 1,
21722 filters: [
21723 ...view.filters || [],
21724 {
21725 field: filter.field,
21726 value: void 0,
21727 operator: filter.operators[0]
21728 }
21729 ]
21730 });
21731 },
21732 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Menu4.ItemLabel, { children: filter.name })
21733 },
21734 filter.field
21735 );
21736 }) })
21737 ] });
21738 }
21739 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
21740 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
21741 return null;
21742 }
21743 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
21744 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21745 AddFilterMenu,
21746 {
21747 triggerProps: {
21748 render: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21749 import_components21.Button,
21750 {
21751 accessibleWhenDisabled: true,
21752 size: "compact",
21753 className: "dataviews-filters-button",
21754 variant: "tertiary",
21755 disabled: !inactiveFilters.length,
21756 ref
21757 }
21758 ),
21759 children: (0, import_i18n26.__)("Add filter")
21760 },
21761 ...{ filters, view, onChangeView, setOpenedFilter }
21762 }
21763 );
21764 }
21765 var add_filter_default = (0, import_element51.forwardRef)(AddFilter);
21766
21767 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
21768 var import_components22 = __toESM(require_components(), 1);
21769 var import_i18n27 = __toESM(require_i18n(), 1);
21770 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
21771 function ResetFilter({
21772 filters,
21773 view,
21774 onChangeView
21775 }) {
21776 const isPrimary = (field) => filters.some(
21777 (_filter) => _filter.field === field && _filter.isPrimary
21778 );
21779 const isDisabled = !view.search && !view.filters?.some(
21780 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
21781 );
21782 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21783 import_components22.Button,
21784 {
21785 disabled: isDisabled,
21786 accessibleWhenDisabled: true,
21787 size: "compact",
21788 variant: "tertiary",
21789 className: "dataviews-filters__reset-button",
21790 onClick: () => {
21791 onChangeView({
21792 ...view,
21793 page: 1,
21794 search: "",
21795 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
21796 });
21797 },
21798 children: (0, import_i18n27.__)("Reset")
21799 }
21800 );
21801 }
21802
21803 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
21804 var import_element52 = __toESM(require_element(), 1);
21805 function useFilters(fields, view) {
21806 return (0, import_element52.useMemo)(() => {
21807 const filters = [];
21808 fields.forEach((field) => {
21809 if (field.filterBy === false || !field.hasElements && !field.Edit) {
21810 return;
21811 }
21812 const operators = field.filterBy.operators;
21813 const isPrimary = !!field.filterBy?.isPrimary;
21814 const isLocked = view.filters?.some(
21815 (f2) => f2.field === field.id && !!f2.isLocked
21816 ) ?? false;
21817 filters.push({
21818 field: field.id,
21819 name: field.label,
21820 elements: field.elements,
21821 getElements: field.getElements,
21822 hasElements: field.hasElements,
21823 singleSelection: operators.some(
21824 (op) => isSingleSelectionOperator(op)
21825 ),
21826 operators,
21827 isVisible: isLocked || isPrimary || !!view.filters?.some(
21828 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
21829 ),
21830 isPrimary,
21831 isLocked
21832 });
21833 });
21834 filters.sort((a2, b2) => {
21835 if (a2.isLocked && !b2.isLocked) {
21836 return -1;
21837 }
21838 if (!a2.isLocked && b2.isLocked) {
21839 return 1;
21840 }
21841 if (a2.isPrimary && !b2.isPrimary) {
21842 return -1;
21843 }
21844 if (!a2.isPrimary && b2.isPrimary) {
21845 return 1;
21846 }
21847 return a2.name.localeCompare(b2.name);
21848 });
21849 return filters;
21850 }, [fields, view]);
21851 }
21852 var use_filters_default = useFilters;
21853
21854 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
21855 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
21856 function Filters({ className }) {
21857 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element53.useContext)(dataviews_context_default);
21858 const addFilterRef = (0, import_element53.useRef)(null);
21859 const filters = use_filters_default(fields, view);
21860 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
21861 add_filter_default,
21862 {
21863 filters,
21864 view,
21865 onChangeView,
21866 ref: addFilterRef,
21867 setOpenedFilter
21868 },
21869 "add-filter"
21870 );
21871 const visibleFilters = filters.filter((filter) => filter.isVisible);
21872 if (visibleFilters.length === 0) {
21873 return null;
21874 }
21875 const filterComponents = [
21876 ...visibleFilters.map((filter) => {
21877 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
21878 Filter,
21879 {
21880 filter,
21881 view,
21882 fields,
21883 onChangeView,
21884 addFilterRef,
21885 openedFilter
21886 },
21887 filter.field
21888 );
21889 }),
21890 addFilter
21891 ];
21892 filterComponents.push(
21893 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
21894 ResetFilter,
21895 {
21896 filters,
21897 view,
21898 onChangeView
21899 },
21900 "reset-filters"
21901 )
21902 );
21903 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
21904 Stack,
21905 {
21906 direction: "row",
21907 justify: "flex-start",
21908 gap: "sm",
21909 style: { width: "fit-content" },
21910 wrap: "wrap",
21911 className,
21912 children: filterComponents
21913 }
21914 );
21915 }
21916 var filters_default = (0, import_element53.memo)(Filters);
21917
21918 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
21919 var import_element54 = __toESM(require_element(), 1);
21920 var import_components23 = __toESM(require_components(), 1);
21921 var import_i18n28 = __toESM(require_i18n(), 1);
21922 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
21923 function FiltersToggle() {
21924 const {
21925 filters,
21926 view,
21927 onChangeView,
21928 setOpenedFilter,
21929 isShowingFilter,
21930 setIsShowingFilter
21931 } = (0, import_element54.useContext)(dataviews_context_default);
21932 const buttonRef = (0, import_element54.useRef)(null);
21933 const onChangeViewWithFilterVisibility = (0, import_element54.useCallback)(
21934 (_view) => {
21935 onChangeView(_view);
21936 setIsShowingFilter(true);
21937 },
21938 [onChangeView, setIsShowingFilter]
21939 );
21940 if (filters.length === 0) {
21941 return null;
21942 }
21943 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
21944 const addFilterButtonProps = {
21945 label: (0, import_i18n28.__)("Add filter"),
21946 "aria-expanded": false,
21947 isPressed: false
21948 };
21949 const toggleFiltersButtonProps = {
21950 label: (0, import_i18n28._x)("Filter", "verb"),
21951 "aria-expanded": isShowingFilter,
21952 isPressed: isShowingFilter,
21953 onClick: () => {
21954 if (!isShowingFilter) {
21955 setOpenedFilter(null);
21956 }
21957 setIsShowingFilter(!isShowingFilter);
21958 }
21959 };
21960 const hasPrimaryOrLockedFilters = filters.some(
21961 (filter) => filter.isPrimary || filter.isLocked
21962 );
21963 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
21964 import_components23.Button,
21965 {
21966 ref: buttonRef,
21967 className: "dataviews-filters__visibility-toggle",
21968 size: "compact",
21969 icon: funnel_default,
21970 disabled: hasPrimaryOrLockedFilters,
21971 accessibleWhenDisabled: true,
21972 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
21973 }
21974 );
21975 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
21976 AddFilterMenu,
21977 {
21978 filters,
21979 view,
21980 onChangeView: onChangeViewWithFilterVisibility,
21981 setOpenedFilter,
21982 triggerProps: { render: buttonComponent }
21983 }
21984 ) : /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
21985 FilterVisibilityToggle,
21986 {
21987 buttonRef,
21988 filtersCount: view.filters?.length,
21989 children: buttonComponent
21990 }
21991 ) });
21992 }
21993 function FilterVisibilityToggle({
21994 buttonRef,
21995 filtersCount,
21996 children
21997 }) {
21998 (0, import_element54.useEffect)(
21999 () => () => {
22000 buttonRef.current?.focus();
22001 },
22002 [buttonRef]
22003 );
22004 return /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(import_jsx_runtime86.Fragment, { children: [
22005 children,
22006 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
22007 ] });
22008 }
22009 var toggle_default = FiltersToggle;
22010
22011 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
22012 var import_element55 = __toESM(require_element(), 1);
22013 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
22014 function FiltersToggled(props) {
22015 const { isShowingFilter } = (0, import_element55.useContext)(dataviews_context_default);
22016 if (!isShowingFilter) {
22017 return null;
22018 }
22019 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(filters_default, { ...props });
22020 }
22021 var filters_toggled_default = FiltersToggled;
22022
22023 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
22024 var import_element56 = __toESM(require_element(), 1);
22025 var import_components24 = __toESM(require_components(), 1);
22026 var import_i18n29 = __toESM(require_i18n(), 1);
22027 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
22028 function DataViewsLayout({ className }) {
22029 const {
22030 actions = [],
22031 data,
22032 fields,
22033 getItemId,
22034 getItemLevel,
22035 hasInitiallyLoaded,
22036 isLoading,
22037 view,
22038 onChangeView,
22039 selection,
22040 onChangeSelection,
22041 setOpenedFilter,
22042 onClickItem,
22043 isItemClickable,
22044 renderItemLink,
22045 defaultLayouts,
22046 containerRef,
22047 empty = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("p", { children: (0, import_i18n29.__)("No results") })
22048 } = (0, import_element56.useContext)(dataviews_context_default);
22049 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
22050 delay: 200
22051 });
22052 if (!hasInitiallyLoaded) {
22053 if (!isDelayedInitialLoading) {
22054 return null;
22055 }
22056 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_components24.Spinner, {}) }) });
22057 }
22058 const ViewComponent = VIEW_LAYOUTS.find(
22059 (v2) => v2.type === view.type && defaultLayouts[v2.type]
22060 )?.component;
22061 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22062 ViewComponent,
22063 {
22064 className,
22065 actions,
22066 data,
22067 fields,
22068 getItemId,
22069 getItemLevel,
22070 isLoading,
22071 onChangeView,
22072 onChangeSelection,
22073 selection,
22074 setOpenedFilter,
22075 onClickItem,
22076 renderItemLink,
22077 isItemClickable,
22078 view,
22079 empty
22080 }
22081 ) });
22082 }
22083
22084 // packages/dataviews/build-module/components/dataviews-footer/index.mjs
22085 var import_element57 = __toESM(require_element(), 1);
22086 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
22087 var EMPTY_ARRAY5 = [];
22088 function DataViewsFooter() {
22089 const {
22090 view,
22091 paginationInfo: { totalItems = 0, totalPages },
22092 data,
22093 actions = EMPTY_ARRAY5,
22094 isLoading,
22095 hasInitiallyLoaded
22096 } = (0, import_element57.useContext)(dataviews_context_default);
22097 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length;
22098 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
22099 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type);
22100 if (!isRefreshing && (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions)) {
22101 return null;
22102 }
22103 return (!!totalItems || isRefreshing) && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22104 "div",
22105 {
22106 className: "dataviews-footer",
22107 inert: isRefreshing ? "true" : void 0,
22108 children: /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
22109 Stack,
22110 {
22111 direction: "row",
22112 justify: "end",
22113 align: "center",
22114 className: clsx_default("dataviews-footer__content", {
22115 "is-refreshing": isDelayedRefreshing
22116 }),
22117 gap: "sm",
22118 children: [
22119 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(BulkActionsFooter, {}),
22120 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(dataviews_pagination_default, {})
22121 ]
22122 }
22123 )
22124 }
22125 );
22126 }
22127
22128 // packages/dataviews/build-module/components/dataviews-search/index.mjs
22129 var import_i18n30 = __toESM(require_i18n(), 1);
22130 var import_element58 = __toESM(require_element(), 1);
22131 var import_components25 = __toESM(require_components(), 1);
22132 var import_compose9 = __toESM(require_compose(), 1);
22133 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
22134 var DataViewsSearch = (0, import_element58.memo)(function Search({ label }) {
22135 const { view, onChangeView } = (0, import_element58.useContext)(dataviews_context_default);
22136 const [search, setSearch, debouncedSearch] = (0, import_compose9.useDebouncedInput)(
22137 view.search
22138 );
22139 (0, import_element58.useEffect)(() => {
22140 if (view.search !== debouncedSearch) {
22141 setSearch(view.search ?? "");
22142 }
22143 }, [view.search, setSearch]);
22144 const onChangeViewRef = (0, import_element58.useRef)(onChangeView);
22145 const viewRef = (0, import_element58.useRef)(view);
22146 (0, import_element58.useEffect)(() => {
22147 onChangeViewRef.current = onChangeView;
22148 viewRef.current = view;
22149 }, [onChangeView, view]);
22150 (0, import_element58.useEffect)(() => {
22151 if (debouncedSearch !== viewRef.current?.search) {
22152 onChangeViewRef.current({
22153 ...viewRef.current,
22154 page: view.page ? 1 : void 0,
22155 startPosition: view.startPosition ? 1 : void 0,
22156 search: debouncedSearch
22157 });
22158 }
22159 }, [debouncedSearch]);
22160 const searchLabel = label || (0, import_i18n30.__)("Search");
22161 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22162 import_components25.SearchControl,
22163 {
22164 className: "dataviews-search",
22165 onChange: setSearch,
22166 value: search,
22167 label: searchLabel,
22168 placeholder: searchLabel,
22169 size: "compact"
22170 }
22171 );
22172 });
22173 var dataviews_search_default = DataViewsSearch;
22174
22175 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
22176 var import_components26 = __toESM(require_components(), 1);
22177 var import_i18n31 = __toESM(require_i18n(), 1);
22178 var import_element59 = __toESM(require_element(), 1);
22179 var import_warning = __toESM(require_warning(), 1);
22180 var import_compose10 = __toESM(require_compose(), 1);
22181 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
22182 var { Menu: Menu5 } = unlock2(import_components26.privateApis);
22183 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
22184 className: "dataviews-config__popover",
22185 placement: "bottom-end",
22186 offset: 9
22187 };
22188 function ViewTypeMenu() {
22189 const { view, onChangeView, defaultLayouts } = (0, import_element59.useContext)(dataviews_context_default);
22190 const availableLayouts = Object.keys(defaultLayouts);
22191 if (availableLayouts.length <= 1) {
22192 return null;
22193 }
22194 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
22195 return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(Menu5, { children: [
22196 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22197 Menu5.TriggerButton,
22198 {
22199 render: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22200 import_components26.Button,
22201 {
22202 size: "compact",
22203 icon: activeView?.icon,
22204 label: (0, import_i18n31.__)("Layout")
22205 }
22206 )
22207 }
22208 ),
22209 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
22210 const config = VIEW_LAYOUTS.find(
22211 (v2) => v2.type === layout
22212 );
22213 if (!config) {
22214 return null;
22215 }
22216 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22217 Menu5.RadioItem,
22218 {
22219 value: layout,
22220 name: "view-actions-available-view",
22221 checked: layout === view.type,
22222 hideOnClick: true,
22223 onChange: (e2) => {
22224 switch (e2.target.value) {
22225 case "list":
22226 case "grid":
22227 case "table":
22228 case "pickerGrid":
22229 case "pickerTable":
22230 case "activity":
22231 const viewWithoutLayout = { ...view };
22232 if ("layout" in viewWithoutLayout) {
22233 delete viewWithoutLayout.layout;
22234 }
22235 return onChangeView({
22236 ...viewWithoutLayout,
22237 type: e2.target.value,
22238 ...defaultLayouts[e2.target.value]
22239 });
22240 }
22241 (0, import_warning.default)("Invalid dataview");
22242 },
22243 children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Menu5.ItemLabel, { children: config.label })
22244 },
22245 layout
22246 );
22247 }) })
22248 ] });
22249 }
22250 function SortFieldControl() {
22251 const { view, fields, onChangeView } = (0, import_element59.useContext)(dataviews_context_default);
22252 const orderOptions = (0, import_element59.useMemo)(() => {
22253 const sortableFields = fields.filter(
22254 (field) => field.enableSorting !== false
22255 );
22256 return sortableFields.map((field) => {
22257 return {
22258 label: field.label,
22259 value: field.id
22260 };
22261 });
22262 }, [fields]);
22263 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22264 import_components26.SelectControl,
22265 {
22266 __next40pxDefaultSize: true,
22267 label: (0, import_i18n31.__)("Sort by"),
22268 value: view.sort?.field,
22269 options: orderOptions,
22270 onChange: (value) => {
22271 onChangeView({
22272 ...view,
22273 sort: {
22274 direction: view?.sort?.direction || "desc",
22275 field: value
22276 },
22277 showLevels: false
22278 });
22279 }
22280 }
22281 );
22282 }
22283 function SortDirectionControl() {
22284 const { view, fields, onChangeView } = (0, import_element59.useContext)(dataviews_context_default);
22285 const sortableFields = fields.filter(
22286 (field) => field.enableSorting !== false
22287 );
22288 if (sortableFields.length === 0) {
22289 return null;
22290 }
22291 let value = view.sort?.direction;
22292 if (!value && view.sort?.field) {
22293 value = "desc";
22294 }
22295 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22296 import_components26.__experimentalToggleGroupControl,
22297 {
22298 className: "dataviews-view-config__sort-direction",
22299 __next40pxDefaultSize: true,
22300 isBlock: true,
22301 label: (0, import_i18n31.__)("Order"),
22302 value,
22303 onChange: (newDirection) => {
22304 if (newDirection === "asc" || newDirection === "desc") {
22305 onChangeView({
22306 ...view,
22307 sort: {
22308 direction: newDirection,
22309 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
22310 fields.find(
22311 (field) => field.enableSorting !== false
22312 )?.id || ""
22313 },
22314 showLevels: false
22315 });
22316 return;
22317 }
22318 (0, import_warning.default)("Invalid direction");
22319 },
22320 children: SORTING_DIRECTIONS.map((direction) => {
22321 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22322 import_components26.__experimentalToggleGroupControlOptionIcon,
22323 {
22324 value: direction,
22325 icon: sortIcons[direction],
22326 label: sortLabels[direction]
22327 },
22328 direction
22329 );
22330 })
22331 }
22332 );
22333 }
22334 function ItemsPerPageControl() {
22335 const { view, config, onChangeView } = (0, import_element59.useContext)(dataviews_context_default);
22336 const { infiniteScrollEnabled } = view;
22337 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
22338 return null;
22339 }
22340 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22341 import_components26.__experimentalToggleGroupControl,
22342 {
22343 __next40pxDefaultSize: true,
22344 isBlock: true,
22345 label: (0, import_i18n31.__)("Items per page"),
22346 value: view.perPage || 10,
22347 disabled: !view?.sort?.field,
22348 onChange: (newItemsPerPage) => {
22349 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
22350 onChangeView({
22351 ...view,
22352 perPage: newItemsPerPageNumber,
22353 page: 1
22354 });
22355 },
22356 children: config.perPageSizes.map((value) => {
22357 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22358 import_components26.__experimentalToggleGroupControlOption,
22359 {
22360 value,
22361 label: value.toString()
22362 },
22363 value
22364 );
22365 })
22366 }
22367 );
22368 }
22369 function ResetViewButton() {
22370 const { onReset } = (0, import_element59.useContext)(dataviews_context_default);
22371 if (onReset === void 0) {
22372 return null;
22373 }
22374 const isDisabled = onReset === false;
22375 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22376 import_components26.Button,
22377 {
22378 variant: "tertiary",
22379 size: "compact",
22380 disabled: isDisabled,
22381 accessibleWhenDisabled: true,
22382 className: "dataviews-view-config__reset-button",
22383 onClick: () => {
22384 if (typeof onReset === "function") {
22385 onReset();
22386 }
22387 },
22388 children: (0, import_i18n31.__)("Reset view")
22389 }
22390 );
22391 }
22392 function DataviewsViewConfigDropdown() {
22393 const { view, onReset } = (0, import_element59.useContext)(dataviews_context_default);
22394 const popoverId = (0, import_compose10.useInstanceId)(
22395 _DataViewsViewConfig,
22396 "dataviews-view-config-dropdown"
22397 );
22398 const activeLayout = VIEW_LAYOUTS.find(
22399 (layout) => layout.type === view.type
22400 );
22401 const isModified = typeof onReset === "function";
22402 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22403 import_components26.Dropdown,
22404 {
22405 expandOnMobile: true,
22406 popoverProps: {
22407 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
22408 id: popoverId
22409 },
22410 renderToggle: ({ onToggle, isOpen }) => {
22411 return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
22412 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22413 import_components26.Button,
22414 {
22415 size: "compact",
22416 icon: cog_default,
22417 label: (0, import_i18n31._x)(
22418 "View options",
22419 "View is used as a noun"
22420 ),
22421 onClick: onToggle,
22422 "aria-expanded": isOpen ? "true" : "false",
22423 "aria-controls": popoverId
22424 }
22425 ),
22426 isModified && /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
22427 ] });
22428 },
22429 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22430 import_components26.__experimentalDropdownContentWrapper,
22431 {
22432 paddingSize: "medium",
22433 className: "dataviews-config__popover-content-wrapper",
22434 children: /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
22435 Stack,
22436 {
22437 direction: "column",
22438 className: "dataviews-view-config",
22439 gap: "xl",
22440 children: [
22441 /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
22442 Stack,
22443 {
22444 direction: "row",
22445 justify: "space-between",
22446 align: "center",
22447 className: "dataviews-view-config__header",
22448 children: [
22449 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22450 import_components26.__experimentalHeading,
22451 {
22452 level: 2,
22453 className: "dataviews-settings-section__title",
22454 children: (0, import_i18n31.__)("Appearance")
22455 }
22456 ),
22457 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ResetViewButton, {})
22458 ]
22459 }
22460 ),
22461 /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22462 /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
22463 Stack,
22464 {
22465 direction: "row",
22466 gap: "sm",
22467 className: "dataviews-view-config__sort-controls",
22468 children: [
22469 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(SortFieldControl, {}),
22470 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(SortDirectionControl, {})
22471 ]
22472 }
22473 ),
22474 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(activeLayout.viewConfigOptions, {}),
22475 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ItemsPerPageControl, {}),
22476 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(PropertiesSection, {})
22477 ] })
22478 ]
22479 }
22480 )
22481 }
22482 )
22483 }
22484 );
22485 }
22486 function _DataViewsViewConfig() {
22487 return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(import_jsx_runtime91.Fragment, { children: [
22488 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ViewTypeMenu, {}),
22489 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(DataviewsViewConfigDropdown, {})
22490 ] });
22491 }
22492 var DataViewsViewConfig = (0, import_element59.memo)(_DataViewsViewConfig);
22493 var dataviews_view_config_default = DataViewsViewConfig;
22494
22495 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22496 var import_components27 = __toESM(require_components(), 1);
22497 var import_element60 = __toESM(require_element(), 1);
22498
22499 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
22500 function getCustomValidity(isValid2, validity) {
22501 let customValidity;
22502 if (isValid2?.required && validity?.required) {
22503 customValidity = validity?.required?.message ? validity.required : void 0;
22504 } else if (isValid2?.pattern && validity?.pattern) {
22505 customValidity = validity.pattern;
22506 } else if (isValid2?.min && validity?.min) {
22507 customValidity = validity.min;
22508 } else if (isValid2?.max && validity?.max) {
22509 customValidity = validity.max;
22510 } else if (isValid2?.minLength && validity?.minLength) {
22511 customValidity = validity.minLength;
22512 } else if (isValid2?.maxLength && validity?.maxLength) {
22513 customValidity = validity.maxLength;
22514 } else if (isValid2?.elements && validity?.elements) {
22515 customValidity = validity.elements;
22516 } else if (validity?.custom) {
22517 customValidity = validity.custom;
22518 }
22519 return customValidity;
22520 }
22521
22522 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22523 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
22524 var { ValidatedCheckboxControl } = unlock2(import_components27.privateApis);
22525 function Checkbox({
22526 field,
22527 onChange,
22528 data,
22529 hideLabelFromVision,
22530 markWhenOptional,
22531 validity
22532 }) {
22533 const { getValue, setValue, label, description, isValid: isValid2 } = field;
22534 const disabled2 = field.isDisabled({ item: data, field });
22535 const onChangeControl = (0, import_element60.useCallback)(() => {
22536 onChange(
22537 setValue({ item: data, value: !getValue({ item: data }) })
22538 );
22539 }, [data, getValue, onChange, setValue]);
22540 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22541 ValidatedCheckboxControl,
22542 {
22543 required: !!field.isValid?.required,
22544 markWhenOptional,
22545 customValidity: getCustomValidity(isValid2, validity),
22546 hidden: hideLabelFromVision,
22547 label,
22548 help: description,
22549 checked: getValue({ item: data }),
22550 onChange: onChangeControl,
22551 disabled: disabled2
22552 }
22553 );
22554 }
22555
22556 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
22557 var import_components28 = __toESM(require_components(), 1);
22558 var import_element61 = __toESM(require_element(), 1);
22559 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
22560 var { ValidatedComboboxControl } = unlock2(import_components28.privateApis);
22561 function Combobox3({
22562 data,
22563 field,
22564 onChange,
22565 hideLabelFromVision,
22566 validity
22567 }) {
22568 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
22569 const value = getValue({ item: data }) ?? "";
22570 const onChangeControl = (0, import_element61.useCallback)(
22571 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
22572 [data, onChange, setValue]
22573 );
22574 const { elements, isLoading } = useElements({
22575 elements: field.elements,
22576 getElements: field.getElements
22577 });
22578 if (isLoading) {
22579 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_components28.Spinner, {});
22580 }
22581 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
22582 ValidatedComboboxControl,
22583 {
22584 required: !!field.isValid?.required,
22585 customValidity: getCustomValidity(isValid2, validity),
22586 label,
22587 value,
22588 help: description,
22589 placeholder,
22590 options: elements,
22591 onChange: onChangeControl,
22592 hideLabelFromVision,
22593 allowReset: true,
22594 expandOnFocus: true
22595 }
22596 );
22597 }
22598
22599 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
22600 var import_components30 = __toESM(require_components(), 1);
22601 var import_element64 = __toESM(require_element(), 1);
22602 var import_i18n33 = __toESM(require_i18n(), 1);
22603 var import_date3 = __toESM(require_date(), 1);
22604
22605 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
22606 var import_components29 = __toESM(require_components(), 1);
22607 var import_element62 = __toESM(require_element(), 1);
22608 var import_i18n32 = __toESM(require_i18n(), 1);
22609 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
22610 var TIME_UNITS_OPTIONS = {
22611 [OPERATOR_IN_THE_PAST]: [
22612 { value: "days", label: (0, import_i18n32.__)("Days") },
22613 { value: "weeks", label: (0, import_i18n32.__)("Weeks") },
22614 { value: "months", label: (0, import_i18n32.__)("Months") },
22615 { value: "years", label: (0, import_i18n32.__)("Years") }
22616 ],
22617 [OPERATOR_OVER]: [
22618 { value: "days", label: (0, import_i18n32.__)("Days ago") },
22619 { value: "weeks", label: (0, import_i18n32.__)("Weeks ago") },
22620 { value: "months", label: (0, import_i18n32.__)("Months ago") },
22621 { value: "years", label: (0, import_i18n32.__)("Years ago") }
22622 ]
22623 };
22624 function RelativeDateControl({
22625 className,
22626 data,
22627 field,
22628 onChange,
22629 hideLabelFromVision,
22630 operator
22631 }) {
22632 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
22633 const { id, label, description, getValue, setValue } = field;
22634 const disabled2 = field.isDisabled({ item: data, field });
22635 const fieldValue = getValue({ item: data });
22636 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
22637 const onChangeValue = (0, import_element62.useCallback)(
22638 (newValue) => onChange(
22639 setValue({
22640 item: data,
22641 value: { value: Number(newValue), unit }
22642 })
22643 ),
22644 [onChange, setValue, data, unit]
22645 );
22646 const onChangeUnit = (0, import_element62.useCallback)(
22647 (newUnit) => onChange(
22648 setValue({
22649 item: data,
22650 value: { value: relValue, unit: newUnit }
22651 })
22652 ),
22653 [onChange, setValue, data, relValue]
22654 );
22655 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
22656 import_components29.BaseControl,
22657 {
22658 id,
22659 className: clsx_default(className, "dataviews-controls__relative-date"),
22660 label,
22661 hideLabelFromVision,
22662 help: description,
22663 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(Stack, { direction: "row", gap: "sm", children: [
22664 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
22665 import_components29.__experimentalNumberControl,
22666 {
22667 __next40pxDefaultSize: true,
22668 className: "dataviews-controls__relative-date-number",
22669 spinControls: "none",
22670 min: 1,
22671 step: 1,
22672 value: relValue,
22673 onChange: onChangeValue,
22674 disabled: disabled2
22675 }
22676 ),
22677 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
22678 import_components29.SelectControl,
22679 {
22680 className: "dataviews-controls__relative-date-unit",
22681 __next40pxDefaultSize: true,
22682 label: (0, import_i18n32.__)("Unit"),
22683 value: unit,
22684 options,
22685 onChange: onChangeUnit,
22686 hideLabelFromVision: true,
22687 disabled: disabled2
22688 }
22689 )
22690 ] })
22691 }
22692 );
22693 }
22694
22695 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
22696 var import_element63 = __toESM(require_element(), 1);
22697 function useDisabledDateMatchers(isValid2, parseDateFn) {
22698 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
22699 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
22700 const disabledMatchers = (0, import_element63.useMemo)(() => {
22701 const matchers = [];
22702 if (minConstraint) {
22703 const minDate = parseDateFn(minConstraint);
22704 if (minDate) {
22705 matchers.push({ before: minDate });
22706 }
22707 }
22708 if (maxConstraint) {
22709 const maxDate = parseDateFn(maxConstraint);
22710 if (maxDate) {
22711 matchers.push({ after: maxDate });
22712 }
22713 }
22714 return matchers.length > 0 ? matchers : void 0;
22715 }, [minConstraint, maxConstraint, parseDateFn]);
22716 return { minConstraint, maxConstraint, disabledMatchers };
22717 }
22718
22719 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
22720 var import_date2 = __toESM(require_date(), 1);
22721 function parseDateTime(dateTimeString) {
22722 if (!dateTimeString) {
22723 return null;
22724 }
22725 const parsed = (0, import_date2.getDate)(dateTimeString);
22726 return parsed && isValid(parsed) ? parsed : null;
22727 }
22728
22729 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
22730 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
22731 var { DateCalendar, ValidatedInputControl } = unlock2(import_components30.privateApis);
22732 var formatDateTime = (value) => {
22733 if (!value) {
22734 return "";
22735 }
22736 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
22737 };
22738 function CalendarDateTimeControl({
22739 data,
22740 field,
22741 onChange,
22742 hideLabelFromVision,
22743 markWhenOptional,
22744 validity,
22745 config
22746 }) {
22747 const { compact } = config || {};
22748 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
22749 const disabled2 = field.isDisabled({ item: data, field });
22750 const fieldValue = getValue({ item: data });
22751 const value = typeof fieldValue === "string" ? fieldValue : void 0;
22752 const [calendarMonth, setCalendarMonth] = (0, import_element64.useState)(() => {
22753 const parsedDate = parseDateTime(value);
22754 return parsedDate || /* @__PURE__ */ new Date();
22755 });
22756 const inputControlRef = (0, import_element64.useRef)(null);
22757 const validationTimeoutRef = (0, import_element64.useRef)(void 0);
22758 const previousFocusRef = (0, import_element64.useRef)(null);
22759 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
22760 const onChangeCallback = (0, import_element64.useCallback)(
22761 (newValue) => onChange(setValue({ item: data, value: newValue })),
22762 [data, onChange, setValue]
22763 );
22764 (0, import_element64.useEffect)(() => {
22765 return () => {
22766 if (validationTimeoutRef.current) {
22767 clearTimeout(validationTimeoutRef.current);
22768 }
22769 };
22770 }, []);
22771 const onSelectDate = (0, import_element64.useCallback)(
22772 (newDate) => {
22773 let dateTimeValue;
22774 if (newDate) {
22775 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
22776 let wpTime;
22777 if (value) {
22778 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
22779 } else {
22780 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
22781 }
22782 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
22783 dateTimeValue = finalDateTime.toISOString();
22784 onChangeCallback(dateTimeValue);
22785 if (validationTimeoutRef.current) {
22786 clearTimeout(validationTimeoutRef.current);
22787 }
22788 } else {
22789 onChangeCallback(void 0);
22790 }
22791 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
22792 validationTimeoutRef.current = setTimeout(() => {
22793 if (inputControlRef.current) {
22794 inputControlRef.current.focus();
22795 inputControlRef.current.blur();
22796 onChangeCallback(dateTimeValue);
22797 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
22798 previousFocusRef.current.focus();
22799 }
22800 }
22801 }, 0);
22802 },
22803 [onChangeCallback, value]
22804 );
22805 const handleManualDateTimeChange = (0, import_element64.useCallback)(
22806 (newValue) => {
22807 if (newValue) {
22808 const dateTime = (0, import_date3.getDate)(newValue);
22809 onChangeCallback(dateTime.toISOString());
22810 const parsedDate = parseDateTime(dateTime.toISOString());
22811 if (parsedDate) {
22812 setCalendarMonth(parsedDate);
22813 }
22814 } else {
22815 onChangeCallback(void 0);
22816 }
22817 },
22818 [onChangeCallback]
22819 );
22820 const { format: fieldFormat } = field;
22821 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
22822 const {
22823 timezone: { string: timezoneString }
22824 } = (0, import_date3.getSettings)();
22825 let displayLabel = label;
22826 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
22827 displayLabel = `${label} (${(0, import_i18n33.__)("Required")})`;
22828 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
22829 displayLabel = `${label} (${(0, import_i18n33.__)("Optional")})`;
22830 }
22831 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
22832 import_components30.BaseControl,
22833 {
22834 id,
22835 label: displayLabel,
22836 help: description,
22837 hideLabelFromVision,
22838 children: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22839 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
22840 ValidatedInputControl,
22841 {
22842 ref: inputControlRef,
22843 __next40pxDefaultSize: true,
22844 required: !!isValid2?.required,
22845 customValidity: getCustomValidity(isValid2, validity),
22846 type: "datetime-local",
22847 label: (0, import_i18n33.__)("Date time"),
22848 hideLabelFromVision: true,
22849 value: formatDateTime(value),
22850 onChange: handleManualDateTimeChange,
22851 disabled: disabled2,
22852 min: minConstraint ? formatDateTime(minConstraint) : void 0,
22853 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
22854 }
22855 ),
22856 !compact && /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
22857 DateCalendar,
22858 {
22859 style: { width: "100%" },
22860 selected: value ? parseDateTime(value) || void 0 : void 0,
22861 onSelect: onSelectDate,
22862 month: calendarMonth,
22863 onMonthChange: setCalendarMonth,
22864 timeZone: timezoneString || void 0,
22865 weekStartsOn,
22866 disabled: disabled2 || disabledMatchers
22867 }
22868 )
22869 ] })
22870 }
22871 );
22872 }
22873 function DateTime({
22874 data,
22875 field,
22876 onChange,
22877 hideLabelFromVision,
22878 markWhenOptional,
22879 operator,
22880 validity,
22881 config
22882 }) {
22883 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
22884 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
22885 RelativeDateControl,
22886 {
22887 className: "dataviews-controls__datetime",
22888 data,
22889 field,
22890 onChange,
22891 hideLabelFromVision,
22892 operator
22893 }
22894 );
22895 }
22896 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
22897 CalendarDateTimeControl,
22898 {
22899 data,
22900 field,
22901 onChange,
22902 hideLabelFromVision,
22903 markWhenOptional,
22904 validity,
22905 config
22906 }
22907 );
22908 }
22909
22910 // packages/dataviews/build-module/components/dataform-controls/date.mjs
22911 var import_components31 = __toESM(require_components(), 1);
22912 var import_element65 = __toESM(require_element(), 1);
22913 var import_i18n34 = __toESM(require_i18n(), 1);
22914 var import_date4 = __toESM(require_date(), 1);
22915 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
22916 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock2(import_components31.privateApis);
22917 var DATE_PRESETS = [
22918 {
22919 id: "today",
22920 label: (0, import_i18n34.__)("Today"),
22921 getValue: () => (0, import_date4.getDate)(null)
22922 },
22923 {
22924 id: "yesterday",
22925 label: (0, import_i18n34.__)("Yesterday"),
22926 getValue: () => {
22927 const today = (0, import_date4.getDate)(null);
22928 return subDays(today, 1);
22929 }
22930 },
22931 {
22932 id: "past-week",
22933 label: (0, import_i18n34.__)("Past week"),
22934 getValue: () => {
22935 const today = (0, import_date4.getDate)(null);
22936 return subDays(today, 7);
22937 }
22938 },
22939 {
22940 id: "past-month",
22941 label: (0, import_i18n34.__)("Past month"),
22942 getValue: () => {
22943 const today = (0, import_date4.getDate)(null);
22944 return subMonths(today, 1);
22945 }
22946 }
22947 ];
22948 var DATE_RANGE_PRESETS = [
22949 {
22950 id: "last-7-days",
22951 label: (0, import_i18n34.__)("Last 7 days"),
22952 getValue: () => {
22953 const today = (0, import_date4.getDate)(null);
22954 return [subDays(today, 7), today];
22955 }
22956 },
22957 {
22958 id: "last-30-days",
22959 label: (0, import_i18n34.__)("Last 30 days"),
22960 getValue: () => {
22961 const today = (0, import_date4.getDate)(null);
22962 return [subDays(today, 30), today];
22963 }
22964 },
22965 {
22966 id: "month-to-date",
22967 label: (0, import_i18n34.__)("Month to date"),
22968 getValue: () => {
22969 const today = (0, import_date4.getDate)(null);
22970 return [startOfMonth(today), today];
22971 }
22972 },
22973 {
22974 id: "last-year",
22975 label: (0, import_i18n34.__)("Last year"),
22976 getValue: () => {
22977 const today = (0, import_date4.getDate)(null);
22978 return [subYears(today, 1), today];
22979 }
22980 },
22981 {
22982 id: "year-to-date",
22983 label: (0, import_i18n34.__)("Year to date"),
22984 getValue: () => {
22985 const today = (0, import_date4.getDate)(null);
22986 return [startOfYear(today), today];
22987 }
22988 }
22989 ];
22990 var parseDate = (dateString) => {
22991 if (!dateString) {
22992 return null;
22993 }
22994 const parsed = (0, import_date4.getDate)(dateString);
22995 return parsed && isValid(parsed) ? parsed : null;
22996 };
22997 var formatDate = (date) => {
22998 if (!date) {
22999 return "";
23000 }
23001 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
23002 };
23003 function ValidatedDateControl({
23004 field,
23005 validity,
23006 inputRefs,
23007 isTouched,
23008 setIsTouched,
23009 children
23010 }) {
23011 const { isValid: isValid2 } = field;
23012 const [customValidity, setCustomValidity] = (0, import_element65.useState)(void 0);
23013 const validateRefs = (0, import_element65.useCallback)(() => {
23014 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23015 for (const ref of refs) {
23016 const input = ref.current;
23017 if (input && !input.validity.valid) {
23018 setCustomValidity({
23019 type: "invalid",
23020 message: input.validationMessage
23021 });
23022 return;
23023 }
23024 }
23025 setCustomValidity(void 0);
23026 }, [inputRefs]);
23027 (0, import_element65.useEffect)(() => {
23028 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23029 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23030 for (const ref of refs) {
23031 const input = ref.current;
23032 if (input) {
23033 input.setCustomValidity(
23034 result?.type === "invalid" && result.message ? result.message : ""
23035 );
23036 }
23037 }
23038 }, [inputRefs, isValid2, validity]);
23039 (0, import_element65.useEffect)(() => {
23040 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23041 const handleInvalid = (event) => {
23042 event.preventDefault();
23043 setIsTouched(true);
23044 };
23045 for (const ref of refs) {
23046 ref.current?.addEventListener("invalid", handleInvalid);
23047 }
23048 return () => {
23049 for (const ref of refs) {
23050 ref.current?.removeEventListener("invalid", handleInvalid);
23051 }
23052 };
23053 }, [inputRefs, setIsTouched]);
23054 (0, import_element65.useEffect)(() => {
23055 if (!isTouched) {
23056 return;
23057 }
23058 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23059 if (result) {
23060 setCustomValidity(result);
23061 } else {
23062 validateRefs();
23063 }
23064 }, [isTouched, isValid2, validity, validateRefs]);
23065 const onBlur = (event) => {
23066 if (isTouched) {
23067 return;
23068 }
23069 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
23070 setIsTouched(true);
23071 }
23072 };
23073 return /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)("div", { onBlur, children: [
23074 children,
23075 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
23076 "p",
23077 {
23078 className: clsx_default(
23079 "components-validated-control__indicator",
23080 customValidity.type === "invalid" ? "is-invalid" : void 0
23081 ),
23082 children: [
23083 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23084 import_components31.Icon,
23085 {
23086 className: "components-validated-control__indicator-icon",
23087 icon: error_default,
23088 size: 16,
23089 fill: "currentColor"
23090 }
23091 ),
23092 customValidity.message
23093 ]
23094 }
23095 ) })
23096 ] });
23097 }
23098 function CalendarDateControl({
23099 data,
23100 field,
23101 onChange,
23102 hideLabelFromVision,
23103 markWhenOptional,
23104 validity
23105 }) {
23106 const {
23107 id,
23108 label,
23109 description,
23110 setValue,
23111 getValue,
23112 isValid: isValid2,
23113 format: fieldFormat
23114 } = field;
23115 const disabled2 = field.isDisabled({ item: data, field });
23116 const [selectedPresetId, setSelectedPresetId] = (0, import_element65.useState)(
23117 null
23118 );
23119 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23120 const fieldValue = getValue({ item: data });
23121 const value = typeof fieldValue === "string" ? fieldValue : void 0;
23122 const [calendarMonth, setCalendarMonth] = (0, import_element65.useState)(() => {
23123 const parsedDate = parseDate(value);
23124 return parsedDate || /* @__PURE__ */ new Date();
23125 });
23126 const [isTouched, setIsTouched] = (0, import_element65.useState)(false);
23127 const validityTargetRef = (0, import_element65.useRef)(null);
23128 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23129 const onChangeCallback = (0, import_element65.useCallback)(
23130 (newValue) => onChange(setValue({ item: data, value: newValue })),
23131 [data, onChange, setValue]
23132 );
23133 const onSelectDate = (0, import_element65.useCallback)(
23134 (newDate) => {
23135 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
23136 onChangeCallback(dateValue);
23137 setSelectedPresetId(null);
23138 setIsTouched(true);
23139 },
23140 [onChangeCallback]
23141 );
23142 const handlePresetClick = (0, import_element65.useCallback)(
23143 (preset) => {
23144 const presetDate = preset.getValue();
23145 const dateValue = formatDate(presetDate);
23146 setCalendarMonth(presetDate);
23147 onChangeCallback(dateValue);
23148 setSelectedPresetId(preset.id);
23149 setIsTouched(true);
23150 },
23151 [onChangeCallback]
23152 );
23153 const handleManualDateChange = (0, import_element65.useCallback)(
23154 (newValue) => {
23155 onChangeCallback(newValue);
23156 if (newValue) {
23157 const parsedDate = parseDate(newValue);
23158 if (parsedDate) {
23159 setCalendarMonth(parsedDate);
23160 }
23161 }
23162 setSelectedPresetId(null);
23163 setIsTouched(true);
23164 },
23165 [onChangeCallback]
23166 );
23167 const {
23168 timezone: { string: timezoneString }
23169 } = (0, import_date4.getSettings)();
23170 let displayLabel = label;
23171 if (isValid2?.required && !markWhenOptional) {
23172 displayLabel = `${label} (${(0, import_i18n34.__)("Required")})`;
23173 } else if (!isValid2?.required && markWhenOptional) {
23174 displayLabel = `${label} (${(0, import_i18n34.__)("Optional")})`;
23175 }
23176 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23177 ValidatedDateControl,
23178 {
23179 field,
23180 validity,
23181 inputRefs: validityTargetRef,
23182 isTouched,
23183 setIsTouched,
23184 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23185 import_components31.BaseControl,
23186 {
23187 id,
23188 className: "dataviews-controls__date",
23189 label: displayLabel,
23190 help: description,
23191 hideLabelFromVision,
23192 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23193 /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
23194 Stack,
23195 {
23196 direction: "row",
23197 gap: "sm",
23198 wrap: "wrap",
23199 justify: "flex-start",
23200 children: [
23201 DATE_PRESETS.map((preset) => {
23202 const isSelected2 = selectedPresetId === preset.id;
23203 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23204 import_components31.Button,
23205 {
23206 className: "dataviews-controls__date-preset",
23207 variant: "tertiary",
23208 isPressed: isSelected2,
23209 size: "small",
23210 disabled: disabled2,
23211 accessibleWhenDisabled: true,
23212 onClick: () => handlePresetClick(preset),
23213 children: preset.label
23214 },
23215 preset.id
23216 );
23217 }),
23218 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23219 import_components31.Button,
23220 {
23221 className: "dataviews-controls__date-preset",
23222 variant: "tertiary",
23223 isPressed: !selectedPresetId,
23224 size: "small",
23225 disabled: !!selectedPresetId || disabled2,
23226 accessibleWhenDisabled: true,
23227 children: (0, import_i18n34.__)("Custom")
23228 }
23229 )
23230 ]
23231 }
23232 ),
23233 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23234 import_components31.__experimentalInputControl,
23235 {
23236 __next40pxDefaultSize: true,
23237 ref: validityTargetRef,
23238 type: "date",
23239 label: (0, import_i18n34.__)("Date"),
23240 hideLabelFromVision: true,
23241 value,
23242 onChange: handleManualDateChange,
23243 required: !!field.isValid?.required,
23244 disabled: disabled2,
23245 min: minConstraint,
23246 max: maxConstraint
23247 }
23248 ),
23249 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23250 DateCalendar2,
23251 {
23252 style: { width: "100%" },
23253 selected: value ? parseDate(value) || void 0 : void 0,
23254 onSelect: onSelectDate,
23255 month: calendarMonth,
23256 onMonthChange: setCalendarMonth,
23257 timeZone: timezoneString || void 0,
23258 weekStartsOn,
23259 disabled: disabled2 || disabledMatchers,
23260 disableNavigation: disabled2
23261 }
23262 )
23263 ] })
23264 }
23265 )
23266 }
23267 );
23268 }
23269 function CalendarDateRangeControl({
23270 data,
23271 field,
23272 onChange,
23273 hideLabelFromVision,
23274 markWhenOptional,
23275 validity
23276 }) {
23277 const {
23278 id,
23279 label,
23280 description,
23281 getValue,
23282 setValue,
23283 isValid: isValid2,
23284 format: fieldFormat
23285 } = field;
23286 const disabled2 = field.isDisabled({ item: data, field });
23287 let value;
23288 const fieldValue = getValue({ item: data });
23289 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
23290 value = fieldValue;
23291 }
23292 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23293 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23294 const onChangeCallback = (0, import_element65.useCallback)(
23295 (newValue) => {
23296 onChange(
23297 setValue({
23298 item: data,
23299 value: newValue
23300 })
23301 );
23302 },
23303 [data, onChange, setValue]
23304 );
23305 const [selectedPresetId, setSelectedPresetId] = (0, import_element65.useState)(
23306 null
23307 );
23308 const selectedRange = (0, import_element65.useMemo)(() => {
23309 if (!value) {
23310 return { from: void 0, to: void 0 };
23311 }
23312 const [from, to] = value;
23313 return {
23314 from: parseDate(from) || void 0,
23315 to: parseDate(to) || void 0
23316 };
23317 }, [value]);
23318 const [calendarMonth, setCalendarMonth] = (0, import_element65.useState)(() => {
23319 return selectedRange.from || /* @__PURE__ */ new Date();
23320 });
23321 const [isTouched, setIsTouched] = (0, import_element65.useState)(false);
23322 const fromInputRef = (0, import_element65.useRef)(null);
23323 const toInputRef = (0, import_element65.useRef)(null);
23324 const updateDateRange = (0, import_element65.useCallback)(
23325 (fromDate, toDate2) => {
23326 if (fromDate && toDate2) {
23327 onChangeCallback([
23328 formatDate(fromDate),
23329 formatDate(toDate2)
23330 ]);
23331 } else if (!fromDate && !toDate2) {
23332 onChangeCallback(void 0);
23333 }
23334 },
23335 [onChangeCallback]
23336 );
23337 const onSelectCalendarRange = (0, import_element65.useCallback)(
23338 (newRange) => {
23339 updateDateRange(newRange?.from, newRange?.to);
23340 setSelectedPresetId(null);
23341 setIsTouched(true);
23342 },
23343 [updateDateRange]
23344 );
23345 const handlePresetClick = (0, import_element65.useCallback)(
23346 (preset) => {
23347 const [startDate, endDate] = preset.getValue();
23348 setCalendarMonth(startDate);
23349 updateDateRange(startDate, endDate);
23350 setSelectedPresetId(preset.id);
23351 setIsTouched(true);
23352 },
23353 [updateDateRange]
23354 );
23355 const handleManualDateChange = (0, import_element65.useCallback)(
23356 (fromOrTo, newValue) => {
23357 const [currentFrom, currentTo] = value || [
23358 void 0,
23359 void 0
23360 ];
23361 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
23362 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
23363 updateDateRange(updatedFrom, updatedTo);
23364 if (newValue) {
23365 const parsedDate = parseDate(newValue);
23366 if (parsedDate) {
23367 setCalendarMonth(parsedDate);
23368 }
23369 }
23370 setSelectedPresetId(null);
23371 setIsTouched(true);
23372 },
23373 [value, updateDateRange]
23374 );
23375 const { timezone } = (0, import_date4.getSettings)();
23376 let displayLabel = label;
23377 if (field.isValid?.required && !markWhenOptional) {
23378 displayLabel = `${label} (${(0, import_i18n34.__)("Required")})`;
23379 } else if (!field.isValid?.required && markWhenOptional) {
23380 displayLabel = `${label} (${(0, import_i18n34.__)("Optional")})`;
23381 }
23382 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23383 ValidatedDateControl,
23384 {
23385 field,
23386 validity,
23387 inputRefs: [fromInputRef, toInputRef],
23388 isTouched,
23389 setIsTouched,
23390 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23391 import_components31.BaseControl,
23392 {
23393 id,
23394 className: "dataviews-controls__date",
23395 label: displayLabel,
23396 help: description,
23397 hideLabelFromVision,
23398 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23399 /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
23400 Stack,
23401 {
23402 direction: "row",
23403 gap: "sm",
23404 wrap: "wrap",
23405 justify: "flex-start",
23406 children: [
23407 DATE_RANGE_PRESETS.map((preset) => {
23408 const isSelected2 = selectedPresetId === preset.id;
23409 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23410 import_components31.Button,
23411 {
23412 className: "dataviews-controls__date-preset",
23413 variant: "tertiary",
23414 isPressed: isSelected2,
23415 size: "small",
23416 disabled: disabled2,
23417 accessibleWhenDisabled: true,
23418 onClick: () => handlePresetClick(preset),
23419 children: preset.label
23420 },
23421 preset.id
23422 );
23423 }),
23424 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23425 import_components31.Button,
23426 {
23427 className: "dataviews-controls__date-preset",
23428 variant: "tertiary",
23429 isPressed: !selectedPresetId,
23430 size: "small",
23431 accessibleWhenDisabled: true,
23432 disabled: !!selectedPresetId || disabled2,
23433 children: (0, import_i18n34.__)("Custom")
23434 }
23435 )
23436 ]
23437 }
23438 ),
23439 /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
23440 Stack,
23441 {
23442 direction: "row",
23443 gap: "sm",
23444 justify: "space-between",
23445 className: "dataviews-controls__date-range-inputs",
23446 children: [
23447 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23448 import_components31.__experimentalInputControl,
23449 {
23450 __next40pxDefaultSize: true,
23451 ref: fromInputRef,
23452 type: "date",
23453 label: (0, import_i18n34.__)("From"),
23454 hideLabelFromVision: true,
23455 value: value?.[0],
23456 onChange: (newValue) => handleManualDateChange("from", newValue),
23457 required: !!field.isValid?.required,
23458 disabled: disabled2,
23459 min: minConstraint,
23460 max: maxConstraint
23461 }
23462 ),
23463 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23464 import_components31.__experimentalInputControl,
23465 {
23466 __next40pxDefaultSize: true,
23467 ref: toInputRef,
23468 type: "date",
23469 label: (0, import_i18n34.__)("To"),
23470 hideLabelFromVision: true,
23471 value: value?.[1],
23472 onChange: (newValue) => handleManualDateChange("to", newValue),
23473 required: !!field.isValid?.required,
23474 disabled: disabled2,
23475 min: minConstraint,
23476 max: maxConstraint
23477 }
23478 )
23479 ]
23480 }
23481 ),
23482 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23483 DateRangeCalendar,
23484 {
23485 style: { width: "100%" },
23486 selected: selectedRange,
23487 onSelect: onSelectCalendarRange,
23488 month: calendarMonth,
23489 onMonthChange: setCalendarMonth,
23490 timeZone: timezone.string || void 0,
23491 weekStartsOn,
23492 disabled: disabled2 || disabledMatchers
23493 }
23494 )
23495 ] })
23496 }
23497 )
23498 }
23499 );
23500 }
23501 function DateControl({
23502 data,
23503 field,
23504 onChange,
23505 hideLabelFromVision,
23506 markWhenOptional,
23507 operator,
23508 validity
23509 }) {
23510 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
23511 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23512 RelativeDateControl,
23513 {
23514 className: "dataviews-controls__date",
23515 data,
23516 field,
23517 onChange,
23518 hideLabelFromVision,
23519 operator
23520 }
23521 );
23522 }
23523 if (operator === OPERATOR_BETWEEN) {
23524 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23525 CalendarDateRangeControl,
23526 {
23527 data,
23528 field,
23529 onChange,
23530 hideLabelFromVision,
23531 markWhenOptional,
23532 validity
23533 }
23534 );
23535 }
23536 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23537 CalendarDateControl,
23538 {
23539 data,
23540 field,
23541 onChange,
23542 hideLabelFromVision,
23543 markWhenOptional,
23544 validity
23545 }
23546 );
23547 }
23548
23549 // packages/dataviews/build-module/components/dataform-controls/select.mjs
23550 var import_components32 = __toESM(require_components(), 1);
23551 var import_element66 = __toESM(require_element(), 1);
23552 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
23553 var { ValidatedSelectControl } = unlock2(import_components32.privateApis);
23554 function Select({
23555 data,
23556 field,
23557 onChange,
23558 hideLabelFromVision,
23559 markWhenOptional,
23560 validity
23561 }) {
23562 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
23563 const disabled2 = field.isDisabled({ item: data, field });
23564 const isMultiple = type === "array";
23565 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
23566 const onChangeControl = (0, import_element66.useCallback)(
23567 (newValue) => onChange(setValue({ item: data, value: newValue })),
23568 [data, onChange, setValue]
23569 );
23570 const { elements, isLoading } = useElements({
23571 elements: field.elements,
23572 getElements: field.getElements
23573 });
23574 if (isLoading) {
23575 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components32.Spinner, {});
23576 }
23577 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23578 ValidatedSelectControl,
23579 {
23580 required: !!field.isValid?.required,
23581 markWhenOptional,
23582 customValidity: getCustomValidity(isValid2, validity),
23583 label,
23584 value,
23585 help: description,
23586 options: elements,
23587 onChange: onChangeControl,
23588 __next40pxDefaultSize: true,
23589 hideLabelFromVision,
23590 multiple: isMultiple,
23591 disabled: disabled2
23592 }
23593 );
23594 }
23595
23596 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
23597 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
23598 var ELEMENTS_THRESHOLD = 10;
23599 function AdaptiveSelect(props) {
23600 const { field } = props;
23601 const { elements } = useElements({
23602 elements: field.elements,
23603 getElements: field.getElements
23604 });
23605 if (elements.length >= ELEMENTS_THRESHOLD) {
23606 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(Combobox3, { ...props });
23607 }
23608 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(Select, { ...props });
23609 }
23610
23611 // packages/dataviews/build-module/components/dataform-controls/email.mjs
23612 var import_components34 = __toESM(require_components(), 1);
23613
23614 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
23615 var import_components33 = __toESM(require_components(), 1);
23616 var import_element67 = __toESM(require_element(), 1);
23617 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
23618 var { ValidatedInputControl: ValidatedInputControl2 } = unlock2(import_components33.privateApis);
23619 function ValidatedText({
23620 data,
23621 field,
23622 onChange,
23623 hideLabelFromVision,
23624 markWhenOptional,
23625 type,
23626 prefix,
23627 suffix,
23628 validity
23629 }) {
23630 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
23631 const value = getValue({ item: data });
23632 const disabled2 = field.isDisabled({ item: data, field });
23633 const onChangeControl = (0, import_element67.useCallback)(
23634 (newValue) => onChange(
23635 setValue({
23636 item: data,
23637 value: newValue
23638 })
23639 ),
23640 [data, setValue, onChange]
23641 );
23642 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
23643 ValidatedInputControl2,
23644 {
23645 required: !!isValid2.required,
23646 markWhenOptional,
23647 customValidity: getCustomValidity(isValid2, validity),
23648 label,
23649 placeholder,
23650 value: value ?? "",
23651 help: description,
23652 onChange: onChangeControl,
23653 hideLabelFromVision,
23654 type,
23655 prefix,
23656 suffix,
23657 disabled: disabled2,
23658 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
23659 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
23660 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
23661 __next40pxDefaultSize: true
23662 }
23663 );
23664 }
23665
23666 // packages/dataviews/build-module/components/dataform-controls/email.mjs
23667 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
23668 function Email({
23669 data,
23670 field,
23671 onChange,
23672 hideLabelFromVision,
23673 markWhenOptional,
23674 validity
23675 }) {
23676 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
23677 ValidatedText,
23678 {
23679 ...{
23680 data,
23681 field,
23682 onChange,
23683 hideLabelFromVision,
23684 markWhenOptional,
23685 validity,
23686 type: "email",
23687 prefix: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components34.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components34.Icon, { icon: envelope_default }) })
23688 }
23689 }
23690 );
23691 }
23692
23693 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
23694 var import_components35 = __toESM(require_components(), 1);
23695 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
23696 function Telephone({
23697 data,
23698 field,
23699 onChange,
23700 hideLabelFromVision,
23701 markWhenOptional,
23702 validity
23703 }) {
23704 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
23705 ValidatedText,
23706 {
23707 ...{
23708 data,
23709 field,
23710 onChange,
23711 hideLabelFromVision,
23712 markWhenOptional,
23713 validity,
23714 type: "tel",
23715 prefix: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components35.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components35.Icon, { icon: mobile_default }) })
23716 }
23717 }
23718 );
23719 }
23720
23721 // packages/dataviews/build-module/components/dataform-controls/url.mjs
23722 var import_components36 = __toESM(require_components(), 1);
23723 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
23724 function Url({
23725 data,
23726 field,
23727 onChange,
23728 hideLabelFromVision,
23729 markWhenOptional,
23730 validity
23731 }) {
23732 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
23733 ValidatedText,
23734 {
23735 ...{
23736 data,
23737 field,
23738 onChange,
23739 hideLabelFromVision,
23740 markWhenOptional,
23741 validity,
23742 type: "url",
23743 prefix: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components36.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components36.Icon, { icon: link_default }) })
23744 }
23745 }
23746 );
23747 }
23748
23749 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
23750 var import_components37 = __toESM(require_components(), 1);
23751 var import_element68 = __toESM(require_element(), 1);
23752 var import_i18n35 = __toESM(require_i18n(), 1);
23753 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
23754 var { ValidatedNumberControl } = unlock2(import_components37.privateApis);
23755 function toNumberOrEmpty(value) {
23756 if (value === "" || value === void 0) {
23757 return "";
23758 }
23759 const number = Number(value);
23760 return Number.isFinite(number) ? number : "";
23761 }
23762 function BetweenControls({
23763 value,
23764 onChange,
23765 hideLabelFromVision,
23766 step
23767 }) {
23768 const [min2 = "", max2 = ""] = value;
23769 const onChangeMin = (0, import_element68.useCallback)(
23770 (newValue) => onChange([toNumberOrEmpty(newValue), max2]),
23771 [onChange, max2]
23772 );
23773 const onChangeMax = (0, import_element68.useCallback)(
23774 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]),
23775 [onChange, min2]
23776 );
23777 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
23778 import_components37.BaseControl,
23779 {
23780 help: (0, import_i18n35.__)("The max. value must be greater than the min. value."),
23781 children: /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(import_components37.Flex, { direction: "row", gap: 4, children: [
23782 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
23783 import_components37.__experimentalNumberControl,
23784 {
23785 label: (0, import_i18n35.__)("Min."),
23786 value: min2,
23787 max: max2 ? Number(max2) - step : void 0,
23788 onChange: onChangeMin,
23789 __next40pxDefaultSize: true,
23790 hideLabelFromVision,
23791 step
23792 }
23793 ),
23794 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
23795 import_components37.__experimentalNumberControl,
23796 {
23797 label: (0, import_i18n35.__)("Max."),
23798 value: max2,
23799 min: min2 ? Number(min2) + step : void 0,
23800 onChange: onChangeMax,
23801 __next40pxDefaultSize: true,
23802 hideLabelFromVision,
23803 step
23804 }
23805 )
23806 ] })
23807 }
23808 );
23809 }
23810 function ValidatedNumber({
23811 data,
23812 field,
23813 onChange,
23814 hideLabelFromVision,
23815 markWhenOptional,
23816 operator,
23817 validity
23818 }) {
23819 const decimals = field.format?.decimals ?? 0;
23820 const step = Math.pow(10, Math.abs(decimals) * -1);
23821 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23822 const value = getValue({ item: data }) ?? "";
23823 const disabled2 = field.isDisabled({ item: data, field });
23824 const onChangeControl = (0, import_element68.useCallback)(
23825 (newValue) => {
23826 onChange(
23827 setValue({
23828 item: data,
23829 // Do not convert an empty string or undefined to a number,
23830 // otherwise there's a mismatch between the UI control (empty)
23831 // and the data relied by onChange (0).
23832 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
23833 })
23834 );
23835 },
23836 [data, onChange, setValue]
23837 );
23838 const onChangeBetweenControls = (0, import_element68.useCallback)(
23839 (newValue) => {
23840 onChange(
23841 setValue({
23842 item: data,
23843 value: newValue
23844 })
23845 );
23846 },
23847 [data, onChange, setValue]
23848 );
23849 if (operator === OPERATOR_BETWEEN) {
23850 let valueBetween = ["", ""];
23851 if (Array.isArray(value) && value.length === 2 && value.every(
23852 (element) => typeof element === "number" || element === ""
23853 )) {
23854 valueBetween = value;
23855 }
23856 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
23857 BetweenControls,
23858 {
23859 value: valueBetween,
23860 onChange: onChangeBetweenControls,
23861 hideLabelFromVision,
23862 step
23863 }
23864 );
23865 }
23866 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
23867 ValidatedNumberControl,
23868 {
23869 required: !!isValid2.required,
23870 markWhenOptional,
23871 customValidity: getCustomValidity(isValid2, validity),
23872 label,
23873 help: description,
23874 value,
23875 onChange: onChangeControl,
23876 __next40pxDefaultSize: true,
23877 hideLabelFromVision,
23878 step,
23879 min: isValid2.min ? isValid2.min.constraint : void 0,
23880 max: isValid2.max ? isValid2.max.constraint : void 0,
23881 disabled: disabled2
23882 }
23883 );
23884 }
23885
23886 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
23887 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
23888 function Integer(props) {
23889 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(ValidatedNumber, { ...props });
23890 }
23891
23892 // packages/dataviews/build-module/components/dataform-controls/number.mjs
23893 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
23894 function Number2(props) {
23895 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(ValidatedNumber, { ...props });
23896 }
23897
23898 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
23899 var import_components38 = __toESM(require_components(), 1);
23900 var import_element69 = __toESM(require_element(), 1);
23901 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
23902 var { ValidatedRadioControl } = unlock2(import_components38.privateApis);
23903 function Radio({
23904 data,
23905 field,
23906 onChange,
23907 hideLabelFromVision,
23908 markWhenOptional,
23909 validity
23910 }) {
23911 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23912 const disabled2 = field.isDisabled({ item: data, field });
23913 const { elements, isLoading } = useElements({
23914 elements: field.elements,
23915 getElements: field.getElements
23916 });
23917 const value = getValue({ item: data });
23918 const onChangeControl = (0, import_element69.useCallback)(
23919 (newValue) => onChange(setValue({ item: data, value: newValue })),
23920 [data, onChange, setValue]
23921 );
23922 if (isLoading) {
23923 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(import_components38.Spinner, {});
23924 }
23925 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
23926 ValidatedRadioControl,
23927 {
23928 required: !!field.isValid?.required,
23929 markWhenOptional,
23930 customValidity: getCustomValidity(isValid2, validity),
23931 label,
23932 help: description,
23933 onChange: onChangeControl,
23934 options: elements,
23935 selected: value,
23936 hideLabelFromVision,
23937 disabled: disabled2
23938 }
23939 );
23940 }
23941
23942 // packages/dataviews/build-module/components/dataform-controls/text.mjs
23943 var import_element70 = __toESM(require_element(), 1);
23944 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
23945 function Text3({
23946 data,
23947 field,
23948 onChange,
23949 hideLabelFromVision,
23950 markWhenOptional,
23951 config,
23952 validity
23953 }) {
23954 const { prefix, suffix } = config || {};
23955 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
23956 ValidatedText,
23957 {
23958 ...{
23959 data,
23960 field,
23961 onChange,
23962 hideLabelFromVision,
23963 markWhenOptional,
23964 validity,
23965 prefix: prefix ? (0, import_element70.createElement)(prefix) : void 0,
23966 suffix: suffix ? (0, import_element70.createElement)(suffix) : void 0
23967 }
23968 }
23969 );
23970 }
23971
23972 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
23973 var import_components39 = __toESM(require_components(), 1);
23974 var import_element71 = __toESM(require_element(), 1);
23975 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
23976 var { ValidatedToggleControl } = unlock2(import_components39.privateApis);
23977 function Toggle({
23978 field,
23979 onChange,
23980 data,
23981 hideLabelFromVision,
23982 markWhenOptional,
23983 validity
23984 }) {
23985 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23986 const disabled2 = field.isDisabled({ item: data, field });
23987 const onChangeControl = (0, import_element71.useCallback)(() => {
23988 onChange(
23989 setValue({ item: data, value: !getValue({ item: data }) })
23990 );
23991 }, [onChange, setValue, data, getValue]);
23992 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
23993 ValidatedToggleControl,
23994 {
23995 required: !!isValid2.required,
23996 markWhenOptional,
23997 customValidity: getCustomValidity(isValid2, validity),
23998 hidden: hideLabelFromVision,
23999 label,
24000 help: description,
24001 checked: getValue({ item: data }),
24002 onChange: onChangeControl,
24003 disabled: disabled2
24004 }
24005 );
24006 }
24007
24008 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
24009 var import_components40 = __toESM(require_components(), 1);
24010 var import_element72 = __toESM(require_element(), 1);
24011 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
24012 var { ValidatedTextareaControl } = unlock2(import_components40.privateApis);
24013 function Textarea({
24014 data,
24015 field,
24016 onChange,
24017 hideLabelFromVision,
24018 markWhenOptional,
24019 config,
24020 validity
24021 }) {
24022 const { rows = 4 } = config || {};
24023 const disabled2 = field.isDisabled({ item: data, field });
24024 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
24025 const value = field.getValue({ item: data });
24026 const onChangeControl = (0, import_element72.useCallback)(
24027 (newValue) => onChange(setValue({ item: data, value: newValue })),
24028 [data, onChange, setValue]
24029 );
24030 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24031 ValidatedTextareaControl,
24032 {
24033 required: !!isValid2.required,
24034 markWhenOptional,
24035 customValidity: getCustomValidity(isValid2, validity),
24036 label,
24037 placeholder,
24038 value: value ?? "",
24039 help: description,
24040 onChange: onChangeControl,
24041 rows,
24042 disabled: disabled2,
24043 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
24044 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
24045 __next40pxDefaultSize: true,
24046 hideLabelFromVision
24047 }
24048 );
24049 }
24050
24051 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
24052 var import_components41 = __toESM(require_components(), 1);
24053 var import_element73 = __toESM(require_element(), 1);
24054 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
24055 var { ValidatedToggleGroupControl } = unlock2(import_components41.privateApis);
24056 function ToggleGroup({
24057 data,
24058 field,
24059 onChange,
24060 hideLabelFromVision,
24061 markWhenOptional,
24062 validity
24063 }) {
24064 const { getValue, setValue, isValid: isValid2 } = field;
24065 const disabled2 = field.isDisabled({ item: data, field });
24066 const value = getValue({ item: data });
24067 const onChangeControl = (0, import_element73.useCallback)(
24068 (newValue) => onChange(setValue({ item: data, value: newValue })),
24069 [data, onChange, setValue]
24070 );
24071 const { elements, isLoading } = useElements({
24072 elements: field.elements,
24073 getElements: field.getElements
24074 });
24075 if (isLoading) {
24076 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_components41.Spinner, {});
24077 }
24078 if (elements.length === 0) {
24079 return null;
24080 }
24081 const selectedOption = elements.find((el) => el.value === value);
24082 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
24083 ValidatedToggleGroupControl,
24084 {
24085 required: !!field.isValid?.required,
24086 markWhenOptional,
24087 customValidity: getCustomValidity(isValid2, validity),
24088 __next40pxDefaultSize: true,
24089 isBlock: true,
24090 label: field.label,
24091 help: selectedOption?.description || field.description,
24092 onChange: onChangeControl,
24093 value,
24094 hideLabelFromVision,
24095 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
24096 import_components41.__experimentalToggleGroupControlOption,
24097 {
24098 label: el.label,
24099 value: el.value,
24100 disabled: disabled2
24101 },
24102 el.value
24103 ))
24104 }
24105 );
24106 }
24107
24108 // packages/dataviews/build-module/components/dataform-controls/array.mjs
24109 var import_components42 = __toESM(require_components(), 1);
24110 var import_element74 = __toESM(require_element(), 1);
24111 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
24112 var { ValidatedFormTokenField } = unlock2(import_components42.privateApis);
24113 function ArrayControl({
24114 data,
24115 field,
24116 onChange,
24117 hideLabelFromVision,
24118 markWhenOptional,
24119 validity
24120 }) {
24121 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
24122 const value = getValue({ item: data });
24123 const disabled2 = field.isDisabled({ item: data, field });
24124 const { elements, isLoading } = useElements({
24125 elements: field.elements,
24126 getElements: field.getElements
24127 });
24128 const arrayValueAsElements = (0, import_element74.useMemo)(
24129 () => Array.isArray(value) ? value.map((token) => {
24130 const element = elements?.find(
24131 (suggestion) => suggestion.value === token
24132 );
24133 return element || { value: token, label: token };
24134 }) : [],
24135 [value, elements]
24136 );
24137 const onChangeControl = (0, import_element74.useCallback)(
24138 (tokens) => {
24139 const valueTokens = tokens.map((token) => {
24140 if (typeof token === "object" && "value" in token) {
24141 return token.value;
24142 }
24143 return token;
24144 });
24145 onChange(setValue({ item: data, value: valueTokens }));
24146 },
24147 [onChange, setValue, data]
24148 );
24149 if (isLoading) {
24150 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_components42.Spinner, {});
24151 }
24152 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24153 ValidatedFormTokenField,
24154 {
24155 required: !!isValid2?.required,
24156 markWhenOptional,
24157 customValidity: getCustomValidity(isValid2, validity),
24158 label: hideLabelFromVision ? void 0 : label,
24159 value: arrayValueAsElements,
24160 onChange: onChangeControl,
24161 placeholder,
24162 suggestions: elements?.map((element) => element.value),
24163 disabled: disabled2,
24164 __experimentalValidateInput: (token) => {
24165 if (field.isValid?.elements && elements) {
24166 return elements.some(
24167 (element) => element.value === token || element.label === token
24168 );
24169 }
24170 return true;
24171 },
24172 __experimentalExpandOnFocus: elements && elements.length > 0,
24173 help: description ?? (field.isValid?.elements ? "" : void 0),
24174 displayTransform: (token) => {
24175 if (typeof token === "object" && "label" in token) {
24176 return token.label;
24177 }
24178 if (typeof token === "string" && elements) {
24179 const element = elements.find(
24180 (el) => el.value === token
24181 );
24182 return element?.label || token;
24183 }
24184 return token;
24185 },
24186 __experimentalRenderItem: ({ item }) => {
24187 if (typeof item === "string" && elements) {
24188 const element = elements.find(
24189 (el) => el.value === item
24190 );
24191 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { children: element?.label || item });
24192 }
24193 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { children: item });
24194 }
24195 }
24196 );
24197 }
24198
24199 // node_modules/colord/index.mjs
24200 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
24201 var t = function(r3) {
24202 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
24203 };
24204 var n = function(r3, t2, n2) {
24205 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
24206 };
24207 var e = function(r3, t2, n2) {
24208 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
24209 };
24210 var u = function(r3) {
24211 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
24212 };
24213 var a = function(r3) {
24214 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
24215 };
24216 var o = function(r3) {
24217 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
24218 };
24219 var i = /^#([0-9a-f]{3,8})$/i;
24220 var s = function(r3) {
24221 var t2 = r3.toString(16);
24222 return t2.length < 2 ? "0" + t2 : t2;
24223 };
24224 var h = function(r3) {
24225 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;
24226 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
24227 };
24228 var b = function(r3) {
24229 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
24230 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
24231 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;
24232 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 };
24233 };
24234 var g = function(r3) {
24235 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
24236 };
24237 var d = function(r3) {
24238 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
24239 };
24240 var f = function(r3) {
24241 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 }));
24242 var t2, n2, e2;
24243 };
24244 var c = function(r3) {
24245 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 };
24246 var t2, n2, e2, u2;
24247 };
24248 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24249 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24250 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24251 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24252 var y = { string: [[function(r3) {
24253 var t2 = i.exec(r3);
24254 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;
24255 }, "hex"], [function(r3) {
24256 var t2 = v.exec(r3) || m.exec(r3);
24257 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;
24258 }, "rgb"], [function(t2) {
24259 var n2 = l.exec(t2) || p.exec(t2);
24260 if (!n2) return null;
24261 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) });
24262 return f(a2);
24263 }, "hsl"]], object: [[function(r3) {
24264 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
24265 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
24266 }, "rgb"], [function(r3) {
24267 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
24268 if (!t(n2) || !t(e2) || !t(u2)) return null;
24269 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
24270 return f(i2);
24271 }, "hsl"], [function(r3) {
24272 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
24273 if (!t(n2) || !t(a2) || !t(o2)) return null;
24274 var h2 = (function(r4) {
24275 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
24276 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
24277 return b(h2);
24278 }, "hsv"]] };
24279 var N = function(r3, t2) {
24280 for (var n2 = 0; n2 < t2.length; n2++) {
24281 var e2 = t2[n2][0](r3);
24282 if (e2) return [e2, t2[n2][1]];
24283 }
24284 return [null, void 0];
24285 };
24286 var x = function(r3) {
24287 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
24288 };
24289 var M = function(r3, t2) {
24290 var n2 = c(r3);
24291 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
24292 };
24293 var H = function(r3) {
24294 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
24295 };
24296 var $ = function(r3, t2) {
24297 var n2 = c(r3);
24298 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
24299 };
24300 var j = (function() {
24301 function r3(r4) {
24302 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
24303 }
24304 return r3.prototype.isValid = function() {
24305 return null !== this.parsed;
24306 }, r3.prototype.brightness = function() {
24307 return n(H(this.rgba), 2);
24308 }, r3.prototype.isDark = function() {
24309 return H(this.rgba) < 0.5;
24310 }, r3.prototype.isLight = function() {
24311 return H(this.rgba) >= 0.5;
24312 }, r3.prototype.toHex = function() {
24313 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;
24314 var r4, t2, e2, u2, a2, i2;
24315 }, r3.prototype.toRgb = function() {
24316 return o(this.rgba);
24317 }, r3.prototype.toRgbString = function() {
24318 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 + ")";
24319 var r4, t2, n2, e2, u2;
24320 }, r3.prototype.toHsl = function() {
24321 return d(c(this.rgba));
24322 }, r3.prototype.toHslString = function() {
24323 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 + "%)";
24324 var r4, t2, n2, e2, u2;
24325 }, r3.prototype.toHsv = function() {
24326 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
24327 var r4;
24328 }, r3.prototype.invert = function() {
24329 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
24330 var r4;
24331 }, r3.prototype.saturate = function(r4) {
24332 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
24333 }, r3.prototype.desaturate = function(r4) {
24334 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
24335 }, r3.prototype.grayscale = function() {
24336 return w(M(this.rgba, -1));
24337 }, r3.prototype.lighten = function(r4) {
24338 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
24339 }, r3.prototype.darken = function(r4) {
24340 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
24341 }, r3.prototype.rotate = function(r4) {
24342 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
24343 }, r3.prototype.alpha = function(r4) {
24344 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
24345 var t2;
24346 }, r3.prototype.hue = function(r4) {
24347 var t2 = c(this.rgba);
24348 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
24349 }, r3.prototype.isEqual = function(r4) {
24350 return this.toHex() === w(r4).toHex();
24351 }, r3;
24352 })();
24353 var w = function(r3) {
24354 return r3 instanceof j ? r3 : new j(r3);
24355 };
24356
24357 // packages/dataviews/build-module/components/dataform-controls/color.mjs
24358 var import_components43 = __toESM(require_components(), 1);
24359 var import_element75 = __toESM(require_element(), 1);
24360 var import_i18n36 = __toESM(require_i18n(), 1);
24361 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
24362 var { ValidatedInputControl: ValidatedInputControl3 } = unlock2(import_components43.privateApis);
24363 var ColorPickerDropdown = ({
24364 color,
24365 onColorChange,
24366 disabled: disabled2
24367 }) => {
24368 const validColor = color && w(color).isValid() ? color : "#ffffff";
24369 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24370 import_components43.Dropdown,
24371 {
24372 className: "dataviews-controls__color-picker-dropdown",
24373 popoverProps: { resize: false },
24374 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24375 import_components43.Button,
24376 {
24377 onClick: onToggle,
24378 "aria-label": (0, import_i18n36.__)("Open color picker"),
24379 size: "small",
24380 disabled: disabled2,
24381 accessibleWhenDisabled: true,
24382 icon: () => /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_components43.ColorIndicator, { colorValue: validColor })
24383 }
24384 ),
24385 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_components43.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24386 import_components43.ColorPicker,
24387 {
24388 color: validColor,
24389 onChange: onColorChange,
24390 enableAlpha: true
24391 }
24392 ) })
24393 }
24394 );
24395 };
24396 function Color({
24397 data,
24398 field,
24399 onChange,
24400 hideLabelFromVision,
24401 markWhenOptional,
24402 validity
24403 }) {
24404 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
24405 const disabled2 = field.isDisabled({ item: data, field });
24406 const value = field.getValue({ item: data }) || "";
24407 const handleColorChange = (0, import_element75.useCallback)(
24408 (newColor) => {
24409 onChange(setValue({ item: data, value: newColor }));
24410 },
24411 [data, onChange, setValue]
24412 );
24413 const handleInputChange = (0, import_element75.useCallback)(
24414 (newValue) => {
24415 onChange(setValue({ item: data, value: newValue || "" }));
24416 },
24417 [data, onChange, setValue]
24418 );
24419 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24420 ValidatedInputControl3,
24421 {
24422 required: !!field.isValid?.required,
24423 markWhenOptional,
24424 customValidity: getCustomValidity(isValid2, validity),
24425 label,
24426 placeholder,
24427 value,
24428 help: description,
24429 onChange: handleInputChange,
24430 hideLabelFromVision,
24431 type: "text",
24432 disabled: disabled2,
24433 prefix: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_components43.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24434 ColorPickerDropdown,
24435 {
24436 color: value,
24437 onColorChange: handleColorChange,
24438 disabled: disabled2
24439 }
24440 ) })
24441 }
24442 );
24443 }
24444
24445 // packages/dataviews/build-module/components/dataform-controls/password.mjs
24446 var import_components44 = __toESM(require_components(), 1);
24447 var import_element76 = __toESM(require_element(), 1);
24448 var import_i18n37 = __toESM(require_i18n(), 1);
24449 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
24450 function Password({
24451 data,
24452 field,
24453 onChange,
24454 hideLabelFromVision,
24455 markWhenOptional,
24456 validity
24457 }) {
24458 const [isVisible2, setIsVisible] = (0, import_element76.useState)(false);
24459 const disabled2 = field.isDisabled({ item: data, field });
24460 const toggleVisibility = (0, import_element76.useCallback)(() => {
24461 setIsVisible((prev) => !prev);
24462 }, []);
24463 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
24464 ValidatedText,
24465 {
24466 ...{
24467 data,
24468 field,
24469 onChange,
24470 hideLabelFromVision,
24471 markWhenOptional,
24472 validity,
24473 type: isVisible2 ? "text" : "password",
24474 suffix: /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(import_components44.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
24475 import_components44.Button,
24476 {
24477 icon: isVisible2 ? unseen_default : seen_default,
24478 onClick: toggleVisibility,
24479 size: "small",
24480 label: isVisible2 ? (0, import_i18n37.__)("Hide password") : (0, import_i18n37.__)("Show password"),
24481 disabled: disabled2,
24482 accessibleWhenDisabled: true
24483 }
24484 ) })
24485 }
24486 }
24487 );
24488 }
24489
24490 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
24491 function hasElements(field) {
24492 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
24493 }
24494
24495 // packages/dataviews/build-module/components/dataform-controls/index.mjs
24496 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
24497 var FORM_CONTROLS = {
24498 adaptiveSelect: AdaptiveSelect,
24499 array: ArrayControl,
24500 checkbox: Checkbox,
24501 color: Color,
24502 combobox: Combobox3,
24503 datetime: DateTime,
24504 date: DateControl,
24505 email: Email,
24506 telephone: Telephone,
24507 url: Url,
24508 integer: Integer,
24509 number: Number2,
24510 password: Password,
24511 radio: Radio,
24512 select: Select,
24513 text: Text3,
24514 toggle: Toggle,
24515 textarea: Textarea,
24516 toggleGroup: ToggleGroup
24517 };
24518 function isEditConfig(value) {
24519 return value && typeof value === "object" && typeof value.control === "string";
24520 }
24521 function createConfiguredControl(config) {
24522 const { control, ...controlConfig } = config;
24523 const BaseControlType = getControlByType(control);
24524 if (BaseControlType === null) {
24525 return null;
24526 }
24527 return function ConfiguredControl(props) {
24528 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(BaseControlType, { ...props, config: controlConfig });
24529 };
24530 }
24531 function getControl(field, fallback) {
24532 if (typeof field.Edit === "function") {
24533 return field.Edit;
24534 }
24535 if (typeof field.Edit === "string") {
24536 return getControlByType(field.Edit);
24537 }
24538 if (isEditConfig(field.Edit)) {
24539 return createConfiguredControl(field.Edit);
24540 }
24541 if (hasElements(field) && field.type !== "array") {
24542 return getControlByType("adaptiveSelect");
24543 }
24544 if (fallback === null) {
24545 return null;
24546 }
24547 return getControlByType(fallback);
24548 }
24549 function getControlByType(type) {
24550 if (Object.keys(FORM_CONTROLS).includes(type)) {
24551 return FORM_CONTROLS[type];
24552 }
24553 return null;
24554 }
24555
24556 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
24557 function getFilterBy(field, defaultOperators, validOperators) {
24558 if (field.filterBy === false) {
24559 return false;
24560 }
24561 const operators = field.filterBy?.operators?.filter(
24562 (op) => validOperators.includes(op)
24563 ) ?? defaultOperators;
24564 if (operators.length === 0) {
24565 return false;
24566 }
24567 return {
24568 isPrimary: !!field.filterBy?.isPrimary,
24569 operators
24570 };
24571 }
24572 var get_filter_by_default = getFilterBy;
24573
24574 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
24575 var getValueFromId = (id) => ({ item }) => {
24576 const path = id.split(".");
24577 let value = item;
24578 for (const segment of path) {
24579 if (value.hasOwnProperty(segment)) {
24580 value = value[segment];
24581 } else {
24582 value = void 0;
24583 }
24584 }
24585 return value;
24586 };
24587 var get_value_from_id_default = getValueFromId;
24588
24589 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
24590 var setValueFromId = (id) => ({ value }) => {
24591 const path = id.split(".");
24592 const result = {};
24593 let current = result;
24594 for (const segment of path.slice(0, -1)) {
24595 current[segment] = {};
24596 current = current[segment];
24597 }
24598 current[path.at(-1)] = value;
24599 return result;
24600 };
24601 var set_value_from_id_default = setValueFromId;
24602
24603 // packages/dataviews/build-module/field-types/email.mjs
24604 var import_i18n38 = __toESM(require_i18n(), 1);
24605
24606 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
24607 function RenderFromElements({
24608 item,
24609 field
24610 }) {
24611 const { elements, isLoading } = useElements({
24612 elements: field.elements,
24613 getElements: field.getElements
24614 });
24615 const value = field.getValue({ item });
24616 if (isLoading) {
24617 return value;
24618 }
24619 if (elements.length === 0) {
24620 return value;
24621 }
24622 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
24623 }
24624
24625 // packages/dataviews/build-module/field-types/utils/render-default.mjs
24626 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
24627 function render({
24628 item,
24629 field
24630 }) {
24631 if (field.hasElements) {
24632 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(RenderFromElements, { item, field });
24633 }
24634 return field.getValueFormatted({ item, field });
24635 }
24636
24637 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
24638 var sort_text_default = (a2, b2, direction) => {
24639 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
24640 };
24641
24642 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
24643 function isValidRequired(item, field) {
24644 const value = field.getValue({ item });
24645 return ![void 0, "", null].includes(value);
24646 }
24647
24648 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
24649 function isValidMinLength(item, field) {
24650 if (typeof field.isValid.minLength?.constraint !== "number") {
24651 return false;
24652 }
24653 const value = field.getValue({ item });
24654 if ([void 0, "", null].includes(value)) {
24655 return true;
24656 }
24657 return String(value).length >= field.isValid.minLength.constraint;
24658 }
24659
24660 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
24661 function isValidMaxLength(item, field) {
24662 if (typeof field.isValid.maxLength?.constraint !== "number") {
24663 return false;
24664 }
24665 const value = field.getValue({ item });
24666 if ([void 0, "", null].includes(value)) {
24667 return true;
24668 }
24669 return String(value).length <= field.isValid.maxLength.constraint;
24670 }
24671
24672 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
24673 function isValidPattern(item, field) {
24674 if (field.isValid.pattern?.constraint === void 0) {
24675 return true;
24676 }
24677 try {
24678 const regexp = new RegExp(field.isValid.pattern.constraint);
24679 const value = field.getValue({ item });
24680 if ([void 0, "", null].includes(value)) {
24681 return true;
24682 }
24683 return regexp.test(String(value));
24684 } catch {
24685 return false;
24686 }
24687 }
24688
24689 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
24690 function isValidElements(item, field) {
24691 const elements = field.elements ?? [];
24692 const validValues = elements.map((el) => el.value);
24693 if (validValues.length === 0) {
24694 return true;
24695 }
24696 const value = field.getValue({ item });
24697 return [].concat(value).every((v2) => validValues.includes(v2));
24698 }
24699
24700 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
24701 function getValueFormatted({
24702 item,
24703 field
24704 }) {
24705 return field.getValue({ item });
24706 }
24707 var get_value_formatted_default_default = getValueFormatted;
24708
24709 // packages/dataviews/build-module/field-types/email.mjs
24710 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])?)*$/;
24711 function isValidCustom(item, field) {
24712 const value = field.getValue({ item });
24713 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
24714 return (0, import_i18n38.__)("Value must be a valid email address.");
24715 }
24716 return null;
24717 }
24718 var email_default = {
24719 type: "email",
24720 render,
24721 Edit: "email",
24722 sort: sort_text_default,
24723 enableSorting: true,
24724 enableGlobalSearch: false,
24725 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24726 validOperators: [
24727 OPERATOR_IS,
24728 OPERATOR_IS_NOT,
24729 OPERATOR_CONTAINS,
24730 OPERATOR_NOT_CONTAINS,
24731 OPERATOR_STARTS_WITH,
24732 // Multiple selection
24733 OPERATOR_IS_ANY,
24734 OPERATOR_IS_NONE,
24735 OPERATOR_IS_ALL,
24736 OPERATOR_IS_NOT_ALL
24737 ],
24738 format: {},
24739 getValueFormatted: get_value_formatted_default_default,
24740 validate: {
24741 required: isValidRequired,
24742 pattern: isValidPattern,
24743 minLength: isValidMinLength,
24744 maxLength: isValidMaxLength,
24745 elements: isValidElements,
24746 custom: isValidCustom
24747 }
24748 };
24749
24750 // packages/dataviews/build-module/field-types/integer.mjs
24751 var import_i18n39 = __toESM(require_i18n(), 1);
24752
24753 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
24754 var sort_number_default = (a2, b2, direction) => {
24755 return direction === "asc" ? a2 - b2 : b2 - a2;
24756 };
24757
24758 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
24759 function isValidMin(item, field) {
24760 if (typeof field.isValid.min?.constraint !== "number") {
24761 return false;
24762 }
24763 const value = field.getValue({ item });
24764 if ([void 0, "", null].includes(value)) {
24765 return true;
24766 }
24767 return Number(value) >= field.isValid.min.constraint;
24768 }
24769
24770 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
24771 function isValidMax(item, field) {
24772 if (typeof field.isValid.max?.constraint !== "number") {
24773 return false;
24774 }
24775 const value = field.getValue({ item });
24776 if ([void 0, "", null].includes(value)) {
24777 return true;
24778 }
24779 return Number(value) <= field.isValid.max.constraint;
24780 }
24781
24782 // packages/dataviews/build-module/field-types/integer.mjs
24783 var format2 = {
24784 separatorThousand: ","
24785 };
24786 function getValueFormatted2({
24787 item,
24788 field
24789 }) {
24790 let value = field.getValue({ item });
24791 if (value === null || value === void 0) {
24792 return "";
24793 }
24794 value = Number(value);
24795 if (!Number.isFinite(value)) {
24796 return String(value);
24797 }
24798 let formatInteger;
24799 if (field.type !== "integer") {
24800 formatInteger = format2;
24801 } else {
24802 formatInteger = field.format;
24803 }
24804 const { separatorThousand } = formatInteger;
24805 const integerValue = Math.trunc(value);
24806 if (!separatorThousand) {
24807 return String(integerValue);
24808 }
24809 return String(integerValue).replace(
24810 /\B(?=(\d{3})+(?!\d))/g,
24811 separatorThousand
24812 );
24813 }
24814 function isValidCustom2(item, field) {
24815 const value = field.getValue({ item });
24816 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
24817 return (0, import_i18n39.__)("Value must be an integer.");
24818 }
24819 return null;
24820 }
24821 var integer_default = {
24822 type: "integer",
24823 render,
24824 Edit: "integer",
24825 sort: sort_number_default,
24826 enableSorting: true,
24827 enableGlobalSearch: false,
24828 defaultOperators: [
24829 OPERATOR_IS,
24830 OPERATOR_IS_NOT,
24831 OPERATOR_LESS_THAN,
24832 OPERATOR_GREATER_THAN,
24833 OPERATOR_LESS_THAN_OR_EQUAL,
24834 OPERATOR_GREATER_THAN_OR_EQUAL,
24835 OPERATOR_BETWEEN
24836 ],
24837 validOperators: [
24838 // Single-selection
24839 OPERATOR_IS,
24840 OPERATOR_IS_NOT,
24841 OPERATOR_LESS_THAN,
24842 OPERATOR_GREATER_THAN,
24843 OPERATOR_LESS_THAN_OR_EQUAL,
24844 OPERATOR_GREATER_THAN_OR_EQUAL,
24845 OPERATOR_BETWEEN,
24846 // Multiple-selection
24847 OPERATOR_IS_ANY,
24848 OPERATOR_IS_NONE,
24849 OPERATOR_IS_ALL,
24850 OPERATOR_IS_NOT_ALL
24851 ],
24852 format: format2,
24853 getValueFormatted: getValueFormatted2,
24854 validate: {
24855 required: isValidRequired,
24856 min: isValidMin,
24857 max: isValidMax,
24858 elements: isValidElements,
24859 custom: isValidCustom2
24860 }
24861 };
24862
24863 // packages/dataviews/build-module/field-types/number.mjs
24864 var import_i18n40 = __toESM(require_i18n(), 1);
24865 var format3 = {
24866 separatorThousand: ",",
24867 separatorDecimal: ".",
24868 decimals: 2
24869 };
24870 function getValueFormatted3({
24871 item,
24872 field
24873 }) {
24874 let value = field.getValue({ item });
24875 if (value === null || value === void 0) {
24876 return "";
24877 }
24878 value = Number(value);
24879 if (!Number.isFinite(value)) {
24880 return String(value);
24881 }
24882 let formatNumber;
24883 if (field.type !== "number") {
24884 formatNumber = format3;
24885 } else {
24886 formatNumber = field.format;
24887 }
24888 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
24889 const fixedValue = value.toFixed(decimals);
24890 const [integerPart, decimalPart] = fixedValue.split(".");
24891 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
24892 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
24893 }
24894 function isEmpty2(value) {
24895 return value === "" || value === void 0 || value === null;
24896 }
24897 function isValidCustom3(item, field) {
24898 const value = field.getValue({ item });
24899 if (!isEmpty2(value) && !Number.isFinite(value)) {
24900 return (0, import_i18n40.__)("Value must be a number.");
24901 }
24902 return null;
24903 }
24904 var number_default = {
24905 type: "number",
24906 render,
24907 Edit: "number",
24908 sort: sort_number_default,
24909 enableSorting: true,
24910 enableGlobalSearch: false,
24911 defaultOperators: [
24912 OPERATOR_IS,
24913 OPERATOR_IS_NOT,
24914 OPERATOR_LESS_THAN,
24915 OPERATOR_GREATER_THAN,
24916 OPERATOR_LESS_THAN_OR_EQUAL,
24917 OPERATOR_GREATER_THAN_OR_EQUAL,
24918 OPERATOR_BETWEEN
24919 ],
24920 validOperators: [
24921 // Single-selection
24922 OPERATOR_IS,
24923 OPERATOR_IS_NOT,
24924 OPERATOR_LESS_THAN,
24925 OPERATOR_GREATER_THAN,
24926 OPERATOR_LESS_THAN_OR_EQUAL,
24927 OPERATOR_GREATER_THAN_OR_EQUAL,
24928 OPERATOR_BETWEEN,
24929 // Multiple-selection
24930 OPERATOR_IS_ANY,
24931 OPERATOR_IS_NONE,
24932 OPERATOR_IS_ALL,
24933 OPERATOR_IS_NOT_ALL
24934 ],
24935 format: format3,
24936 getValueFormatted: getValueFormatted3,
24937 validate: {
24938 required: isValidRequired,
24939 min: isValidMin,
24940 max: isValidMax,
24941 elements: isValidElements,
24942 custom: isValidCustom3
24943 }
24944 };
24945
24946 // packages/dataviews/build-module/field-types/text.mjs
24947 var text_default = {
24948 type: "text",
24949 render,
24950 Edit: "text",
24951 sort: sort_text_default,
24952 enableSorting: true,
24953 enableGlobalSearch: false,
24954 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24955 validOperators: [
24956 // Single selection
24957 OPERATOR_IS,
24958 OPERATOR_IS_NOT,
24959 OPERATOR_CONTAINS,
24960 OPERATOR_NOT_CONTAINS,
24961 OPERATOR_STARTS_WITH,
24962 // Multiple selection
24963 OPERATOR_IS_ANY,
24964 OPERATOR_IS_NONE,
24965 OPERATOR_IS_ALL,
24966 OPERATOR_IS_NOT_ALL
24967 ],
24968 format: {},
24969 getValueFormatted: get_value_formatted_default_default,
24970 validate: {
24971 required: isValidRequired,
24972 pattern: isValidPattern,
24973 minLength: isValidMinLength,
24974 maxLength: isValidMaxLength,
24975 elements: isValidElements
24976 }
24977 };
24978
24979 // packages/dataviews/build-module/field-types/datetime.mjs
24980 var import_date7 = __toESM(require_date(), 1);
24981
24982 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
24983 var import_date6 = __toESM(require_date(), 1);
24984 function parseDateLike(value) {
24985 if (!value) {
24986 return null;
24987 }
24988 if (!isValid(new Date(value))) {
24989 return null;
24990 }
24991 const parsed = (0, import_date6.getDate)(value);
24992 return parsed && isValid(parsed) ? parsed : null;
24993 }
24994 function validateDateLikeBoundary(item, field, boundary) {
24995 const constraint = field.isValid[boundary]?.constraint;
24996 if (typeof constraint !== "string") {
24997 return false;
24998 }
24999 const value = field.getValue({ item });
25000 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
25001 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
25002 return true;
25003 }
25004 const parsedConstraint = parseDateLike(constraint);
25005 const parsedValue = parseDateLike(String(boundaryValue));
25006 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
25007 }
25008 function isValidMinDate(item, field) {
25009 return validateDateLikeBoundary(item, field, "min");
25010 }
25011 function isValidMaxDate(item, field) {
25012 return validateDateLikeBoundary(item, field, "max");
25013 }
25014
25015 // packages/dataviews/build-module/field-types/datetime.mjs
25016 var format4 = {
25017 datetime: (0, import_date7.getSettings)().formats.datetime,
25018 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
25019 };
25020 function getValueFormatted4({
25021 item,
25022 field
25023 }) {
25024 const value = field.getValue({ item });
25025 if (["", void 0, null].includes(value)) {
25026 return "";
25027 }
25028 let formatDatetime;
25029 if (field.type !== "datetime") {
25030 formatDatetime = format4;
25031 } else {
25032 formatDatetime = field.format;
25033 }
25034 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
25035 }
25036 var sort = (a2, b2, direction) => {
25037 const timeA = new Date(a2).getTime();
25038 const timeB = new Date(b2).getTime();
25039 return direction === "asc" ? timeA - timeB : timeB - timeA;
25040 };
25041 var datetime_default = {
25042 type: "datetime",
25043 render,
25044 Edit: "datetime",
25045 sort,
25046 enableSorting: true,
25047 enableGlobalSearch: false,
25048 defaultOperators: [
25049 OPERATOR_ON,
25050 OPERATOR_NOT_ON,
25051 OPERATOR_BEFORE,
25052 OPERATOR_AFTER,
25053 OPERATOR_BEFORE_INC,
25054 OPERATOR_AFTER_INC,
25055 OPERATOR_IN_THE_PAST,
25056 OPERATOR_OVER
25057 ],
25058 validOperators: [
25059 OPERATOR_ON,
25060 OPERATOR_NOT_ON,
25061 OPERATOR_BEFORE,
25062 OPERATOR_AFTER,
25063 OPERATOR_BEFORE_INC,
25064 OPERATOR_AFTER_INC,
25065 OPERATOR_IN_THE_PAST,
25066 OPERATOR_OVER
25067 ],
25068 format: format4,
25069 getValueFormatted: getValueFormatted4,
25070 validate: {
25071 required: isValidRequired,
25072 elements: isValidElements,
25073 min: isValidMinDate,
25074 max: isValidMaxDate
25075 }
25076 };
25077
25078 // packages/dataviews/build-module/field-types/date.mjs
25079 var import_date8 = __toESM(require_date(), 1);
25080 var format5 = {
25081 date: (0, import_date8.getSettings)().formats.date,
25082 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
25083 };
25084 function getValueFormatted5({
25085 item,
25086 field
25087 }) {
25088 const value = field.getValue({ item });
25089 if (["", void 0, null].includes(value)) {
25090 return "";
25091 }
25092 let formatDate2;
25093 if (field.type !== "date") {
25094 formatDate2 = format5;
25095 } else {
25096 formatDate2 = field.format;
25097 }
25098 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
25099 }
25100 var sort2 = (a2, b2, direction) => {
25101 const timeA = new Date(a2).getTime();
25102 const timeB = new Date(b2).getTime();
25103 return direction === "asc" ? timeA - timeB : timeB - timeA;
25104 };
25105 var date_default = {
25106 type: "date",
25107 render,
25108 Edit: "date",
25109 sort: sort2,
25110 enableSorting: true,
25111 enableGlobalSearch: false,
25112 defaultOperators: [
25113 OPERATOR_ON,
25114 OPERATOR_NOT_ON,
25115 OPERATOR_BEFORE,
25116 OPERATOR_AFTER,
25117 OPERATOR_BEFORE_INC,
25118 OPERATOR_AFTER_INC,
25119 OPERATOR_IN_THE_PAST,
25120 OPERATOR_OVER,
25121 OPERATOR_BETWEEN
25122 ],
25123 validOperators: [
25124 OPERATOR_ON,
25125 OPERATOR_NOT_ON,
25126 OPERATOR_BEFORE,
25127 OPERATOR_AFTER,
25128 OPERATOR_BEFORE_INC,
25129 OPERATOR_AFTER_INC,
25130 OPERATOR_IN_THE_PAST,
25131 OPERATOR_OVER,
25132 OPERATOR_BETWEEN
25133 ],
25134 format: format5,
25135 getValueFormatted: getValueFormatted5,
25136 validate: {
25137 required: isValidRequired,
25138 elements: isValidElements,
25139 min: isValidMinDate,
25140 max: isValidMaxDate
25141 }
25142 };
25143
25144 // packages/dataviews/build-module/field-types/boolean.mjs
25145 var import_i18n41 = __toESM(require_i18n(), 1);
25146
25147 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
25148 function isValidRequiredForBool(item, field) {
25149 const value = field.getValue({ item });
25150 return value === true;
25151 }
25152
25153 // packages/dataviews/build-module/field-types/boolean.mjs
25154 function getValueFormatted6({
25155 item,
25156 field
25157 }) {
25158 const value = field.getValue({ item });
25159 if (value === true) {
25160 return (0, import_i18n41.__)("True");
25161 }
25162 if (value === false) {
25163 return (0, import_i18n41.__)("False");
25164 }
25165 return "";
25166 }
25167 function isValidCustom4(item, field) {
25168 const value = field.getValue({ item });
25169 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
25170 return (0, import_i18n41.__)("Value must be true, false, or undefined");
25171 }
25172 return null;
25173 }
25174 var sort3 = (a2, b2, direction) => {
25175 const boolA = Boolean(a2);
25176 const boolB = Boolean(b2);
25177 if (boolA === boolB) {
25178 return 0;
25179 }
25180 if (direction === "asc") {
25181 return boolA ? 1 : -1;
25182 }
25183 return boolA ? -1 : 1;
25184 };
25185 var boolean_default = {
25186 type: "boolean",
25187 render,
25188 Edit: "checkbox",
25189 sort: sort3,
25190 validate: {
25191 required: isValidRequiredForBool,
25192 elements: isValidElements,
25193 custom: isValidCustom4
25194 },
25195 enableSorting: true,
25196 enableGlobalSearch: false,
25197 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25198 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25199 format: {},
25200 getValueFormatted: getValueFormatted6
25201 };
25202
25203 // packages/dataviews/build-module/field-types/media.mjs
25204 var media_default = {
25205 type: "media",
25206 render: () => null,
25207 Edit: null,
25208 sort: () => 0,
25209 enableSorting: false,
25210 enableGlobalSearch: false,
25211 defaultOperators: [],
25212 validOperators: [],
25213 format: {},
25214 getValueFormatted: get_value_formatted_default_default,
25215 // cannot validate any constraint, so
25216 // the only available validation for the field author
25217 // would be providing a custom validator.
25218 validate: {}
25219 };
25220
25221 // packages/dataviews/build-module/field-types/array.mjs
25222 var import_i18n42 = __toESM(require_i18n(), 1);
25223
25224 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
25225 function isValidRequiredForArray(item, field) {
25226 const value = field.getValue({ item });
25227 return Array.isArray(value) && value.length > 0 && value.every(
25228 (element) => ![void 0, "", null].includes(element)
25229 );
25230 }
25231
25232 // packages/dataviews/build-module/field-types/array.mjs
25233 function getValueFormatted7({
25234 item,
25235 field
25236 }) {
25237 const value = field.getValue({ item });
25238 const arr = Array.isArray(value) ? value : [];
25239 return arr.join(", ");
25240 }
25241 function render2({ item, field }) {
25242 return getValueFormatted7({ item, field });
25243 }
25244 function isValidCustom5(item, field) {
25245 const value = field.getValue({ item });
25246 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
25247 return (0, import_i18n42.__)("Value must be an array.");
25248 }
25249 if (!value.every((v2) => typeof v2 === "string")) {
25250 return (0, import_i18n42.__)("Every value must be a string.");
25251 }
25252 return null;
25253 }
25254 var sort4 = (a2, b2, direction) => {
25255 const arrA = Array.isArray(a2) ? a2 : [];
25256 const arrB = Array.isArray(b2) ? b2 : [];
25257 if (arrA.length !== arrB.length) {
25258 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
25259 }
25260 const joinedA = arrA.join(",");
25261 const joinedB = arrB.join(",");
25262 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
25263 };
25264 var array_default = {
25265 type: "array",
25266 render: render2,
25267 Edit: "array",
25268 sort: sort4,
25269 enableSorting: true,
25270 enableGlobalSearch: false,
25271 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25272 validOperators: [
25273 OPERATOR_IS_ANY,
25274 OPERATOR_IS_NONE,
25275 OPERATOR_IS_ALL,
25276 OPERATOR_IS_NOT_ALL
25277 ],
25278 format: {},
25279 getValueFormatted: getValueFormatted7,
25280 validate: {
25281 required: isValidRequiredForArray,
25282 elements: isValidElements,
25283 custom: isValidCustom5
25284 }
25285 };
25286
25287 // packages/dataviews/build-module/field-types/password.mjs
25288 function getValueFormatted8({
25289 item,
25290 field
25291 }) {
25292 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
25293 }
25294 var password_default = {
25295 type: "password",
25296 render,
25297 Edit: "password",
25298 sort: () => 0,
25299 // Passwords should not be sortable for security reasons
25300 enableSorting: false,
25301 enableGlobalSearch: false,
25302 defaultOperators: [],
25303 validOperators: [],
25304 format: {},
25305 getValueFormatted: getValueFormatted8,
25306 validate: {
25307 required: isValidRequired,
25308 pattern: isValidPattern,
25309 minLength: isValidMinLength,
25310 maxLength: isValidMaxLength,
25311 elements: isValidElements
25312 }
25313 };
25314
25315 // packages/dataviews/build-module/field-types/telephone.mjs
25316 var telephone_default = {
25317 type: "telephone",
25318 render,
25319 Edit: "telephone",
25320 sort: sort_text_default,
25321 enableSorting: true,
25322 enableGlobalSearch: false,
25323 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25324 validOperators: [
25325 OPERATOR_IS,
25326 OPERATOR_IS_NOT,
25327 OPERATOR_CONTAINS,
25328 OPERATOR_NOT_CONTAINS,
25329 OPERATOR_STARTS_WITH,
25330 // Multiple selection
25331 OPERATOR_IS_ANY,
25332 OPERATOR_IS_NONE,
25333 OPERATOR_IS_ALL,
25334 OPERATOR_IS_NOT_ALL
25335 ],
25336 format: {},
25337 getValueFormatted: get_value_formatted_default_default,
25338 validate: {
25339 required: isValidRequired,
25340 pattern: isValidPattern,
25341 minLength: isValidMinLength,
25342 maxLength: isValidMaxLength,
25343 elements: isValidElements
25344 }
25345 };
25346
25347 // packages/dataviews/build-module/field-types/color.mjs
25348 var import_i18n43 = __toESM(require_i18n(), 1);
25349 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
25350 function render3({ item, field }) {
25351 if (field.hasElements) {
25352 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(RenderFromElements, { item, field });
25353 }
25354 const value = get_value_formatted_default_default({ item, field });
25355 if (!value || !w(value).isValid()) {
25356 return value;
25357 }
25358 return /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
25359 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
25360 "div",
25361 {
25362 style: {
25363 width: "16px",
25364 height: "16px",
25365 borderRadius: "50%",
25366 backgroundColor: value,
25367 border: "1px solid #ddd",
25368 flexShrink: 0
25369 }
25370 }
25371 ),
25372 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)("span", { children: value })
25373 ] });
25374 }
25375 function isValidCustom6(item, field) {
25376 const value = field.getValue({ item });
25377 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
25378 return (0, import_i18n43.__)("Value must be a valid color.");
25379 }
25380 return null;
25381 }
25382 var sort5 = (a2, b2, direction) => {
25383 const colorA = w(a2);
25384 const colorB = w(b2);
25385 if (!colorA.isValid() && !colorB.isValid()) {
25386 return 0;
25387 }
25388 if (!colorA.isValid()) {
25389 return direction === "asc" ? 1 : -1;
25390 }
25391 if (!colorB.isValid()) {
25392 return direction === "asc" ? -1 : 1;
25393 }
25394 const hslA = colorA.toHsl();
25395 const hslB = colorB.toHsl();
25396 if (hslA.h !== hslB.h) {
25397 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
25398 }
25399 if (hslA.s !== hslB.s) {
25400 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
25401 }
25402 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
25403 };
25404 var color_default = {
25405 type: "color",
25406 render: render3,
25407 Edit: "color",
25408 sort: sort5,
25409 enableSorting: true,
25410 enableGlobalSearch: false,
25411 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25412 validOperators: [
25413 OPERATOR_IS,
25414 OPERATOR_IS_NOT,
25415 OPERATOR_IS_ANY,
25416 OPERATOR_IS_NONE
25417 ],
25418 format: {},
25419 getValueFormatted: get_value_formatted_default_default,
25420 validate: {
25421 required: isValidRequired,
25422 elements: isValidElements,
25423 custom: isValidCustom6
25424 }
25425 };
25426
25427 // packages/dataviews/build-module/field-types/url.mjs
25428 var url_default = {
25429 type: "url",
25430 render,
25431 Edit: "url",
25432 sort: sort_text_default,
25433 enableSorting: true,
25434 enableGlobalSearch: false,
25435 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25436 validOperators: [
25437 OPERATOR_IS,
25438 OPERATOR_IS_NOT,
25439 OPERATOR_CONTAINS,
25440 OPERATOR_NOT_CONTAINS,
25441 OPERATOR_STARTS_WITH,
25442 // Multiple selection
25443 OPERATOR_IS_ANY,
25444 OPERATOR_IS_NONE,
25445 OPERATOR_IS_ALL,
25446 OPERATOR_IS_NOT_ALL
25447 ],
25448 format: {},
25449 getValueFormatted: get_value_formatted_default_default,
25450 validate: {
25451 required: isValidRequired,
25452 pattern: isValidPattern,
25453 minLength: isValidMinLength,
25454 maxLength: isValidMaxLength,
25455 elements: isValidElements
25456 }
25457 };
25458
25459 // packages/dataviews/build-module/field-types/no-type.mjs
25460 var sort6 = (a2, b2, direction) => {
25461 if (typeof a2 === "number" && typeof b2 === "number") {
25462 return sort_number_default(a2, b2, direction);
25463 }
25464 return sort_text_default(a2, b2, direction);
25465 };
25466 var no_type_default = {
25467 // type: no type for this one
25468 render,
25469 Edit: null,
25470 sort: sort6,
25471 enableSorting: true,
25472 enableGlobalSearch: false,
25473 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25474 validOperators: getAllOperatorNames(),
25475 format: {},
25476 getValueFormatted: get_value_formatted_default_default,
25477 validate: {
25478 required: isValidRequired,
25479 elements: isValidElements
25480 }
25481 };
25482
25483 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
25484 function supportsNumericRangeConstraint(type) {
25485 return type === "integer" || type === "number";
25486 }
25487 function supportsDateRangeConstraint(type) {
25488 return type === "date" || type === "datetime";
25489 }
25490 function normalizeRangeRule(value, fieldType, key) {
25491 const validator = fieldType.validate[key];
25492 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
25493 return { constraint: value, validate: validator };
25494 }
25495 return void 0;
25496 }
25497 function getIsValid(field, fieldType) {
25498 const rules = field.isValid;
25499 let required;
25500 if (rules?.required === true && fieldType.validate.required !== void 0) {
25501 required = {
25502 constraint: true,
25503 validate: fieldType.validate.required
25504 };
25505 }
25506 let elements;
25507 if ((rules?.elements === true || // elements is enabled unless the field opts-out
25508 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
25509 elements = {
25510 constraint: true,
25511 validate: fieldType.validate.elements
25512 };
25513 }
25514 const min2 = normalizeRangeRule(rules?.min, fieldType, "min");
25515 const max2 = normalizeRangeRule(rules?.max, fieldType, "max");
25516 const minLengthValue = rules?.minLength;
25517 let minLength;
25518 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
25519 minLength = {
25520 constraint: minLengthValue,
25521 validate: fieldType.validate.minLength
25522 };
25523 }
25524 const maxLengthValue = rules?.maxLength;
25525 let maxLength;
25526 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
25527 maxLength = {
25528 constraint: maxLengthValue,
25529 validate: fieldType.validate.maxLength
25530 };
25531 }
25532 const patternValue = rules?.pattern;
25533 let pattern;
25534 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
25535 pattern = {
25536 constraint: patternValue,
25537 validate: fieldType.validate.pattern
25538 };
25539 }
25540 const custom = rules?.custom ?? fieldType.validate.custom;
25541 return {
25542 required,
25543 elements,
25544 min: min2,
25545 max: max2,
25546 minLength,
25547 maxLength,
25548 pattern,
25549 custom
25550 };
25551 }
25552
25553 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
25554 function getFilter(fieldType) {
25555 return fieldType.validOperators.reduce((accumulator, operator) => {
25556 const operatorObj = getOperatorByName(operator);
25557 if (operatorObj?.filter) {
25558 accumulator[operator] = operatorObj.filter;
25559 }
25560 return accumulator;
25561 }, {});
25562 }
25563
25564 // packages/dataviews/build-module/field-types/utils/get-format.mjs
25565 function getFormat(field, fieldType) {
25566 return {
25567 ...fieldType.format,
25568 ...field.format
25569 };
25570 }
25571 var get_format_default = getFormat;
25572
25573 // packages/dataviews/build-module/field-types/index.mjs
25574 function getFieldTypeByName(type) {
25575 const found = [
25576 email_default,
25577 integer_default,
25578 number_default,
25579 text_default,
25580 datetime_default,
25581 date_default,
25582 boolean_default,
25583 media_default,
25584 array_default,
25585 password_default,
25586 telephone_default,
25587 color_default,
25588 url_default
25589 ].find((fieldType) => fieldType?.type === type);
25590 if (!!found) {
25591 return found;
25592 }
25593 return no_type_default;
25594 }
25595 function normalizeFields(fields) {
25596 return fields.map((field) => {
25597 const fieldType = getFieldTypeByName(field.type);
25598 const getValue = field.getValue || get_value_from_id_default(field.id);
25599 const sort7 = function(a2, b2, direction) {
25600 const aValue = getValue({ item: a2 });
25601 const bValue = getValue({ item: b2 });
25602 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
25603 };
25604 return {
25605 id: field.id,
25606 label: field.label || field.id,
25607 header: field.header || field.label || field.id,
25608 description: field.description,
25609 placeholder: field.placeholder,
25610 getValue,
25611 setValue: field.setValue || set_value_from_id_default(field.id),
25612 elements: field.elements,
25613 getElements: field.getElements,
25614 hasElements: hasElements(field),
25615 isVisible: field.isVisible,
25616 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
25617 enableHiding: field.enableHiding ?? true,
25618 readOnly: field.readOnly ?? false,
25619 // The type provides defaults for the following props
25620 type: fieldType.type,
25621 render: field.render ?? fieldType.render,
25622 Edit: getControl(field, fieldType.Edit),
25623 sort: sort7,
25624 enableSorting: field.enableSorting ?? fieldType.enableSorting,
25625 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
25626 isValid: getIsValid(field, fieldType),
25627 filterBy: get_filter_by_default(
25628 field,
25629 fieldType.defaultOperators,
25630 fieldType.validOperators
25631 ),
25632 filter: getFilter(fieldType),
25633 format: get_format_default(field, fieldType),
25634 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
25635 };
25636 });
25637 }
25638
25639 // packages/dataviews/build-module/hooks/use-data.mjs
25640 var import_element77 = __toESM(require_element(), 1);
25641 function useData({
25642 view,
25643 data: shownData,
25644 getItemId,
25645 isLoading,
25646 paginationInfo,
25647 selection
25648 }) {
25649 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
25650 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element77.useState)(
25651 !isLoading
25652 );
25653 (0, import_element77.useEffect)(() => {
25654 if (!isLoading) {
25655 setHasInitiallyLoaded(true);
25656 }
25657 }, [isLoading]);
25658 const previousDataRef = (0, import_element77.useRef)(shownData);
25659 const previousPaginationInfoRef = (0, import_element77.useRef)(paginationInfo);
25660 (0, import_element77.useEffect)(() => {
25661 if (!isLoading) {
25662 previousDataRef.current = shownData;
25663 previousPaginationInfoRef.current = paginationInfo;
25664 }
25665 }, [shownData, isLoading, paginationInfo]);
25666 const [visibleEntries, setVisibleEntries] = (0, import_element77.useState)([]);
25667 const positionMapRef = (0, import_element77.useRef)(/* @__PURE__ */ new Map());
25668 const allLoadedRecordsRef = (0, import_element77.useRef)([]);
25669 const prevViewParamsRef = (0, import_element77.useRef)({
25670 search: void 0,
25671 filters: void 0,
25672 perPage: void 0
25673 });
25674 const scrollDirectionRef = (0, import_element77.useRef)(void 0);
25675 const prevStartPositionRef = (0, import_element77.useRef)(void 0);
25676 const hasInitializedRef = (0, import_element77.useRef)(false);
25677 const allLoadedRecords = (0, import_element77.useMemo)(() => {
25678 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
25679 if (view.startPosition < prevStartPositionRef.current) {
25680 scrollDirectionRef.current = "up";
25681 } else if (view.startPosition > prevStartPositionRef.current) {
25682 scrollDirectionRef.current = "down";
25683 }
25684 }
25685 prevStartPositionRef.current = view.startPosition;
25686 const currentFiltersKey = JSON.stringify(view.filters ?? []);
25687 const prevFiltersKey = prevViewParamsRef.current.filters;
25688 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
25689 hasInitializedRef.current = true;
25690 prevViewParamsRef.current = {
25691 search: view.search,
25692 filters: currentFiltersKey,
25693 perPage: view.perPage
25694 };
25695 if (shouldReset) {
25696 positionMapRef.current.clear();
25697 scrollDirectionRef.current = void 0;
25698 const startPosition = view.search ? 1 : view.startPosition ?? 1;
25699 const records = shownData.map((record, index2) => {
25700 const position = startPosition + index2;
25701 positionMapRef.current.set(getItemId(record), position);
25702 return {
25703 ...record,
25704 position
25705 };
25706 });
25707 allLoadedRecordsRef.current = records;
25708 return records;
25709 }
25710 const prev = allLoadedRecordsRef.current;
25711 const shownDataIds = new Set(shownData.map(getItemId));
25712 const scrollDirection = scrollDirectionRef.current;
25713 const basePosition = view.search ? 1 : view.startPosition ?? 1;
25714 const newRecords = shownData.map((record, index2) => {
25715 const itemId = getItemId(record);
25716 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0;
25717 if (position !== void 0) {
25718 positionMapRef.current.set(itemId, position);
25719 }
25720 return {
25721 ...record,
25722 position
25723 };
25724 });
25725 if (newRecords.length === 0) {
25726 return prev;
25727 }
25728 const prevWithoutDuplicates = prev.filter(
25729 (record) => !shownDataIds.has(getItemId(record))
25730 );
25731 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
25732 allRecords.sort((a2, b2) => {
25733 const posA = a2.position;
25734 const posB = b2.position;
25735 return posA - posB;
25736 });
25737 let result = allRecords;
25738 if (visibleEntries.length > 0) {
25739 const visibleMin = Math.min(...visibleEntries);
25740 const visibleMax = Math.max(...visibleEntries);
25741 const buffer = 20;
25742 const recordPositions = allRecords.map(
25743 (r3) => r3.position
25744 );
25745 const minRecordPos = Math.min(...recordPositions);
25746 const maxRecordPos = Math.max(...recordPositions);
25747 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
25748 if (hasOverlap) {
25749 result = allRecords.filter((record) => {
25750 const itemId = getItemId(record);
25751 const isSelected2 = selection?.includes(itemId);
25752 if (isSelected2) {
25753 return true;
25754 }
25755 const itemPosition = record.position;
25756 if (scrollDirection === "up") {
25757 return itemPosition <= visibleMax + buffer;
25758 } else if (scrollDirection === "down") {
25759 return itemPosition >= visibleMin - buffer;
25760 }
25761 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
25762 });
25763 }
25764 }
25765 allLoadedRecordsRef.current = result;
25766 return result;
25767 }, [
25768 shownData,
25769 view.search,
25770 view.filters,
25771 view.perPage,
25772 view.startPosition,
25773 view.infiniteScrollEnabled,
25774 visibleEntries,
25775 selection,
25776 getItemId
25777 ]);
25778 if (!isInfiniteScrollEnabled) {
25779 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
25780 return {
25781 data: dataToReturn.map((item) => ({
25782 ...item,
25783 position: void 0
25784 })),
25785 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
25786 hasInitiallyLoaded,
25787 setVisibleEntries: void 0
25788 };
25789 }
25790 return {
25791 data: allLoadedRecords,
25792 paginationInfo,
25793 hasInitiallyLoaded,
25794 setVisibleEntries
25795 };
25796 }
25797
25798 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
25799 var import_element78 = __toESM(require_element(), 1);
25800 var import_compose11 = __toESM(require_compose(), 1);
25801 function captureAnchorElement(container, anchorElementRef, direction) {
25802 const containerRect = container.getBoundingClientRect();
25803 const centerY = containerRect.top + containerRect.height / 2;
25804 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
25805 if (items.length === 0) {
25806 return false;
25807 }
25808 const bestAnchor = items.reduce((best, item) => {
25809 const itemRect = item.getBoundingClientRect();
25810 const itemCenterY = itemRect.top + itemRect.height / 2;
25811 const distance = Math.abs(itemCenterY - centerY);
25812 const bestRect = best.getBoundingClientRect();
25813 const bestCenterY = bestRect.top + bestRect.height / 2;
25814 const bestDistance = Math.abs(bestCenterY - centerY);
25815 return distance < bestDistance ? item : best;
25816 });
25817 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
25818 const anchorRect = bestAnchor.getBoundingClientRect();
25819 anchorElementRef.current = {
25820 posinset,
25821 viewportOffset: anchorRect.top - containerRect.top,
25822 direction
25823 };
25824 return true;
25825 }
25826 function useInfiniteScroll({
25827 view,
25828 onChangeView,
25829 isLoading,
25830 paginationInfo,
25831 containerRef,
25832 setVisibleEntries
25833 }) {
25834 const anchorElementRef = (0, import_element78.useRef)(null);
25835 const viewRef = (0, import_element78.useRef)(view);
25836 const isLoadingRef = (0, import_element78.useRef)(isLoading);
25837 const onChangeViewRef = (0, import_element78.useRef)(onChangeView);
25838 const totalItemsRef = (0, import_element78.useRef)(paginationInfo.totalItems);
25839 (0, import_element78.useLayoutEffect)(() => {
25840 viewRef.current = view;
25841 isLoadingRef.current = isLoading;
25842 onChangeViewRef.current = onChangeView;
25843 totalItemsRef.current = paginationInfo.totalItems;
25844 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
25845 const intersectionObserverCallback = (0, import_element78.useCallback)(
25846 (entries) => {
25847 if (!setVisibleEntries) {
25848 return;
25849 }
25850 setVisibleEntries((prev) => {
25851 const newVisibleEntries = new Set(prev);
25852 let hasChanged = false;
25853 entries.forEach((entry) => {
25854 const posInSet = Number(
25855 entry.target?.attributes?.getNamedItem(
25856 "aria-posinset"
25857 )?.value
25858 );
25859 if (isNaN(posInSet)) {
25860 return;
25861 }
25862 if (entry.isIntersecting) {
25863 if (!newVisibleEntries.has(posInSet)) {
25864 newVisibleEntries.add(posInSet);
25865 hasChanged = true;
25866 }
25867 } else if (newVisibleEntries.has(posInSet)) {
25868 newVisibleEntries.delete(posInSet);
25869 hasChanged = true;
25870 }
25871 });
25872 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
25873 });
25874 },
25875 [setVisibleEntries]
25876 );
25877 (0, import_element78.useLayoutEffect)(() => {
25878 const container = containerRef.current;
25879 const anchor = anchorElementRef.current;
25880 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
25881 return;
25882 }
25883 const anchorElement = container.querySelector(
25884 `[aria-posinset="${anchor.posinset}"]`
25885 );
25886 if (anchorElement) {
25887 const containerRect = container.getBoundingClientRect();
25888 const anchorRect = anchorElement.getBoundingClientRect();
25889 const currentOffset = anchorRect.top - containerRect.top;
25890 const scrollAdjustment = currentOffset - anchor.viewportOffset;
25891 if (Math.abs(scrollAdjustment) > 1) {
25892 container.scrollTop += scrollAdjustment;
25893 }
25894 }
25895 anchorElementRef.current = null;
25896 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
25897 const intersectionObserverRef = (0, import_element78.useRef)(
25898 null
25899 );
25900 (0, import_element78.useEffect)(() => {
25901 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
25902 if (intersectionObserverRef.current) {
25903 intersectionObserverRef.current.disconnect();
25904 intersectionObserverRef.current = null;
25905 }
25906 return;
25907 }
25908 intersectionObserverRef.current = new IntersectionObserver(
25909 intersectionObserverCallback,
25910 { root: null, rootMargin: "0px", threshold: 0.1 }
25911 );
25912 return () => {
25913 if (intersectionObserverRef.current) {
25914 intersectionObserverRef.current.disconnect();
25915 intersectionObserverRef.current = null;
25916 }
25917 };
25918 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
25919 (0, import_element78.useEffect)(() => {
25920 if (!view.infiniteScrollEnabled || !containerRef.current) {
25921 return;
25922 }
25923 let lastScrollTop = 0;
25924 const BOTTOM_THRESHOLD = 600;
25925 const TOP_THRESHOLD = 800;
25926 const handleScroll = (0, import_compose11.throttle)((event) => {
25927 const currentView = viewRef.current;
25928 const totalItems = totalItemsRef.current;
25929 const target = event.target;
25930 const scrollTop = target.scrollTop;
25931 const scrollHeight = target.scrollHeight;
25932 const clientHeight = target.clientHeight;
25933 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
25934 lastScrollTop = scrollTop;
25935 if (isLoadingRef.current) {
25936 return;
25937 }
25938 const currentStartPosition = currentView.startPosition || 1;
25939 const batchSize = currentView.perPage || 10;
25940 const currentEndPosition = Math.min(
25941 currentStartPosition + batchSize,
25942 totalItems
25943 );
25944 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
25945 if (currentEndPosition < totalItems) {
25946 const newStartPosition = currentEndPosition;
25947 captureAnchorElement(target, anchorElementRef, "down");
25948 onChangeViewRef.current({
25949 ...currentView,
25950 startPosition: newStartPosition
25951 });
25952 }
25953 }
25954 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
25955 if (currentStartPosition > 1) {
25956 const calculatedStartPosition = currentStartPosition - batchSize;
25957 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
25958 captureAnchorElement(target, anchorElementRef, "up");
25959 onChangeViewRef.current({
25960 ...currentView,
25961 startPosition: newStartPosition
25962 });
25963 }
25964 }
25965 }, 50);
25966 const container = containerRef.current;
25967 container.addEventListener("scroll", handleScroll);
25968 return () => {
25969 container.removeEventListener("scroll", handleScroll);
25970 handleScroll.cancel();
25971 };
25972 }, [containerRef, view.infiniteScrollEnabled]);
25973 return {
25974 intersectionObserver: intersectionObserverRef.current
25975 };
25976 }
25977
25978 // packages/dataviews/build-module/dataviews/index.mjs
25979 var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1);
25980 var defaultGetItemId = (item) => item.id;
25981 var defaultIsItemClickable = () => true;
25982 var EMPTY_ARRAY6 = [];
25983 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} };
25984 var dataViewsLayouts = VIEW_LAYOUTS.filter(
25985 (viewLayout) => !viewLayout.isPicker
25986 );
25987 function DefaultUI({
25988 header,
25989 search = true,
25990 searchLabel = void 0
25991 }) {
25992 const { view } = (0, import_element79.useContext)(dataviews_context_default);
25993 const isInfiniteScroll = view.infiniteScrollEnabled;
25994 return /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(import_jsx_runtime117.Fragment, { children: [
25995 /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(
25996 Stack,
25997 {
25998 direction: "row",
25999 align: "top",
26000 justify: "space-between",
26001 className: clsx_default("dataviews__view-actions", {
26002 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
26003 }),
26004 gap: "xs",
26005 children: [
26006 /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(
26007 Stack,
26008 {
26009 direction: "row",
26010 justify: "start",
26011 gap: "sm",
26012 className: "dataviews__search",
26013 children: [
26014 search && /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(dataviews_search_default, { label: searchLabel }),
26015 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(toggle_default, {})
26016 ]
26017 }
26018 ),
26019 /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
26020 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(dataviews_view_config_default, {}),
26021 header
26022 ] })
26023 ]
26024 }
26025 ),
26026 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
26027 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(DataViewsLayout, {}),
26028 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(DataViewsFooter, {})
26029 ] });
26030 }
26031 function DataViews({
26032 view,
26033 onChangeView,
26034 fields,
26035 search = true,
26036 searchLabel = void 0,
26037 actions = EMPTY_ARRAY6,
26038 data,
26039 getItemId = defaultGetItemId,
26040 getItemLevel,
26041 isLoading = false,
26042 paginationInfo,
26043 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS,
26044 selection: selectionProperty,
26045 onChangeSelection,
26046 onClickItem,
26047 renderItemLink,
26048 isItemClickable = defaultIsItemClickable,
26049 header,
26050 children,
26051 config = { perPageSizes: [10, 20, 50, 100] },
26052 empty,
26053 onReset
26054 }) {
26055 const [selectionState, setSelectionState] = (0, import_element79.useState)([]);
26056 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0;
26057 const selection = isUncontrolled ? selectionState : selectionProperty;
26058 const {
26059 data: displayData,
26060 paginationInfo: displayPaginationInfo,
26061 hasInitiallyLoaded,
26062 setVisibleEntries
26063 } = useData({
26064 view,
26065 data,
26066 getItemId,
26067 isLoading,
26068 selection,
26069 paginationInfo
26070 });
26071 const containerRef = (0, import_element79.useRef)(null);
26072 const [containerWidth, setContainerWidth] = (0, import_element79.useState)(0);
26073 const resizeObserverRef = (0, import_compose12.useResizeObserver)(
26074 (resizeObserverEntries) => {
26075 setContainerWidth(
26076 resizeObserverEntries[0].borderBoxSize[0].inlineSize
26077 );
26078 },
26079 { box: "border-box" }
26080 );
26081 const [openedFilter, setOpenedFilter] = (0, import_element79.useState)(null);
26082 function setSelectionWithChange(value) {
26083 const newValue = typeof value === "function" ? value(selection) : value;
26084 if (isUncontrolled) {
26085 setSelectionState(newValue);
26086 }
26087 if (onChangeSelection) {
26088 onChangeSelection(newValue);
26089 }
26090 }
26091 const _fields = (0, import_element79.useMemo)(() => normalizeFields(fields), [fields]);
26092 const _selection = (0, import_element79.useMemo)(() => {
26093 if (view.infiniteScrollEnabled) {
26094 return selection;
26095 }
26096 return selection.filter(
26097 (id) => data.some((item) => getItemId(item) === id)
26098 );
26099 }, [selection, data, getItemId, view.infiniteScrollEnabled]);
26100 const filters = use_filters_default(_fields, view);
26101 const hasPrimaryOrLockedFilters = (0, import_element79.useMemo)(
26102 () => (filters || []).some(
26103 (filter) => filter.isPrimary || filter.isLocked
26104 ),
26105 [filters]
26106 );
26107 const [isShowingFilter, setIsShowingFilter] = (0, import_element79.useState)(
26108 hasPrimaryOrLockedFilters
26109 );
26110 const { intersectionObserver } = useInfiniteScroll({
26111 view,
26112 onChangeView,
26113 isLoading,
26114 paginationInfo,
26115 containerRef,
26116 setVisibleEntries
26117 });
26118 (0, import_element79.useEffect)(() => {
26119 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
26120 setIsShowingFilter(true);
26121 }
26122 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
26123 const defaultLayouts = (0, import_element79.useMemo)(
26124 () => Object.fromEntries(
26125 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
26126 return dataViewsLayouts.some(
26127 (viewLayout) => viewLayout.type === layoutType
26128 );
26129 }).map(([key, value]) => [
26130 key,
26131 value === true ? {} : value
26132 ])
26133 ),
26134 [defaultLayoutsProperty]
26135 );
26136 if (!defaultLayouts[view.type]) {
26137 return null;
26138 }
26139 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
26140 dataviews_context_default.Provider,
26141 {
26142 value: {
26143 view,
26144 onChangeView,
26145 fields: _fields,
26146 actions,
26147 data: displayData,
26148 isLoading,
26149 paginationInfo: displayPaginationInfo,
26150 selection: _selection,
26151 onChangeSelection: setSelectionWithChange,
26152 openedFilter,
26153 setOpenedFilter,
26154 getItemId,
26155 getItemLevel,
26156 isItemClickable,
26157 onClickItem,
26158 renderItemLink,
26159 containerWidth,
26160 containerRef,
26161 resizeObserverRef,
26162 defaultLayouts,
26163 filters,
26164 isShowingFilter,
26165 setIsShowingFilter,
26166 config,
26167 empty,
26168 hasInitiallyLoaded,
26169 onReset,
26170 intersectionObserver
26171 },
26172 children: /* @__PURE__ */ (0, import_jsx_runtime117.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
26173 DefaultUI,
26174 {
26175 header,
26176 search,
26177 searchLabel
26178 }
26179 ) })
26180 }
26181 );
26182 }
26183 var DataViewsSubComponents = DataViews;
26184 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
26185 DataViewsSubComponents.Filters = filters_default;
26186 DataViewsSubComponents.FiltersToggled = filters_toggled_default;
26187 DataViewsSubComponents.FiltersToggle = toggle_default;
26188 DataViewsSubComponents.Layout = DataViewsLayout;
26189 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
26190 DataViewsSubComponents.Pagination = DataViewsPagination;
26191 DataViewsSubComponents.Search = dataviews_search_default;
26192 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
26193 DataViewsSubComponents.Footer = DataViewsFooter;
26194 var dataviews_default = DataViewsSubComponents;
26195
26196 // widgets/news/components/news-list/news-list.tsx
26197 var import_date10 = __toESM(require_date());
26198 var import_element80 = __toESM(require_element());
26199 var import_html_entities = __toESM(require_html_entities());
26200 var import_i18n44 = __toESM(require_i18n());
26201
26202 // packages/style-runtime/src/index.ts
26203 var STYLE_HASH_ATTRIBUTE14 = "data-wp-hash";
26204 function getRuntime14() {
26205 const globalScope = globalThis;
26206 if (globalScope.__wpStyleRuntime) {
26207 return globalScope.__wpStyleRuntime;
26208 }
26209 globalScope.__wpStyleRuntime = {
26210 documents: /* @__PURE__ */ new Map(),
26211 styles: /* @__PURE__ */ new Map(),
26212 injectedStyles: /* @__PURE__ */ new WeakMap()
26213 };
26214 if (typeof document !== "undefined") {
26215 registerDocument14(document);
26216 }
26217 return globalScope.__wpStyleRuntime;
26218 }
26219 function documentContainsStyleHash14(targetDocument, hash) {
26220 if (!targetDocument.head) {
26221 return false;
26222 }
26223 for (const style of targetDocument.head.querySelectorAll(
26224 `style[${STYLE_HASH_ATTRIBUTE14}]`
26225 )) {
26226 if (style.getAttribute(STYLE_HASH_ATTRIBUTE14) === hash) {
26227 return true;
26228 }
26229 }
26230 return false;
26231 }
26232 function injectStyle14(targetDocument, hash, css) {
26233 if (!targetDocument.head) {
26234 return;
26235 }
26236 const runtime = getRuntime14();
26237 let injectedStyles = runtime.injectedStyles.get(targetDocument);
26238 if (!injectedStyles) {
26239 injectedStyles = /* @__PURE__ */ new Set();
26240 runtime.injectedStyles.set(targetDocument, injectedStyles);
26241 }
26242 if (injectedStyles.has(hash)) {
26243 return;
26244 }
26245 if (documentContainsStyleHash14(targetDocument, hash)) {
26246 injectedStyles.add(hash);
26247 return;
26248 }
26249 const style = targetDocument.createElement("style");
26250 style.setAttribute(STYLE_HASH_ATTRIBUTE14, hash);
26251 style.appendChild(targetDocument.createTextNode(css));
26252 targetDocument.head.appendChild(style);
26253 injectedStyles.add(hash);
26254 }
26255 function registerDocument14(targetDocument) {
26256 const runtime = getRuntime14();
26257 runtime.documents.set(
26258 targetDocument,
26259 (runtime.documents.get(targetDocument) ?? 0) + 1
26260 );
26261 for (const [hash, css] of runtime.styles) {
26262 injectStyle14(targetDocument, hash, css);
26263 }
26264 return () => {
26265 const count = runtime.documents.get(targetDocument);
26266 if (count === void 0) {
26267 return;
26268 }
26269 if (count <= 1) {
26270 runtime.documents.delete(targetDocument);
26271 return;
26272 }
26273 runtime.documents.set(targetDocument, count - 1);
26274 };
26275 }
26276 function registerStyle14(hash, css) {
26277 const runtime = getRuntime14();
26278 runtime.styles.set(hash, css);
26279 for (const targetDocument of runtime.documents.keys()) {
26280 injectStyle14(targetDocument, hash, css);
26281 }
26282 }
26283
26284 // widgets/news/components/news-list/news-list.module.css
26285 if (typeof process === "undefined" || true) {
26286 registerStyle14("98f9a3b1c2", ".bdaa5dfae93273b5__root{flex:1;min-height:0;min-width:0;overflow:auto}._2861fc2db3e2384a__feedIcon{align-items:center;background-color:var(--wpds-color-bg-track-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-md,4px);color:var(--wpds-color-fg-content-neutral-weak,#707070);display:flex;height:100%;justify-content:center;width:100%}._0b17b846e53f552a__titleLink{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._33e124d0c35f629a__meta{color:var(--wpds-color-fg-content-neutral-weak,#707070)}");
26287 }
26288 var news_list_default = { "root": "bdaa5dfae93273b5__root", "feedIcon": "_2861fc2db3e2384a__feedIcon", "titleLink": "_0b17b846e53f552a__titleLink", "meta": "_33e124d0c35f629a__meta" };
26289
26290 // widgets/news/components/news-list/news-list.tsx
26291 var import_jsx_runtime118 = __toESM(require_jsx_runtime());
26292 var NEWS_FEEDS = [
26293 {
26294 key: "news",
26295 label: (0, import_i18n44.__)("WordPress Blog"),
26296 siteUrl: (0, import_i18n44._x)("https://wordpress.org/news/", "News dashboard widget"),
26297 apiUrl: "https://wordpress.org/news/wp-json/wp/v2/posts?per_page=4&_fields=id,title,link,date"
26298 },
26299 {
26300 key: "planet",
26301 label: (0, import_i18n44.__)("Other WordPress News"),
26302 siteUrl: (0, import_i18n44._x)("https://planet.wordpress.org/", "News dashboard widget"),
26303 apiUrl: "https://planet.wordpress.org/wp-json/wp/v2/posts?per_page=4&_fields=id,title,link,date"
26304 }
26305 ];
26306 var DEFAULT_LAYOUTS2 = { list: {} };
26307 var INITIAL_VIEW = {
26308 type: "list",
26309 page: 1,
26310 perPage: 4,
26311 search: "",
26312 filters: [],
26313 fields: [],
26314 titleField: "title",
26315 descriptionField: "meta",
26316 mediaField: "feedIcon",
26317 showMedia: true,
26318 layout: { density: "compact" }
26319 };
26320 function FeedIcon({ item }) {
26321 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)("div", { className: news_list_default.feedIcon, "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(Icon, { icon: item.feedKey === "news" ? wordpress_default : globe_default }) });
26322 }
26323 function NewsTitle({ item }) {
26324 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(Link, { href: item.url, openInNewTab: true, className: news_list_default.titleLink, children: item.title });
26325 }
26326 function NewsMeta({ item }) {
26327 return /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(Text, { variant: "body-sm", className: news_list_default.meta, children: [
26328 item.feedLabel,
26329 " \xB7 ",
26330 (0, import_date10.dateI18n)((0, import_i18n44.__)("M j, Y g:i a"), item.date)
26331 ] });
26332 }
26333 var emptyState = /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(Stack, { align: "center", justify: "center", style: { margin: "24px 0" }, children: /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(empty_state_exports.Root, { children: [
26334 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(empty_state_exports.Icon, { icon: post_list_default }),
26335 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(empty_state_exports.Title, { children: (0, import_i18n44.__)("Quiet for now \u2014 the next headline is on its way.") })
26336 ] }) });
26337 function combineFeedPosts(newsFeeds) {
26338 return newsFeeds.flatMap(
26339 (feed) => feed.posts.map((post) => ({
26340 id: `${feed.key}-${post.id}`,
26341 feedKey: feed.key,
26342 feedLabel: feed.label,
26343 title: (0, import_html_entities.decodeEntities)(post.title.rendered),
26344 url: post.link,
26345 date: post.date
26346 }))
26347 ).sort(
26348 (a2, b2) => new Date(b2.date).getTime() - new Date(a2.date).getTime()
26349 );
26350 }
26351 function NewsList() {
26352 const [view, setView] = (0, import_element80.useState)(INITIAL_VIEW);
26353 const [newsFeeds, setNewsFeeds] = (0, import_element80.useState)([]);
26354 const [isLoading, setIsLoading] = (0, import_element80.useState)(true);
26355 (0, import_element80.useEffect)(() => {
26356 Promise.all(
26357 NEWS_FEEDS.map(async (feed) => {
26358 try {
26359 const posts = await fetch(feed.apiUrl).then(
26360 (r3) => r3.json()
26361 );
26362 return {
26363 key: feed.key,
26364 label: feed.label,
26365 siteUrl: feed.siteUrl,
26366 posts
26367 };
26368 } catch {
26369 return {
26370 key: feed.key,
26371 label: feed.label,
26372 siteUrl: feed.siteUrl,
26373 posts: []
26374 };
26375 }
26376 })
26377 ).then(setNewsFeeds).finally(() => setIsLoading(false));
26378 }, []);
26379 const items = (0, import_element80.useMemo)(() => combineFeedPosts(newsFeeds), [newsFeeds]);
26380 const fields = (0, import_element80.useMemo)(
26381 () => [
26382 {
26383 id: "title",
26384 label: (0, import_i18n44.__)("Title"),
26385 enableSorting: false,
26386 enableHiding: false,
26387 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(NewsTitle, { item })
26388 },
26389 {
26390 id: "meta",
26391 label: (0, import_i18n44.__)("Source"),
26392 enableSorting: false,
26393 enableHiding: false,
26394 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(NewsMeta, { item })
26395 },
26396 {
26397 id: "feedIcon",
26398 label: (0, import_i18n44.__)("Source"),
26399 enableSorting: false,
26400 enableHiding: false,
26401 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(FeedIcon, { item })
26402 }
26403 ],
26404 []
26405 );
26406 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)("div", { className: news_list_default.root, children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
26407 dataviews_default,
26408 {
26409 data: items,
26410 fields,
26411 view,
26412 onChangeView: setView,
26413 getItemId: (item) => item.id,
26414 isLoading,
26415 paginationInfo: {
26416 totalItems: items.length,
26417 totalPages: 1
26418 },
26419 defaultLayouts: DEFAULT_LAYOUTS2,
26420 empty: emptyState,
26421 children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(dataviews_default.Layout, {})
26422 }
26423 ) });
26424 }
26425
26426 // widgets/news/render.module.css
26427 if (typeof process === "undefined" || true) {
26428 registerStyle14("41468018c3", "._2ab2c8be44ad767d__footer{border-block-start:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);padding-block:var(--wpds-dimension-padding-lg,16px);padding-inline:var(--wpds-dimension-padding-2xl,24px)}");
26429 }
26430 var render_default = { "footer": "_2ab2c8be44ad767d__footer" };
26431
26432 // widgets/news/render.tsx
26433 var import_jsx_runtime119 = __toESM(require_jsx_runtime());
26434 function WordPressNews() {
26435 return /* @__PURE__ */ (0, import_jsx_runtime119.jsxs)(import_jsx_runtime119.Fragment, { children: [
26436 /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(NewsList, {}),
26437 /* @__PURE__ */ (0, import_jsx_runtime119.jsx)("div", { className: render_default.footer, children: /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
26438 Link,
26439 {
26440 href: (0, import_i18n45._x)(
26441 "https://wordpress.org/news/all-posts/",
26442 "News dashboard widget"
26443 ),
26444 openInNewTab: true,
26445 children: (0, import_i18n45.__)("See all")
26446 }
26447 ) })
26448 ] });
26449 }
26450 export {
26451 WordPressNews as default
26452 };
26453 /*! Bundled license information:
26454
26455 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
26456 (**
26457 * @license React
26458 * use-sync-external-store-shim.development.js
26459 *
26460 * Copyright (c) Meta Platforms, Inc. and affiliates.
26461 *
26462 * This source code is licensed under the MIT license found in the
26463 * LICENSE file in the root directory of this source tree.
26464 *)
26465
26466 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
26467 (**
26468 * @license React
26469 * use-sync-external-store-shim/with-selector.development.js
26470 *
26471 * Copyright (c) Meta Platforms, Inc. and affiliates.
26472 *
26473 * This source code is licensed under the MIT license found in the
26474 * LICENSE file in the root directory of this source tree.
26475 *)
26476 */
26477